I’m trying to observe changes to the model of the EditCategoryTabs controller but for some reasons, nothing happens:
import { observes } from "@ember-decorators/object"
import { withPluginApi } from "discourse/lib/plugin-api"
function initialize(api) {
api.modifyClass(
"controller:edit-category.tabs",
(Superclass) =>
class extends Superclass {
@observes("model.parent_category_id")
onParentCategoryChange() {
console.log("Apply some logic here when parent category changes");
}
}
);
}
export default {
name: "new-category-permissions",
initialize() {
withPluginApi(initialize);
},
}
I tried many things but I’m still not able to trigger the observer callback when the model changes. Anything I missed that might explain how to this correctly?
For the context, I’m using Discourse 3.5.1 built with official launcher.
Thanks @Arkshine for having a look! I can’t edit the post to reflect the new file location.
I thought about overriding saveCategory too but in that case I would like to apply the logic as soon as the form is modified. I even tried to observe change on the formData (without success).