view descriptions from dmp editor ui

This commit is contained in:
amentis 2024-03-15 18:28:39 +02:00
parent 030f59ac06
commit 54e194e078
3 changed files with 42 additions and 31 deletions

View File

@ -90,7 +90,7 @@
<li *ngFor="let description of descriptionsInSection(section.id); let descriptionIndex = index" (click)="editDescription(description.id, false)" class="active-dataset">
<div class="d-flex flex-direction-row">
<div class="label" matTooltip="{{description.label}}">{{'DMP-EDITOR.DESCRIPTION' | translate}}: {{ description.label }}</div>
<mat-icon *ngIf="description.status !== descriptionStatusEnum.Finalized" class="ml-2 mr-2 remove-dataset size-16" matTooltip="{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}" (click)="$event.stopPropagation(); removeDataset(dataset.get('id').value, datasetIndex)">close</mat-icon>
<mat-icon *ngIf="description.status !== descriptionStatusEnum.Finalized" class="ml-2 mr-2 remove-dataset size-16" matTooltip="{{'DMP-EDITOR.ACTIONS.DELETE' | translate}}" (click)="$event.stopPropagation(); removeDescription(description.id)">close</mat-icon>
<mat-icon *ngIf="description.status === descriptionStatusEnum.Finalized" class="ml-2 mr-2 status-icon check-icon size-16" matTooltip="{{'TYPES.DATASET-STATUS.FINALISED' | translate}}">check</mat-icon>
</div>
</li>

View File

@ -46,6 +46,7 @@ import { DmpEditorResolver } from './dmp-editor.resolver';
import { DmpEditorService } from './dmp-editor.service';
import { DmpUserRole } from '@app/core/common/enum/dmp-user-role';
import { DmpUserType } from '@app/core/common/enum/dmp-user-type';
import { DescriptionService } from '@app/core/services/description/description.service';
@Component({
selector: 'app-dmp-editor',
@ -123,7 +124,8 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
private languageInfoService: LanguageInfoService,
public enumUtils: EnumUtils,
public descriptionTemplateService: DescriptionTemplateService,
public userService: UserService
public userService: UserService,
public descriptionService: DescriptionService
) {
super(dialog, language, formService, router, uiNotificationService, httpErrorHandlingService, filterService, datePipe, route, queryParamsService);
@ -185,7 +187,15 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
prepareForm(data: Dmp) {
try {
this.editorModel = data ? new DmpEditorModel().fromModel(data) : new DmpEditorModel();
if (data.descriptions) {
if (data.status == DmpStatus.Finalized) {
data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status === DescriptionStatus.Finalized);
} else {
data.descriptions = data.descriptions.filter(x => x.isActive === IsActive.Active && x.status !== DescriptionStatus.Canceled);
}
}
this.item = data;
this.selectedBlueprint = data?.blueprint;
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
this.buildForm();
@ -381,7 +391,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
//
//
public descriptionsInSection(sectionId: Guid) {
this.item?.descriptions?.filter(x => x?.dmpDescriptionTemplate?.sectionId === sectionId) || [];
return this.item?.descriptions?.filter(x => x?.dmpDescriptionTemplate?.sectionId === sectionId) || [];
}
editDescription(id: string, isNew: boolean, showModal: boolean = false) {
@ -1119,34 +1129,34 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
// }
// public removeDataset(datasetId: string, index: number) {
// const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
// maxWidth: '300px',
// restoreFocus: false,
// data: {
// message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
// confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
// cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
// isDeleteConfirmation: true
// }
// });
// dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
// if (result) {
// if (datasetId) {
// this.datasetService.delete(datasetId)
// .pipe(takeUntil(this._destroyed))
// .subscribe(
// complete => {
// this.onDeleteCallbackSuccess();
// },
// error => this.onDeleteCallbackError(error)
// );
// }
public removeDescription(descriptionId: Guid) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '300px',
restoreFocus: false,
data: {
message: this.language.instant('GENERAL.CONFIRMATION-DIALOG.DELETE-ITEM'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.DELETE'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
isDeleteConfirmation: true
}
});
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
if (descriptionId) {
this.descriptionService.delete(descriptionId)
.pipe(takeUntil(this._destroyed))
.subscribe(
complete => {
this.onCallbackSuccess();
},
error => this.onCallbackError(error)
);
}
// this.formGroup.get('datasets')['controls'].splice(index, 1);
// this.step = 0;
// }
// });
// }
this.step = 0;
}
});
}
// onDeleteCallbackSuccess(): void {
// this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-DELETE'), SnackBarNotificationLevel.Success);

View File

@ -57,6 +57,7 @@ export class DmpEditorResolver extends BaseEditorResolver {
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.label)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.status)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.isActive)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.id)].join('.'),
[nameof<Dmp>(x => x.descriptions), nameof<Description>(x => x.dmpDescriptionTemplate), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),