rm redundant action
This commit is contained in:
parent
1c31884475
commit
86bc9bb3e6
|
@ -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"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
|
@ -1,7 +1,8 @@
|
||||||
export default Ember.Component.extend({
|
export default Ember.Component.extend({
|
||||||
actions: {
|
actions: {
|
||||||
clickPlan(plan) {
|
clickPlan(plan) {
|
||||||
this.selectPlan(plan);
|
this.plans.map(p => p.set("selected", false));
|
||||||
|
plan.set("selected", true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,10 +9,7 @@ export default Ember.Controller.extend({
|
||||||
);
|
);
|
||||||
const elements = this.get("stripe").elements();
|
const elements = this.get("stripe").elements();
|
||||||
|
|
||||||
this.set(
|
this.set("cardElement", elements.create("card", { hidePostalCode: true }));
|
||||||
"cardElement",
|
|
||||||
elements.create("card", { hidePostalCode: true, disabled: true })
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
|
|
|
@ -12,9 +12,10 @@
|
||||||
|
|
||||||
<div id="subscribe-buttons">
|
<div id="subscribe-buttons">
|
||||||
{{#each plans as |plan|}}
|
{{#each plans as |plan|}}
|
||||||
{{#d-button
|
{{#ds-button
|
||||||
action="clickPlan"
|
action="clickPlan"
|
||||||
actionParam=plan
|
actionParam=plan
|
||||||
|
selected=plan.selected
|
||||||
class="btn btn-discourse-subscriptions-subscribe"
|
class="btn btn-discourse-subscriptions-subscribe"
|
||||||
}}
|
}}
|
||||||
<div class="interval">
|
<div class="interval">
|
||||||
|
@ -23,6 +24,6 @@
|
||||||
<span class="amount">
|
<span class="amount">
|
||||||
{{format-currency plan.currency plan.amountDollars}}
|
{{format-currency plan.currency plan.amountDollars}}
|
||||||
</span>
|
</span>
|
||||||
{{/d-button}}
|
{{/ds-button}}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import componentTest from "helpers/component-test";
|
import componentTest from "helpers/component-test";
|
||||||
|
import EmberObject from "@ember/object";
|
||||||
|
|
||||||
moduleForComponent("payment-options", { integration: true });
|
moduleForComponent("payment-options", { integration: true });
|
||||||
|
|
||||||
|
@ -53,21 +54,21 @@ componentTest("Discourse Subscriptions payment options has content", {
|
||||||
});
|
});
|
||||||
|
|
||||||
componentTest("Discourse Subscriptions payment options plan is selected", {
|
componentTest("Discourse Subscriptions payment options plan is selected", {
|
||||||
template: `{{payment-options plans=plans selectPlan=selectPlan}}`,
|
template: `{{payment-options plans=plans}}`,
|
||||||
|
|
||||||
beforeEach() {},
|
beforeEach() {},
|
||||||
|
|
||||||
async test(assert) {
|
async test(assert) {
|
||||||
assert.expect(1);
|
|
||||||
this.set("plans", [
|
this.set("plans", [
|
||||||
{ currency: "aud", interval: "year", amountDollars: "44.99" },
|
EmberObject.create({
|
||||||
{ currency: "gdp", interval: "month", amountDollars: "9.99" }
|
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");
|
await click(".btn-discourse-subscriptions-subscribe:first-child");
|
||||||
|
|
||||||
|
assert.ok(this.get("plans.firstObject.selected"), "it selected the plan");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue