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 5b4aab3
Show file tree
Hide file tree
Showing 3 changed files with 26 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
1 change: 1 addition & 0 deletions tests/dummy/mirage/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function makeServer(config) {
});

this.get("/files/multi", () => new Response(200, {}, {}));
this.get("/search", () => []);
},
});
}

0 comments on commit 5b4aab3

Please sign in to comment.