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() {
|
templateChanged: function() {
|
||||||
this.set('loading', true);
|
this.set('loading', true);
|
||||||
Ember.$.ajax(this.get('selectedTemplate'), 'GET').then((response) => {
|
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('selectedTemplateModel', response);
|
||||||
this.set('loading', false);
|
this.set('loading', false);
|
||||||
Ember.run.later(() => {
|
Ember.run.later(() => {
|
||||||
|
|
@ -80,14 +85,21 @@ export default Ember.Component.extend(NewOrEdit, {
|
||||||
},
|
},
|
||||||
validate: function() {
|
validate: function() {
|
||||||
var errors = [];
|
var errors = [];
|
||||||
|
if (!this.get('templateName')) {
|
||||||
if (!this.get('selectedTemplateModel').name) {
|
|
||||||
errors.push('Name is required');
|
errors.push('Name is required');
|
||||||
}
|
}
|
||||||
if (!this.get('selectedTemplateModel').description) {
|
if (!this.get('templateDescription')) {
|
||||||
errors.push('Description is required');
|
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) {
|
if (errors.length) {
|
||||||
this.set('errors', errors.uniq());
|
this.set('errors', errors.uniq());
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -66,6 +66,10 @@
|
||||||
<option value={{option}}>{{option}}</option>
|
<option value={{option}}>{{option}}</option>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</select>
|
</select>
|
||||||
|
{{else}}
|
||||||
|
{{#if (eq question.type 'multiline')}}
|
||||||
|
{{textarea value=question.answer rows='5' class='form-control'}}
|
||||||
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue