Skip to content

Commit 80fafbf

Browse files
committed
Request-a-copy: Angular flow control changes
1 parent d1bcb9f commit 80fafbf

7 files changed

Lines changed: 34 additions & 14 deletions

File tree

src/app/item-page/access-by-token/field-components/file-download-link/item-secure-file-download-link.component.html

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
[target]="isBlank ? '_blank': '_self'"
44
[ngClass]="cssClasses"
55
[attr.aria-label]="('file-download-link.download' | translate) + dsoNameService.getName(bitstream)">
6-
<!-- If the user cannot download the file by auth or token, show a lock icon -->
7-
<span role="img" *ngIf="(canDownload$ | async) === false && (canDownloadWithToken$ | async) === false" [attr.aria-label]="'file-download-link.restricted' | translate" class="pr-1"><i class="fas fa-lock"></i></span>
8-
<!-- If the user can download the file by token, and NOT normally show a lock open icon -->
9-
<span role="img" *ngIf="(canDownloadWithToken$ | async) && (canDownload$ | async) === false" [attr.aria-label]="'file-download-link.secure-access' | translate" class="pr-1"><i class="fa-solid fa-lock-open" style="color: #26a269;"></i></span>
6+
@if ((canDownload$ | async) === false && (canDownloadWithToken$ | async) === false) {
7+
<!-- If the user cannot download the file by auth or token, show a lock icon -->
8+
<span role="img" [attr.aria-label]="'file-download-link.restricted' | translate" class="pr-1"><i class="fas fa-lock"></i></span>
9+
} @else if ((canDownloadWithToken$ | async) && (canDownload$ | async) === false) {
10+
<!-- If the user can download the file by token, and NOT normally show a lock open icon -->
11+
<span role="img" [attr.aria-label]="'file-download-link.secure-access' | translate" class="pr-1"><i class="fa-solid fa-lock-open" style="color: #26a269;"></i></span>
12+
}
1013
<!-- Otherwise, show no icon (normal download by authorized user), public access etc. -->
1114
<ng-container *ngTemplateOutlet="content"></ng-container>
1215
</a>

