RED-3800: RSS editing

This commit is contained in:
Adina Țeudan 2022-12-13 13:28:39 +02:00
parent 85e5c5623a
commit 8c4d78f3e2
8 changed files with 99 additions and 55 deletions

View File

@ -1,9 +1,9 @@
<section class="dialog">
<div translate="rss-dialog.title" class="dialog-header heading-l"></div>
<div class="dialog-header heading-l" translate="rss-dialog.title"></div>
<hr />
<div class="dialog-content">
<div class="table output-data" *ngIf="rssData$ | async as rssEntry">
<div *ngIf="rssData$ | async as rssEntry" class="table output-data">
<div class="table-header">Component</div>
<div class="table-header">Value</div>
<div class="table-header">Transformation</div>
@ -12,27 +12,26 @@
<ng-container *ngFor="let entry of rssEntry.result | keyvalue: originalOrder">
<div class="bold">{{ entry.key }}</div>
<div>
<div class="value-content">
<iqser-editable-input
(save)="saveEdit($event, entry.value.originalKey)"
[buttonsType]="iconButtonTypes.dark"
[cancelTooltip]="'rss-dialog.actions.cancel-edit-name' | translate"
[class]="'w-200'"
[editTooltip]="'rss-dialog.actions.edit-name' | translate"
[saveTooltip]="'rss-dialog.actions.save-name' | translate"
[value]="entry.value.value ?? entry.value.originalValue"
></iqser-editable-input>
<div class="actions">
<iqser-editable-input
(save)="saveEdit($event, entry)"
[buttonsType]="iconButtonTypes.dark"
[cancelTooltip]="'rss-dialog.actions.cancel-edit' | translate"
[editTooltip]="'rss-dialog.actions.edit' | translate"
[saveTooltip]="'rss-dialog.actions.save' | translate"
[value]="entry.value.value ?? entry.value.originalValue"
>
<ng-container slot="editing">
<iqser-circle-button
(action)="undo()"
icon="red:undo"
[showDot]="false"
(action)="undo(entry)"
*ngIf="entry.value.value"
[showDot]="true"
[tooltip]="'rss-dialog.actions.undo' | translate"
[type]="iconButtonTypes.dark"
class="ml-2"
icon="red:undo"
></iqser-circle-button>
</div>
</div>
</ng-container>
</iqser-editable-input>
</div>
<div>{{ entry.value.transformation }}</div>
<div>{{ entry.value.scmAnnotations | json }}</div>
@ -41,17 +40,17 @@
</div>
<div class="dialog-actions">
<button color="primary" mat-flat-button type="submit" (click)="exportJSON()">
<button (click)="exportJSON()" color="primary" mat-flat-button type="submit">
{{ 'rss-dialog.actions.export-json' | translate }}
</button>
<button color="primary" mat-flat-button type="button" (click)="exportXML()">
<button (click)="exportXML()" color="primary" mat-flat-button type="button">
{{ 'rss-dialog.actions.export-xml' | translate }}
</button>
<button color="primary" mat-flat-button type="button" (click)="exportAllInDossier()" *ngIf="userPreferences.areDevFeaturesEnabled">
<button (click)="exportAllInDossier()" *ngIf="userPreferences.areDevFeaturesEnabled" color="primary" mat-flat-button type="button">
{{ 'Export All' }}
</button>
<div class="all-caps-label cancel" mat-dialog-close translate="rss-dialog.actions.close"></div>
</div>
<iqser-circle-button class="dialog-close" icon="iqser:close" (action)="close()"></iqser-circle-button>
<iqser-circle-button (action)="close()" class="dialog-close" icon="iqser:close"></iqser-circle-button>
</section>

View File

