2014-09-25 11:32:08 -04:00
|
|
|
import UserField from 'admin/models/user-field';
|
|
|
|
|
|
|
|
export default Ember.ArrayController.extend({
|
|
|
|
fieldTypes: null,
|
|
|
|
createDisabled: Em.computed.gte('model.length', 3),
|
2014-10-02 15:56:28 -04:00
|
|
|
|
|
|
|
userFieldsDescription: function() {
|
|
|
|
return I18n.t('admin.user_fields.description');
|
|
|
|
}.property(),
|
|
|
|
|
2014-09-26 14:48:34 -04:00
|
|
|
userFieldsName: function() {
|
|
|
|
return I18n.t('admin.user_fields.name');
|
|
|
|
}.property(),
|
2014-09-25 11:32:08 -04:00
|
|
|
|
|
|
|
_performDestroy: function(f, model) {
|
|
|
|
return f.destroy().then(function() {
|
|
|
|
model.removeObject(f);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
createField: function() {
|
2014-09-26 14:48:34 -04:00
|
|
|
this.pushObject(UserField.create({ field_type: 'text' }));
|
2014-09-25 11:32:08 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
destroy: function(f) {
|
|
|
|
var model = this.get('model'),
|
|
|
|
self = this;
|
|
|
|
|
|
|
|
// Only confirm if we already been saved
|
|
|
|
if (f.get('id')) {
|
|
|
|
bootbox.confirm(I18n.t("admin.user_fields.delete_confirm"), function(result) {
|
|
|
|
if (result) { self._performDestroy(f, model); }
|
|
|
|
});
|
|
|
|
} else {
|
|
|
|
self._performDestroy(f, model);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|