save plan model

This commit is contained in:
Rimian Perkins
2019-09-24 20:44:51 +10:00
parent 0d82bcf37e
commit a2d120c8b5
14 changed files with 109 additions and 18 deletions
@@ -1,7 +1,11 @@
export default Ember.Controller.extend({
actions: {
createPlan() {
this.transitionToRoute("adminPlugins.discourse-patrons.plans");
this.get("model")
.save()
.then(() => {
this.transitionToRoute("adminPlugins.discourse-patrons.plans");
});
}
}
});
@@ -5,7 +5,7 @@ export default {
this.route("discourse-patrons", function() {
this.route("subscriptions");
this.route("plans", function() {
this.route("show", { path: '/:plan-id' });
this.route("show", { path: "/:plan-id" });
});
});
}
@@ -1 +1,22 @@
export default Discourse.Route.extend({});
import { ajax } from "discourse/lib/ajax";
export default Discourse.Route.extend({
model() {
return Ember.Object.create({
name: "",
interval: "month",
amount: 0,
intervals: ["day", "week", "month", "year"],
save() {
const data = {
interval: this.interval,
amount: this.amount,
name: this.name
};
return ajax("/patrons/admin/plans", { method: "post", data });
}
});
}
});
@@ -0,0 +1 @@
export default Discourse.Route.extend({});
@@ -1,7 +1,22 @@
<h4>[plans show]</h4>
<h4>{{i18n 'discourse_patrons.admin.plans.title'}}</h4>
<form class="form-horizontal">
<div>
<label for="name">{{i18n 'discourse_patrons.admin.plans.show.name'}}</label>
{{input type="text" name="name" value=model.name}}
</div>
<div>
<label for="amount">{{i18n 'discourse_patrons.admin.plans.show.amount'}}</label>
{{input type="text" name="name" value=model.amount}}
</div>
<div>
<label for="interval">{{i18n 'discourse_patrons.admin.plans.show.interval'}}</label>
{{combo-box valueAttribute="value" content=model.intervals value=model.interval}}
</div>
</form>
<div class="buttons">
{{d-button label="plans.show" action="createPlan" icon="plus"}}
{{d-button label="discourse_patrons.admin.plans.show.create" action="createPlan" icon="plus"}}
</div>
@@ -1,7 +1,10 @@
<h3>{{i18n 'discourse_patrons.admin.plans.title'}}</h3>
{{#link-to 'adminPlugins.discourse-patrons.plans.show' 'new' class="btn btn-primary"}}
{{d-icon "plus"}}
<span>{{i18n 'discourse_patrons.admin.plans.new'}}</span>
{{/link-to}}
{{outlet}}