Skip to content

Commit

Permalink
Merged in task/main-cris/DSC-2052-full-view (pull request DSpace#2579)
Browse files Browse the repository at this point in the history
[DSC-2052] change canDownload method with pipe

Approved-by: Giuseppe Digilio
  • Loading branch information
FrancescoMolinaro authored and atarix83 committed Nov 27, 2024
2 parents e7729fb + 2b8b3fc commit 60764b4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ <h3 class="h5 simple-view-element-header">{{"item.page.filesection.original.bund
</dl>
</div>
<div *ngIf="!hasNoDownload(file)" class="col-2">
<ds-file-download-link [showIcon]="(canDownload(file) | async) === false" [bitstream]="file" [item]="item">
<ds-file-download-link [showIcon]="(file.self | dsCanDownloadFile | async) === false" [bitstream]="file" [item]="item">
{{"item.page.filesection.download" | translate}}
</ds-file-download-link>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -68,6 +69,7 @@ import { FileSectionComponent } from '../../../simple/field-components/file-sect
ThemedFileDownloadLinkComponent,
FileSizePipe,
MetadataFieldWrapperComponent,
CanDownloadFilePipe,
],
standalone: true,
})
Expand Down
20 changes: 20 additions & 0 deletions src/app/shared/utils/can-download-file.pipe.ts
Original file line number Diff line number Diff line change
@@ -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<boolean> {
return this.authorizationServcie.isAuthorized(FeatureID.CanDownload, href);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -32,6 +33,7 @@ import { ThemedThumbnailComponent } from '../../../../../../../app/thumbnail/the
ThemedFileDownloadLinkComponent,
FileSizePipe,
MetadataFieldWrapperComponent,
CanDownloadFilePipe,
],
})
export class FullFileSectionComponent extends BaseComponent {
Expand Down

0 comments on commit 60764b4

Please sign in to comment.