@ -1,9 +1,9 @@
import { Component, Inject } from '@angular/core';
import { Component, Inject, OnInit } from '@angular/core';
import { BaseDialogComponent, IconButtonTypes } from '@iqser/common-ui';
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
import { RssService } from '@services/files/rss.service';
import { IFile, IRssEntry } from '@red/domain';
import { firstValueFrom, Observable } from 'rxjs';
import { BehaviorSubject, firstValueFrom } from 'rxjs';
import { map } from 'rxjs/operators';
import { FilesMapService } from '@services/files/files-map.service';
import { UserPreferenceService } from '@users/user-preference.service';
@ -17,12 +17,10 @@ interface RssData {
templateUrl: './rss-dialog.component.html',
styleUrls: ['./rss-dialog.component.scss'],
})
export class RssDialogComponent extends BaseDialogComponent {
export class RssDialogComponent extends BaseDialogComponent implements OnInit {
readonly iconButtonTypes = IconButtonTypes;
rssData$: Observable<IRssEntry>;
originalOrder = (a: KeyValue<string, any>, b: KeyValue<string, any>): number => 0;
rssData$ = new BehaviorSubject<IRssEntry>(null);
constructor(
protected readonly _dialogRef: MatDialogRef<RssDialogComponent>,
@ -32,22 +30,14 @@ export class RssDialogComponent extends BaseDialogComponent {
@Inject(MAT_DIALOG_DATA) readonly data: RssData,
) {
super(_dialogRef);
this.rssData$ = this._rssService.getRSSData(this.data.file.dossierId, this.data.file.fileId).pipe(
map(entry => {
const mapped = {};
for (const key of Object.keys(entry.result)) {
const newKey = key.replace(new RegExp('_', 'g'), ' ');
(<any>entry.result[key]).originalKey = key;
mapped[newKey] = entry.result[key];
}
return {
filaName: entry.filaName,
result: mapped,
};
}),
);
}
async ngOnInit(): Promise<void> {
await this.#loadData();
}
originalOrder = (a: KeyValue<string, any>, b: KeyValue<string, any>): number => 0;
exportJSON() {
this._rssService.exportJSON(this.data.file.dossierId, this.data.file.fileId, this.data.file.filename).subscribe();
}
@ -68,14 +58,39 @@ export class RssDialogComponent extends BaseDialogComponent {
this.exportJSON();
}
undo() {
console.log('Undo');
async undo(entry: KeyValue<string, any>) {
this._loadingService.start();
await firstValueFrom(this._rssService.revertOverride(this.data.file.dossierId, this.data.file.fileId, [entry.value.originalKey]));
await this.#loadData();
}
saveEdit(event: string, originalKey: string) {
console.log(event, originalKey);
/**
* https://qa2.iqser.cloud/redaction-gateway-v1/swagger-ui/index.html#/rss-controller/revertOverrides
*/
async saveEdit(event: string, entry: KeyValue<string, any>) {
this._loadingService.start();
await firstValueFrom(
this._rssService.override(this.data.file.dossierId, this.data.file.fileId, { [entry.value.originalKey]: event }),
);
await this.#loadData();
}
async #loadData(): Promise<void> {
this._loadingService.start();
const rssData = await firstValueFrom(
this._rssService.getRSSData(this.data.file.dossierId, this.data.file.fileId).pipe(
map(entry => {
const mapped = {};
for (const key of Object.keys(entry.result)) {
const newKey = key.replace(new RegExp('_', 'g'), ' ');
(<any>entry.result[key]).originalKey = key;
mapped[newKey] = entry.result[key];
}
return {
filaName: entry.filaName,
result: mapped,
};
}),
),
);
this.rssData$.next(rssData);
this._loadingService.stop();
}
}

View File

@ -40,6 +40,20 @@ export class RssService extends GenericService<void> {
});
}
@Validate()
override(
@RequiredParam() dossierId: string,
@RequiredParam() fileId: string,
@RequiredParam() componentOverrides: Record<string, string>,
) {
return this._post({ componentOverrides }, `rss/override/${dossierId}/${fileId}`);
}
@Validate()
revertOverride(@RequiredParam() dossierId: string, @RequiredParam() fileId: string, @RequiredParam() components: string[]) {
return this._post({ components }, `rss/override/revert/${dossierId}/${fileId}`);
}
exportJSON(dossierId: string, fileId: string, name: string) {
return this.getRSSData(dossierId, fileId).pipe(
tap(data => {

View File

@ -1953,9 +1953,13 @@
},
"rss-dialog": {
"actions": {
"cancel-edit": "",
"close": "",
"edit": "",
"export-json": "",
"export-xml": ""
"export-xml": "",
"save": "",
"undo": ""
},
"title": ""
},

View File

@ -1953,9 +1953,13 @@
},
"rss-dialog": {
"actions": {
"cancel-edit": "Cancel",
"close": "Close",
"edit": "Edit",
"export-json": "Export JSON",
"export-xml": "Export XML"
"export-xml": "Export XML",
"save": "Save",
"undo": "Undo"
},
"title": "Structured Component Management"
},

View File

@ -1953,9 +1953,13 @@
},
"rss-dialog": {
"actions": {
"cancel-edit": "",
"close": "",
"edit": "",
"export-json": "",
"export-xml": ""
"export-xml": "",
"save": "",
"undo": ""
},
"title": ""
},

View File

@ -1953,9 +1953,13 @@
},
"rss-dialog": {
"actions": {
"cancel-edit": "Cancel",
"close": "Close",
"edit": "Edit",
"export-json": "Export JSON",
"export-xml": "Export XML"
"export-xml": "Export XML",
"save": "Save",
"undo": "Undo"
},
"title": "Structured Component Management"
},

@ -1 +1 @@
Subproject commit 5f9c754abf0fb4fcc0606d811a66c5bbb88d164a
Subproject commit b58f1ca2fed8e8ddf2834c0fd15e48d00b6a1329