rm redundant action

This commit is contained in:
Rimian Perkins 2019-12-10 10:15:30 +11:00
parent 1c31884475
commit 86bc9bb3e6
5 changed files with 27 additions and 15 deletions

View File

@ -0,0 +1,12 @@
import Button from "discourse/components/d-button";
export default Button.extend({
seleted: false,
init() {
this._super(...arguments);
this.classNameBindings = this.classNameBindings.concat(
"selected:btn-primary"
);
}
});

View File

@ -1,7 +1,8 @@
export default Ember.Component.extend({
actions: {
clickPlan(plan) {
this.selectPlan(plan);
this.plans.map(p => p.set("selected", false));
plan.set("selected", true);
}
}
});

View File

@ -9,10 +9,7 @@ export default Ember.Controller.extend({
);
const elements = this.get("stripe").elements();
this.set(
"cardElement",
elements.create("card", { hidePostalCode: true, disabled: true })
);
this.set("cardElement", elements.create("card", { hidePostalCode: true }));
},
actions: {

View File

@ -12,9 +12,10 @@
<div id="subscribe-buttons">
{{#each plans as |plan|}}
{{#d-button
{{#ds-button
action="clickPlan"
actionParam=plan
selected=plan.selected
class="btn btn-discourse-subscriptions-subscribe"
}}
<div class="interval">
@ -23,6 +24,6 @@
<span class="amount">
{{format-currency plan.currency plan.amountDollars}}
</span>
{{/d-button}}
{{/ds-button}}
{{/each}}
</div>

View File

@ -1,4 +1,5 @@
import componentTest from "helpers/component-test";
import EmberObject from "@ember/object";
moduleForComponent("payment-options", { integration: true });
@ -53,21 +54,21 @@ componentTest("Discourse Subscriptions payment options has content", {
});
componentTest("Discourse Subscriptions payment options plan is selected", {
template: `{{payment-options plans=plans selectPlan=selectPlan}}`,
template: `{{payment-options plans=plans}}`,
beforeEach() {},
async test(assert) {
assert.expect(1);
this.set("plans", [
{ currency: "aud", interval: "year", amountDollars: "44.99" },
{ currency: "gdp", interval: "month", amountDollars: "9.99" }
EmberObject.create({
currency: "aud",
interval: "year",
amountDollars: "44.99"
})
]);
this.set("selectPlan", function(plan) {
assert.equal(plan, this.get('plans.firstObject'), "the plan is selected");
});
await click(".btn-discourse-subscriptions-subscribe:first-child");
assert.ok(this.get("plans.firstObject.selected"), "it selected the plan");
}
});