Edit template on dmp-dataset editor

This commit is contained in:
apapachristou 2020-09-08 10:36:18 +03:00
parent 1dbe320706
commit eb7a5571c4
12 changed files with 105 additions and 101 deletions

View File

@ -3,9 +3,7 @@
<ng-container *ngIf="value as values">
<mat-chip *ngFor="let value of values" [disabled]="disabled" [selectable]="selectable" [removable]="removable">
<ng-container *ngIf="_selectedItems.get(stringify(value)) as selectedItem">
<ng-template #cellTemplate *ngIf="_selectedValueTemplate(selectedItem)" [ngTemplateOutlet]="_selectedValueTemplate(selectedItem)" [ngTemplateOutletContext]="{
item: selectedItem
}"></ng-template>
<ng-template #cellTemplate *ngIf="_selectedValueTemplate(selectedItem)" [ngTemplateOutlet]="_selectedValueTemplate(selectedItem)" [ngTemplateOutletContext]="{ item: selectedItem }"></ng-template>
<div *ngIf="!_selectedValueTemplate(selectedItem)">{{_displayFn(selectedItem)}}</div>
<mat-icon matChipRemove *ngIf="!disabled && removable" (click)="_removeSelectedItem(_selectedItems.get(stringify(value)), $event)">cancel</mat-icon>
</ng-container>

View File

