save plan model
This commit is contained in:
+5
-1
@@ -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" });
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
+22
-1
@@ -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({});
|
||||
|
||||
+17
-2
@@ -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}}
|
||||
|
||||
Reference in New Issue
Block a user