Skip to content

Commit

Permalink
feat(list): add url for LinkTo generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Yelinz committed Jun 13, 2024
1 parent 2e6ecda commit e1f376d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 15 deletions.
18 changes: 11 additions & 7 deletions addon/components/document-list-item.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,17 @@
</td>
{{else if (eq column "link")}}
<td>
{{#let (this.config.documentListLinkTo @document) as |linkConfig|}}
<LinkTo
@route={{linkConfig.route}}
@query={{hash document=@document.id}}
>
{{linkConfig.label}}
</LinkTo>
{{#let (await (this.config.documentListLinkTo @document)) as |linkConfig|}}
{{#if linkConfig.url}}
<a href={{linkConfig.url}}>{{linkConfig.label}}</a>
{{else}}
<LinkTo
@route={{linkConfig.route}}
@query={{hash document=@document.id}}
>
{{linkConfig.label}}
</LinkTo>
{{/if}}
{{/let}}
</td>
{{else if (eq column "date")}}
Expand Down
28 changes: 20 additions & 8 deletions tests/dummy/app/services/alexandria-config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { later } from "@ember/runloop";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { macroCondition, isTesting } from "@embroider/macros";

import AlexandriaConfigService from "ember-alexandria/services/alexandria-config";

export default class CustomAlexandriaConfigService extends AlexandriaConfigService {
@service router;

enablePDFConversion = true;
enableWebDAV = true;

Expand Down Expand Up @@ -35,18 +38,27 @@ export default class CustomAlexandriaConfigService extends AlexandriaConfigServi
return {};
}

resolveUser(id) {
async resolveUser(id) {
const timeout = macroCondition(isTesting()) ? 1 : 200;

return new Promise((resolve) =>
later(this, () => resolve((id || "").toUpperCase()), timeout),
);
await new Promise((resolve) => setTimeout(resolve, timeout));

return (id || "-").toUpperCase();
}

documentListLinkTo() {
@action
async documentListLinkTo(document) {
const timeout = macroCondition(isTesting()) ? 1 : 200;

await new Promise((resolve) => setTimeout(resolve, timeout));

return {
route: "index",
label: "To document detail",
url: this.router.urlFor("alexandria-meta", 1, {
queryParams: {
document: document.id,
},
}),
label: "View Detail",
};
}
}

0 comments on commit e1f376d

Please sign in to comment.