mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 13:01:14 +08:00
FEATURE: Admin interface for adding custom fields for users
This commit is contained in:
@ -0,0 +1,36 @@
|
||||
import UserField from 'admin/models/user-field';
|
||||
|
||||
export default Ember.ArrayController.extend({
|
||||
fieldTypes: null,
|
||||
|
||||
createDisabled: Em.computed.gte('model.length', 3),
|
||||
|
||||
_performDestroy: function(f, model) {
|
||||
return f.destroy().then(function() {
|
||||
model.removeObject(f);
|
||||
});
|
||||
},
|
||||
|
||||
actions: {
|
||||
createField: function() {
|
||||
this.pushObject(UserField.create({
|
||||
field_type: 'text',
|
||||
name: I18n.t('admin.user_fields.untitled')
|
||||
}));
|
||||
},
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user