diff --git a/app/components/modal-catalog-launch/component.js b/app/components/modal-catalog-launch/component.js index 318a37d82..67d09f092 100644 --- a/app/components/modal-catalog-launch/component.js +++ b/app/components/modal-catalog-launch/component.js @@ -41,6 +41,11 @@ export default Ember.Component.extend(NewOrEdit, { templateChanged: function() { this.set('loading', true); Ember.$.ajax(this.get('selectedTemplate'), 'GET').then((response) => { + if (response.questions) { + response.questions.forEach((item) => { + item.answer = item.default; + }); + } this.set('selectedTemplateModel', response); this.set('loading', false); Ember.run.later(() => { @@ -80,14 +85,21 @@ export default Ember.Component.extend(NewOrEdit, { }, validate: function() { var errors = []; - - if (!this.get('selectedTemplateModel').name) { + if (!this.get('templateName')) { errors.push('Name is required'); } - if (!this.get('selectedTemplateModel').description) { + if (!this.get('templateDescription')) { errors.push('Description is required'); } + if (this.get('selectedTemplateModel.questions')) { + this.get('selectedTemplateModel.questions').forEach((item) => { + if (item.required && !item.answer){ + errors.push(`${item.label} is required`); + } + }); + } + if (errors.length) { this.set('errors', errors.uniq()); return false; diff --git a/app/components/modal-catalog-launch/template.hbs b/app/components/modal-catalog-launch/template.hbs index 3a6e269fd..c8ae85478 100644 --- a/app/components/modal-catalog-launch/template.hbs +++ b/app/components/modal-catalog-launch/template.hbs @@ -66,6 +66,10 @@ {{/each}} + {{else}} + {{#if (eq question.type 'multiline')}} + {{textarea value=question.answer rows='5' class='form-control'}} + {{/if}} {{/if}} {{/if}} {{/if}}