Fixes bug on DMP Template (profile) not showing saved values. (Issue #134)
This commit is contained in:
parent
ee367b3032
commit
273b05da00
|
@ -1,5 +1,4 @@
|
||||||
export interface DmpProfileExternalAutoCompleteField {
|
export interface DmpProfileExternalAutoCompleteField {
|
||||||
placeholder: string;
|
|
||||||
url: string;
|
url: string;
|
||||||
optionsRoot: string;
|
optionsRoot: string;
|
||||||
multiAutoComplete: boolean;
|
multiAutoComplete: boolean;
|
||||||
|
|
|
@ -250,13 +250,13 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
this.dmpService.createDmp(this.formGroup.getRawValue())
|
this.dmpService.createDmp(this.formGroup.getRawValue())
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => {
|
complete => {
|
||||||
if (showAddDatasetDialog) {
|
if (showAddDatasetDialog) {
|
||||||
this.addDatasetOpenDialog(complete);
|
this.addDatasetOpenDialog(complete);
|
||||||
}
|
}
|
||||||
else { this.onCallbackSuccess() }
|
else { this.onCallbackSuccess() }
|
||||||
},
|
},
|
||||||
error => this.onCallbackError(error)
|
error => this.onCallbackError(error)
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -304,8 +304,8 @@ export class DmpEditorComponent extends BaseComponent implements OnInit, IBreadC
|
||||||
this.dmpService.delete(this.dmp.id)
|
this.dmpService.delete(this.dmp.id)
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(
|
.subscribe(
|
||||||
complete => { this.onCallbackSuccess() },
|
complete => { this.onCallbackSuccess() },
|
||||||
error => this.onDeleteCallbackError(error)
|
error => this.onDeleteCallbackError(error)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -15,6 +15,10 @@ import { ValidJsonValidator } from "../../../library/auto-complete/auto-complete
|
||||||
import { UserInfoListingModel } from "../../../core/model/user/user-info-listing";
|
import { UserInfoListingModel } from "../../../core/model/user/user-info-listing";
|
||||||
import { DatasetModel } from "../../../core/model/dataset/dataset";
|
import { DatasetModel } from "../../../core/model/dataset/dataset";
|
||||||
import { ProjectTabModel } from "./project-tab/project-tab-model";
|
import { ProjectTabModel } from "./project-tab/project-tab-model";
|
||||||
|
import { DmpProfileExternalAutoCompleteFieldDataEditorModel } from "../../admin/dmp-profile/editor/external-autocomplete/dmp-profile-external-autocomplete-field-editor.model";
|
||||||
|
import { DmpProfileType } from "../../../core/common/enum/dmp-profile-type";
|
||||||
|
import { DmpProfileFieldDataType } from "../../../core/common/enum/dmp-profile-field-type";
|
||||||
|
import { DmpProfileField } from "../../../core/model/dmp-profile/dmp-profile-field";
|
||||||
|
|
||||||
export class DmpEditorModel {
|
export class DmpEditorModel {
|
||||||
public id: string;
|
public id: string;
|
||||||
|
@ -86,6 +90,15 @@ export class DmpEditorModel {
|
||||||
if (this.dynamicFields) { this.dynamicFields.forEach(item => dynamicFields.push(item.buildForm())); }
|
if (this.dynamicFields) { this.dynamicFields.forEach(item => dynamicFields.push(item.buildForm())); }
|
||||||
formGroup.addControl('dynamicFields', new FormBuilder().array(dynamicFields));
|
formGroup.addControl('dynamicFields', new FormBuilder().array(dynamicFields));
|
||||||
|
|
||||||
|
if (this.definition) {
|
||||||
|
const fields = new Array<FormGroup>();
|
||||||
|
this.definition.fields.forEach(item => fields.push(new DmpDefinitionFieldEditorModel().fromModel(item).buildForm()));
|
||||||
|
const definition = new FormBuilder().group({
|
||||||
|
fields: new FormBuilder().array(fields)
|
||||||
|
});
|
||||||
|
formGroup.addControl('definition', definition);
|
||||||
|
}
|
||||||
|
|
||||||
return formGroup;
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -162,3 +175,39 @@ export class DmpDynamicFieldDependencyEditorModel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class DmpDefinitionFieldEditorModel implements DmpProfileField {
|
||||||
|
public id: string;
|
||||||
|
public type: DmpProfileType;
|
||||||
|
public dataType: DmpProfileFieldDataType;
|
||||||
|
public required = false;
|
||||||
|
public label: string;
|
||||||
|
public value: any;
|
||||||
|
public externalAutocomplete?: DmpProfileExternalAutoCompleteFieldDataEditorModel;
|
||||||
|
|
||||||
|
fromModel(item: DmpProfileField): DmpDefinitionFieldEditorModel {
|
||||||
|
this.type = item.type;
|
||||||
|
this.dataType = item.dataType;
|
||||||
|
this.required = item.required;
|
||||||
|
this.label = item.label;
|
||||||
|
this.id = item.id;
|
||||||
|
this.value = item.value;
|
||||||
|
if (item.externalAutocomplete)
|
||||||
|
this.externalAutocomplete = new DmpProfileExternalAutoCompleteFieldDataEditorModel().fromModel(item.externalAutocomplete);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
buildForm(): FormGroup {
|
||||||
|
const formGroup = new FormBuilder().group({
|
||||||
|
type: [this.type],
|
||||||
|
id: [this.id],
|
||||||
|
dataType: [this.dataType],
|
||||||
|
required: [this.required],
|
||||||
|
label: [this.label],
|
||||||
|
value: [this.value]
|
||||||
|
});
|
||||||
|
if (this.externalAutocomplete) {
|
||||||
|
formGroup.addControl('externalAutocomplete', this.externalAutocomplete.buildForm());
|
||||||
|
}
|
||||||
|
return formGroup;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@
|
||||||
</div>
|
</div>
|
||||||
<app-dynamic-dmp-field-resolver *ngIf="selectedDmpProfileDefinition" [formGroup]="formGroup"
|
<app-dynamic-dmp-field-resolver *ngIf="selectedDmpProfileDefinition" [formGroup]="formGroup"
|
||||||
[dmpProfileDefinition]="selectedDmpProfileDefinition"
|
[dmpProfileDefinition]="selectedDmpProfileDefinition"
|
||||||
[dmpProfileId]="selectedDmpProfileId">
|
[dmpProfileId]="formGroup.get('profile').value.id">
|
||||||
</app-dynamic-dmp-field-resolver>
|
</app-dynamic-dmp-field-resolver>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,6 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
||||||
dmpProfileAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
dmpProfileAutoCompleteConfiguration: SingleAutoCompleteConfiguration;
|
||||||
|
|
||||||
selectedDmpProfileDefinition: DmpProfileDefinition;
|
selectedDmpProfileDefinition: DmpProfileDefinition;
|
||||||
selectedDmpProfileId: string;
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dmpProfileService: DmpProfileService,
|
private dmpProfileService: DmpProfileService,
|
||||||
|
@ -57,17 +56,7 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
|
|
||||||
if (this.formGroup.get('profile'))
|
if (this.formGroup.get('definition')) { this.selectedDmpProfileDefinition = this.formGroup.get('definition').value; }
|
||||||
this.dmpProfileService.getSingle(this.formGroup.get('profile').value.id)
|
|
||||||
.pipe(takeUntil(this._destroyed))
|
|
||||||
.subscribe(result => {
|
|
||||||
this.selectedDmpProfileDefinition = result.definition;
|
|
||||||
this.selectedDmpProfileId = result.id;
|
|
||||||
if (this.formGroup.get('properties')) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
this.registerFormEventsForDmpProfile();
|
this.registerFormEventsForDmpProfile();
|
||||||
|
|
||||||
this.dmpProfileAutoCompleteConfiguration = {
|
this.dmpProfileAutoCompleteConfiguration = {
|
||||||
|
@ -102,7 +91,6 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
||||||
registerFormEventsForDmpProfile(definitionProperties?: DmpProfileDefinition): void {
|
registerFormEventsForDmpProfile(definitionProperties?: DmpProfileDefinition): void {
|
||||||
this.formGroup.get('profile').valueChanges
|
this.formGroup.get('profile').valueChanges
|
||||||
.pipe(
|
.pipe(
|
||||||
startWith(null),
|
|
||||||
takeUntil(this._destroyed))
|
takeUntil(this._destroyed))
|
||||||
.subscribe(Option => {
|
.subscribe(Option => {
|
||||||
if (Option instanceof Object) {
|
if (Option instanceof Object) {
|
||||||
|
@ -111,11 +99,9 @@ export class GeneralTabComponent extends BaseComponent implements OnInit {
|
||||||
.pipe(takeUntil(this._destroyed))
|
.pipe(takeUntil(this._destroyed))
|
||||||
.subscribe(result => {
|
.subscribe(result => {
|
||||||
this.selectedDmpProfileDefinition = result.definition;
|
this.selectedDmpProfileDefinition = result.definition;
|
||||||
this.selectedDmpProfileId = result.id;
|
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.selectedDmpProfileDefinition = null;
|
this.selectedDmpProfileDefinition = null;
|
||||||
this.selectedDmpProfileId = null;
|
|
||||||
}
|
}
|
||||||
this.selectedDmpProfileDefinition = definitionProperties;
|
this.selectedDmpProfileDefinition = definitionProperties;
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue