From 1fff3b5b86ac495804fe4ffb3442043e149ee80b Mon Sep 17 00:00:00 2001 From: Kim Shepherd Date: Mon, 24 Mar 2025 12:56:32 +0100 Subject: [PATCH] Request-a-copy: Changes to support access expiry as delta/date storage - psql max --- .../core/data/item-request-data.service.ts | 24 +--------- .../email-request-copy.component.html | 4 +- .../email-request-copy.component.ts | 46 ++++++++++++++++--- .../themed-email-request-copy.component.ts | 7 +-- .../grant-request-copy.component.html | 2 +- .../grant-request-copy.component.ts | 7 ++- .../email-request-copy.component.ts | 7 ++- 7 files changed, 58 insertions(+), 39 deletions(-) diff --git a/src/app/core/data/item-request-data.service.ts b/src/app/core/data/item-request-data.service.ts index 351c96a70d..7c0bb9f21e 100644 --- a/src/app/core/data/item-request-data.service.ts +++ b/src/app/core/data/item-request-data.service.ts @@ -125,7 +125,7 @@ export class ItemRequestDataService extends IdentifiableDataService * @param suggestOpenAccess Whether or not to suggest the item to become open access * @param accessPeriod How long in seconds to grant access, from the decision date (only applies to links, not attachments) */ - grant(token: string, email: RequestCopyEmail, suggestOpenAccess = false, accessPeriod = 0): Observable> { + grant(token: string, email: RequestCopyEmail, suggestOpenAccess = false, accessPeriod: string = null): Observable> { return this.process(token, email, true, suggestOpenAccess, accessPeriod); } @@ -137,7 +137,7 @@ export class ItemRequestDataService extends IdentifiableDataService * @param suggestOpenAccess Whether or not to suggest the item to become open access * @param accessPeriod How long in seconds to grant access, from the decision date (only applies to links, not attachments) */ - process(token: string, email: RequestCopyEmail, grant: boolean, suggestOpenAccess = false, accessPeriod = 0): Observable> { + process(token: string, email: RequestCopyEmail, grant: boolean, suggestOpenAccess = false, accessPeriod: string = null): Observable> { const requestId = this.requestService.generateRequestId(); this.getItemRequestEndpointByToken(token).pipe( @@ -161,26 +161,6 @@ export class ItemRequestDataService extends IdentifiableDataService return this.rdbService.buildFromRequestUUID(requestId); } - // TODO: Remove this, after discussion about implications and compare to bitstream data service byItemHandle - // Reviewers may ask that we instead just wrap the REST response in pagination even though we only expect one obj - /** - * Get a sanitized item request using the searchBy method and the access token sent to the original requester. - * - * @param accessToken access token contained in the secure link sent to a requester - */ - getSanitizedRequestByAccessTokenPaged(accessToken: string): Observable>> { - // We only expect / want one result as access tokens are unique - const findListOptions = Object.assign({}, new FindListOptions(), { - elementsPerPage: 1, - currentPage: 1, - searchParams: [ - new RequestParam('accessToken', accessToken), - ], - }); - // Pipe the paginated searchBy results and return a single item request - return this.searchBy('byAccessToken', findListOptions); - } - /** * Get a sanitized item request using the searchBy method and the access token sent to the original requester. * diff --git a/src/app/request-copy/email-request-copy/email-request-copy.component.html b/src/app/request-copy/email-request-copy/email-request-copy.component.html index 473d976d0d..c3fe7d0435 100644 --- a/src/app/request-copy/email-request-copy/email-request-copy.component.html +++ b/src/app/request-copy/email-request-copy/email-request-copy.component.html @@ -15,7 +15,7 @@ - @if (hasValue(validAccessPeriods) && validAccessPeriods.length > 0) { + @if (hasValue(validAccessPeriods$ | async) && (validAccessPeriods$ | async).length > 0) {
@@ -28,7 +28,7 @@
- @for (accessPeriod of validAccessPeriods; track accessPeriod) { + @for (accessPeriod of (validAccessPeriods$ | async); track accessPeriod) {