2020-09-18 10:14:06 +00:00
|
|
|
import Component from '@ember/component';
|
|
|
|
|
|
|
|
export default Component.extend({
|
|
|
|
tagName: '',
|
2020-09-30 11:33:01 +00:00
|
|
|
|
|
|
|
shouldShowPermissionForm: false,
|
|
|
|
|
2020-09-18 10:14:06 +00:00
|
|
|
actions: {
|
|
|
|
createNewLabel: function(template, term) {
|
|
|
|
return template.replace(/{{term}}/g, term);
|
|
|
|
},
|
|
|
|
isUnique: function(items, term) {
|
|
|
|
return !items.findBy('Name', term);
|
|
|
|
},
|
2020-09-30 11:33:01 +00:00
|
|
|
add: function(name, changeset, value) {
|
|
|
|
if (!(changeset.get(name) || []).includes(value) && value.isNew) {
|
|
|
|
changeset.pushObject(name, value);
|
|
|
|
changeset.validate();
|
|
|
|
}
|
|
|
|
},
|
|
|
|
delete: function(name, changeset, value) {
|
|
|
|
if ((changeset.get(name) || []).includes(value)) {
|
|
|
|
changeset.removeObject(name, value);
|
|
|
|
changeset.validate();
|
|
|
|
}
|
|
|
|
},
|
2020-09-18 10:14:06 +00:00
|
|
|
},
|
|
|
|
});
|