Skip to content

Commit

Permalink
bug #13206 : cp 13206 collect
Browse files Browse the repository at this point in the history
  • Loading branch information
Hassane Diaby committed Oct 3, 2024
1 parent 9733071 commit 2b1ea34
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,11 @@

<div class="row">
<div class="col-12">
<button class="btn primary download-btn" [disabled]="archiveUnit['#object'] == null" (click)="onDownloadObjectFromUnit(archiveUnit)">
<button
class="btn primary download-btn"
[disabled]="!archiveUnit['#object'] || !hasDownloadDocumentRole"
(click)="onDownloadObjectFromUnit(archiveUnit)"
>
<span>{{ 'COLLECT.ARCHIVE_UNIT_PREVIEW.FIELDS.DOWNLOAD_DOC' | translate }}</span>
<i class="vitamui-icon vitamui-icon-deposit"></i>
</button>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { Observable } from 'rxjs';
import { Unit } from 'ui-frontend-common';
import { TenantSelectionService, Unit } from 'ui-frontend-common';
import { ArchiveCollectService } from '../../archive-collect.service';

@Component({
Expand All @@ -52,15 +52,20 @@ export class ArchiveUnitInformationTabComponent implements OnInit, OnChanges {

uaPath$: Observable<{ fullPath: string; resumePath: string }>;
fullPath = false;
hasDownloadDocumentRole = false;

constructor(private archiveService: ArchiveCollectService) {}
constructor(
private archiveService: ArchiveCollectService,
private tenantSelectionService: TenantSelectionService,
) {}

ngOnInit() {
// TODO : Créer Web service de création du chemin d'archive
// this.uaPath$ = this.archiveService.buildArchiveUnitPath(this.archiveUnit, this.accessContract);
}

ngOnChanges(changes: SimpleChanges): void {
this.checkDownloadPermissions();
if (changes.archiveUnit?.currentValue['#id']) {
// TODO : Créer Web service de création du chemin d'archive
// this.uaPath$ = this.archiveService.buildArchiveUnitPath(this.archiveUnit, this.accessContract);
Expand All @@ -75,4 +80,12 @@ export class ArchiveUnitInformationTabComponent implements OnInit, OnChanges {
showArchiveUniteFullPath() {
this.fullPath = true;
}

private checkDownloadPermissions() {
this.archiveService
.hasCollectRole('ROLE_COLLECT_GET_ARCHIVE_BINARY', this.tenantSelectionService.getSelectedTenant().identifier)
.subscribe((result) => {
this.hasDownloadDocumentRole = result;
});
}
}

0 comments on commit 2b1ea34

Please sign in to comment.