From 2b8b3fcda17a4f48ad05c24f26276f1a565a5d2b Mon Sep 17 00:00:00 2001 From: FrancescoMolinaro Date: Wed, 27 Nov 2024 16:31:56 +0100 Subject: [PATCH] [DSC-2052] change canDownload method with pipe --- .../full-file-section.component.html | 2 +- .../full-file-section.component.ts | 2 ++ .../shared/utils/can-download-file.pipe.ts | 20 +++++++++++++++++++ .../full-file-section.component.ts | 2 ++ 4 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 src/app/shared/utils/can-download-file.pipe.ts diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.html b/src/app/item-page/full/field-components/file-section/full-file-section.component.html index 0f69323d113..dfd36cb3dca 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.html +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.html @@ -33,7 +33,7 @@

{{"item.page.filesection.original.bund
- + {{"item.page.filesection.download" | translate}}
diff --git a/src/app/item-page/full/field-components/file-section/full-file-section.component.ts b/src/app/item-page/full/field-components/file-section/full-file-section.component.ts index cc84f6168be..9064ced7ed7 100644 --- a/src/app/item-page/full/field-components/file-section/full-file-section.component.ts +++ b/src/app/item-page/full/field-components/file-section/full-file-section.component.ts @@ -42,6 +42,7 @@ import { MetadataFieldWrapperComponent } from '../../../../shared/metadata-field import { NotificationsService } from '../../../../shared/notifications/notifications.service'; import { PaginationComponent } from '../../../../shared/pagination/pagination.component'; import { PaginationComponentOptions } from '../../../../shared/pagination/pagination-component-options.model'; +import { CanDownloadFilePipe } from '../../../../shared/utils/can-download-file.pipe'; import { FileSizePipe } from '../../../../shared/utils/file-size-pipe'; import { followLink } from '../../../../shared/utils/follow-link-config.model'; import { VarDirective } from '../../../../shared/utils/var.directive'; @@ -68,6 +69,7 @@ import { FileSectionComponent } from '../../../simple/field-components/file-sect ThemedFileDownloadLinkComponent, FileSizePipe, MetadataFieldWrapperComponent, + CanDownloadFilePipe, ], standalone: true, }) diff --git a/src/app/shared/utils/can-download-file.pipe.ts b/src/app/shared/utils/can-download-file.pipe.ts new file mode 100644 index 00000000000..848c75a855c --- /dev/null +++ b/src/app/shared/utils/can-download-file.pipe.ts @@ -0,0 +1,20 @@ +import { + Pipe, + PipeTransform, +} from '@angular/core'; +import { Observable } from 'rxjs'; + +import { AuthorizationDataService } from '../../core/data/feature-authorization/authorization-data.service'; +import { FeatureID } from '../../core/data/feature-authorization/feature-id'; + +@Pipe({ + name: 'dsCanDownloadFile', + standalone: true, +}) +export class CanDownloadFilePipe implements PipeTransform { + constructor(private authorizationServcie: AuthorizationDataService) { + } + transform(href: string): Observable { + return this.authorizationServcie.isAuthorized(FeatureID.CanDownload, href); + } +} diff --git a/src/themes/custom/app/item-page/full/field-components/file-section/full-file-section.component.ts b/src/themes/custom/app/item-page/full/field-components/file-section/full-file-section.component.ts index 1475cd04ee9..74461705144 100644 --- a/src/themes/custom/app/item-page/full/field-components/file-section/full-file-section.component.ts +++ b/src/themes/custom/app/item-page/full/field-components/file-section/full-file-section.component.ts @@ -10,6 +10,7 @@ import { FullFileSectionComponent as BaseComponent } from '../../../../../../../ import { ThemedFileDownloadLinkComponent } from '../../../../../../../app/shared/file-download-link/themed-file-download-link.component'; import { MetadataFieldWrapperComponent } from '../../../../../../../app/shared/metadata-field-wrapper/metadata-field-wrapper.component'; import { PaginationComponent } from '../../../../../../../app/shared/pagination/pagination.component'; +import { CanDownloadFilePipe } from '../../../../../../../app/shared/utils/can-download-file.pipe'; import { FileSizePipe } from '../../../../../../../app/shared/utils/file-size-pipe'; import { VarDirective } from '../../../../../../../app/shared/utils/var.directive'; import { ThemedThumbnailComponent } from '../../../../../../../app/thumbnail/themed-thumbnail.component'; @@ -32,6 +33,7 @@ import { ThemedThumbnailComponent } from '../../../../../../../app/thumbnail/the ThemedFileDownloadLinkComponent, FileSizePipe, MetadataFieldWrapperComponent, + CanDownloadFilePipe, ], }) export class FullFileSectionComponent extends BaseComponent {