2021-12-09 07:47:56 -05:00
|
|
|
import { action } from "@ember/object";
|
2019-10-23 13:06:54 -04:00
|
|
|
import Controller from "@ember/controller";
|
2022-11-07 11:39:27 -05:00
|
|
|
import { inject as service } from "@ember/service";
|
2019-04-26 06:16:21 -04:00
|
|
|
|
2019-10-23 13:06:54 -04:00
|
|
|
export default Controller.extend({
|
2022-11-07 11:39:27 -05:00
|
|
|
router: service(),
|
|
|
|
|
|
|
|
get adminRoutes() {
|
|
|
|
return this.allAdminRoutes.filter((r) => this.routeExists(r.full_location));
|
|
|
|
},
|
|
|
|
|
|
|
|
get brokenAdminRoutes() {
|
|
|
|
return this.allAdminRoutes.filter(
|
|
|
|
(r) => !this.routeExists(r.full_location)
|
|
|
|
);
|
|
|
|
},
|
|
|
|
|
|
|
|
get allAdminRoutes() {
|
2019-05-27 04:15:39 -04:00
|
|
|
return this.model
|
2022-11-07 11:39:27 -05:00
|
|
|
.filter((p) => p?.enabled)
|
2017-02-09 12:11:53 -05:00
|
|
|
.map((p) => {
|
2022-11-07 11:39:27 -05:00
|
|
|
return p.admin_route;
|
2017-02-09 12:11:53 -05:00
|
|
|
})
|
2022-11-07 11:39:27 -05:00
|
|
|
.filter(Boolean);
|
2019-04-26 06:16:21 -04:00
|
|
|
},
|
|
|
|
|
2021-12-09 07:47:56 -05:00
|
|
|
@action
|
|
|
|
toggleMenu() {
|
|
|
|
const adminDetail = document.querySelector(".admin-detail");
|
|
|
|
["mobile-closed", "mobile-open"].forEach((state) => {
|
|
|
|
adminDetail.classList.toggle(state);
|
|
|
|
});
|
2018-07-02 23:14:53 -04:00
|
|
|
},
|
2022-11-07 11:39:27 -05:00
|
|
|
|
|
|
|
routeExists(routeName) {
|
|
|
|
try {
|
|
|
|
this.router.urlFor(routeName);
|
|
|
|
return true;
|
|
|
|
} catch (e) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2015-02-06 17:32:59 -05:00
|
|
|
});
|