Request-a-copy: Changes to support access expiry as delta/date storage

This commit is contained in:
Kim Shepherd
2025-03-18 18:07:27 +01:00
parent 16451807f9
commit 57b618ce34
6 changed files with 16 additions and 16 deletions

View File

@@ -211,11 +211,10 @@ export class ItemRequestDataService extends IdentifiableDataService<ItemRequest>
* if the 'send secure link' feature is configured. * if the 'send secure link' feature is configured.
* Expects integer values, conversion to number is done in this processing * Expects integer values, conversion to number is done in this processing
*/ */
getConfiguredAccessPeriods(): Observable<number[]> { getConfiguredAccessPeriods(): Observable<string[]> {
return this.configService.findByPropertyName('request.item.grant.link.period').pipe( return this.configService.findByPropertyName('request.item.grant.link.period').pipe(
getFirstCompletedRemoteData(), getFirstCompletedRemoteData(),
map((propertyRD: RemoteData<ConfigurationProperty>) => propertyRD.hasSucceeded ? propertyRD.payload.values : []), map((propertyRD: RemoteData<ConfigurationProperty>) => propertyRD.hasSucceeded ? propertyRD.payload.values : []),
map((values) => values.map(value => parseInt(value, 10))),
); );
} }

View File

@@ -86,10 +86,10 @@ export class ItemRequest implements CacheableObject {
@autoserialize @autoserialize
accessToken: string; accessToken: string;
/** /**
* Access period of the request * Access expiry date of the request
*/ */
@autoserialize @autoserialize
accessPeriod: number; accessExpiry: string;
/** /**
* The {@link HALLink}s for this ItemRequest * The {@link HALLink}s for this ItemRequest

View File

@@ -45,7 +45,7 @@ describe('EmailRequestCopyComponent', () => {
spyOn(component.send, 'emit').and.stub(); spyOn(component.send, 'emit').and.stub();
component.subject = 'test-subject'; component.subject = 'test-subject';
component.message = 'test-message'; component.message = 'test-message';
component.validAccessPeriods = [0]; component.validAccessPeriods = ['FOREVER'];
component.submit(); component.submit();
expect(component.send.emit).toHaveBeenCalledWith(new RequestCopyEmail('test-subject', 'test-message')); expect(component.send.emit).toHaveBeenCalledWith(new RequestCopyEmail('test-subject', 'test-message'));
}); });

View File

@@ -34,7 +34,7 @@ export class EmailRequestCopyComponent implements OnInit {
* Event emitter for sending the email * Event emitter for sending the email
*/ */
@Output() send: EventEmitter<RequestCopyEmail> = new EventEmitter<RequestCopyEmail>(); @Output() send: EventEmitter<RequestCopyEmail> = new EventEmitter<RequestCopyEmail>();
@Output() selectedAccessPeriod: EventEmitter<number> = new EventEmitter(); @Output() selectedAccessPeriod: EventEmitter<string> = new EventEmitter();
/** /**
* The subject of the email * The subject of the email
@@ -49,12 +49,13 @@ export class EmailRequestCopyComponent implements OnInit {
/** /**
* A list of valid access periods to render in a drop-down menu * A list of valid access periods to render in a drop-down menu
*/ */
@Input() validAccessPeriods: number[] = []; @Input() validAccessPeriods: string [] = [];
/** /**
* The selected access period * The selected access period, e.g. +7DAYS, +12MONTHS, FOREVER. These will be
* calculated as a timestamp to store as the access expiry date for the requested item
*/ */
accessPeriod = 0; accessPeriod = 'FOREVER';
protected readonly hasValue = hasValue; protected readonly hasValue = hasValue;
@@ -86,7 +87,7 @@ export class EmailRequestCopyComponent implements OnInit {
* Update the access period when a dropdown menu button is clicked for a value * Update the access period when a dropdown menu button is clicked for a value
* @param accessPeriod * @param accessPeriod
*/ */
selectAccessPeriod(accessPeriod: number) { selectAccessPeriod(accessPeriod: string) {
this.accessPeriod = accessPeriod; this.accessPeriod = accessPeriod;
this.selectedAccessPeriod.emit(accessPeriod); this.selectedAccessPeriod.emit(accessPeriod);
} }

View File

@@ -76,7 +76,7 @@ export class GrantRequestCopyComponent implements OnInit {
/** /**
* A list of integers determining valid access periods in seconds * A list of integers determining valid access periods in seconds
*/ */
validAccessPeriods$: Observable<number[]>; validAccessPeriods$: Observable<string[]>;
/** /**
* The currently selected access period * The currently selected access period

View File

@@ -2088,15 +2088,15 @@
"grant-request-copy.access-period.header": "Access period", "grant-request-copy.access-period.header": "Access period",
"grant-request-copy.access-period.120": "2 minutes", "grant-request-copy.access-period.+1DAY": "1 day",
"grant-request-copy.access-period.240": "4 minutes", "grant-request-copy.access-period.+1WEEK": "1 week",
"grant-request-copy.access-period.86400": "1 day", "grant-request-copy.access-period.+1MONTH": "1 month",
"grant-request-copy.access-period.604800": "7 days", "grant-request-copy.access-period.+3MONTHS": "3 months",
"grant-request-copy.access-period.0": "Forever", "grant-request-copy.access-period.FOREVER": "Forever",
"health.breadcrumbs": "Health", "health.breadcrumbs": "Health",