UX: Don't save automatically when resetting site settings in admin page.
This commit is contained in:
parent
656d82665d
commit
0fa92699e2
|
@ -17,7 +17,7 @@ const CUSTOM_TYPES = [
|
||||||
];
|
];
|
||||||
|
|
||||||
export default Ember.Mixin.create({
|
export default Ember.Mixin.create({
|
||||||
classNameBindings: [":row", ":setting", "setting.overridden", "typeClass"],
|
classNameBindings: [":row", ":setting", "overridden", "typeClass"],
|
||||||
content: Ember.computed.alias("setting"),
|
content: Ember.computed.alias("setting"),
|
||||||
validationMessage: null,
|
validationMessage: null,
|
||||||
isSecret: Ember.computed.oneWay("setting.secret"),
|
isSecret: Ember.computed.oneWay("setting.secret"),
|
||||||
|
@ -81,12 +81,16 @@ export default Ember.Mixin.create({
|
||||||
return "site-settings/" + typeClass;
|
return "site-settings/" + typeClass;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@computed("setting.default", "buffered.value")
|
||||||
|
overridden(settingDefault, bufferedValue) {
|
||||||
|
return settingDefault !== bufferedValue;
|
||||||
|
},
|
||||||
|
|
||||||
_watchEnterKey: function() {
|
_watchEnterKey: function() {
|
||||||
const self = this;
|
this.$().on("keydown.setting-enter", ".input-setting-string", e => {
|
||||||
this.$().on("keydown.setting-enter", ".input-setting-string", function(e) {
|
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
// enter key
|
// enter key
|
||||||
self.send("save");
|
this.send("save");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}.on("didInsertElement"),
|
}.on("didInsertElement"),
|
||||||
|
@ -124,7 +128,6 @@ export default Ember.Mixin.create({
|
||||||
|
|
||||||
resetDefault() {
|
resetDefault() {
|
||||||
this.set("buffered.value", this.get("setting.default"));
|
this.set("buffered.value", this.get("setting.default"));
|
||||||
this.send("save");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
toggleSecret() {
|
toggleSecret() {
|
||||||
|
|
|
@ -47,6 +47,19 @@ QUnit.test("changing value updates dirty state", async assert => {
|
||||||
"setting isn't marked as overriden after undo"
|
"setting isn't marked as overriden after undo"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
await click("button.cancel");
|
||||||
|
assert.ok(
|
||||||
|
exists(".row.setting.overridden"),
|
||||||
|
"setting is marked as overriden after cancel"
|
||||||
|
);
|
||||||
|
|
||||||
|
await click("button.undo");
|
||||||
|
await click("button.ok");
|
||||||
|
assert.ok(
|
||||||
|
!exists(".row.setting.overridden"),
|
||||||
|
"setting isn't marked as overriden after undo"
|
||||||
|
);
|
||||||
|
|
||||||
await fillIn(".input-setting-string", "Test");
|
await fillIn(".input-setting-string", "Test");
|
||||||
await keyEvent(".input-setting-string", "keydown", 13); // enter
|
await keyEvent(".input-setting-string", "keydown", 13); // enter
|
||||||
assert.ok(
|
assert.ok(
|
||||||
|
|
Loading…
Reference in New Issue