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

Fix approver checkmarks #191

Merged
merged 1 commit into from
Jun 1, 2023
Merged
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
2 changes: 2 additions & 0 deletions web/app/components/document/sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@
{{#each this.approvers as |approver|}}
<li>
<Person::Approver
@document={{@document}}
@imgURL={{approver.imgURL}}
@email={{approver.email}}
/>
Expand All @@ -241,6 +242,7 @@
{{#each this.approvers as |approver|}}
<li>
<Person::Approver
@document={{@document}}
@imgURL={{approver.imgURL}}
@email={{approver.email}}
/>
Expand Down
2 changes: 1 addition & 1 deletion web/app/components/person/approver.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Person
@badge={{if (has-approved-doc @email) "approved"}}
@badge={{if (has-approved-doc @document @email) "approved"}}
@imgURL={{@imgURL}}
@email={{@email}}
/>
2 changes: 2 additions & 0 deletions web/app/components/person/approver.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import Component from "@glimmer/component";
import { HermesDocument } from "hermes/types/document";

interface PersonApproverComponentSignature {
Element: HTMLDivElement;
Args: {
document: HermesDocument;
email: string;
imgURL?: string;
};
Expand Down
29 changes: 23 additions & 6 deletions web/app/helpers/has-approved-doc.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
import { helper } from "@ember/component/helper";
import { HermesDocument } from "hermes/types/document";

export default helper(([document, approverEmail]: [HermesDocument, string]) => {
if (document.approvedBy) {
return document.approvedBy.some((email) => email === approverEmail);
} else {
return false;
export interface HasApprovedDocSignature {
Args: {
Positional: [HermesDocument, string];
};
Return: boolean;
}

const hasApprovedDoc = helper<HasApprovedDocSignature>(
([document, approverEmail]: [HermesDocument, string]) => {
if (document.approvedBy) {
return document.approvedBy.some((email) => email === approverEmail);
} else {
return false;
}
}
);

export default hasApprovedDoc;

declare module "@glint/environment-ember-loose/registry" {
export default interface Registry {
"has-approved-doc": typeof hasApprovedDoc;
}
});
}