@ -54,7 +54,7 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn
// formGroup: FormGroup = null;
datasetProfileDefinitionModel: DatasetDescriptionFormEditorModel;
availableProfiles: DatasetProfileModel[] = [];
// availableProfiles: DatasetProfileModel[] = [];
// itemId: string;
// publicId: string;
// profileUpdateId: string;
@ -68,6 +68,7 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn
@Input() dmpId: string;
@Input() datasetId: string;
@Input() isNewDataset: boolean;
@Input() availableProfiles: DatasetProfileModel[];
@Output() formChanged: EventEmitter<any> = new EventEmitter();
readonly separatorKeysCodes: number[] = [ENTER, COMMA];
@ -102,8 +103,10 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn
this.datasetWizardModel = new DatasetWizardEditorModel();
this.registerFormListeners();
if (this.isNewDataset) {
this.loadDatasetProfiles();
}
// console.log(this.formGroup);
this.profilesAutoCompleteConfiguration = {
filterFn: this.filterProfiles.bind(this),
initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
@ -112,56 +115,53 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn
subtitleFn: (item) => item['description']
};
if (!this.isNewDataset) {
this.loadDatasetProfiles();
}
if (this.datasetId) {
this.datasetWizardService.getSingle(this.datasetId)
.pipe(takeUntil(this._destroyed))
.subscribe(data => {
this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
this.lockStatus = lockStatus;
this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
this.needsUpdate();
this.formGroup = this.datasetWizardModel.buildForm();
this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
if (this.datasetWizardModel.status === DatasetStatus.Finalized || lockStatus) {
this.formGroup.disable();
this.viewOnly = true;
}
if (!lockStatus && !isNullOrUndefined(this.authService.current())) {
this.lock = new LockModel(data.id, this.authService.current());
// if (this.datasetId) {
// this.datasetWizardService.getSingle(this.datasetId)
// .pipe(takeUntil(this._destroyed))
// .subscribe(data => {
// this.lockService.checkLockStatus(data.id).pipe(takeUntil(this._destroyed)).subscribe(lockStatus => {
// this.lockStatus = lockStatus;
// this.datasetWizardModel = new DatasetWizardEditorModel().fromModel(data);
// this.needsUpdate();
// this.formGroup = this.datasetWizardModel.buildForm();
// this.editMode = this.datasetWizardModel.status === DatasetStatus.Draft;
// if (this.datasetWizardModel.status === DatasetStatus.Finalized || lockStatus) {
// this.formGroup.disable();
// this.viewOnly = true;
// }
// if (!lockStatus && !isNullOrUndefined(this.authService.current())) {
// this.lock = new LockModel(data.id, this.authService.current());
this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
this.lock.id = Guid.parse(result);
interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
});
}
// if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
this.loadDatasetProfiles();
this.registerFormListeners();
// this.availableProfiles = this.datasetWizardModel.dmp.profiles;
// this.lockService.createOrUpdate(this.lock).pipe(takeUntil(this._destroyed)).subscribe(async result => {
// this.lock.id = Guid.parse(result);
// interval(this.configurationService.lockInterval).pipe(takeUntil(this._destroyed)).subscribe(() => this.pumpLock());
// });
// }
// // if (this.viewOnly) { this.formGroup.disable(); } // For future use, to make Dataset edit like DMP.
// this.loadDatasetProfiles();
// this.registerFormListeners();
// // this.availableProfiles = this.datasetWizardModel.dmp.profiles;
this.onChanges();
this.formChanged.emit(this.formGroup);
})
},
error => {
switch (error.status) {
case 403:
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-ALLOWED'), SnackBarNotificationLevel.Error);
break;
case 404:
this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-FOUND'), SnackBarNotificationLevel.Error);
break;
default:
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.ERRORS.HTTP-REQUEST-ERROR'), SnackBarNotificationLevel.Error);
}
this.router.navigate(['/datasets/']);
return observableOf(null);
});
}
// this.onChanges();
// this.formChanged.emit(this.formGroup);
// })
// },
// error => {
// switch (error.status) {
// case 403:
// this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-ALLOWED'), SnackBarNotificationLevel.Error);
// break;
// case 404:
// this.uiNotificationService.snackBarNotification(this.language.instant('DATASET-WIZARD.MESSAGES.DATASET-NOT-FOUND'), SnackBarNotificationLevel.Error);
// break;
// default:
// this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.ERRORS.HTTP-REQUEST-ERROR'), SnackBarNotificationLevel.Error);
// }
// this.router.navigate(['/datasets/']);
// return observableOf(null);
// });
// }
}
public dashboardTourDmp: GuidedTour = {
@ -205,7 +205,7 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn
this.dmpValueChanged(x);
});
if (this.isNewDataset) {
// if (this.isNewDataset) {
this.formGroup.get('profile').valueChanges
.pipe(takeUntil(this._destroyed))
.subscribe(x => {
@ -213,7 +213,7 @@ export class DatasetEditorDetailsComponent extends BaseComponent implements OnIn
this.datasetProfileValueChanged(x.id);
}
});
}
// }
}
dmpValueChanged(dmp: DmpListingModel) {

View File

@ -13,7 +13,7 @@
</div>
<div class="profile-form">
<mat-form-field *ngIf="!isNewDataset">
<app-multiple-auto-complete required='true' [formControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}" [configuration]="profilesAutoCompleteConfiguration">
<app-multiple-auto-complete required='true' [formControl]="formGroup.get('profiles')" placeholder="{{'DMP-EDITOR.FIELDS.SELECT-TEMPLATE' | translate}}" [configuration]="profilesAutoCompleteConfiguration" (optionRemoved)="onRemoveTemplate($event)">
</app-multiple-auto-complete>
<mat-error *ngIf="formGroup.get('profiles').hasError('backendError')">
{{formGroup.get('profiles').getError('backendError').message}}</mat-error>

View File

@ -1,6 +1,6 @@
import { BaseComponent } from '@common/base/base.component';
import { OnInit, Component, Input, Output, EventEmitter } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { FormGroup, FormArray } from '@angular/forms';
import { TranslateService } from '@ngx-translate/core';
import { ConfigurationService } from '@app/core/services/configuration/configuration.service';
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
@ -23,6 +23,7 @@ import { DatasetWizardService } from '@app/core/services/dataset-wizard/dataset-
import { DatasetDescriptionFormEditorModel } from '@app/ui/misc/dataset-description-form/dataset-description-form.model';
import { DatasetWizardEditorModel } from '@app/ui/dataset/dataset-wizard/dataset-wizard-editor.model';
import { DmpListingModel } from '@app/core/model/dmp/dmp-listing';
import { UiNotificationService, SnackBarNotificationLevel } from '@app/core/services/notification/ui-notification-service';
@Component({
selector: 'dataset-info',
@ -59,7 +60,8 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
private _service: DmpService,
private dmpProfileService: DmpProfileService,
private router: Router,
private route: ActivatedRoute
private route: ActivatedRoute,
private uiNotificationService: UiNotificationService
) {
super();
}
@ -212,4 +214,25 @@ export class DatasetInfoComponent extends BaseComponent implements OnInit {
});
}
onRemoveTemplate(event) {
let found = false;
const profiles = this.formGroup.get('profiles').value;
this.formGroup.get('datasets')['controls'].forEach(element => {
if (element.get('profile').value.id === event.id) {
found = true;
this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.UNSUCCESSFUL-REMOVE-TEMPLATE'), SnackBarNotificationLevel.Success);
}
});
if (found) {
this.formGroup.get('profiles').setValue(profiles);
this.profilesAutoCompleteConfiguration = {
filterFn: this.filterProfiles.bind(this),
initialItems: (excludedItems: any[]) => this.filterProfiles('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
displayFn: (item) => item['label'],
titleFn: (item) => item['label'],
subtitleFn: (item) => item['description']
};
}
}
}

