Skip to content

Commit

Permalink
refactor(document-view): change document search URL in document dossier
Browse files Browse the repository at this point in the history
  • Loading branch information
MitanOmar committed Sep 16, 2024
1 parent 2e80c66 commit 10d3971
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
26 changes: 21 additions & 5 deletions addon/components/document-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,27 @@ export default class DocumentViewComponent extends Component {

@task
*fetchDocuments() {
const documents = yield this.store.query("document", {
include: "category,files,tags",
filter: this.args.filters || {},
sort: this.sort ? `${this.sortDirection}${this.sort}` : "",
});
const files = yield this.store.query(
"file",
{
include: "document,renderings",
filter: this.args.filters || {},
},
{
adapterOptions: {
customEndpoint: "search",
},
},
);

const documents = Array.from(
new Map(
files.map((file) => [
file.document.id,
this.store.peekRecord("document", file.document.id),
]),
).values(),
);

return yield this.config.documentsPostProcess(documents);
}
Expand Down
6 changes: 4 additions & 2 deletions addon/controllers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ export default class IndexController extends Controller {
category: this.category,
tags: this.tags.length ? this.tags.join(",") : undefined,
marks: this.marks.length ? this.marks.join(",") : undefined,
search: this.search,
query: this.search,
activeGroup: this.activeGroup,
};

if (this.config && this.config.modelMetaFilters?.document) {
filters = {
...filters,
metainfo: JSON.stringify(this.config.modelMetaFilters.document),
document_metainfo: JSON.stringify(
this.config.modelMetaFilters.document,
),
};
}

Expand Down

0 comments on commit 10d3971

Please sign in to comment.