Skip to content

Commit

Permalink
Fix and expand RelatedHermesDocument type
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley committed Oct 18, 2023
1 parent 2376bca commit 8dc460b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class DocumentSidebarRelatedResourcesListItemResourceComponent ex
*/
protected get docType() {
this.assertResourceIsDocument(this.args.resource);
return this.args.resource.type;
return this.args.resource.documentType;
}

/**
Expand Down Expand Up @@ -73,7 +73,7 @@ export default class DocumentSidebarRelatedResourcesListItemResourceComponent ex
* with the correct data model.
*/
private assertResourceIsDocument(
document: RelatedResource
document: RelatedResource,
): asserts document is RelatedHermesDocument {
if (!("googleFileID" in document)) {
throw new Error("resource must be a document");
Expand Down
6 changes: 5 additions & 1 deletion web/app/components/related-resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ export interface RelatedHermesDocument {
id: number;
googleFileID: string;
title: string;
type: string;
documentType: string;
documentNumber: string;
sortOrder: number;
status: string;
owners?: string[];
ownerPhotos?: string[];
product?: string;
}

export enum RelatedResourcesScope {
Expand Down
13 changes: 8 additions & 5 deletions web/app/components/related-resources/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface RelatedResourcesAddComponentSignature {
dd: XDropdownListAnchorAPI | null,
query: string,
shouldIgnoreDelay?: boolean,
options?: SearchOptions
options?: SearchOptions,
) => Promise<void>;
getObject: (dd: XDropdownListAnchorAPI | null, id: string) => Promise<void>;
headerTitle: string;
Expand Down Expand Up @@ -329,8 +329,11 @@ export default class RelatedResourcesAddComponent extends Component<RelatedResou
const relatedHermesDocument = {
googleFileID: attrs.objectID,
title: attrs.title,
type: attrs.docType,
documentType: attrs.docType,
documentNumber: attrs.docNumber,
owners: attrs.owners,
ownerPhotos: attrs.ownerPhotos,
product: attrs.product,
sortOrder: 1,
} as RelatedHermesDocument;

Expand All @@ -352,7 +355,7 @@ export default class RelatedResourcesAddComponent extends Component<RelatedResou
*/
@action private checkForDuplicate(
urlOrID: string,
resourceIsHermesDocument = false
resourceIsHermesDocument = false,
) {
let isDuplicate = false;
if (resourceIsHermesDocument) {
Expand Down Expand Up @@ -400,7 +403,7 @@ export default class RelatedResourcesAddComponent extends Component<RelatedResou
*/
@action protected didInsertInput(
dd: XDropdownListAnchorAPI,
e: HTMLInputElement
e: HTMLInputElement,
) {
this.searchInput = e;
this._dd = dd;
Expand Down Expand Up @@ -626,7 +629,7 @@ export default class RelatedResourcesAddComponent extends Component<RelatedResou
private getAlgoliaObject = restartableTask(async (id: string) => {
assert(
"full url format expected",
this.firstPartyURLFormat === FirstPartyURLFormat.FullURL
this.firstPartyURLFormat === FirstPartyURLFormat.FullURL,
);

this.checkForDuplicate(id, true);
Expand Down
5 changes: 4 additions & 1 deletion web/mirage/factories/related-hermes-document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ export default Factory.extend({
title() {
return `Related Document ${this.id}`;
},
type: "RFC",
documentType: "RFC",
documentNumber() {
return `LAB-00${this.id}`;
},
status: "In review",
product: "Labs",
owners: ["[email protected]"],
});

0 comments on commit 8dc460b

Please sign in to comment.