mirror of
https://github.com/discourse/discourse.git
synced 2025-04-15 22:30:59 +08:00
FIX: Should be possible to save an empty theme_field in the editor
Removing the theme_field JS object when the value was empty caused the server to maintain the previous value, making it impossible to delete the content of a field.
This commit is contained in:
parent
5d75bd4831
commit
d08939ab05
@ -60,7 +60,7 @@ const Theme = RestModel.extend({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@computed("fieldNames", "theme_fields.@each.error")
|
@computed("fieldNames", "theme_fields.[]", "theme_fields.@each.error")
|
||||||
fields(fieldNames) {
|
fields(fieldNames) {
|
||||||
const hash = {};
|
const hash = {};
|
||||||
Object.keys(fieldNames).forEach(target => {
|
Object.keys(fieldNames).forEach(target => {
|
||||||
@ -208,11 +208,15 @@ const Theme = RestModel.extend({
|
|||||||
this.theme_fields.pushObject(field);
|
this.theme_fields.pushObject(field);
|
||||||
themeFields[key] = field;
|
themeFields[key] = field;
|
||||||
} else {
|
} else {
|
||||||
if (Ember.isEmpty(value)) {
|
const changed =
|
||||||
this.theme_fields.removeObject(themeFields[key]);
|
(Ember.isEmpty(existingField.value) && !Ember.isEmpty(value)) ||
|
||||||
themeFields[key] = null;
|
(Ember.isEmpty(value) && !Ember.isEmpty(existingField.value));
|
||||||
} else {
|
|
||||||
existingField.value = value;
|
existingField.value = value;
|
||||||
|
if (changed) {
|
||||||
|
// Observing theme_fields.@each.value is too slow, so manually notify
|
||||||
|
// if the value goes to/from blank
|
||||||
|
this.notifyPropertyChange("theme_fields.[]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user