Skip to content

Commit 60764b4

Browse files
FrancescoMolinaroatarix83
authored andcommitted
Merged in task/main-cris/DSC-2052-full-view (pull request DSpace#2579)
[DSC-2052] change canDownload method with pipe Approved-by: Giuseppe Digilio
2 parents e7729fb + 2b8b3fc commit 60764b4

4 files changed

Lines changed: 25 additions & 1 deletion

File tree

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ <h3 class="h5 simple-view-element-header">{{"item.page.filesection.original.bund
3333
</dl>
3434
</div>
3535
<div *ngIf="!hasNoDownload(file)" class="col-2">
36-
<ds-file-download-link [showIcon]="(canDownload(file) | async) === false" [bitstream]="file" [item]="item">
36+
<ds-file-download-link [showIcon]="(file.self | dsCanDownloadFile | async) === false" [bitstream]="file" [item]="item">
3737
{{"item.page.filesection.download" | translate}}
3838
</ds-file-download-link>
3939
</div>

src/app/item-page/full/field-components/file-section/full-file-section.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { MetadataFieldWrapperComponent } from '../../../../shared/metadata-field
4242
import { NotificationsService } from '../../../../shared/notifications/notifications.service';
4343
import { PaginationComponent } from '../../../../shared/pagination/pagination.component';
4444
import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model';
45+
import { CanDownloadFilePipe } from '../../../../shared/utils/can-download-file.pipe';
4546
import { FileSizePipe } from '../../../../shared/utils/file-size-pipe';
4647
import { followLink } from '../../../../shared/utils/follow-link-config.model';
4748
import { VarDirective } from '../../../../shared/utils/var.directive';
@@ -68,6 +69,7 @@ import { FileSectionComponent } from '../../../simple/field-components/file-sect
6869
ThemedFileDownloadLinkComponent,
6970
FileSizePipe,
7071
MetadataFieldWrapperComponent,
72+
CanDownloadFilePipe,
7173
],
7274
standalone: true,
7375
})
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {
2+
Pipe,
3+
PipeTransform,
4+
} from '@angular/core';
5+
import { Observable } from 'rxjs';
6+
7+
import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service';
8+
import { FeatureID } from '../../core/data/feature-authorization/feature-id';
9+
10+
@Pipe({
11+
name: 'dsCanDownloadFile',
12+
standalone: true,
13+
})
14+
export class CanDownloadFilePipe implements PipeTransform {
15+
constructor(private authorizationServcie: AuthorizationDataService) {
16+
}
17+
transform(href: string): Observable<boolean> {
18+
return this.authorizationServcie.isAuthorized(FeatureID.CanDownload, href);
19+
}
20+
}

src/themes/custom/app/item-page/full/field-components/file-section/full-file-section.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import { FullFileSectionComponent as BaseComponent } from '../../../../../../../
1010
import { ThemedFileDownloadLinkComponent } from '../../../../../../../app/shared/file-download-link/themed-file-download-link.component';
1111
import { MetadataFieldWrapperComponent } from '../../../../../../../app/shared/metadata-field-wrapper/metadata-field-wrapper.component';
1212
import { PaginationComponent } from '../../../../../../../app/shared/pagination/pagination.component';
13+
import { CanDownloadFilePipe } from '../../../../../../../app/shared/utils/can-download-file.pipe';
1314
import { FileSizePipe } from '../../../../../../../app/shared/utils/file-size-pipe';
1415
import { VarDirective } from '../../../../../../../app/shared/utils/var.directive';
1516
import { ThemedThumbnailComponent } from '../../../../../../../app/thumbnail/themed-thumbnail.component';
@@ -32,6 +33,7 @@ import { ThemedThumbnailComponent } from '../../../../../../../app/thumbnail/the
3233
ThemedFileDownloadLinkComponent,
3334
FileSizePipe,
3435
MetadataFieldWrapperComponent,
36+
CanDownloadFilePipe,
3537
],
3638
})
3739
export class FullFileSectionComponent extends BaseComponent {

0 commit comments

Comments
 (0)