DEV: Resolve deprecations for compatibility with latest ember (#20)
This commit is contained in:
parent
652ead612e
commit
4d7491226a
|
@ -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: {
|
||||
|
|
|
@ -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", {
|
||||
|
|
Loading…
Reference in New Issue