Spiegel von
https://github.com/paviliondev/discourse-custom-wizard.git
synchronisiert 2024-11-22 17:30:29 +01:00
52 Zeilen
1,2 KiB
JavaScript
52 Zeilen
1,2 KiB
JavaScript
import discourseComputed from "discourse-common/utils/decorators";
|
|
import { notEmpty } from "@ember/object/computed";
|
|
import CustomWizardLogs from "../models/custom-wizard-logs";
|
|
import Controller from "@ember/controller";
|
|
|
|
export default Controller.extend({
|
|
refreshing: false,
|
|
hasLogs: notEmpty("logs"),
|
|
page: 0,
|
|
canLoadMore: true,
|
|
logs: [],
|
|
documentationUrl: "https://thepavilion.io/t/2818",
|
|
messageKey: "viewing",
|
|
|
|
loadLogs() {
|
|
if (!this.canLoadMore) {
|
|
return;
|
|
}
|
|
|
|
this.set("refreshing", true);
|
|
|
|
CustomWizardLogs.list()
|
|
.then((result) => {
|
|
if (!result || result.length === 0) {
|
|
this.set("canLoadMore", false);
|
|
}
|
|
this.set("logs", this.logs.concat(result));
|
|
})
|
|
.finally(() => this.set("refreshing", false));
|
|
},
|
|
|
|
@discourseComputed("hasLogs", "refreshing")
|
|
noResults(hasLogs, refreshing) {
|
|
return !hasLogs && !refreshing;
|
|
},
|
|
|
|
actions: {
|
|
loadMore() {
|
|
this.set("page", (this.page += 1));
|
|
this.loadLogs();
|
|
},
|
|
|
|
refresh() {
|
|
this.setProperties({
|
|
canLoadMore: true,
|
|
page: 0,
|
|
logs: [],
|
|
});
|
|
this.loadLogs();
|
|
},
|
|
},
|
|
});
|