View File

@ -92,9 +92,9 @@
</ul>
</li>
</ol>
<ul *ngIf="!isNewDataset" class="add-dataset-option">
<ul *ngIf="!isNewDataset && hasProfile()" class="add-dataset-option">
<li>
<a class="add-dataset-btn" (click)="addDataset()" target="_blank">
<a class="add-dataset-btn stepper-btn" (click)="addDataset()" target="_blank">
<mat-icon>add</mat-icon>{{'DMP-LISTING.ACTIONS.ADD-DATASET-SHORT' | translate}}
</a>
</li>
@ -124,7 +124,7 @@
<dataset-info *ngIf="isNewDataset" [hidden]="this.step !== 1" [formGroup]="formGroup" [dmp]="dmp" [isPublic]="isPublic" [isFinalized]="isFinalized || lockStatus" [isUserOwner]="isUserOwner" [isNewDataset]="isNewDataset" [hasDmpId]="hasDmpId" (onFormChanged)="formChanged()"></dataset-info>
<div *ngFor="let dataset of datasets.controls; let i = index" [hidden]="this.step !== i + stepsBeforeDatasets">
<dataset-editor-details [formGroup]="dataset" [isNewDataset]="isNewDataset" [dmpId]="formGroup.get('id').value" (formChanged)="formChanged($event)"></dataset-editor-details>
<dataset-editor-details [formGroup]="dataset" [isNewDataset]="isNewDataset" [dmpId]="formGroup.get('id').value" [availableProfiles]="formGroup.get('profiles').value" (formChanged)="formChanged($event)"></dataset-editor-details>
</div>
</div>
</div>

View File

