2015-11-16 13:09:13 +01:00
|
|
|
import Ember from 'ember';
|
|
|
|
|
|
|
|
export default Ember.Component.extend({
|
|
|
|
actions: {
|
|
|
|
add(element) {
|
2016-01-22 00:19:46 +01:00
|
|
|
this.sendAction('addElement', element);
|
2015-11-16 13:09:13 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
del(element) {
|
|
|
|
if (this.get('canDeleteInputFields')) {
|
2016-01-22 00:19:46 +01:00
|
|
|
this.sendAction('deleteElement', element);
|
2015-11-16 13:09:13 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
userInteraction() {
|
|
|
|
if (!this.get('shouldShowErrors')) {
|
|
|
|
this.set('shouldShowErrors', true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
canDeleteInputFields: Ember.computed('minimumInputFields', 'content.[]', function() {
|
|
|
|
if (this.get('content.length') > this.get('minimumInputFields')) {
|
|
|
|
return true;
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
|
|
|
canNotDeleteInputFields: Ember.computed('canDeleteInputFields', function() {
|
|
|
|
return !this.get('canDeleteInputFields');
|
|
|
|
}),
|
|
|
|
|
2016-01-22 00:19:46 +01:00
|
|
|
classNames: ['grouped-input'],
|
2015-11-16 13:09:13 +01:00
|
|
|
classNameBindings: ['errorClass'],
|
|
|
|
|
2015-11-19 21:16:32 +01:00
|
|
|
errors: [],
|
|
|
|
|
2015-11-22 19:15:15 +01:00
|
|
|
errorClass: Ember.computed('showErrors', 'errors', function() {
|
2016-01-19 05:46:52 +01:00
|
|
|
if (this.get('showErrors')) {
|
2015-11-22 19:15:15 +01:00
|
|
|
return this.get('fmConfig').errorClass;
|
2015-11-16 13:09:13 +01:00
|
|
|
}
|
|
|
|
}),
|
|
|
|
|
2015-11-22 19:15:15 +01:00
|
|
|
fmConfig: Ember.inject.service('fm-config'),
|
|
|
|
|
2015-11-16 13:09:13 +01:00
|
|
|
minimumInputFields: 1,
|
|
|
|
|
2015-11-19 21:16:32 +01:00
|
|
|
shouldShowErrors: false,
|
|
|
|
|
|
|
|
step: undefined,
|
|
|
|
|
|
|
|
type: undefined
|
2015-11-16 13:09:13 +01:00
|
|
|
});
|