diff --git a/web/app/components/custom-editable-field.ts b/web/app/components/custom-editable-field.ts index e5bb6cef8..462742ce2 100644 --- a/web/app/components/custom-editable-field.ts +++ b/web/app/components/custom-editable-field.ts @@ -14,7 +14,7 @@ interface CustomEditableFieldComponentSignature { field: string; attributes: CustomEditableField; onChange: (value: any) => void; - loading?: boolean; + isSaving?: boolean; disabled?: boolean; }; } diff --git a/web/app/components/document/index.hbs b/web/app/components/document/index.hbs index 9a63b6b88..65e4008a0 100644 --- a/web/app/components/document/index.hbs +++ b/web/app/components/document/index.hbs @@ -1,4 +1,7 @@ -
+
-
+
{{#unless @modelIsChanging}} {{! diff --git a/web/app/components/document/index.ts b/web/app/components/document/index.ts index 0095d517d..09301b0e9 100644 --- a/web/app/components/document/index.ts +++ b/web/app/components/document/index.ts @@ -12,7 +12,6 @@ import { action } from "@ember/object"; interface DocumentIndexComponentSignature { document: HermesDocument; - docType: string; modelIsChanging: boolean; } @@ -30,6 +29,21 @@ export default class DocumentIndexComponent extends Component { try { let fetchResponse = await this.fetchSvc.fetch("/api/v1/drafts/" + docID, { diff --git a/web/app/components/document/sidebar.ts b/web/app/components/document/sidebar.ts index 20488c733..d2a62190b 100644 --- a/web/app/components/document/sidebar.ts +++ b/web/app/components/document/sidebar.ts @@ -28,13 +28,20 @@ import Ember from "ember"; import htmlElement from "hermes/utils/html-element"; import ConfigService from "hermes/services/config"; import isValidURL from "hermes/utils/is-valid-u-r-l"; +import { GoogleUser } from "../inputs/people-select"; import { HermesDocumentType } from "hermes/types/document-type"; +const serializePeople = (people: GoogleUser[]): HermesUser[] => { + return people.map((p) => ({ + email: p.emailAddresses[0]?.value as string, + imgURL: p.photos?.[0]?.url, + })); +}; + interface DocumentSidebarComponentSignature { Args: { profile: AuthenticatedUser; document: HermesDocument; - docType: HermesDocumentType; deleteDraft: (docId: string) => void; isCollapsed: boolean; toggleCollapsed: () => void; @@ -73,6 +80,8 @@ export default class DocumentSidebarComponent extends Component { + const docTypes = (await this.fetchSvc + .fetch("/api/v1/document-types") + .then((r) => r?.json())) as HermesDocumentType[]; + + assert("docTypes must exist", docTypes); + + const docType = docTypes.find( + (dt) => dt.name === this.args.document.docType + ); + + assert("docType must exist", docType); + this.docType = docType; + }); + @action refreshRoute() { // We force refresh due to a bug with `refreshModel: true` // See: https://github.com/emberjs/ember.js/issues/19260 @@ -510,6 +534,40 @@ export default class DocumentSidebarComponent extends Component { + let maybePromises = []; + + const contributorsPromise = this.fetchSvc + .fetch(`/api/v1/people?emails=${this.contributors.join(",")}`) + .then((r) => r?.json()); + + const approversPromise = this.fetchSvc + .fetch(`/api/v1/people?emails=${this.approvers.join(",")}`) + .then((r) => r?.json()); + + maybePromises.push(this.contributors.length ? contributorsPromise : []); + maybePromises.push(this.approvers.length ? approversPromise : []); + + if (!maybePromises.length) { + return; + } + + const [contributors, approvers] = await Promise.all(maybePromises); + + if (contributors.length) { + this.contributors = serializePeople(contributors); + } + + if (approvers.length) { + this.approvers = serializePeople(approvers); + } + }); + /** * A task that waits for a short time and then resolves. * Used to trigger the "link created" state of the share button. diff --git a/web/app/components/document/sidebar/header.hbs b/web/app/components/document/sidebar/header.hbs index 25af86344..bdf19afb5 100644 --- a/web/app/components/document/sidebar/header.hbs +++ b/web/app/components/document/sidebar/header.hbs @@ -1,4 +1,4 @@ -