mirror of
https://github.com/discourse/discourse.git
synced 2025-05-10 01:23:09 +08:00
UX: Don't reload page after saving settings when editing category.
This commit is contained in:
parent
bc81f64a64
commit
dd142eec03
@ -64,29 +64,33 @@ export default Ember.Controller.extend(ModalFunctionality, {
|
|||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
saveCategory() {
|
saveCategory() {
|
||||||
const self = this,
|
const model = this.get("model");
|
||||||
model = this.get("model"),
|
|
||||||
parentCategory = this.site
|
const parentCategory = this.site
|
||||||
.get("categories")
|
.get("categories")
|
||||||
.findBy("id", parseInt(model.get("parent_category_id"), 10));
|
.findBy("id", parseInt(model.get("parent_category_id"), 10));
|
||||||
|
|
||||||
this.set("saving", true);
|
this.set("saving", true);
|
||||||
model.set("parentCategory", parentCategory);
|
model.set("parentCategory", parentCategory);
|
||||||
|
|
||||||
this.get("model")
|
model
|
||||||
.save()
|
.save()
|
||||||
.then(function(result) {
|
.then(result => {
|
||||||
self.set("saving", false);
|
this.set("saving", false);
|
||||||
self.send("closeModal");
|
|
||||||
model.setProperties({
|
model.setProperties({
|
||||||
slug: result.category.slug,
|
slug: result.category.slug,
|
||||||
id: result.category.id
|
id: result.category.id
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (this.get("selectedTab") !== "settings") {
|
||||||
|
this.send("closeModal");
|
||||||
DiscourseURL.redirectTo("/c/" + Discourse.Category.slugFor(model));
|
DiscourseURL.redirectTo("/c/" + Discourse.Category.slugFor(model));
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.catch(function(error) {
|
.catch(error => {
|
||||||
self.flash(extractError(error), "error");
|
this.flash(extractError(error), "error");
|
||||||
self.set("saving", false);
|
this.set("saving", false);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -3,7 +3,17 @@ import { acceptance } from "helpers/qunit-helpers";
|
|||||||
|
|
||||||
acceptance("Category Edit", {
|
acceptance("Category Edit", {
|
||||||
loggedIn: true,
|
loggedIn: true,
|
||||||
settings: { email_in: true }
|
settings: { email_in: true },
|
||||||
|
pretend(server, helper) {
|
||||||
|
server.post("/categories", () => {
|
||||||
|
return helper.response({
|
||||||
|
category: {
|
||||||
|
slug: "bug",
|
||||||
|
id: 999
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
QUnit.test("Can open the category modal", async assert => {
|
QUnit.test("Can open the category modal", async assert => {
|
||||||
@ -18,21 +28,25 @@ QUnit.test("Can open the category modal", async assert => {
|
|||||||
|
|
||||||
QUnit.test("Editing the category", async assert => {
|
QUnit.test("Editing the category", async assert => {
|
||||||
await visit("/c/bug");
|
await visit("/c/bug");
|
||||||
|
|
||||||
await click(".edit-category");
|
await click(".edit-category");
|
||||||
await fillIn("#edit-text-color", "#ff0000");
|
|
||||||
|
|
||||||
await click(".edit-category-topic-template");
|
await click(".edit-category-settings a");
|
||||||
await fillIn(".d-editor-input", "this is the new topic template");
|
|
||||||
|
|
||||||
await click(".edit-category-settings");
|
|
||||||
const searchPriorityChooser = selectKit("#category-search-priority");
|
const searchPriorityChooser = selectKit("#category-search-priority");
|
||||||
await searchPriorityChooser.expand();
|
await searchPriorityChooser.expand();
|
||||||
await searchPriorityChooser.selectRowByValue(1);
|
await searchPriorityChooser.selectRowByValue(1);
|
||||||
|
await click("#save-category");
|
||||||
|
|
||||||
|
assert.ok(visible(".d-modal"), "it does not close the modal");
|
||||||
|
|
||||||
|
await click(".edit-category-general a");
|
||||||
|
await fillIn("#edit-text-color", "#ff0000");
|
||||||
|
|
||||||
|
await click(".edit-category-topic-template a");
|
||||||
|
await fillIn(".d-editor-input", "this is the new topic template");
|
||||||
await click("#save-category");
|
await click("#save-category");
|
||||||
|
|
||||||
assert.ok(!visible(".d-modal"), "it closes the modal");
|
assert.ok(!visible(".d-modal"), "it closes the modal");
|
||||||
|
|
||||||
assert.equal(
|
assert.equal(
|
||||||
DiscourseURL.redirectedTo,
|
DiscourseURL.redirectedTo,
|
||||||
"/c/bug",
|
"/c/bug",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user