Skip to content

Commit

Permalink
fix: fixed the document sorting and removed some comments in the tag …
Browse files Browse the repository at this point in the history
…service
  • Loading branch information
StephanH90 authored and czosel committed Sep 17, 2021
1 parent 52057dc commit 77f1280
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
14 changes: 12 additions & 2 deletions addon/components/document-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,20 @@ export default class DocumentViewComponent extends Component {

constructor(parent, args) {
super(parent, args);
// Adds a key down event listener to enable Ctrl+A document selection of all docs
/* Adds a key down event listener to enable Ctrl+A document selection of all docs
as well as ESC key press for deselection of all docs */
window.addEventListener("keydown", (event) => {
this.handleKeyDown(event);
});

// Initiliase the sorting param of the route
if (this.router?.currentRoute?.queryParams?.sort) {
this.sort = decodeURIComponent(this.router.currentRoute.queryParams.sort);
if (this.sort[0] === "-") {
// reverse sorting
this.sortDirection = "-";
}
}
}

get canDrop() {
Expand All @@ -42,7 +52,7 @@ export default class DocumentViewComponent extends Component {
this.sortDirection = "";
}
this.router.transitionTo({
queryParams: { sort: this.sort, sortDirection: this.sortDirection },
queryParams: { sort: this.sortDirection + this.sort },
});
this.fetchDocuments.perform();
}
Expand Down
4 changes: 2 additions & 2 deletions addon/controllers/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export default class ApplicationController extends Controller {
tags: this.tags,
search: this.search,
activeGroup: this.activeGroup,
sort: this.sort,
sortDirection: this.sortDirection,
// sort: this.sort,
// sortDirection: this.sortDirection,
};

if (this.config && this.config.modelMetaFilters.document) {
Expand Down
4 changes: 1 addition & 3 deletions addon/services/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,8 @@ export default class TagsService extends Service {
* @returns {Object} addedTag The added tag
*/
@action async add(document, tag) {
// debugger;
if (typeof tag === "string") {
tag = tag.trim();
// const existing = this.allTags.findBy("name", tag);
const existing = this.allTags.findBy("id", dasherize(tag));
if (existing) {
tag = existing;
Expand Down Expand Up @@ -92,6 +90,6 @@ export default class TagsService extends Service {
document.tags.removeObject(tag);
await document.save();

this.fetchSearchTags.perform(); // TODO: Is this required?
this.fetchSearchTags.perform();
}
}

0 comments on commit 77f1280

Please sign in to comment.