diff --git a/addon/components/document-view.js b/addon/components/document-view.js index f680f7e0..0eb9c1ac 100644 --- a/addon/components/document-view.js +++ b/addon/components/document-view.js @@ -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); } diff --git a/addon/controllers/index.js b/addon/controllers/index.js index b391ab28..2393cd08 100644 --- a/addon/controllers/index.js +++ b/addon/controllers/index.js @@ -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, + ), }; } diff --git a/tests/dummy/mirage/config.js b/tests/dummy/mirage/config.js index 6050fbfa..b98887ed 100644 --- a/tests/dummy/mirage/config.js +++ b/tests/dummy/mirage/config.js @@ -27,6 +27,7 @@ export default function makeServer(config) { }); this.get("/files/multi", () => new Response(200, {}, {})); + this.get("/search", () => []); }, }); }