0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-12-01 21:11:10 +01:00
discourse-custom-wizard/assets/javascripts/discourse/controllers/admin-wizards-submissions-show.js.es6
2021-07-14 14:05:13 +08:00

36 Zeilen
980 B
JavaScript

import Controller from "@ember/controller";
import { fmt } from "discourse/lib/computed";
import { empty } from "@ember/object/computed";
import CustomWizard from "../models/custom-wizard";
export default Controller.extend({
downloadUrl: fmt("wizard.id", "/admin/wizards/submissions/%@/download"),
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();
}
},
},
});