mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 19:39:30 +08:00
Add ability to run validation on site settings. notification_email and other email address settings are now validated.
This commit is contained in:
@ -8,6 +8,8 @@
|
||||
**/
|
||||
Discourse.SiteSetting = Discourse.Model.extend({
|
||||
|
||||
validationMessage: null,
|
||||
|
||||
/**
|
||||
Is the boolean setting true?
|
||||
|
||||
@ -67,6 +69,7 @@ Discourse.SiteSetting = Discourse.Model.extend({
|
||||
**/
|
||||
resetValue: function() {
|
||||
this.set('value', this.get('originalValue'));
|
||||
this.set('validationMessage', null);
|
||||
},
|
||||
|
||||
/**
|
||||
@ -76,13 +79,20 @@ Discourse.SiteSetting = Discourse.Model.extend({
|
||||
**/
|
||||
save: function() {
|
||||
// Update the setting
|
||||
var setting = this, data = {};
|
||||
var self = this, data = {};
|
||||
data[this.get('setting')] = this.get('value');
|
||||
return Discourse.ajax("/admin/site_settings/" + this.get('setting'), {
|
||||
data: data,
|
||||
type: 'PUT'
|
||||
}).then(function() {
|
||||
setting.set('originalValue', setting.get('value'));
|
||||
self.set('originalValue', self.get('value'));
|
||||
self.set('validationMessage', null);
|
||||
}, function(e) {
|
||||
if (e.responseJSON && e.responseJSON.errors) {
|
||||
self.set('validationMessage', e.responseJSON.errors[0]);
|
||||
} else {
|
||||
self.set('validationMessage', I18n.t('generic_error'));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
Reference in New Issue
Block a user