RED-8748 - update export button

This commit is contained in:
Valentin Mihai 2024-07-29 15:51:05 +03:00
parent 5ddae5f664
commit 171e18c8a9
4 changed files with 32 additions and 1 deletions

View File

@ -6,6 +6,7 @@
[matMenuTriggerFor]="bulkComponentDownloadMenu"
[matTooltipPosition]="'above'"
[matTooltip]="'documine-export.export-tooltip' | translate"
[hidden]="true"
class="red-tab"
>
{{ 'documine-export.export' | translate }}

View File

@ -20,6 +20,7 @@
[tooltipPosition]="tooltipPosition"
[helpModeKeyPrefix]="helpModeKeyPrefix"
[isDossierOverviewWorkflow]="isDossierOverviewWorkflow"
[file]="file"
></redaction-expandable-file-actions>
</div>
</ng-template>

View File

@ -1,3 +1,14 @@
@if (isDocumine) {
<iqser-circle-button
[attr.help-mode-key]="'component_download'"
[icon]="'red:extract'"
[matMenuTriggerFor]="bulkComponentDownloadMenu"
[tooltip]="'documine-export.export-tooltip' | translate"
[tooltipPosition]="tooltipPosition"
dropdownButton
></iqser-circle-button>
}
<ng-container *ngFor="let btn of displayedButtons; trackBy: trackBy">
<iqser-circle-button
(action)="btn.action($event)"
@ -73,3 +84,8 @@
</ng-container>
</button>
</mat-menu>
<mat-menu #bulkComponentDownloadMenu="matMenu">
<button (click)="downloadComponentAsJSON()" [innerHTML]="'component-download.json' | translate" mat-menu-item></button>
<button (click)="downloadComponentAsXML()" [innerHTML]="'component-download.xml' | translate" mat-menu-item></button>
</mat-menu>

View File

@ -1,6 +1,6 @@
import { Component, inject, Input, OnChanges, SimpleChanges, ViewChild } from '@angular/core';
import { Action, ActionTypes, Dossier, File } from '@red/domain';
import { CircleButtonComponent, CircleButtonType, IqserDialog, StopPropagationDirective, Toaster } from '@iqser/common-ui';
import { CircleButtonComponent, CircleButtonType, getConfig, IqserDialog, StopPropagationDirective, Toaster } from '@iqser/common-ui';
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
import { FileDownloadService } from '@upload-download/services/file-download.service';
import { PermissionsService } from '@services/permissions.service';
@ -13,6 +13,8 @@ import { FileDownloadBtnComponent } from '@shared/components/buttons/file-downlo
import { MatSlideToggle } from '@angular/material/slide-toggle';
import { MatTooltip } from '@angular/material/tooltip';
import { MatIcon } from '@angular/material/icon';
import { firstValueFrom } from 'rxjs';
import { ComponentLogService } from '@services/files/component-log.service';
@Component({
selector: 'redaction-expandable-file-actions',
@ -44,11 +46,13 @@ export class ExpandableFileActionsComponent implements OnChanges {
@Input() tooltipPosition: IqserTooltipPosition;
@Input() helpModeKeyPrefix: 'dossier' | 'editor';
@Input() isDossierOverviewWorkflow = false;
@Input() file: File;
displayedButtons: Action[];
hiddenButtons: Action[];
expanded = false;
@ViewChild(MatMenuTrigger) readonly matMenu: MatMenuTrigger;
readonly trackBy = trackByFactory();
readonly isDocumine = getConfig().IS_DOCUMINE;
readonly #appBaseHref = inject(APP_BASE_HREF);
constructor(
@ -56,6 +60,7 @@ export class ExpandableFileActionsComponent implements OnChanges {
private readonly _toaster: Toaster,
private readonly _permissionsService: PermissionsService,
private readonly _dialog: IqserDialog,
private readonly _componentLogService: ComponentLogService,
) {}
ngOnChanges(changes: SimpleChanges) {
@ -124,4 +129,12 @@ export class ExpandableFileActionsComponent implements OnChanges {
params: { downloadHref: `${this.#appBaseHref}/main/downloads` },
});
}
downloadComponentAsJSON() {
return firstValueFrom(this._componentLogService.exportJSON(this.file.dossierTemplateId, this.file.dossierId, this.file));
}
async downloadComponentAsXML() {
return firstValueFrom(this._componentLogService.exportXML(this.file.dossierTemplateId, this.file.dossierId, this.file));
}
}