add the basic form

This commit is contained in:
Rimian Perkins 2019-08-27 22:05:30 +10:00
parent e956551d0f
commit f1de907c32
3 changed files with 51 additions and 6 deletions

View File

@ -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("|") : [];
}
}
});

View File

@ -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>

View File

@ -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');
} }
}); });