Compare commits
2 Commits
977a05ce6f
...
cb0d95fc3c
Author | SHA1 | Date |
---|---|---|
Sofia Papacharalampous | cb0d95fc3c | |
Sofia Papacharalampous | cd3b608a97 |
|
@ -17,12 +17,13 @@ import { TranslateService } from '@ngx-translate/core';
|
||||||
import { Subject } from 'rxjs';
|
import { Subject } from 'rxjs';
|
||||||
import { debounceTime, delay, map, takeUntil, tap } from 'rxjs/operators';
|
import { debounceTime, delay, map, takeUntil, tap } from 'rxjs/operators';
|
||||||
import { GENERAL_ANIMATIONS } from '../../animations/animations';
|
import { GENERAL_ANIMATIONS } from '../../animations/animations';
|
||||||
import { EditorCustomValidators } from '../../custom-validators/editor-custom-validators';
|
|
||||||
import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel, DescriptionTemplateSectionEditorModel } from '../../description-template-editor.model';
|
import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel, DescriptionTemplateSectionEditorModel } from '../../description-template-editor.model';
|
||||||
import { DescriptionTemplateFieldSetPersist, DescriptionTemplateReferenceTypeFieldPersist } from '@app/core/model/description-template/description-template-persist';
|
import { DescriptionTemplateFieldSetPersist, DescriptionTemplateReferenceTypeFieldPersist } from '@app/core/model/description-template/description-template-persist';
|
||||||
import { DescriptionEditorModel } from '@app/ui/description/editor/description-editor.model';
|
import { DescriptionEditorModel } from '@app/ui/description/editor/description-editor.model';
|
||||||
import { Description } from '@app/core/model/description/description';
|
import { Description } from '@app/core/model/description/description';
|
||||||
import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service';
|
import { VisibilityRulesService } from '@app/ui/description/editor/description-form/visibility-rules/visibility-rules.service';
|
||||||
|
import { ReferenceTypeService } from '@app/core/services/reference-type/reference-type.service';
|
||||||
|
import { ReferenceType } from '@app/core/model/reference-type/reference-type';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-description-template-editor-composite-field-component',
|
selector: 'app-description-template-editor-composite-field-component',
|
||||||
|
@ -56,9 +57,7 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
|
||||||
previewFieldSet: DescriptionTemplateFieldSet = null;
|
previewFieldSet: DescriptionTemplateFieldSet = null;
|
||||||
previewPropertiesFormGroup: UntypedFormGroup = null;
|
previewPropertiesFormGroup: UntypedFormGroup = null;
|
||||||
descriptionTemplateFieldTypeEnum = DescriptionTemplateFieldType;
|
descriptionTemplateFieldTypeEnum = DescriptionTemplateFieldType;
|
||||||
|
private availableReferenceTypes: ReferenceType[] = [];
|
||||||
private myCustomValidators: EditorCustomValidators = new EditorCustomValidators();
|
|
||||||
|
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private dialog: MatDialog,
|
private dialog: MatDialog,
|
||||||
|
@ -66,7 +65,8 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
|
||||||
public enumUtils: EnumUtils,
|
public enumUtils: EnumUtils,
|
||||||
public datasetProfileService: DescriptionTemplateService,
|
public datasetProfileService: DescriptionTemplateService,
|
||||||
private configurationService: ConfigurationService,
|
private configurationService: ConfigurationService,
|
||||||
public visibilityRulesService: VisibilityRulesService
|
public visibilityRulesService: VisibilityRulesService,
|
||||||
|
private referenceTypeService: ReferenceTypeService,
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
}
|
}
|
||||||
|
@ -79,9 +79,6 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
if (this.viewOnly) {
|
if (this.viewOnly) {
|
||||||
this.form.get('hasCommentField').disable();
|
this.form.get('hasCommentField').disable();
|
||||||
|
@ -90,6 +87,9 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
|
||||||
this.showExtendedDescription = !!this.form.get('extendedDescription').value;
|
this.showExtendedDescription = !!this.form.get('extendedDescription').value;
|
||||||
this.showAdditionalInfo = !!this.form.get('additionalInformation').value;
|
this.showAdditionalInfo = !!this.form.get('additionalInformation').value;
|
||||||
|
|
||||||
|
// TODO: check network
|
||||||
|
this.referenceTypeService.query(ReferenceTypeService.DefaultReferenceTypeLookup()).subscribe(referenceTypes => this.availableReferenceTypes = referenceTypes.items as ReferenceType[]);
|
||||||
|
|
||||||
this.form.valueChanges.pipe(takeUntil(this._destroyed)).subscribe(changes => {
|
this.form.valueChanges.pipe(takeUntil(this._destroyed)).subscribe(changes => {
|
||||||
this.previewDirty = true;
|
this.previewDirty = true;
|
||||||
this.generatePreviewForm();
|
this.generatePreviewForm();
|
||||||
|
@ -156,8 +156,10 @@ export class DescriptionTemplateEditorCompositeFieldComponent extends BaseCompon
|
||||||
|
|
||||||
if (editorField.data.fieldType === DescriptionTemplateFieldType.REFERENCE_TYPES) {
|
if (editorField.data.fieldType === DescriptionTemplateFieldType.REFERENCE_TYPES) {
|
||||||
convertedField.data = editorField.data;
|
convertedField.data = editorField.data;
|
||||||
|
let selectedReferenceType: ReferenceType = this.availableReferenceTypes.find(referenceType => referenceType.id == (editorField.data as DescriptionTemplateReferenceTypeFieldPersist).referenceTypeId);
|
||||||
(convertedField.data as DescriptionTemplateReferenceTypeData).referenceType = {
|
(convertedField.data as DescriptionTemplateReferenceTypeData).referenceType = {
|
||||||
id: (editorField.data as DescriptionTemplateReferenceTypeFieldPersist).referenceTypeId
|
id: (editorField.data as DescriptionTemplateReferenceTypeFieldPersist).referenceTypeId,
|
||||||
|
name: selectedReferenceType?.name
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
convertedField.data = editorField.data;
|
convertedField.data = editorField.data;
|
||||||
|
|
|
@ -2,30 +2,17 @@
|
||||||
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
|
||||||
import { FormGroupDirective, NgForm, UntypedFormArray, UntypedFormControl, UntypedFormGroup, } from '@angular/forms';
|
import { FormGroupDirective, NgForm, UntypedFormArray, UntypedFormControl, UntypedFormGroup, } from '@angular/forms';
|
||||||
import { ErrorStateMatcher } from '@angular/material/core';
|
import { ErrorStateMatcher } from '@angular/material/core';
|
||||||
import { MatDialog } from '@angular/material/dialog';
|
|
||||||
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
|
import { MatSlideToggleChange } from '@angular/material/slide-toggle';
|
||||||
import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type';
|
import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type';
|
||||||
import { ValidationType } from '@app/core/common/enum/validation-type';
|
import { ValidationType } from '@app/core/common/enum/validation-type';
|
||||||
import {
|
import { DescriptionTemplateLabelAndMultiplicityData, DescriptionTemplateLabelData, DescriptionTemplateRadioBoxData, DescriptionTemplateSelectData, DescriptionTemplateSelectOption,DescriptionTemplateUploadData } from '@app/core/model/description-template/description-template';
|
||||||
DescriptionTemplateExternalDatasetData,
|
|
||||||
DescriptionTemplateLabelAndMultiplicityData,
|
|
||||||
DescriptionTemplateLabelData,
|
|
||||||
DescriptionTemplateRadioBoxData,
|
|
||||||
DescriptionTemplateReferenceTypeData,
|
|
||||||
DescriptionTemplateSelectData,
|
|
||||||
DescriptionTemplateSelectOption,
|
|
||||||
DescriptionTemplateUploadData
|
|
||||||
} from '@app/core/model/description-template/description-template';
|
|
||||||
import { DescriptionTemplateFieldPersist } from '@app/core/model/description-template/description-template-persist';
|
import { DescriptionTemplateFieldPersist } from '@app/core/model/description-template/description-template-persist';
|
||||||
import { ConfigurationService } from "@app/core/services/configuration/configuration.service";
|
import { ConfigurationService } from "@app/core/services/configuration/configuration.service";
|
||||||
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
|
import { DescriptionTemplateService } from '@app/core/services/description-template/description-template.service';
|
||||||
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
import { EnumUtils } from '@app/core/services/utilities/enum-utils.service';
|
||||||
import { BaseComponent } from '@common/base/base.component';
|
import { BaseComponent } from '@common/base/base.component';
|
||||||
import { Observable, of } from 'rxjs';
|
|
||||||
import { map } from 'rxjs/operators';
|
|
||||||
import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel } from '../../description-template-editor.model';
|
import { DescriptionTemplateFieldEditorModel, DescriptionTemplateRuleEditorModel } from '../../description-template-editor.model';
|
||||||
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
import { ValidationErrorModel } from '@common/forms/validation/error-model/validation-error-model';
|
||||||
import { FilterService } from '@common/modules/text-filter/filter-service';
|
|
||||||
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
|
import { SemanticsService } from '@app/core/services/semantic/semantics.service';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -37,7 +24,6 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
|
||||||
@Input() viewOnly: boolean;
|
@Input() viewOnly: boolean;
|
||||||
@Input() form: UntypedFormGroup;
|
@Input() form: UntypedFormGroup;
|
||||||
validationTypeEnum = ValidationType;
|
validationTypeEnum = ValidationType;
|
||||||
// isFieldMultiplicityEnabled = false;
|
|
||||||
|
|
||||||
fieldType: DescriptionTemplateFieldType;
|
fieldType: DescriptionTemplateFieldType;
|
||||||
descriptionTemplateFieldTypeEnum = DescriptionTemplateFieldType;
|
descriptionTemplateFieldTypeEnum = DescriptionTemplateFieldType;
|
||||||
|
@ -54,13 +40,10 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
|
||||||
constructor(
|
constructor(
|
||||||
public enumUtils: EnumUtils,
|
public enumUtils: EnumUtils,
|
||||||
public descriptionTemplateService: DescriptionTemplateService,
|
public descriptionTemplateService: DescriptionTemplateService,
|
||||||
private dialog: MatDialog,
|
|
||||||
private configurationService: ConfigurationService,
|
private configurationService: ConfigurationService,
|
||||||
private filterService: FilterService,
|
|
||||||
public semanticsService: SemanticsService
|
public semanticsService: SemanticsService
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue