add the basic form
This commit is contained in:
parent
e956551d0f
commit
f1de907c32
|
@ -1 +1,35 @@
|
||||||
export default Ember.Component.extend({});
|
import { default as computed } from "ember-addons/ember-computed-decorators";
|
||||||
|
|
||||||
|
export default Ember.Component.extend({
|
||||||
|
@computed
|
||||||
|
causes() {
|
||||||
|
const categoryEnabled =
|
||||||
|
Discourse.SiteSettings.discourse_donations_cause_category;
|
||||||
|
|
||||||
|
if (categoryEnabled) {
|
||||||
|
let categoryIds = Discourse.SiteSettings.discourse_donations_causes_categories.split(
|
||||||
|
"|"
|
||||||
|
);
|
||||||
|
|
||||||
|
if (categoryIds.length) {
|
||||||
|
categoryIds = categoryIds.map(Number);
|
||||||
|
return this.site
|
||||||
|
.get("categoriesList")
|
||||||
|
.filter(c => {
|
||||||
|
return categoryIds.indexOf(c.id) > -1;
|
||||||
|
})
|
||||||
|
.map(c => {
|
||||||
|
return {
|
||||||
|
id: c.id,
|
||||||
|
name: c.name
|
||||||
|
};
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const causes = Discourse.SiteSettings.discourse_donations_causes;
|
||||||
|
return causes ? causes.split("|") : [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
|
@ -1,2 +1,10 @@
|
||||||
|
<form id="payment-form" class="form-horizontal">
|
||||||
hello world
|
<div class="control-group discourse-donations-cause">
|
||||||
|
<label class="control-label">
|
||||||
|
{{i18n 'discourse_donations.cause.label'}}
|
||||||
|
</label>
|
||||||
|
<div class="controls controls-dropdown">
|
||||||
|
{{combo-box content=causes value=cause none='discourse_donations.cause.placeholder'}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
|
@ -2,10 +2,13 @@ import componentTest from "helpers/component-test";
|
||||||
|
|
||||||
moduleForComponent("donation-form", { integration: true });
|
moduleForComponent("donation-form", { integration: true });
|
||||||
|
|
||||||
componentTest("donation form", {
|
componentTest("donation form has content", {
|
||||||
template: `{{donation-form}}`,
|
template: `{{donation-form}}`,
|
||||||
|
|
||||||
test(assert) {
|
async test(assert) {
|
||||||
assert.ok(true);
|
assert.ok(find('#payment-form').length, 'The form renders');
|
||||||
|
assert.equal(find('.discourse-donations-cause .selected-name')
|
||||||
|
.text()
|
||||||
|
.trim(), 'Select a cause', 'It has the combo box');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue