Skip to content

Commit

Permalink
feat: save the status of documents view in the query parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
MitanOmar committed Nov 22, 2024
1 parent f4179e0 commit 3f662a8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion addon/components/document-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default class DocumentViewComponent extends Component {

@tracked isDragOver = false;
@tracked dragCounter = 0;
@tracked listView = true;
@tracked listView = this.args.listView === "true";
@tracked sort = "title";
@tracked sortDirection = "";
// Needed for ember-resource
Expand All @@ -38,9 +38,13 @@ export default class DocumentViewComponent extends Component {

@action toggleView() {
this.listView = !this.listView;
this.router.transitionTo(this.router.currentRouteName, {
queryParams: { listView: this.listView },
});
}

@action setSort(sortAttribute) {
debugger;
if (this.sort === sortAttribute) {
this.sortDirection = this.sortDirection === "" ? "-" : "";
} else {
Expand Down
2 changes: 2 additions & 0 deletions addon/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export default class IndexController extends Controller {
"document",
"activeGroup",
"sort",
"listView",
];

@service("alexandria-config") config;
Expand All @@ -22,6 +23,7 @@ export default class IndexController extends Controller {
@tracked document;
@tracked activeGroup;
@tracked sort;
@tracked listView = "true";

get documentFilters() {
let filters = {
Expand Down
1 change: 1 addition & 0 deletions addon/routes/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export default class IndexRoute extends Route {
search: PARAM_OPTIONS,
document: PARAM_OPTIONS,
activeGroup: PARAM_OPTIONS,
listView: PARAM_OPTIONS,
};

@service("alexandria-config") config;
Expand Down
1 change: 1 addition & 0 deletions addon/templates/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

<DocumentView
@filters={{this.documentFilters}}
@listView={{this.listView}}
class="uk-border-top"
/>
</section>
Expand Down

0 comments on commit 3f662a8

Please sign in to comment.