DEV: Resolve deprecations for compatibility with latest ember (#20)

This commit is contained in:
David Taylor 2024-01-09 12:44:56 +00:00 committed by GitHub
parent 652ead612e
commit 4d7491226a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 19 deletions

View File

@ -8,7 +8,10 @@ export default Component.extend({
@discourseComputed("router.currentRoute.queryParams.cards")
showingCards(cardsParam) {
return cardsParam === "yes";
return (
cardsParam === "yes" ||
(cardsParam === undefined && settings.default_view === "cards")
);
},
actions: {

View File

@ -11,6 +11,15 @@ export default {
withPluginApi("0.8.7", (api) => {
api.modifyClass("route:users", {
pluginId: "user-card-directory",
get templateName() {
if (this.modelFor("users")?.showAsCards) {
return "users-as-card-directory";
} else {
return "users";
}
},
resetController(controller, isExiting) {
this._super(...arguments);
if (isExiting) {
@ -22,29 +31,15 @@ export default {
cards: { refreshModel: true },
},
beforeModel(transition) {
this._super(transition);
if (
settings.default_view === "cards" &&
!transition.to.queryParams.cards
) {
this.transitionTo({ queryParams: { cards: "yes" } });
}
},
model(params) {
return this._super(params).then((model) => {
model.showAsCards = params["cards"] === "yes";
model.showAsCards =
params["cards"] === "yes" ||
(params["cards"] === undefined &&
settings.default_view === "cards");
return model;
});
},
renderTemplate(controller, model) {
if (model.showAsCards) {
return this.render("users-as-card-directory");
}
return this._super();
},
});
api.modifyClass("controller:users", {