src/app/item-page/access-by-token/field-components/file-download-link/item-secure-file-download-link.component.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import {
22
AsyncPipe,
33
NgClass,
4-
NgIf,
54
NgTemplateOutlet,
65
} from '@angular/common';
76
import {
@@ -41,7 +40,7 @@ import {
4140
styleUrls: ['./item-secure-file-download-link.component.scss'],
4241
standalone: true,
4342
imports: [
44-
RouterLink, NgClass, NgIf, NgTemplateOutlet, AsyncPipe, TranslateModule,
43+
RouterLink, NgClass, NgTemplateOutlet, AsyncPipe, TranslateModule,
4544
],
4645
})
4746
/**

src/app/item-page/simple/field-components/file-section/file-section.component.html

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<ds-metadata-field-wrapper [label]="label | translate">
44
<div class="file-section">
55
@for (file of bitstreams; track file; let last = $last) {
6-
<ds-file-download-link [bitstream]="file" [item]="item">
6+
@if (hasAccessToken() === true) {
7+
<ds-item-secure-file-download-link [bitstream]="file" [item]="item">
78
<span>
89
@if (primaryBitsreamId === file.id) {
910
<span class="badge bg-primary">{{ 'item.page.bitstreams.primary' | translate }}</span>
@@ -14,7 +15,21 @@
1415
@if (!last) {
1516
<span innerHTML="{{separator}}"></span>
1617
}
17-
</ds-file-download-link>
18+
</ds-item-secure-file-download-link>
19+
} @else {
20+
<ds-file-download-link [bitstream]="file" [item]="item">
21+
<span>
22+
@if (primaryBitsreamId === file.id) {
23+
<span class="badge bg-primary">{{ 'item.page.bitstreams.primary' | translate }}</span>
24+
}
25+
{{ dsoNameService.getName(file) }}
26+
</span>
27+
<span> ({{(file?.sizeBytes) | dsFileSize }})</span>
28+
@if (!last) {
29+
<span innerHTML="{{separator}}"></span>
30+
}
31+
</ds-file-download-link>
32+
}
1833
}
1934
@if (isLoading) {
2035
<ds-loading message="{{'loading.default' | translate}}" [showMessage]="false"></ds-loading>

src/app/request-copy/grant-deny-request-copy/grant-deny-request-copy.component.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ <h3 class="mb-4">{{ 'grant-deny-request-copy.header' | translate }}</h3>
3636
}
3737
</div>
3838
</div>
39+
}
3940
<!-- Display the "already handled" message if there is a decision date, and either no access token (attachment was sent in email) or the request was denied -->
40-
@if (itemRequestRD.payload.decisionDate && (itemRequestRD.payload.acceptRequest === false || !itemRequestRD.payload.accessToken)) {
41+
@if (itemRequestRD.payload.decisionDate && (!itemRequestRD.payload.acceptRequest || !itemRequestRD.payload.accessToken)) {
4142
<div class="processed-message">
4243
<p>{{ 'grant-deny-request-copy.processed' | translate }}</p>
4344
<p class="text-center">
4445
<a routerLink="/home" class="btn btn-primary">{{ 'grant-deny-request-copy.home-page' | translate }}</a>
4546
</p>
4647
</div>
4748
}
48-
}
4949
</div>
5050
}
5151
@if (!itemRequestRD || itemRequestRD?.isLoading) {

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { NO_ERRORS_SCHEMA } from '@angular/core';
22
import {
33
ComponentFixture,
4+
fakeAsync,
45
TestBed,
6+
tick,
57
waitForAsync,
68
} from '@angular/core/testing';
79
import { By } from '@angular/platform-browser';
@@ -138,14 +140,16 @@ describe('GrantDenyRequestCopyComponent', () => {
138140
expect(message).toBeNull();
139141
});
140142

141-
it('should be displayed when decisionDate is defined', () => {
143+
it('should be displayed when decisionDate is defined', fakeAsync(() => {
142144
component.itemRequestRD$ = createSuccessfulRemoteDataObject$(Object.assign(new ItemRequest(), itemRequest, {
143145
decisionDate: 'defined-date',
144146
}));
145147
fixture.detectChanges();
148+
tick(); // Simulate passage of time
149+
fixture.detectChanges();
146150

147151
const message = fixture.debugElement.query(By.css('.processed-message'));
148152
expect(message).not.toBeNull();
149-
});
153+
}));
150154
});
151155
});

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
@@ -47,7 +47,7 @@ import { ThemedEmailRequestCopyComponent } from '../email-request-copy/themed-em
4747
styleUrls: ['./grant-request-copy.component.scss'],
4848
templateUrl: './grant-request-copy.component.html',
4949
standalone: true,
50-
imports: [CommonModule, VarDirective, NgIf, ThemedEmailRequestCopyComponent, FormsModule, ThemedLoadingComponent, AsyncPipe, TranslateModule, RouterLink, NgClass],
50+
imports: [CommonModule, VarDirective, ThemedEmailRequestCopyComponent, FormsModule, ThemedLoadingComponent, AsyncPipe, TranslateModule, RouterLink, NgClass],
5151
})
5252
/**
5353
* Component for granting an item request

src/themes/custom/app/register-email-form/register-email-form.component.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { TranslateModule } from '@ngx-translate/core';
88
import { AlertComponent } from 'src/app/shared/alert/alert.component';
99
import { GoogleRecaptchaComponent } from 'src/app/shared/google-recaptcha/google-recaptcha.component';
1010

11-
import { AltchaCaptchaComponent } from '../../../../app/item-page/bitstreams/request-a-copy/altcha-captcha.component';
1211
import { RegisterEmailFormComponent as BaseComponent } from '../../../../app/register-email-form/register-email-form.component';
1312
import { BtnDisabledDirective } from '../../../../app/shared/btn-disabled.directive';
1413

0 commit comments

Comments
 (0)