changes on the dmp editor frontend
This commit is contained in:
parent
3bd60509e7
commit
7ad8077bc8
|
@ -223,7 +223,7 @@ public class DmpReferenceQuery extends QueryBase<DmpReferenceEntity> {
|
||||||
else if (item.prefix(DmpReference._reference) || item.prefix(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
else if (item.prefix(DmpReference._reference) || item.prefix(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
||||||
else if (item.match(DmpReference._dmp) || item.match(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
else if (item.match(DmpReference._dmp) || item.match(PublicDmpReference._dmp)) return DmpReferenceEntity._dmpId;
|
||||||
else if (item.match(DmpReference._reference) || item.match(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
else if (item.match(DmpReference._reference) || item.match(PublicDmpReference._reference)) return DmpReferenceEntity._referenceId;
|
||||||
else if (item.match(DmpReference._data)) return DmpReferenceEntity._data;
|
else if (item.prefix(DmpReference._data)) return DmpReferenceEntity._data;
|
||||||
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
|
else if (item.match(DmpReference._createdAt)) return DmpReferenceEntity._createdAt;
|
||||||
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
|
else if (item.match(DmpReference._updatedAt)) return DmpReferenceEntity._updatedAt;
|
||||||
else if (item.match(DmpReference._hash)) return DmpReferenceEntity._updatedAt;
|
else if (item.match(DmpReference._hash)) return DmpReferenceEntity._updatedAt;
|
||||||
|
|
|
@ -604,6 +604,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
dmpReferencePersist.setData(new DmpReferenceDataPersist());
|
dmpReferencePersist.setData(new DmpReferenceDataPersist());
|
||||||
dmpReferencePersist.getData().setBlueprintFieldId(fieldValuePersist.getFieldId());
|
dmpReferencePersist.getData().setBlueprintFieldId(fieldValuePersist.getFieldId());
|
||||||
dmpReferencePersist.setReference(referencePersist);
|
dmpReferencePersist.setReference(referencePersist);
|
||||||
|
dmpReferencePersists.add(dmpReferencePersist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -668,6 +669,7 @@ public class DmpServiceImpl implements DmpService {
|
||||||
|
|
||||||
if (!isUpdate) {
|
if (!isUpdate) {
|
||||||
data = new DmpReferenceEntity();
|
data = new DmpReferenceEntity();
|
||||||
|
data.setId(UUID.randomUUID());
|
||||||
data.setReferenceId(referenceEntity.getId());
|
data.setReferenceId(referenceEntity.getId());
|
||||||
data.setDmpId(dmpId);
|
data.setDmpId(dmpId);
|
||||||
data.setCreatedAt(Instant.now());
|
data.setCreatedAt(Instant.now());
|
||||||
|
|
|
@ -13,25 +13,25 @@ import { User } from "../user/user";
|
||||||
import { DmpReference } from './dmp-reference';
|
import { DmpReference } from './dmp-reference';
|
||||||
|
|
||||||
export interface Dmp extends BaseEntity {
|
export interface Dmp extends BaseEntity {
|
||||||
label: string;
|
label?: string;
|
||||||
version: number;
|
version?: number;
|
||||||
status: DmpStatus;
|
status?: DmpStatus;
|
||||||
versionStatus: DmpVersionStatus;
|
versionStatus?: DmpVersionStatus;
|
||||||
properties: DmpProperties;
|
properties?: DmpProperties;
|
||||||
groupId: String;
|
groupId?: String;
|
||||||
description: String;
|
description?: String;
|
||||||
finalizedAt: Date;
|
finalizedAt?: Date;
|
||||||
publishedAt: Date;
|
publishedAt?: Date;
|
||||||
creator: User;
|
creator?: User;
|
||||||
accessType: DmpAccessType;
|
accessType?: DmpAccessType;
|
||||||
blueprint: DmpBlueprint;
|
blueprint?: DmpBlueprint;
|
||||||
language: String;
|
language?: String;
|
||||||
publicAfter: Date;
|
publicAfter?: Date;
|
||||||
dmpReferences: DmpReference[];
|
dmpReferences?: DmpReference[];
|
||||||
dmpUsers: DmpUser[];
|
dmpUsers?: DmpUser[];
|
||||||
descriptions: Description[];
|
descriptions?: Description[];
|
||||||
dmpDescriptionTemplates: DmpDescriptionTemplate[];
|
dmpDescriptionTemplates?: DmpDescriptionTemplate[];
|
||||||
entityDois: EntityDoi[];
|
entityDois?: EntityDoi[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DmpProperties {
|
export interface DmpProperties {
|
||||||
|
@ -59,11 +59,11 @@ export interface DmpUser extends BaseEntity {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DmpDescriptionTemplate extends BaseEntity {
|
export interface DmpDescriptionTemplate extends BaseEntity {
|
||||||
dmp: Dmp;
|
dmp?: Dmp;
|
||||||
currentDescriptionTemplate: DescriptionTemplate; //TODO: what is this?
|
currentDescriptionTemplate?: DescriptionTemplate; //TODO: what is this?
|
||||||
descriptionTemplates: DescriptionTemplate[]; //TODO: why it is array?
|
descriptionTemplates?: DescriptionTemplate[]; //TODO: why it is array?
|
||||||
descriptionTemplateGroupId: Guid;
|
descriptionTemplateGroupId?: Guid;
|
||||||
sectionId: Guid;
|
sectionId?: Guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -107,7 +107,7 @@ export interface DmpReferenceDataPersist {
|
||||||
blueprintFieldId: Guid;
|
blueprintFieldId: Guid;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DmpDescriptionTemplatePersist extends BaseEntityPersist {
|
export interface DmpDescriptionTemplatePersist {
|
||||||
descriptionTemplateGroupId: Guid;
|
descriptionTemplateGroupId: Guid;
|
||||||
sectionId: Guid;
|
sectionId: Guid;
|
||||||
}
|
}
|
||||||
|
|
|
@ -163,7 +163,8 @@ export class DescriptionTemplateService {
|
||||||
lookup.project = {
|
lookup.project = {
|
||||||
fields: [
|
fields: [
|
||||||
nameof<DescriptionTemplate>(x => x.id),
|
nameof<DescriptionTemplate>(x => x.id),
|
||||||
nameof<DescriptionTemplate>(x => x.label)
|
nameof<DescriptionTemplate>(x => x.label),
|
||||||
|
nameof<DescriptionTemplate>(x => x.groupId),
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
lookup.order = { items: [nameof<DescriptionTemplate>(x => x.label)] };
|
lookup.order = { items: [nameof<DescriptionTemplate>(x => x.label)] };
|
||||||
|
|
|
@ -219,6 +219,7 @@ export class ReferenceTypeEditorComponent extends BaseEditor<ReferenceTypeEditor
|
||||||
removeField(fieldIndex: number): void {
|
removeField(fieldIndex: number): void {
|
||||||
const fieldCode = (this.formGroup.get('definition').get('fields') as FormArray).at(fieldIndex).get('code').value
|
const fieldCode = (this.formGroup.get('definition').get('fields') as FormArray).at(fieldIndex).get('code').value
|
||||||
|
|
||||||
|
|
||||||
if (this.propertyCodes.length > 0) {
|
if (this.propertyCodes.length > 0) {
|
||||||
if (this.propertyCodes.includes(fieldCode)) {
|
if (this.propertyCodes.includes(fieldCode)) {
|
||||||
this.propertyCodes.splice(this.propertyCodes.indexOf(fieldCode), 1);
|
this.propertyCodes.splice(this.propertyCodes.indexOf(fieldCode), 1);
|
||||||
|
|
|
@ -150,22 +150,22 @@
|
||||||
</rich-text-editor-component>
|
</rich-text-editor-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.RESEARCHERS">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.RESEARCHERS">
|
||||||
<app-reference-field-component [form]="formGroup.get('properties').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Researcher"></app-reference-field-component>
|
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Researcher"></app-reference-field-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.ORGANIZATIONS">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.ORGANIZATIONS">
|
||||||
<app-reference-field-component [form]="formGroup.get('properties').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Organizations"></app-reference-field-component>
|
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Organizations"></app-reference-field-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.FUNDER">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.FUNDER">
|
||||||
<app-reference-field-component [form]="formGroup.get('properties').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Funder"></app-reference-field-component>
|
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Funder"></app-reference-field-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.GRANT">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.GRANT">
|
||||||
<app-reference-field-component [form]="formGroup.get('properties').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Grants"></app-reference-field-component>
|
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Grants"></app-reference-field-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.PROJECT">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.PROJECT">
|
||||||
<app-reference-field-component [form]="formGroup.get('properties').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Project"></app-reference-field-component>
|
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Project"></app-reference-field-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.LICENSE">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.LICENSE">
|
||||||
<app-reference-field-component [form]="formGroup.get('properties').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Licenses"></app-reference-field-component>
|
<app-reference-field-component [form]="formGroup.get('properties').get('dmpBlueprintValues').get(field.id).get('references')" [referenceType]="referenceTypeEnum.Licenses"></app-reference-field-component>
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.LANGUAGE">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.LANGUAGE">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
|
@ -178,21 +178,21 @@
|
||||||
<mat-error *ngIf="formGroup.get('language').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="formGroup.get('language').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<!-- <div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.CONTACT">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.CONTACT">
|
||||||
<div class="contact-form">
|
<!-- <div class="contact-form">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-select [formControl]="formGroup.get('extraProperties').get('contact')" placeholder="{{'DMP-EDITOR.FIELDS.CONTACT' | translate}}">
|
<mat-select [formControl]="formGroup.get('properties').get('contacts')" placeholder="{{'DMP-EDITOR.FIELDS.CONTACT' | translate}}">
|
||||||
<mat-option *ngFor="let vis of getAssociates()" [value]="vis.id">
|
<mat-option *ngFor="let vis of getAssociates()" [value]="vis.id">
|
||||||
{{vis.name | translate}}
|
{{vis.name | translate}}
|
||||||
</mat-option>
|
</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('contact').hasError('backendError')">
|
<mat-error *ngIf="formGroup.get('properties').get('contacts').hasError('backendError')">
|
||||||
{{formGroup.get('extraProperties').get('contact').getError('backendError').message}}</mat-error>
|
{{formGroup.get('properties').get('contacts').getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="formGroup.get('extraProperties').get('contact').hasError('required')">
|
<mat-error *ngIf="formGroup.get('properties').get('contacts').hasError('required')">
|
||||||
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div> -->
|
||||||
</div> -->
|
</div>
|
||||||
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.ACCESS_RIGHTS">
|
<div *ngIf="field.systemFieldType == dmpBlueprintSystemFieldTypeEnum.ACCESS_RIGHTS">
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-select [formControl]="formGroup.get('accessType')" placeholder="{{'DMP-EDITOR.FIELDS.ACCESS-TYPE' | translate}}">
|
<mat-select [formControl]="formGroup.get('accessType')" placeholder="{{'DMP-EDITOR.FIELDS.ACCESS-TYPE' | translate}}">
|
||||||
|
@ -240,18 +240,17 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 card" *ngIf="section.hasTemplates">
|
<div class="col-12 card" *ngIf="section.hasTemplates">
|
||||||
{{formGroup.get('descriptionTemplates').value | json}}
|
{{formGroup.get('descriptionTemplates').get(section.id).value | json}}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="input-form">
|
<div class="input-form">
|
||||||
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
|
<div class="heading">{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES' | translate}}</div>
|
||||||
<mat-form-field class="w-100">
|
<mat-form-field class="w-100">
|
||||||
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
|
<mat-label>{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}</mat-label>
|
||||||
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id).get('descriptionTemplateGroupId')" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionRemoved)="onRemoveDescriptionTemplate($event, i)" (optionActionClicked)="onPreviewDescriptionTemplate($event, i)" (optionSelected)="onDescriptionTemplateSelected($event, i)">
|
<app-multiple-auto-complete placeholder="{{'DMP-EDITOR.FIELDS.DESCRIPTION-TEMPLATES-HINT' | translate}}" [hidePlaceholder]="true" required='true' [formControl]="formGroup.get('descriptionTemplates').get(section.id)" [configuration]="descriptionTemplateService.descriptionTempalteGroupMultipleAutocompleteConfiguration" (optionRemoved)="onRemoveDescriptionTemplate($event, i)" (optionActionClicked)="onPreviewDescriptionTemplate($event, i)" (optionSelected)="onDescriptionTemplateSelected($event, i)">
|
||||||
</app-multiple-auto-complete>
|
</app-multiple-auto-complete>
|
||||||
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).get('descriptionTemplateGroupId').hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).get('descriptionTemplateGroupId').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('backendError')">{{formGroup.get('descriptionTemplates').get(section.id).getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).get('descriptionTemplateGroupId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="formGroup.get('descriptionTemplates').get(section.id).hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<div class="col pl-0 pt-0 pb-0 d-flex">
|
<div class="col pl-0 pt-0 pb-0 d-flex">
|
||||||
<span class="not-found-template">{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}}</span>
|
<span class="not-found-template">{{'DMP-EDITOR.NO-TEMPLATE-MESSAGE' | translate}}</span>
|
||||||
|
|
|
@ -38,7 +38,7 @@ import { LanguageInfo } from '@app/core/model/language-info';
|
||||||
import { LanguageInfoService } from '@app/core/services/culture/language-info-service';
|
import { LanguageInfoService } from '@app/core/services/culture/language-info-service';
|
||||||
import { DmpAccessType } from '@app/core/common/enum/dmp-access-type';
|
import { DmpAccessType } from '@app/core/common/enum/dmp-access-type';
|
||||||
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||||
import { UntypedFormArray } from '@angular/forms';
|
import { UntypedFormArray, UntypedFormGroup } from '@angular/forms';
|
||||||
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
|
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -201,22 +201,33 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
|
|
||||||
refreshOnNavigateToData(id?: Guid): void {
|
refreshOnNavigateToData(id?: Guid): void {
|
||||||
this.formGroup.markAsPristine();
|
this.formGroup.markAsPristine();
|
||||||
let route = [];
|
|
||||||
|
|
||||||
if (id === null) {
|
if (this.isNew) {
|
||||||
route.push('../..');
|
let route = [];
|
||||||
} else if (this.isNew) {
|
|
||||||
route.push('../' + id);
|
route.push('../' + id);
|
||||||
|
this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
|
||||||
} else {
|
} else {
|
||||||
route.push('..');
|
this.refreshData();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.router.navigate(route, { queryParams: { 'lookup': this.queryParamsService.serializeLookup(this.lookupParams), 'lv': ++this.lv }, replaceUrl: true, relativeTo: this.route });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
persistEntity(onSuccess?: (response) => void): void {
|
persistEntity(onSuccess?: (response) => void): void {
|
||||||
const formData = this.formService.getValue(this.formGroup.value) as DmpPersist;
|
const formData = this.formService.getValue(this.formGroup.value) as DmpPersist;
|
||||||
|
|
||||||
|
//Transform to persist
|
||||||
|
//Transform descriptionTemplates
|
||||||
|
formData.descriptionTemplates = [];
|
||||||
|
for (const fieldId in (this.formGroup.get('descriptionTemplates') as UntypedFormGroup).controls) {
|
||||||
|
formData.descriptionTemplates.push(this.formGroup.get('descriptionTemplates').get(fieldId).value);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Transform properties
|
||||||
|
formData.properties.dmpBlueprintValues = [];
|
||||||
|
for (const fieldId in (this.formGroup.get('properties').get('dmpBlueprintValues') as UntypedFormGroup).controls) {
|
||||||
|
formData.properties.dmpBlueprintValues.push(this.formGroup.get('properties').get('dmpBlueprintValues').get(fieldId).value);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.dmpService.persist(formData)
|
this.dmpService.persist(formData)
|
||||||
.pipe(takeUntil(this._destroyed)).subscribe(
|
.pipe(takeUntil(this._destroyed)).subscribe(
|
||||||
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
complete => onSuccess ? onSuccess(complete) : this.onCallbackSuccess(complete),
|
||||||
|
@ -293,6 +304,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
selectBlueprint() {
|
selectBlueprint() {
|
||||||
this.dmpBlueprintService.getSingle(this.formGroup.get('blueprint').value, DmpEditorResolver.blueprintLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
this.dmpBlueprintService.getSingle(this.formGroup.get('blueprint').value, DmpEditorResolver.blueprintLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
||||||
this.selectedBlueprint = data;
|
this.selectedBlueprint = data;
|
||||||
|
this.buildFormAfterBlueprintSelection();
|
||||||
this.nextStep();
|
this.nextStep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -301,10 +313,20 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
this.dmpBlueprintService.getSingle(this.configurationService.defaultBlueprintId, DmpEditorResolver.blueprintLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
this.dmpBlueprintService.getSingle(this.configurationService.defaultBlueprintId, DmpEditorResolver.blueprintLookupFields()).pipe(takeUntil(this._destroyed)).subscribe(data => {
|
||||||
this.selectedBlueprint = data;
|
this.selectedBlueprint = data;
|
||||||
this.formGroup.get('blueprint').setValue(this.selectedBlueprint.id);
|
this.formGroup.get('blueprint').setValue(this.selectedBlueprint.id);
|
||||||
|
this.buildFormAfterBlueprintSelection();
|
||||||
this.nextStep();
|
this.nextStep();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private buildFormAfterBlueprintSelection() {
|
||||||
|
const dmp: Dmp = {
|
||||||
|
label: this.formGroup.get('label').value,
|
||||||
|
description: this.formGroup.get('description').value,
|
||||||
|
blueprint: this.selectedBlueprint,
|
||||||
|
}
|
||||||
|
this.prepareForm(dmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
|
@ -312,7 +334,7 @@ export class DmpEditorComponent extends BaseEditor<DmpEditorModel, Dmp> implemen
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
public descriptionsInSection(sectionId: Guid) {
|
public descriptionsInSection(sectionId: Guid) {
|
||||||
this.item.descriptions.filter(x => x.dmpDescriptionTemplate.sectionId === sectionId);
|
this.item?.descriptions?.filter(x => x?.dmpDescriptionTemplate?.sectionId === sectionId) || [];
|
||||||
}
|
}
|
||||||
|
|
||||||
editDescription(id: string, isNew: boolean, showModal: boolean = false) {
|
editDescription(id: string, isNew: boolean, showModal: boolean = false) {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
import { FormControl, UntypedFormBuilder, UntypedFormGroup, Validators } from "@angular/forms";
|
||||||
import { DmpAccessType } from "@app/core/common/enum/dmp-access-type";
|
import { DmpAccessType } from "@app/core/common/enum/dmp-access-type";
|
||||||
import { DmpStatus } from "@app/core/common/enum/dmp-status";
|
import { DmpStatus } from "@app/core/common/enum/dmp-status";
|
||||||
import { DmpBlueprint } from "@app/core/model/dmp-blueprint/dmp-blueprint";
|
import { DmpBlueprint } from "@app/core/model/dmp-blueprint/dmp-blueprint";
|
||||||
|
@ -14,12 +14,11 @@ import { Guid } from "@common/types/guid";
|
||||||
export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
|
export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
|
||||||
label: string;
|
label: string;
|
||||||
status: DmpStatus;
|
status: DmpStatus;
|
||||||
properties: DmpPropertiesEditorModel;
|
properties: DmpPropertiesEditorModel = new DmpPropertiesEditorModel();
|
||||||
description: String;
|
description: String;
|
||||||
language: String;
|
language: String;
|
||||||
blueprint: Guid;
|
blueprint: Guid;
|
||||||
accessType: DmpAccessType;
|
accessType: DmpAccessType;
|
||||||
// references: DmpReferenceEditorModel[] = [];
|
|
||||||
descriptionTemplates: DmpDescriptionTemplateEditorModel[] = [];
|
descriptionTemplates: DmpDescriptionTemplateEditorModel[] = [];
|
||||||
permissions: string[];
|
permissions: string[];
|
||||||
|
|
||||||
|
@ -38,8 +37,36 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
|
||||||
this.language = item.language;
|
this.language = item.language;
|
||||||
this.blueprint = item.blueprint?.id;
|
this.blueprint = item.blueprint?.id;
|
||||||
this.accessType = item.accessType;
|
this.accessType = item.accessType;
|
||||||
//if (item.dmpReferences) { item.dmpReferences.map(x => this.references.push(new DmpReferenceEditorModel().fromModel(x))); }
|
|
||||||
if (item.dmpDescriptionTemplates) { item.dmpDescriptionTemplates.map(x => this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel().fromModel(x))); }
|
item.blueprint.definition.sections.forEach(section => {
|
||||||
|
if (section.hasTemplates) {
|
||||||
|
const sectionTempaltesFromDmp = item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id) || [];
|
||||||
|
|
||||||
|
if (sectionTempaltesFromDmp.length > 0) {
|
||||||
|
item.dmpDescriptionTemplates?.filter(x => x.sectionId == section.id).forEach(dmpDescriptionTemplate => {
|
||||||
|
this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel().fromModel(
|
||||||
|
{
|
||||||
|
sectionId: section.id,
|
||||||
|
descriptionTemplateGroupId: dmpDescriptionTemplate?.descriptionTemplateGroupId,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
} else if (section.descriptionTemplates?.length > 0) {
|
||||||
|
section.descriptionTemplates.forEach(blueprintDefinedDescriptionTemplate => {
|
||||||
|
this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel().fromModel(
|
||||||
|
{
|
||||||
|
sectionId: section.id,
|
||||||
|
descriptionTemplateGroupId: blueprintDefinedDescriptionTemplate?.descriptionTemplateId,
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.descriptionTemplates.push(new DmpDescriptionTemplateEditorModel().fromModel(
|
||||||
|
{
|
||||||
|
sectionId: section.id,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -58,32 +85,18 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
|
||||||
language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators],
|
language: [{ value: this.language, disabled: disabled }, context.getValidation('language').validators],
|
||||||
blueprint: [{ value: this.blueprint, disabled: disabled }, context.getValidation('blueprint').validators],
|
blueprint: [{ value: this.blueprint, disabled: disabled }, context.getValidation('blueprint').validators],
|
||||||
accessType: [{ value: this.accessType, disabled: disabled }, context.getValidation('accessType').validators],
|
accessType: [{ value: this.accessType, disabled: disabled }, context.getValidation('accessType').validators],
|
||||||
// references: this.formBuilder.array(
|
|
||||||
// (this.references ?? []).map(
|
|
||||||
// (item, index) => new DmpReferenceEditorModel(
|
|
||||||
// this.validationErrorModel
|
|
||||||
// ).fromModel(item).buildForm({
|
|
||||||
// rootPath: `references[${index}].`
|
|
||||||
// }), context.getValidation('references')
|
|
||||||
// )
|
|
||||||
// ),
|
|
||||||
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
|
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// (this.references ?? []).filter(x => x?.data?.blueprintFieldId).map(x => x?.data?.blueprintFieldId).map(
|
|
||||||
// (item, index) => formGroup.addControl(item.data.blueprintFieldId.toString(), new DmpReferenceEditorModel(
|
|
||||||
// this.validationErrorModel
|
|
||||||
// ).fromModel(item).buildForm({
|
|
||||||
// rootPath: `references[${index}].`
|
|
||||||
// })), context.getValidation('references')
|
|
||||||
// )
|
|
||||||
const descriptionTemplatesFormGroup = this.formBuilder.group({});
|
const descriptionTemplatesFormGroup = this.formBuilder.group({});
|
||||||
(this.descriptionTemplates ?? []).filter(x => x?.sectionId).map(x => x.sectionId).map(
|
(this.descriptionTemplates ?? []).filter(x => x?.sectionId).map(x => x.sectionId).map(
|
||||||
(item, index) => descriptionTemplatesFormGroup.addControl(item.toString(), this.descriptionTemplates.find(x => x.sectionId === item).buildForm({
|
(item, index) => descriptionTemplatesFormGroup.addControl(item.toString(),
|
||||||
rootPath: `descriptionTemplates[${index}].`
|
new FormControl(this.descriptionTemplates?.filter(x => x.sectionId === item)?.filter(x => x.descriptionTemplateGroupId).map(x => x.descriptionTemplateGroupId) || [], context.getValidation('descriptionTemplates').validators))
|
||||||
})), context.getValidation('descriptionTemplates')
|
);
|
||||||
)
|
// // buildForm({
|
||||||
|
// // rootPath: `descriptionTemplates[${index}].`
|
||||||
|
// })), //context.getValidation('descriptionTemplates')
|
||||||
|
// ))
|
||||||
formGroup.addControl('descriptionTemplates', descriptionTemplatesFormGroup);
|
formGroup.addControl('descriptionTemplates', descriptionTemplatesFormGroup);
|
||||||
|
|
||||||
return formGroup;
|
return formGroup;
|
||||||
|
@ -100,7 +113,6 @@ export class DmpEditorModel extends BaseEditorModel implements DmpPersist {
|
||||||
baseValidationArray.push({ key: 'language', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'language')] });
|
baseValidationArray.push({ key: 'language', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'language')] });
|
||||||
baseValidationArray.push({ key: 'blueprint', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'blueprint')] });
|
baseValidationArray.push({ key: 'blueprint', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'blueprint')] });
|
||||||
baseValidationArray.push({ key: 'accessType', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'accessType')] });
|
baseValidationArray.push({ key: 'accessType', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'accessType')] });
|
||||||
//baseValidationArray.push({ key: 'references', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'references')] });
|
|
||||||
baseValidationArray.push({ key: 'descriptionTemplates', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'descriptionTemplates')] });
|
baseValidationArray.push({ key: 'descriptionTemplates', validators: [Validators.required, BackendErrorValidator(this.validationErrorModel, 'descriptionTemplates')] });
|
||||||
baseValidationArray.push({ key: 'hash', validators: [] });
|
baseValidationArray.push({ key: 'hash', validators: [] });
|
||||||
|
|
||||||
|
@ -126,11 +138,10 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
|
||||||
this.dmpBlueprintValues.push(new DmpBlueprintValueEditorModel().fromModel(
|
this.dmpBlueprintValues.push(new DmpBlueprintValueEditorModel().fromModel(
|
||||||
{
|
{
|
||||||
fieldId: field.id,
|
fieldId: field.id,
|
||||||
fieldValue: item?.dmpBlueprintValues?.find(x => x.fieldId == field.id)?.fieldValue
|
fieldValue: item?.dmpBlueprintValues?.find(x => x.fieldId == field.id)?.fieldValue,
|
||||||
}, dmpReferences));
|
}, dmpReferences));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
// if (item?.dmpBlueprintValues) { item.dmpBlueprintValues.map(x => this.dmpBlueprintValues.push(new DmpBlueprintValueEditorModel().fromModel(x, dmpReferences))); }
|
|
||||||
if (item?.contacts) { item.contacts.map(x => this.contacts.push(new DmpContactEditorModel().fromModel(x))); }
|
if (item?.contacts) { item.contacts.map(x => this.contacts.push(new DmpContactEditorModel().fromModel(x))); }
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
|
@ -162,11 +173,14 @@ export class DmpPropertiesEditorModel implements DmpPropertiesPersist {
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
const dmpBlueprintValuesFormGroup = this.formBuilder.group({});
|
||||||
(this.dmpBlueprintValues ?? []).filter(x => x?.fieldId).map(
|
(this.dmpBlueprintValues ?? []).filter(x => x?.fieldId).map(
|
||||||
(item, index) => formGroup.addControl(item.fieldId.toString(), item.buildForm({
|
(item, index) => dmpBlueprintValuesFormGroup.addControl(item.fieldId.toString(), item.buildForm({
|
||||||
rootPath: `dmpBlueprintValues[${index}].`
|
rootPath: `dmpBlueprintValues[${index}].`
|
||||||
})), context.getValidation('dmpBlueprintValues')
|
})), context.getValidation('dmpBlueprintValues')
|
||||||
)
|
)
|
||||||
|
formGroup.addControl('dmpBlueprintValues', dmpBlueprintValuesFormGroup);
|
||||||
|
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
@ -201,7 +215,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[]): DmpBlueprintValueEditorModel {
|
fromModel(item: DmpBlueprintValue, dmpReferences: DmpReference[]): DmpBlueprintValueEditorModel {
|
||||||
this.fieldId = item.fieldId;
|
this.fieldId = item.fieldId;
|
||||||
this.fieldValue = item.fieldValue;
|
this.fieldValue = item.fieldValue;
|
||||||
this.references = dmpReferences.filter(x => x.data?.blueprintFieldId === this.fieldId);
|
this.references = dmpReferences?.filter(x => x.data?.blueprintFieldId === this.fieldId) || [];
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +236,7 @@ export class DmpBlueprintValueEditorModel implements DmpBlueprintValuePersist {
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
fieldId: [{ value: this.fieldId, disabled: disabled }, context.getValidation('fieldId').validators],
|
fieldId: [{ value: this.fieldId, disabled: disabled }, context.getValidation('fieldId').validators],
|
||||||
fieldValue: [{ value: this.fieldValue, disabled: disabled }, context.getValidation('fieldValue').validators],
|
fieldValue: [{ value: this.fieldValue, disabled: disabled }, context.getValidation('fieldValue').validators],
|
||||||
references: [{ value: this.references, disabled: disabled }, context.getValidation('references').validators],
|
references: [{ value: this.references?.map(x => x.reference), disabled: disabled }, context.getValidation('references').validators],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,10 +379,8 @@ export class DmpReferenceEditorModel implements DmpReferencePersist {
|
||||||
}
|
}
|
||||||
|
|
||||||
export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplatePersist {
|
export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplatePersist {
|
||||||
id: Guid;
|
|
||||||
descriptionTemplateGroupId: Guid;
|
descriptionTemplateGroupId: Guid;
|
||||||
sectionId: Guid;
|
sectionId: Guid;
|
||||||
hash: string;
|
|
||||||
|
|
||||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
|
||||||
|
@ -377,10 +389,8 @@ export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplate
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
fromModel(item: DmpDescriptionTemplate): DmpDescriptionTemplateEditorModel {
|
fromModel(item: DmpDescriptionTemplate): DmpDescriptionTemplateEditorModel {
|
||||||
this.id = item.id;
|
|
||||||
this.descriptionTemplateGroupId = item.descriptionTemplateGroupId;
|
this.descriptionTemplateGroupId = item.descriptionTemplateGroupId;
|
||||||
this.sectionId = item.sectionId;
|
this.sectionId = item.sectionId;
|
||||||
this.hash = item.hash;
|
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -399,10 +409,8 @@ export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplate
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.formBuilder.group({
|
return this.formBuilder.group({
|
||||||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
|
||||||
descriptionTemplateGroupId: [{ value: this.descriptionTemplateGroupId, disabled: disabled }, context.getValidation('descriptionTemplateGroupId').validators],
|
descriptionTemplateGroupId: [{ value: this.descriptionTemplateGroupId, disabled: disabled }, context.getValidation('descriptionTemplateGroupId').validators],
|
||||||
sectionId: [{ value: this.sectionId, disabled: disabled }, context.getValidation('sectionId').validators],
|
sectionId: [{ value: this.sectionId, disabled: disabled }, context.getValidation('sectionId').validators],
|
||||||
hash: [{ value: this.hash, disabled: disabled }, context.getValidation('hash').validators]
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -414,10 +422,8 @@ export class DmpDescriptionTemplateEditorModel implements DmpDescriptionTemplate
|
||||||
|
|
||||||
const baseContext: ValidationContext = new ValidationContext();
|
const baseContext: ValidationContext = new ValidationContext();
|
||||||
const baseValidationArray: Validation[] = new Array<Validation>();
|
const baseValidationArray: Validation[] = new Array<Validation>();
|
||||||
baseValidationArray.push({ key: 'id', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}id`)] });
|
|
||||||
baseValidationArray.push({ key: 'descriptionTemplateGroupId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateGroupId`)] });
|
baseValidationArray.push({ key: 'descriptionTemplateGroupId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}descriptionTemplateGroupId`)] });
|
||||||
baseValidationArray.push({ key: 'sectionId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sectionId`)] });
|
baseValidationArray.push({ key: 'sectionId', validators: [BackendErrorValidator(validationErrorModel, `${rootPath}sectionId`)] });
|
||||||
baseValidationArray.push({ key: 'hash', validators: [] });
|
|
||||||
|
|
||||||
baseContext.validation = baseValidationArray;
|
baseContext.validation = baseValidationArray;
|
||||||
return baseContext;
|
return baseContext;
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
|
||||||
import { Description } from '@app/core/model/description/description';
|
import { Description } from '@app/core/model/description/description';
|
||||||
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
import { DescriptionTemplatesInSection, DmpBlueprint, DmpBlueprintDefinition, DmpBlueprintDefinitionSection, FieldInSection } from '@app/core/model/dmp-blueprint/dmp-blueprint';
|
||||||
import { Dmp, DmpBlueprintValue, DmpContact, DmpDescriptionTemplate, DmpProperties } from '@app/core/model/dmp/dmp';
|
import { Dmp, DmpBlueprintValue, DmpContact, DmpDescriptionTemplate, DmpProperties } from '@app/core/model/dmp/dmp';
|
||||||
import { DmpReference } from '@app/core/model/dmp/dmp-reference';
|
import { DmpReference, DmpReferenceData } from '@app/core/model/dmp/dmp-reference';
|
||||||
import { Reference } from '@app/core/model/reference/reference';
|
import { Reference } from '@app/core/model/reference/reference';
|
||||||
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
import { DmpService } from '@app/core/services/dmp/dmp.service';
|
||||||
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
import { BreadcrumbService } from '@app/ui/misc/breadcrumb/breadcrumb.service';
|
||||||
|
@ -26,12 +26,14 @@ export class DmpEditorResolver extends BaseEditorResolver {
|
||||||
nameof<Dmp>(x => x.label),
|
nameof<Dmp>(x => x.label),
|
||||||
nameof<Dmp>(x => x.status),
|
nameof<Dmp>(x => x.status),
|
||||||
nameof<Dmp>(x => x.versionStatus),
|
nameof<Dmp>(x => x.versionStatus),
|
||||||
nameof<Dmp>(x => x.accessType),
|
|
||||||
nameof<Dmp>(x => x.version),
|
|
||||||
nameof<Dmp>(x => x.isActive),
|
|
||||||
nameof<Dmp>(x => x.groupId),
|
nameof<Dmp>(x => x.groupId),
|
||||||
|
nameof<Dmp>(x => x.description),
|
||||||
|
nameof<Dmp>(x => x.language),
|
||||||
|
nameof<Dmp>(x => x.accessType),
|
||||||
|
nameof<Dmp>(x => x.isActive),
|
||||||
nameof<Dmp>(x => x.version),
|
nameof<Dmp>(x => x.version),
|
||||||
nameof<Dmp>(x => x.updatedAt),
|
nameof<Dmp>(x => x.updatedAt),
|
||||||
|
nameof<Dmp>(x => x.publicAfter),
|
||||||
|
|
||||||
[nameof<Dmp>(x => x.properties), nameof<DmpProperties>(x => x.dmpBlueprintValues), nameof<DmpBlueprintValue>(x => x.fieldId)].join('.'),
|
[nameof<Dmp>(x => x.properties), nameof<DmpProperties>(x => x.dmpBlueprintValues), nameof<DmpBlueprintValue>(x => x.fieldId)].join('.'),
|
||||||
[nameof<Dmp>(x => x.properties), nameof<DmpProperties>(x => x.dmpBlueprintValues), nameof<DmpBlueprintValue>(x => x.fieldValue)].join('.'),
|
[nameof<Dmp>(x => x.properties), nameof<DmpProperties>(x => x.dmpBlueprintValues), nameof<DmpBlueprintValue>(x => x.fieldValue)].join('.'),
|
||||||
|
@ -55,12 +57,13 @@ export class DmpEditorResolver extends BaseEditorResolver {
|
||||||
// [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.name)].join('.'),
|
// [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.user.name)].join('.'),
|
||||||
// [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'),
|
// [nameof<Dmp>(x => x.dmpUsers), nameof<DmpUser>(x => x.role)].join('.'),
|
||||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.id)].join('.'),
|
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.id)].join('.'),
|
||||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.data)].join('.'),
|
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.data), nameof<DmpReferenceData>(x => x.blueprintFieldId)].join('.'),
|
||||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.id)].join('.'),
|
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.id)].join('.'),
|
||||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.label)].join('.'),
|
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.label)].join('.'),
|
||||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.type)].join('.'),
|
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.type)].join('.'),
|
||||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.source)].join('.'),
|
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.source)].join('.'),
|
||||||
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.reference)].join('.'),
|
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.reference)].join('.'),
|
||||||
|
[nameof<Dmp>(x => x.dmpReferences), nameof<DmpReference>(x => x.reference), nameof<Reference>(x => x.sourceType)].join('.'),
|
||||||
|
|
||||||
|
|
||||||
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
|
[nameof<Dmp>(x => x.dmpDescriptionTemplates), nameof<DmpDescriptionTemplate>(x => x.sectionId)].join('.'),
|
||||||
|
|
|
@ -7,5 +7,5 @@
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<span *ngIf="!form.disabled" class="not-found">{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}}</span>
|
<span *ngIf="!form.disabled" class="not-found">{{'REFERENCE-FIELD.COULD-NOT-FIND-MESSAGE' | translate}}</span>
|
||||||
<span *ngIf="!form.disabled" class="insert-manually" (click)="addResearcher($event)">{{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}}</span>
|
<span *ngIf="!form.disabled" class="insert-manually" (click)="addReference($event)">{{'REFERENCE-FIELD.ACTIONS.INSERT-MANUALLY' | translate}}</span>
|
||||||
</div>
|
</div>
|
|
@ -17,308 +17,28 @@ export class ReferenceFieldComponent extends BaseComponent implements OnInit {
|
||||||
@Input() form: UntypedFormGroup = null;
|
@Input() form: UntypedFormGroup = null;
|
||||||
|
|
||||||
multipleAutoCompleteSearchConfiguration: MultipleAutoCompleteConfiguration;
|
multipleAutoCompleteSearchConfiguration: MultipleAutoCompleteConfiguration;
|
||||||
// referenceTypeEnum = ReferenceType;
|
|
||||||
|
|
||||||
// @Input() viewOnly = false;
|
|
||||||
// @Output() formChanged: EventEmitter<any> = new EventEmitter();
|
|
||||||
|
|
||||||
// public filteringTagsAsync = false;
|
|
||||||
// public filteredTags: ExternalSourceItemModel[];
|
|
||||||
|
|
||||||
// readonly separatorKeysCodes: number[] = [ENTER, COMMA];
|
|
||||||
|
|
||||||
// externalDatasetAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
|
|
||||||
// filterFn: this.searchDatasetExternalDatasets.bind(this),
|
|
||||||
// initialItems: (type) => this.searchDatasetExternalDatasets('', type),//.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1),
|
|
||||||
// displayFn: (item) => item ? item.name : null,
|
|
||||||
// titleFn: (item) => item ? item.name : null,
|
|
||||||
// subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
|
||||||
// };
|
|
||||||
|
|
||||||
// registriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
|
|
||||||
// filterFn: this.searchDatasetExternalRegistries.bind(this),
|
|
||||||
// initialItems: (type) => this.searchDatasetExternalRegistries('', type),
|
|
||||||
// displayFn: (item) => item ? item.name : null,
|
|
||||||
// titleFn: (item) => item ? item.name : null,
|
|
||||||
// subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
|
||||||
// };
|
|
||||||
|
|
||||||
// dataRepositoriesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
|
|
||||||
// filterFn: this.searchDatasetExternalDataRepositories.bind(this),
|
|
||||||
// initialItems: (type) => this.searchDatasetExternalDataRepositories('', type),
|
|
||||||
// displayFn: (item) => item ? item.name : null,
|
|
||||||
// titleFn: (item) => item ? item.name : null,
|
|
||||||
// subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
|
||||||
// };
|
|
||||||
|
|
||||||
// servicesAutoCompleteConfiguration: SingleAutoCompleteConfiguration = {
|
|
||||||
// filterFn: this.searchDatasetExternalServices.bind(this),
|
|
||||||
// initialItems: (type) => this.searchDatasetExternalServices('', type),
|
|
||||||
// displayFn: (item) => item ? item.label : null,
|
|
||||||
// titleFn: (item) => item ? item.label : null,
|
|
||||||
// subtitleFn: (item) => item.source ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.source : item.tag ? this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.SOURCE:') + item.tag : this.language.instant('TYPES.EXTERNAL-DATASET-TYPE.NO-SOURCE')
|
|
||||||
// };
|
|
||||||
|
|
||||||
// tagsAutoCompleteConfiguration: MultipleAutoCompleteConfiguration = {
|
|
||||||
// filterFn: this.filterTags.bind(this),
|
|
||||||
// initialItems: (excludedItems: any[]) => this.filterTags('').pipe(map(result => result.filter(resultItem => (excludedItems || []).map(x => x.id).indexOf(resultItem.id) === -1))),
|
|
||||||
// displayFn: (item) => this.showTag(item),
|
|
||||||
// titleFn: (item) => item['name'],
|
|
||||||
// valueAssign: (item) => this.addTag(item)
|
|
||||||
// };
|
|
||||||
|
|
||||||
// externalSourcesConfiguration: ExternalSourcesConfiguration;
|
|
||||||
|
|
||||||
// // new AutoCompleteConfiguration(this.externalSourcesService.searchDatasetRepository.bind(this.externalSourcesService),
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
// private dialog: MatDialog,
|
|
||||||
// private router: Router,
|
|
||||||
// private language: TranslateService,
|
|
||||||
// private externalSourcesService: ExternalSourcesService,
|
|
||||||
// private externalSourcesConfigurationService: ExternalSourcesConfigurationService,
|
|
||||||
// private externalDataRepositoryService: ExternalDataRepositoryService,
|
|
||||||
// private externalDatasetService: ExternalDatasetService,
|
|
||||||
// private externalRegistryService: ExternalRegistryService,
|
|
||||||
private referenceService: ReferenceService,
|
private referenceService: ReferenceService,
|
||||||
public enumUtils: EnumUtils,
|
public enumUtils: EnumUtils,
|
||||||
) { super(); }
|
) { super(); }
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.multipleAutoCompleteSearchConfiguration = this.referenceService.getMultipleAutoCompleteSearchConfiguration(this.referenceType);
|
this.multipleAutoCompleteSearchConfiguration = this.referenceService.getMultipleAutoCompleteSearchConfiguration(this.referenceType);
|
||||||
|
|
||||||
|
|
||||||
// this.externalSourcesConfigurationService.getExternalSourcesConfiguration()
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(result => {
|
|
||||||
// this.externalSourcesConfiguration = result;
|
|
||||||
// this.externalSourcesConfiguration.dataRepositories.push({ key: '', label: 'All' });
|
|
||||||
// this.externalSourcesConfiguration.externalDatasets.push({ key: '', label: 'All' });
|
|
||||||
// this.externalSourcesConfiguration.registries.push({ key: '', label: 'All' });
|
|
||||||
// this.externalSourcesConfiguration.services.push({ key: '', label: 'All' });
|
|
||||||
// if (!isNullOrUndefined(this.externalSourcesConfiguration.tags)) {
|
|
||||||
// this.externalSourcesConfiguration.tags.push({ key: '', label: 'All' });
|
|
||||||
// } else {
|
|
||||||
// this.externalSourcesConfiguration.tags = [{ key: '', label: 'All' }];
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// this.formGroup.valueChanges
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(val => {
|
|
||||||
// this.formChanged.emit(val);
|
|
||||||
// });
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// public cancel(): void {
|
addReference() {
|
||||||
// this.router.navigate(['/datasets']);
|
// const dialogRef = this.dialog.open(DatasetExternalDataRepositoryDialogEditorComponent, {
|
||||||
// }
|
// width: '500px',
|
||||||
|
// restoreFocus: false,
|
||||||
// externalDatasetsOnItemChange(event) {
|
// data: {}
|
||||||
// const externalDatasetModel = new ExternalDatasetEditorModel(event.id, event.abbreviation, event.name, event.pid ? event.pid : event.reference, event.source);
|
// });
|
||||||
// (<UntypedFormArray>this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm());
|
// dialogRef.afterClosed()
|
||||||
// }
|
// .pipe(takeUntil(this._destroyed))
|
||||||
|
// .subscribe(result => {
|
||||||
// registriesOnItemChange(event) {
|
// if (!result) { return; }
|
||||||
// const registryModel = new ExternalRegistryEditorModel(event.abbreviation, event.definition, event.id, event.name, event.pid ? event.pid : event.reference, event.uri, event.source);
|
// const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.name, result.abbreviation, result.uri, result.pid, result.source);
|
||||||
// (<UntypedFormArray>this.formGroup.get('registries')).push(registryModel.buildForm());
|
// (<UntypedFormArray>this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm());
|
||||||
// }
|
// });
|
||||||
|
}
|
||||||
// servicesOnItemChange(event) {
|
|
||||||
// const serviceModel = new ExternalServiceEditorModel(event.abbreviation, event.definition, event.id, event.label, event.reference, event.uri);
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// tagsOnItemChange(event) {
|
|
||||||
// const tagModel = new ExternalTagEditorModel(event.id, event.name);
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('tags')).push(tagModel.buildForm());
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
// dataRepositoriesOnItemChange(event) {
|
|
||||||
// const dataRepositoryModel = new ExternalDataRepositoryEditorModel(event.id, event.name, event.abbreviation, event.uri, event.pid, event.source);
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm());
|
|
||||||
// }
|
|
||||||
|
|
||||||
// addDataRepository() {
|
|
||||||
// const dialogRef = this.dialog.open(DatasetExternalDataRepositoryDialogEditorComponent, {
|
|
||||||
// width: '500px',
|
|
||||||
// restoreFocus: false,
|
|
||||||
// data: {}
|
|
||||||
// });
|
|
||||||
// dialogRef.afterClosed()
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(result => {
|
|
||||||
// if (!result) { return; }
|
|
||||||
// const dataRepositoryModel = new ExternalDataRepositoryEditorModel(result.id, result.name, result.abbreviation, result.uri, result.pid, result.source);
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('dataRepositories')).push(dataRepositoryModel.buildForm());
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// addRegistry() {
|
|
||||||
// const dialogRef = this.dialog.open(DatasetExternalRegistryDialogEditorComponent, {
|
|
||||||
// width: '500px',
|
|
||||||
// restoreFocus: false,
|
|
||||||
// data: {}
|
|
||||||
// });
|
|
||||||
// dialogRef.afterClosed()
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(result => {
|
|
||||||
// if (!result) { return; }
|
|
||||||
// const registryModel = new ExternalRegistryEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source);
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('registries')).push(registryModel.buildForm());
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// addExternalDataset() {
|
|
||||||
// const dialogRef = this.dialog.open(DatasetExternalDatasetDialogEditorComponent, {
|
|
||||||
// width: '500px',
|
|
||||||
// restoreFocus: false,
|
|
||||||
// data: {}
|
|
||||||
// });
|
|
||||||
// dialogRef.afterClosed()
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(result => {
|
|
||||||
// if (!result) { return; }
|
|
||||||
// const externalDatasetModel = new ExternalDatasetEditorModel(result.id, result.abbreviation, result.name, result.reference, result.source);
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('externalDatasets')).push(externalDatasetModel.buildForm());
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// addService() {
|
|
||||||
// const dialogRef = this.dialog.open(DatasetExternalServiceDialogEditorComponent, {
|
|
||||||
// width: '500px',
|
|
||||||
// restoreFocus: false,
|
|
||||||
// data: {}
|
|
||||||
// });
|
|
||||||
// dialogRef.afterClosed()
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(result => {
|
|
||||||
// if (!result) { return; }
|
|
||||||
// const serviceModel = new ExternalServiceEditorModel(result.abbreviation, result.definition, result.id, result.label, result.reference, result.uri, result.source);
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('services')).push(serviceModel.buildForm());
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// searchDatasetExternalDatasets(query: string, type: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
// const requestItem: RequestItem<ExternalDatasetCriteria> = new RequestItem();
|
|
||||||
// requestItem.criteria = new ExternalDatasetCriteria();
|
|
||||||
// requestItem.criteria.like = query;
|
|
||||||
// requestItem.criteria.type = type;
|
|
||||||
// return this.externalSourcesService.searchDatasetSExternalDatasetservice(requestItem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// searchDatasetExternalDataRepositories(query: string, type: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
// const requestItem: RequestItem<DataRepositoryCriteria> = new RequestItem();
|
|
||||||
// requestItem.criteria = new DataRepositoryCriteria();
|
|
||||||
// requestItem.criteria.like = query;
|
|
||||||
// requestItem.criteria.type = type;
|
|
||||||
// return this.externalSourcesService.searchDatasetRepository(requestItem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// searchDatasetExternalRegistries(query: string, type: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
// const requestItem: RequestItem<RegistryCriteria> = new RequestItem();
|
|
||||||
// requestItem.criteria = new RegistryCriteria();
|
|
||||||
// requestItem.criteria.like = query;
|
|
||||||
// requestItem.criteria.type = type;
|
|
||||||
// return this.externalSourcesService.searchDatasetRegistry(requestItem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// searchDatasetExternalServices(query: string, type: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
// const requestItem: RequestItem<ServiceCriteria> = new RequestItem();
|
|
||||||
// requestItem.criteria = new ServiceCriteria();
|
|
||||||
// requestItem.criteria.like = query;
|
|
||||||
// requestItem.criteria.type = type;
|
|
||||||
// return this.externalSourcesService.searchDatasetService(requestItem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// searchDatasetTags(query: string, type: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
// const requestItem: RequestItem<TagCriteria> = new RequestItem();
|
|
||||||
// requestItem.criteria = new TagCriteria();
|
|
||||||
// requestItem.criteria.like = query;
|
|
||||||
// requestItem.criteria.type = type;
|
|
||||||
// return this.externalSourcesService.searchDatasetTags(requestItem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// removeTag(tag: any) {
|
|
||||||
// (<UntypedFormArray>this.formGroup.get('tags')).removeAt(((<UntypedFormArray>this.formGroup.get('tags')).value as any[]).indexOf(tag));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// addTag(ev: any) {
|
|
||||||
// let item: ExternalTagEditorModel;
|
|
||||||
// //this.filteredTags = this.formGroup.get('tags').value;
|
|
||||||
// if (typeof ev === 'string') {
|
|
||||||
// item = new ExternalTagEditorModel('', ev);
|
|
||||||
// } else {
|
|
||||||
// item = ev;
|
|
||||||
// }
|
|
||||||
// if (item.name !== '' ) {
|
|
||||||
// return item;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// isInternal(element: any): boolean {
|
|
||||||
// if (element.get('source') == null) {
|
|
||||||
// // console.log(element);
|
|
||||||
// }
|
|
||||||
// return element.get('source').value === 'Internal';
|
|
||||||
// }
|
|
||||||
|
|
||||||
// updateDataRepository(dataRepository: UntypedFormGroup) {
|
|
||||||
// this.externalDataRepositoryService.create(dataRepository.value)
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(
|
|
||||||
// (result) => {
|
|
||||||
// dataRepository.setValue(result);
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// updateExternalDataset(externalDataset: UntypedFormGroup) {
|
|
||||||
// this.externalDatasetService.create(externalDataset.value)
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(
|
|
||||||
// (result) => {
|
|
||||||
// externalDataset.setValue(result);
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// updateRegistry(registry: UntypedFormGroup) {
|
|
||||||
// this.externalRegistryService.create(registry.value)
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(
|
|
||||||
// (result) => {
|
|
||||||
// registry.setValue(result);
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// updateService(service: UntypedFormGroup) {
|
|
||||||
// this.externalServiceService.create(service.value)
|
|
||||||
// .pipe(takeUntil(this._destroyed))
|
|
||||||
// .subscribe(
|
|
||||||
// (result) => {
|
|
||||||
// service.setValue(result);
|
|
||||||
// }
|
|
||||||
// );
|
|
||||||
// }
|
|
||||||
|
|
||||||
// filterTags(value: string): Observable<ExternalSourceItemModel[]> {
|
|
||||||
// this.filteringTagsAsync = true;
|
|
||||||
|
|
||||||
// const requestItem: RequestItem<TagCriteria> = new RequestItem();
|
|
||||||
// const criteria: TagCriteria = new TagCriteria();
|
|
||||||
// criteria.like = value;
|
|
||||||
// requestItem.criteria = criteria;
|
|
||||||
// return this.externalSourcesService.searchDatasetTags(requestItem);
|
|
||||||
// }
|
|
||||||
|
|
||||||
// showTag(ev: any) {
|
|
||||||
// if (typeof ev === 'string') {
|
|
||||||
// return ev;
|
|
||||||
// } else {
|
|
||||||
// return ev.name;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue