1
0
Fork 0
Dieser Commit ist enthalten in:
angusmcleod 2021-07-14 14:05:13 +08:00
Ursprung 34fee3729c
Commit 56a1463413
3 geänderte Dateien mit 52 neuen und 48 gelöschten Zeilen

Datei anzeigen

@ -1,34 +1,36 @@
import Controller from "@ember/controller"; import Controller from "@ember/controller";
import { fmt } from "discourse/lib/computed"; import { fmt } from "discourse/lib/computed";
import { empty } from '@ember/object/computed'; import { empty } from "@ember/object/computed";
import CustomWizard from "../models/custom-wizard"; import CustomWizard from "../models/custom-wizard";
export default Controller.extend({ export default Controller.extend({
downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download"), downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download"),
noResults: empty('submissions'), noResults: empty("submissions"),
page: 0, page: 0,
total: 0, total: 0,
loadMoreSubmissions() { loadMoreSubmissions() {
const page = this.get('page'); const page = this.get("page");
const wizardId = this.get('wizard.id'); const wizardId = this.get("wizard.id");
this.set('loadingMore', true); this.set("loadingMore", true);
CustomWizard.submissions(wizardId, page).then(result => { CustomWizard.submissions(wizardId, page)
.then((result) => {
if (result.submissions) { if (result.submissions) {
this.get('submissions').pushObjects(result.submissions); this.get("submissions").pushObjects(result.submissions);
} }
}).finally(() => { })
this.set('loadingMore', false); .finally(() => {
this.set("loadingMore", false);
}); });
}, },
actions: { actions: {
loadMore() { loadMore() {
if (!this.loadingMore && (this.submissions.length < this.total)) { if (!this.loadingMore && this.submissions.length < this.total) {
this.set('page', this.get('page') + 1); this.set("page", this.get("page") + 1);
this.loadMoreSubmissions(); this.loadMoreSubmissions();
} }
} },
} },
}); });

Datei anzeigen

@ -220,8 +220,9 @@ CustomWizard.reopenClass({
return ajax(`/admin/wizards/submissions/${wizardId}`, { return ajax(`/admin/wizards/submissions/${wizardId}`, {
type: "GET", type: "GET",
data data,
}).then(result => { })
.then((result) => {
if (result.wizard) { if (result.wizard) {
let fields = ["username"]; let fields = ["username"];
let submissions = []; let submissions = [];
@ -243,7 +244,7 @@ CustomWizard.reopenClass({
} }
}); });
submission['submitted_at'] = s.submitted_at; submission["submitted_at"] = s.submitted_at;
submissions.push(submission); submissions.push(submission);
}); });
@ -253,10 +254,11 @@ CustomWizard.reopenClass({
wizard, wizard,
fields, fields,
submissions, submissions,
total total,
}; };
} }
}).catch(popupAjaxError); })
.catch(popupAjaxError);
}, },
create(wizardJson = {}) { create(wizardJson = {}) {

Datei anzeigen

@ -12,7 +12,7 @@ export default DiscourseRoute.extend({
wizard: model.wizard, wizard: model.wizard,
fields: model.fields, fields: model.fields,
submissions: A(model.submissions), submissions: A(model.submissions),
total: model.total total: model.total,
}); });
}, },
}); });