Fixed issue on dmp blueprint fields form, integrated new version endpoint
This commit is contained in:
parent
ed2a29d14b
commit
5802c2149d
|
@ -10,7 +10,6 @@ export interface DmpBlueprint extends BaseEntity {
|
|||
label: string;
|
||||
definition: DmpBlueprintDefinition;
|
||||
status: DmpBlueprintStatus;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface DmpBlueprintDefinition {
|
||||
|
@ -54,7 +53,18 @@ export interface DmpBlueprintPersist extends BaseEntityPersist {
|
|||
label: string;
|
||||
definition: DmpBlueprintDefinitionPersist;
|
||||
status: DmpBlueprintStatus;
|
||||
description: string;
|
||||
}
|
||||
|
||||
export interface CloneDmpBlueprintPersist {
|
||||
label: string;
|
||||
definition: DmpBlueprintDefinitionPersist;
|
||||
status: DmpBlueprintStatus;
|
||||
}
|
||||
|
||||
export interface NewVersionDmpBlueprintPersist {
|
||||
label: string;
|
||||
definition: DmpBlueprintDefinitionPersist;
|
||||
status: DmpBlueprintStatus;
|
||||
}
|
||||
|
||||
export interface DmpBlueprintDefinitionPersist {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { HttpClient, HttpHeaders, HttpResponse } from '@angular/common/http';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { DmpBlueprint, DmpBlueprintDefinitionSection, DmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||
import { DmpBlueprint, DmpBlueprintDefinitionSection, DmpBlueprintPersist, NewVersionDmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||
import { DmpBlueprintLookup } from '@app/core/query/dmp-blueprint.lookup';
|
||||
import { MultipleAutoCompleteConfiguration } from '@app/library/auto-complete/multiple/multiple-auto-complete-configuration';
|
||||
import { SingleAutoCompleteConfiguration } from '@app/library/auto-complete/single/single-auto-complete-configuration';
|
||||
|
@ -16,6 +16,7 @@ import { nameof } from 'ts-simple-nameof';
|
|||
import { ConfigurationService } from '../configuration/configuration.service';
|
||||
import { BaseHttpV2Service } from '../http/base-http-v2.service';
|
||||
import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status';
|
||||
import { error } from 'console';
|
||||
|
||||
@Injectable()
|
||||
export class DmpBlueprintService {
|
||||
|
@ -66,6 +67,15 @@ export class DmpBlueprintService {
|
|||
catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
newVersion(item: NewVersionDmpBlueprintPersist, reqFields: string[] = []): Observable<DmpBlueprint> {
|
||||
const url = `${this.apiBase}/new-version`;
|
||||
const options = { params: { f: reqFields } };
|
||||
|
||||
return this.http
|
||||
.post<DmpBlueprint>(url, item).pipe(
|
||||
catchError((error: any) => throwError(error)));
|
||||
}
|
||||
|
||||
downloadXML(id: Guid): Observable<HttpResponse<Blob>> {
|
||||
const url = `${this.apiBase}/xml/export/${id}`;
|
||||
let headerXml: HttpHeaders = this.headers.set('Content-Type', 'application/xml');
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { NgModule } from '@angular/core';
|
||||
import { RouterModule, Routes } from '@angular/router';
|
||||
import { AdminAuthGuard } from '@app/core/admin-auth-guard.service';
|
||||
import { DmpBlueprintEditorComponent } from './editor/dmp-blueprint-editor.component';
|
||||
import { DmpBlueprintListingComponent } from './listing/dmp-blueprint-listing.component';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
|
@ -43,7 +42,27 @@ const routes: Routes = [
|
|||
}),
|
||||
authContext: {
|
||||
permissions: [AppPermission.EditDmpBlueprint]
|
||||
},
|
||||
action: 'clone'
|
||||
}
|
||||
|
||||
},
|
||||
{
|
||||
path: 'new-version/:newversionid',
|
||||
canActivate: [AuthGuard],
|
||||
component: DmpBlueprintEditorComponent,
|
||||
canDeactivate: [PendingChangesGuard],
|
||||
resolve: {
|
||||
'entity': DmpBlueprintEditorResolver
|
||||
},
|
||||
data: {
|
||||
...BreadcrumbService.generateRouteDataConfiguration({
|
||||
title: 'BREADCRUMBS.EDIT-DMP-BLUEPRINT'
|
||||
}),
|
||||
authContext: {
|
||||
permissions: [AppPermission.EditDmpBlueprint]
|
||||
},
|
||||
action: 'new-version'
|
||||
}
|
||||
|
||||
},
|
||||
|
|
|
@ -2,12 +2,16 @@
|
|||
<div class="container-fluid dmp-blueprint-editor">
|
||||
<div class="row align-items-center mb-4" *ngIf="formGroup">
|
||||
<div class="col-auto">
|
||||
<h3 *ngIf="isNew && !isClone">{{'DMP-BLUEPRINT-EDITOR.TITLE.NEW' | translate}}</h3>
|
||||
<h3 *ngIf="isNew && isClone">
|
||||
<h3 *ngIf="isNew">{{'DMP-BLUEPRINT-EDITOR.TITLE.NEW' | translate}}</h3>
|
||||
<h3 *ngIf="isClone">
|
||||
<span>{{'DMP-BLUEPRINT-EDITOR.TITLE.CLONE' | translate}}</span>
|
||||
{{formGroup.get('label').value}}
|
||||
</h3>
|
||||
<h3 *ngIf="!isNew">{{formGroup.get('label').value}}</h3>
|
||||
<h3 *ngIf="isNewVersion">
|
||||
<span>{{'DMP-BLUEPRINT-EDITOR.TITLE.NEW-VERSION' | translate}}</span>
|
||||
{{formGroup.get('label').value}}
|
||||
</h3>
|
||||
<!-- <h3 *ngIf="!isNew">{{formGroup.get('label').value}}</h3> -->
|
||||
</div>
|
||||
<div class="col"></div>
|
||||
<div class="col-auto" *ngIf="!isNew">
|
||||
|
|
|
@ -15,7 +15,7 @@ import { DmpBlueprintStatus } from '@app/core/common/enum/dmp-blueprint-status';
|
|||
import { DmpBlueprintSystemFieldType } from '@app/core/common/enum/dmp-blueprint-system-field-type';
|
||||
import { IsActive } from '@app/core/common/enum/is-active.enum';
|
||||
import { AppPermission } from '@app/core/common/enum/permission.enum';
|
||||
import { DmpBlueprint, DmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||
import { DmpBlueprint, DmpBlueprintPersist, NewVersionDmpBlueprintPersist } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||
import { AuthService } from '@app/core/services/auth/auth.service';
|
||||
import { LoggingService } from '@app/core/services/logging/logging-service';
|
||||
import { MatomoService } from '@app/core/services/matomo/matomo-service';
|
||||
|
@ -51,6 +51,8 @@ import { MatCheckboxChange } from '@angular/material/checkbox';
|
|||
export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorModel, DmpBlueprint> implements OnInit {
|
||||
|
||||
isNew = true;
|
||||
isClone = false;
|
||||
isNewVersion = false;
|
||||
isDeleted = false;
|
||||
formGroup: UntypedFormGroup = null;
|
||||
showInactiveDetails = false;
|
||||
|
@ -116,6 +118,24 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
ngOnInit(): void {
|
||||
this.matomoService.trackPageView('Admin: DMP Blueprints');
|
||||
super.ngOnInit();
|
||||
this.initModelFlags(this.route.snapshot.data['action']);
|
||||
this.route.data.subscribe(d => this.initModelFlags(d['action']));
|
||||
}
|
||||
|
||||
private initModelFlags(action: string): void {
|
||||
if (action == 'clone') {
|
||||
this.isNew = false;
|
||||
this.isClone = true;
|
||||
this.isNewVersion = false;
|
||||
} else if (action == 'new-version') {
|
||||
this.isNew = false;
|
||||
this.isClone = false;
|
||||
this.isNewVersion = true;
|
||||
} else {
|
||||
this.isNew = true;
|
||||
this.isClone = false;
|
||||
this.isNewVersion = false;
|
||||
}
|
||||
}
|
||||
|
||||
getItem(itemId: Guid, successFunction: (item: DmpBlueprint) => void) {
|
||||
|
@ -163,6 +183,7 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
}
|
||||
|
||||
persistEntity(onSuccess?: (response) => void): void {
|
||||
if (this.isNew && !this.isClone && !this.isNewVersion){
|
||||
const formData = this.formService.getValue(this.formGroup.value) as DmpBlueprintPersist;
|
||||
|
||||
this.dmpBlueprintService.persist(formData)
|
||||
|
@ -170,6 +191,15 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
} else if (this.isNewVersion && !this.isNew && !this.isClone) {
|
||||
const formData = this.formService.getValue(this.formGroup.value) as NewVersionDmpBlueprintPersist;
|
||||
|
||||
this.dmpBlueprintService.newVersion(formData)
|
||||
.pipe(takeUntil(this._destroyed)).subscribe(
|
||||
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
||||
error => this.onCallbackError(error)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
formSubmit(): void {
|
||||
|
@ -278,19 +308,23 @@ export class DmpBlueprintEditorComponent extends BaseEditor<DmpBlueprintEditorMo
|
|||
}
|
||||
|
||||
addSystemField(sectionIndex: number, matSelect: MatSelectChange): void {
|
||||
const systemFieldTypes = matSelect.value as number[];
|
||||
let systemFieldTypes = matSelect.value as number[];
|
||||
let sectionsFormArray: FormArray = this.formGroup.get('definition').get('sections') as FormArray;
|
||||
let sectionFieldsFormArray: FormArray = sectionsFormArray.at(sectionIndex).get('fields') as FormArray;
|
||||
const fieldSize = sectionFieldsFormArray.length;
|
||||
systemFieldTypes = systemFieldTypes.filter(field => !sectionsFormArray.controls.some(x => (x.get('fields') as FormArray).controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === field)));
|
||||
for (let systemFieldType of systemFieldTypes) {
|
||||
const fieldSize = ((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray).length;
|
||||
if (fieldSize == 0) {
|
||||
((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray).push(this.editorModel.createChildSystemField(sectionIndex, fieldSize, systemFieldType));
|
||||
return;
|
||||
} else {
|
||||
if (!((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray).controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === systemFieldType)) {
|
||||
((this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields') as FormArray).push(this.editorModel.createChildSystemField(sectionIndex, fieldSize, systemFieldType));
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
sectionFieldsFormArray.push(this.editorModel.createChildSystemField(sectionIndex, fieldSize, systemFieldType));
|
||||
// const fieldSize = sectionFieldsFormArray.length;
|
||||
// if (fieldSize == 0) {
|
||||
// sectionFieldsFormArray.push(this.editorModel.createChildSystemField(sectionIndex, fieldSize, systemFieldType));
|
||||
// return;
|
||||
// } else {
|
||||
// if (!sectionFieldsFormArray.controls.some(y => (y as UntypedFormGroup).get('systemFieldType')?.value === systemFieldType)) {
|
||||
// sectionFieldsFormArray.push(this.editorModel.createChildSystemField(sectionIndex, fieldSize, systemFieldType));
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
|||
super.fromModel(item);
|
||||
this.label = item.label;
|
||||
this.status = item.status;
|
||||
this.description = item.description;
|
||||
this.definition = new DmpBlueprintDefinitionEditorModel(this.validationErrorModel).fromModel(item.definition);
|
||||
}
|
||||
return this;
|
||||
|
@ -69,6 +68,7 @@ export class DmpBlueprintEditorModel extends BaseEditorModel implements DmpBluep
|
|||
}
|
||||
|
||||
createChildSystemField(sectionIndex: number, index: number, systemFieldType: DmpBlueprintSystemFieldType): UntypedFormGroup {
|
||||
console.log(sectionIndex, index, systemFieldType.toString());
|
||||
const field: FieldInSectionEditorModel = new FieldInSectionEditorModel(this.validationErrorModel);
|
||||
field.id = Guid.create();
|
||||
field.ordinal = index + 1;
|
||||
|
|
|
@ -21,8 +21,6 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver {
|
|||
nameof<DmpBlueprint>(x => x.id),
|
||||
nameof<DmpBlueprint>(x => x.label),
|
||||
nameof<DmpBlueprint>(x => x.status),
|
||||
nameof<DmpBlueprint>(x => x.description),
|
||||
nameof<DmpBlueprint>(x => x.status),
|
||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.id)].join('.'),
|
||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.label)].join('.'),
|
||||
[nameof<DmpBlueprint>(x => x.definition), nameof<DmpBlueprintDefinition>(x => x.sections), nameof<DmpBlueprintDefinitionSection>(x => x.description)].join('.'),
|
||||
|
@ -56,10 +54,13 @@ export class DmpBlueprintEditorResolver extends BaseEditorResolver {
|
|||
];
|
||||
const id = route.paramMap.get('id');
|
||||
const cloneid = route.paramMap.get('cloneid');
|
||||
const newversion = route.paramMap.get("newversionid");
|
||||
if (id != null) {
|
||||
return this.dmpBlueprintService.getSingle(Guid.parse(id), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed));
|
||||
} else if (cloneid != null) {
|
||||
return this.dmpBlueprintService.clone(Guid.parse(cloneid), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed));
|
||||
} else if (newversion != null) {
|
||||
return this.dmpBlueprintService.getSingle(Guid.parse(newversion), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(x.id?.toString(), x.label)), takeUntil(this._destroyed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -93,6 +93,12 @@
|
|||
<button mat-menu-item [routerLink]="['./' + row.id]">
|
||||
<mat-icon>edit</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.EDIT' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item [routerLink]="['./new-version/' + row.id]">
|
||||
<mat-icon>queue</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.NEW-VERSION' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item (click)="newVersionFromFile(row.id, row.label)">
|
||||
<mat-icon>file_copy</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.NEW-VERSION-FROM-FILE' | translate}}
|
||||
</button>
|
||||
<button mat-menu-item [routerLink]="['./clone/' + row.id]">
|
||||
<mat-icon>content_copy</mat-icon>{{'DMP-BLUEPRINT-LISTING.ACTIONS.CLONE' | translate}}
|
||||
</button>
|
||||
|
|
|
@ -48,7 +48,6 @@ export class DmpBlueprintListingComponent extends BaseListingComponent<DmpBluepr
|
|||
private readonly lookupFields: string[] = [
|
||||
nameof<DmpBlueprint>(x => x.id),
|
||||
nameof<DmpBlueprint>(x => x.label),
|
||||
nameof<DmpBlueprint>(x => x.description),
|
||||
nameof<DmpBlueprint>(x => x.status),
|
||||
nameof<DmpBlueprint>(x => x.updatedAt),
|
||||
nameof<DmpBlueprint>(x => x.createdAt),
|
||||
|
|
|
@ -574,9 +574,7 @@
|
|||
"PRODUCED": "Produced dataset",
|
||||
"REUSED": "Reused dataset",
|
||||
"OTHER": "Other"
|
||||
},
|
||||
"FIELD-LABEL": "Label",
|
||||
"FIELD-MULTIPLE-SELECT": "Multiple Select"
|
||||
}
|
||||
},
|
||||
"ERROR-MESSAGES": {
|
||||
"FIELD-OTHER-SOURCES-REQUIRED": "At least one source must be provided.",
|
||||
|
@ -1595,7 +1593,9 @@
|
|||
"TITLE": {
|
||||
"NEW": "New DMP Blueprint",
|
||||
"NEW-PROFILE-CLONE": "New Clone Of ",
|
||||
"EDIT": "Edit"
|
||||
"EDIT": "Edit",
|
||||
"CLONE": "Clone DMP Blueprint",
|
||||
"NEW-VERSION":"Create New Version of DMP Blueprint"
|
||||
},
|
||||
"FIELDS": {
|
||||
"TITLE": "Fields",
|
||||
|
@ -1921,6 +1921,8 @@
|
|||
"DELETE": "Delete",
|
||||
"EDIT": "Edit",
|
||||
"CLONE": "Clone",
|
||||
"NEW-VERSION": "New Version",
|
||||
"NEW-VERSION-FROM-FILE": "New Version from File",
|
||||
"DOWNLOAD-XML": "Download XML"
|
||||
},
|
||||
"IMPORT": {
|
||||
|
|
Loading…
Reference in New Issue