mirror of https://github.com/rancher/ui.git
Add multiline support and some error checking
This commit is contained in:
parent
8ab81d73dc
commit
c8c11f4d38
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -66,6 +66,10 @@
|
|||
<option value={{option}}>{{option}}</option>
|
||||
{{/each}}
|
||||
</select>
|
||||
{{else}}
|
||||
{{#if (eq question.type 'multiline')}}
|
||||
{{textarea value=question.answer rows='5' class='form-control'}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
|
|
|
|||
Loading…
Reference in New Issue