Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
UX: Move category editing/creation to its own page (#10973)
* Move new/edit category modals to its own page * Fix JS tests * Minor fixes to new-category UI * Add mobile toggle * Use global pretender endpoint so plugins can benefit too * Alignment fix * Minor review fixes * Styling refactor * Move some SCSS out of the modal
- Loading branch information
Showing
25 changed files
with
505 additions
and
351 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
app/assets/javascripts/discourse/app/routes/discovery-edit-category.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import I18n from "I18n"; | ||
import DiscourseRoute from "discourse/routes/discourse"; | ||
import Category from "discourse/models/category"; | ||
|
||
export default DiscourseRoute.extend({ | ||
model(params) { | ||
return Category.reloadBySlugPath(params.slug).then((result) => { | ||
const record = this.store.createRecord("category", result.category); | ||
record.setupGroupsAndPermissions(); | ||
this.site.updateCategory(record); | ||
return record; | ||
}); | ||
}, | ||
|
||
titleToken() { | ||
return I18n.t("category.edit_dialog_title", { | ||
categoryName: this.currentModel.name, | ||
}); | ||
}, | ||
|
||
renderTemplate() { | ||
this.render("edit-category", { | ||
controller: "edit-category", | ||
outlet: "list-container", | ||
model: this.currentModel, | ||
}); | ||
}, | ||
}); |
30 changes: 30 additions & 0 deletions
30
app/assets/javascripts/discourse/app/routes/discovery-edit-child-category.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import I18n from "I18n"; | ||
import DiscourseRoute from "discourse/routes/discourse"; | ||
import Category from "discourse/models/category"; | ||
|
||
export default DiscourseRoute.extend({ | ||
model(params) { | ||
return Category.reloadBySlug(params.slug, params.parentSlug).then( | ||
(result) => { | ||
const record = this.store.createRecord("category", result.category); | ||
record.setupGroupsAndPermissions(); | ||
this.site.updateCategory(record); | ||
return record; | ||
} | ||
); | ||
}, | ||
|
||
titleToken() { | ||
return I18n.t("category.edit_dialog_title", { | ||
categoryName: this.currentModel.name, | ||
}); | ||
}, | ||
|
||
renderTemplate() { | ||
this.render("edit-category", { | ||
controller: "edit-category", | ||
outlet: "list-container", | ||
model: this.currentModel, | ||
}); | ||
}, | ||
}); |
32 changes: 32 additions & 0 deletions
32
app/assets/javascripts/discourse/app/routes/new-category.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import I18n from "I18n"; | ||
import DiscourseRoute from "discourse/routes/discourse"; | ||
import { SEARCH_PRIORITIES } from "discourse/lib/constants"; | ||
|
||
export default DiscourseRoute.extend({ | ||
model() { | ||
const groups = this.site.groups, | ||
everyoneName = groups.findBy("id", 0).name; | ||
|
||
return this.store.createRecord("category", { | ||
color: "0088CC", | ||
text_color: "FFFFFF", | ||
group_permissions: [{ group_name: everyoneName, permission_type: 1 }], | ||
available_groups: groups.map((g) => g.name), | ||
allow_badges: true, | ||
topic_featured_link_allowed: true, | ||
custom_fields: {}, | ||
search_priority: SEARCH_PRIORITIES.normal, | ||
}); | ||
}, | ||
|
||
titleToken() { | ||
return I18n.t("category.create"); | ||
}, | ||
|
||
renderTemplate() { | ||
this.render("edit-category", { | ||
controller: "edit-category", | ||
model: this.currentModel, | ||
}); | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
6f5d8ca
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit has been mentioned on Discourse Meta. There might be relevant details there:
https://meta.discourse.org/t/how-to-edit-category/168510/4