Skip to content

Commit 57b618c

Browse files
committed
Request-a-copy: Changes to support access expiry as delta/date storage
1 parent 1645180 commit 57b618c

6 files changed

Lines changed: 16 additions & 16 deletions

File tree

src/app/core/data/item-request-data.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,10 @@ export class ItemRequestDataService extends IdentifiableDataService<ItemRequest>
211211
* if the 'send secure link' feature is configured.
212212
* Expects integer values, conversion to number is done in this processing
213213
*/
214-
getConfiguredAccessPeriods(): Observable<number[]> {
214+
getConfiguredAccessPeriods(): Observable<string[]> {
215215
return this.configService.findByPropertyName('request.item.grant.link.period').pipe(
216216
getFirstCompletedRemoteData(),
217217
map((propertyRD: RemoteData<ConfigurationProperty>) => propertyRD.hasSucceeded ? propertyRD.payload.values : []),
218-
map((values) => values.map(value => parseInt(value, 10))),
219218
);
220219
}
221220

src/app/core/shared/item-request.model.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,10 @@ export class ItemRequest implements CacheableObject {
8686
@autoserialize
8787
accessToken: string;
8888
/**
89-
* Access period of the request
89+
* Access expiry date of the request
9090
*/
9191
@autoserialize
92-
accessPeriod: number;
92+
accessExpiry: string;
9393

9494
/**
9595
* The {@link HALLink}s for this ItemRequest

src/app/request-copy/email-request-copy/email-request-copy.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ describe('EmailRequestCopyComponent', () => {
4545
spyOn(component.send, 'emit').and.stub();
4646
component.subject = 'test-subject';
4747
component.message = 'test-message';
48-
component.validAccessPeriods = [0];
48+
component.validAccessPeriods = ['FOREVER'];
4949
component.submit();
5050
expect(component.send.emit).toHaveBeenCalledWith(new RequestCopyEmail('test-subject', 'test-message'));
5151
});

src/app/request-copy/email-request-copy/email-request-copy.component.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class EmailRequestCopyComponent implements OnInit {
3434
* Event emitter for sending the email
3535
*/
3636
@Output() send: EventEmitter<RequestCopyEmail> = new EventEmitter<RequestCopyEmail>();
37-
@Output() selectedAccessPeriod: EventEmitter<number> = new EventEmitter();
37+
@Output() selectedAccessPeriod: EventEmitter<string> = new EventEmitter();
3838

3939
/**
4040
* The subject of the email
@@ -49,12 +49,13 @@ export class EmailRequestCopyComponent implements OnInit {
4949
/**
5050
* A list of valid access periods to render in a drop-down menu
5151
*/
52-
@Input() validAccessPeriods: number[] = [];
52+
@Input() validAccessPeriods: string [] = [];
5353

5454
/**
55-
* The selected access period
55+
* The selected access period, e.g. +7DAYS, +12MONTHS, FOREVER. These will be
56+
* calculated as a timestamp to store as the access expiry date for the requested item
5657
*/
57-
accessPeriod = 0;
58+
accessPeriod = 'FOREVER';
5859

5960
protected readonly hasValue = hasValue;
6061

@@ -86,7 +87,7 @@ export class EmailRequestCopyComponent implements OnInit {
8687
* Update the access period when a dropdown menu button is clicked for a value
8788
* @param accessPeriod
8889
*/
89-
selectAccessPeriod(accessPeriod: number) {
90+
selectAccessPeriod(accessPeriod: string) {
9091
this.accessPeriod = accessPeriod;
9192
this.selectedAccessPeriod.emit(accessPeriod);
9293
}

src/app/request-copy/grant-request-copy/grant-request-copy.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class GrantRequestCopyComponent implements OnInit {
7676
/**
7777
* A list of integers determining valid access periods in seconds
7878
*/
79-
validAccessPeriods$: Observable<number[]>;
79+
validAccessPeriods$: Observable<string[]>;
8080

8181
/**
8282
* The currently selected access period

src/assets/i18n/en.json5

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2088,15 +2088,15 @@
20882088

20892089
"grant-request-copy.access-period.header": "Access period",
20902090

2091-
"grant-request-copy.access-period.120": "2 minutes",
2091+
"grant-request-copy.access-period.+1DAY": "1 day",
20922092

2093-
"grant-request-copy.access-period.240": "4 minutes",
2093+
"grant-request-copy.access-period.+1WEEK": "1 week",
20942094

2095-
"grant-request-copy.access-period.86400": "1 day",
2095+
"grant-request-copy.access-period.+1MONTH": "1 month",
20962096

2097-
"grant-request-copy.access-period.604800": "7 days",
2097+
"grant-request-copy.access-period.+3MONTHS": "3 months",
20982098

2099-
"grant-request-copy.access-period.0": "Forever",
2099+
"grant-request-copy.access-period.FOREVER": "Forever",
21002100

21012101
"health.breadcrumbs": "Health",
21022102

0 commit comments

Comments
 (0)