@ -307,7 +307,7 @@ a:hover {
font-size: 14px;
}
.previous {
.previous, .add-dataset-btn {
color: #212121;
background: #f5f5f5 0% 0% no-repeat padding-box;
box-shadow: 0px 3px 6px #1e202029;
@ -332,9 +332,9 @@ a:hover {
cursor: pointer;
}
.previous-disabled {
.previous-disabled, .add-dataset-btn-disabled {
border: 1px solid #b5b5b5;
color: #b5b5b5;
color: #b5b5b5 !important;
cursor: auto !important;
}
@ -395,26 +395,6 @@ a:hover {
list-style-type: none;
}
.add-dataset-btn {
color: #212121;
background: #f5f5f5 0% 0% no-repeat padding-box;
box-shadow: 0px 3px 6px #1e202029;
border: 2px solid #212121;
font-weight: 500;
cursor: pointer;
border-radius: 30px;
opacity: 1;
width: 154px;
height: 40px;
display: -webkit-box;
display: flex;
-webkit-box-pack: center;
justify-content: center;
-webkit-box-align: center;
align-items: center;
font-size: 14px;
}
// ::ng-deep .mat-tab-labels {
// justify-content: space-between;
// }

View File

@ -378,11 +378,6 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}
}
datasetFormChanged(formGroup: FormGroup) {
// this.datasetFormGroup = formGroup;
// console.log(this.datasetFormGroup);
}
isAuthenticated() {
return this.authService.current() != null;
}
@ -715,17 +710,19 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
}
addDataset() {
if (this.formGroup.get('datasets')) {
// const datasetWizardModel = { dmp: this.dmpModel };
// const datasetWizardEditorModel = new DatasetWizardEditorModel().fromModel(datasetWizardModel);
// this.formGroup.get('datasets')['controls'].push(datasetWizardEditorModel.buildForm());
this.formGroup.get('datasets')['controls'].push(new DatasetWizardEditorModel().buildForm());
// console.log(this.formGroup.get('datasets'))
};
if (!this.formGroup.get('datasets')) {
this.formGroup.addControl('datasets', new FormBuilder().array(new Array<FormControl>()));
}
this.formGroup.get('datasets')['controls'].push(new DatasetWizardEditorModel().buildForm());
this.datasets = this.formGroup.get('datasets') as FormArray;
this.step = this.stepsBeforeDatasets + this.formGroup.get('datasets')['controls'].length - 1;
this.maxStep = this.maxStep + this.formGroup.get('datasets')['controls'].length - 1;
}
hasProfile(): boolean {
return this.formGroup.get('profiles') && this.formGroup.get('profiles').value && this.formGroup.get('profiles').value.length > 0;
}
addDatasetOpenDialog(id: String) {
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
maxWidth: '500px',
@ -740,7 +737,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
dialogRef.afterClosed().pipe(takeUntil(this._destroyed)).subscribe(result => {
if (result) {
this.router.navigate(['datasets/new/' + id]);
// this.router.navigate(['datasets/new/' + id]);
this.addDataset();
} else {
id != null ? this.router.navigate(['/plans', 'edit', id]) : this.router.navigate(['/plans']);
}

View File

@ -23,7 +23,8 @@
"UNSUCCESSFUL-DATASET-PROFILE-DELETE": "Diese Vorlage kann nicht gelöscht werden, da Datensatzbeschreibungen noch damit verbunden sind",
"SUCCESSFUL-DELETE": "Erfolgreich gelöscht",
"UNSUCCESSFUL-DELETE": "Löschen fehlgeschlagen",
"UNSUCCESSFUL-EMAIL-SEND": "E-Mail versenden fehlgeschlagen"
"UNSUCCESSFUL-EMAIL-SEND": "E-Mail versenden fehlgeschlagen",
"UNSUCCESSFUL-REMOVE-TEMPLATE": "Failed to remove template, one or more datasets of this DMP use this template"
},
"ERRORS": {
"HTTP-REQUEST-ERROR": "Ein unerwarteter Fehler ist aufgetreten"

View File

@ -23,7 +23,8 @@
"UNSUCCESSFUL-DATASET-PROFILE-DELETE": "This template can not deleted, because Dataset Descriptions are associated with it",
"SUCCESSFUL-DELETE": "Successful Delete",
"UNSUCCESSFUL-DELETE": "Unsuccessful Delete",
"UNSUCCESSFUL-EMAIL-SEND": "Failed sending email"
"UNSUCCESSFUL-EMAIL-SEND": "Failed sending email",
"UNSUCCESSFUL-REMOVE-TEMPLATE": "Failed to remove template, one or more datasets of this DMP use this template"
},
"ERRORS": {
"HTTP-REQUEST-ERROR": "An Unexpected Error Has Occurred"

View File

@ -23,7 +23,8 @@
"SUCCESSFUL-DELETE": "Borrado correcto",
"UNSUCCESSFUL-DATASET-PROFILE-DELETE": "Esta plantilla no se puede borrar, porque está asociada a descripciones del dataset",
"UNSUCCESSFUL-DELETE": "Borrado fallido",
"UNSUCCESSFUL-EMAIL-SEND": "Fallo enviando el correo"
"UNSUCCESSFUL-EMAIL-SEND": "Fallo enviando el correo",
"UNSUCCESSFUL-REMOVE-TEMPLATE": "Failed to remove template, one or more datasets of this DMP use this template"
},
"ERRORS": {
"HTTP-REQUEST-ERROR": "Se ha producido un error inesperado"

View File

@ -23,7 +23,8 @@
"UNSUCCESSFUL-DATASET-PROFILE-DELETE": "Το template δεν μπορεί να διαγραφεί, επειδή οι περιγραφές των συνόλων δεδομένων σχετίζονται με αυτό",
"SUCCESSFUL-DELETE": "Επιτυχής διαγραφή",
"UNSUCCESSFUL-DELETE": "Αποτυχημένη διαγραφή",
"UNSUCCESSFUL-EMAIL-SEND": "Αποτυχία αποστολής email"
"UNSUCCESSFUL-EMAIL-SEND": "Αποτυχία αποστολής email",
"UNSUCCESSFUL-REMOVE-TEMPLATE": "Failed to remove template, one or more datasets of this DMP use this template"
},
"ERRORS": {
"HTTP-REQUEST-ERROR": "Παρουσιάστηκε μη αναμενόμενο σφάλμα"

View File

@ -22,7 +22,8 @@
"SUCCESSFUL-DATASET-PROFILE-DELETE": "Silme Başarılı",
"UNSUCCESSFUL-DATASET-PROFILE-DELETE": "Veri seti Tanımları ilişkilendirildiği için bu şablon silinemez",
"UNSUCCESSFUL-DELETE": "Başarısız Silme",
"UNSUCCESSFUL-EMAIL-SEND": "E-posta gönderilemedi"
"UNSUCCESSFUL-EMAIL-SEND": "E-posta gönderilemedi",
"UNSUCCESSFUL-REMOVE-TEMPLATE": "Failed to remove template, one or more datasets of this DMP use this template"
},
"ERRORS": {
"HTTP-REQUEST-ERROR": "Beklenmeyen Bir Hata Oluştu"