ember-alexandria
Version:
Document management frontend for the alexandria backend
51 lines (44 loc) • 1.42 kB
JavaScript
import Route from "@ember/routing/route";
import { next } from "@ember/runloop";
import { service } from "@ember/service";
const PARAM_OPTIONS = { refreshModel: true };
export default class IndexRoute extends Route {
queryParams = {
category: PARAM_OPTIONS,
tags: PARAM_OPTIONS,
marks: PARAM_OPTIONS,
search: PARAM_OPTIONS,
document: PARAM_OPTIONS,
activeGroup: PARAM_OPTIONS,
listView: {},
};
("alexandria-config") config;
("alexandria-documents") documents;
("alexandria-marks") marks;
model() {}
afterModel(model, transition) {
/* Depending on how ember alexandria is used we might have to reset
the document selection on navigation */
if (Object.keys(transition.to.queryParams).length === 0) {
next(this, () => {
this.documents.clearDocumentSelection();
});
}
this.config.alexandriaQueryParams = transition.to.parent.params;
this.config.activeGroup = transition.to.queryParams.activeGroup;
}
resetController(controller) {
/* Depending on how ember alexandria is used we might have to reset
the document selection on navigation */
controller.setProperties({
category: undefined,
tags: [],
marks: [],
search: undefined,
document: undefined,
activeGroup: undefined,
sort: undefined,
});
this.documents.selectedDocuments = [];
}
}