destroy plans
This commit is contained in:
parent
1bedc1ba2f
commit
e2f1f0f523
|
@ -8,8 +8,14 @@ module DiscoursePatrons
|
|||
before_action :set_api_key
|
||||
|
||||
def index
|
||||
begin
|
||||
plans = ::Stripe::Plan.list
|
||||
|
||||
render_json_dump plans.data
|
||||
|
||||
rescue ::Stripe::InvalidRequestError => e
|
||||
return render_json_error e.message
|
||||
end
|
||||
end
|
||||
|
||||
def create
|
||||
|
@ -31,8 +37,14 @@ module DiscoursePatrons
|
|||
end
|
||||
|
||||
def destroy
|
||||
begin
|
||||
plan = ::Stripe::Plan.delete(params[:id])
|
||||
|
||||
render_json_dump plan
|
||||
|
||||
rescue ::Stripe::InvalidRequestError => e
|
||||
return render_json_error e.message
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -6,7 +6,9 @@ const AdminPlan = Discourse.Model.extend({
|
|||
amount: 0,
|
||||
intervals: ["day", "week", "month", "year"],
|
||||
|
||||
destroy() {},
|
||||
destroy() {
|
||||
return ajax(`/patrons/admin/plans/${this.id}`, { method: "delete" });
|
||||
},
|
||||
|
||||
save() {
|
||||
const data = {
|
||||
|
@ -20,7 +22,7 @@ const AdminPlan = Discourse.Model.extend({
|
|||
});
|
||||
|
||||
AdminPlan.reopenClass({
|
||||
find() {
|
||||
findAll() {
|
||||
return ajax("/patrons/admin/plans", { method: "get" }).then(result =>
|
||||
result.map(plan => AdminPlan.create(plan))
|
||||
);
|
||||
|
|
|
@ -2,7 +2,7 @@ import AdminPlan from "discourse/plugins/discourse-patrons/discourse/models/admi
|
|||
|
||||
export default Discourse.Route.extend({
|
||||
model() {
|
||||
return AdminPlan.find();
|
||||
return AdminPlan.findAll();
|
||||
},
|
||||
|
||||
actions: {
|
||||
|
@ -13,9 +13,12 @@ export default Discourse.Route.extend({
|
|||
I18n.t("yes_value"),
|
||||
confirmed => {
|
||||
if (confirmed) {
|
||||
plan.destroy().then(() => {
|
||||
this.controllerFor("adminPluginsDiscoursePatronsPlansIndex")
|
||||
.get("model")
|
||||
.removeObject(plan);
|
||||
})
|
||||
.catch(data => bootbox.alert(data.jqXHR.responseJSON.errors.join("\n")));
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -68,7 +68,7 @@ en:
|
|||
active: Active
|
||||
product:
|
||||
product_id: Product ID
|
||||
group: Group
|
||||
group: User Group
|
||||
active: Active
|
||||
operations:
|
||||
destroy:
|
||||
|
|
Loading…
Reference in New Issue