FIX: Reset category edit page button state (#11218)

Fixes two small issues:
- buttons stayed disabled after deleting a category
- on a newly-created category, the Edit button was missing on the category landing page
This commit is contained in:
Penar Musaraj 2020-11-12 10:03:58 -05:00 committed by GitHub
parent df003eaf7b
commit 698b7ace10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,6 +95,7 @@ export default Controller.extend({
model.setProperties({ model.setProperties({
slug: result.category.slug, slug: result.category.slug,
id: result.category.id, id: result.category.id,
can_edit: result.category.can_edit,
permission: PermissionType.FULL, permission: PermissionType.FULL,
notification_level: NotificationLevels.REGULAR, notification_level: NotificationLevels.REGULAR,
}); });
@ -115,15 +116,19 @@ export default Controller.extend({
I18n.t("yes_value"), I18n.t("yes_value"),
(result) => { (result) => {
if (result) { if (result) {
this.model.destroy().then( this.model
.destroy()
.then(
() => { () => {
this.transitionToRoute("discovery.categories"); this.transitionToRoute("discovery.categories");
}, },
() => { () => {
this.displayErrors([I18n.t("category.delete_error")]); this.displayErrors([I18n.t("category.delete_error")]);
this.set("deleting", false);
} }
); )
.finally(() => {
this.set("deleting", false);
});
} else { } else {
this.set("deleting", false); this.set("deleting", false);
} }