Meta topic: https://meta.discourse.org/t/subscriptions-add-pagination-to-admin-subscriptions-view/172500 This adds support for pagination using our `{{load-more}}` component in core. Implementation on the backend was a bit tricky because we don't return all results from Stripe, only those that match local subscriptions stored in the `DiscourseSubscriptions::Subscription` model.
31 lines
838 B
JavaScript
31 lines
838 B
JavaScript
import AdminSubscription from "discourse/plugins/discourse-subscriptions/discourse/models/admin-subscription";
|
|
import Controller from "@ember/controller";
|
|
import showModal from "discourse/lib/show-modal";
|
|
|
|
export default Controller.extend({
|
|
loading: false,
|
|
|
|
actions: {
|
|
showCancelModal(subscription) {
|
|
showModal("admin-cancel-subscription", {
|
|
model: subscription,
|
|
});
|
|
},
|
|
|
|
loadMore() {
|
|
if (!this.loading && this.model.has_more) {
|
|
this.set("loading", true);
|
|
|
|
return AdminSubscription.loadMore(this.model.last_record).then(
|
|
(result) => {
|
|
const updated = this.model.data.concat(result.data);
|
|
this.set("model", result);
|
|
this.set("model.data", updated);
|
|
this.set("loading", false);
|
|
}
|
|
);
|
|
}
|
|
},
|
|
},
|
|
});
|