Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(document-view): change document search URL in document dossier #945

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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", () => []);
},
});
}
Loading