2020-04-12 01:27:16 +02:00
|
|
|
import Controller from "@ember/controller";
|
|
|
|
import { fmt } from "discourse/lib/computed";
|
2021-07-14 08:04:19 +02:00
|
|
|
import { empty } from '@ember/object/computed';
|
|
|
|
import CustomWizard from "../models/custom-wizard";
|
2020-04-12 01:27:16 +02:00
|
|
|
|
|
|
|
export default Controller.extend({
|
2021-03-28 11:06:49 +02:00
|
|
|
downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download"),
|
2021-07-14 08:04:19 +02:00
|
|
|
noResults: empty('submissions'),
|
|
|
|
page: 0,
|
|
|
|
total: 0,
|
|
|
|
|
|
|
|
loadMoreSubmissions() {
|
|
|
|
const page = this.get('page');
|
|
|
|
const wizardId = this.get('wizard.id');
|
|
|
|
|
|
|
|
this.set('loadingMore', true);
|
|
|
|
CustomWizard.submissions(wizardId, page).then(result => {
|
|
|
|
if (result.submissions) {
|
|
|
|
this.get('submissions').pushObjects(result.submissions);
|
|
|
|
}
|
|
|
|
}).finally(() => {
|
|
|
|
this.set('loadingMore', false);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
loadMore() {
|
|
|
|
if (!this.loadingMore && (this.submissions.length < this.total)) {
|
|
|
|
this.set('page', this.get('page') + 1);
|
|
|
|
this.loadMoreSubmissions();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-03-28 11:06:49 +02:00
|
|
|
});
|