final description template preview changes
This commit is contained in:
parent
2e9d1366e9
commit
b642ec52bc
|
@ -1,7 +1,8 @@
|
||||||
import { Component, Input, OnInit, SimpleChanges } from '@angular/core';
|
import { Component, Input, OnInit, SimpleChanges } from '@angular/core';
|
||||||
import { UntypedFormGroup } from '@angular/forms';
|
import { UntypedFormGroup } from '@angular/forms';
|
||||||
import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
|
import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type';
|
||||||
import { DescriptionTemplatePersist } from '@app/core/model/description-template/description-template-persist';
|
import { DescriptionTemplate, DescriptionTemplateBaseFieldData, DescriptionTemplateDefinition, DescriptionTemplateField, DescriptionTemplateFieldSet, DescriptionTemplateMultiplicity, DescriptionTemplatePage, DescriptionTemplateReferenceTypeData, DescriptionTemplateRule, DescriptionTemplateSection } from '@app/core/model/description-template/description-template';
|
||||||
|
import { DescriptionTemplateBaseFieldDataPersist, DescriptionTemplateDefinitionPersist, DescriptionTemplateFieldPersist, DescriptionTemplateFieldSetPersist, DescriptionTemplateMultiplicityPersist, DescriptionTemplatePagePersist, DescriptionTemplatePersist, DescriptionTemplateReferenceTypeFieldPersist, DescriptionTemplateRulePersist, DescriptionTemplateSectionPersist } from '@app/core/model/description-template/description-template-persist';
|
||||||
import { Description } from '@app/core/model/description/description';
|
import { Description } from '@app/core/model/description/description';
|
||||||
import { DescriptionEditorModel } from '@app/ui/description/editor/description-editor.model';
|
import { DescriptionEditorModel } from '@app/ui/description/editor/description-editor.model';
|
||||||
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';
|
||||||
|
@ -23,7 +24,7 @@ export class FinalPreviewComponent implements OnInit {
|
||||||
previewPropertiesFormGroup
|
previewPropertiesFormGroup
|
||||||
@Input() formGroup = null;
|
@Input() formGroup = null;
|
||||||
|
|
||||||
constructor(private visibilityRulesService: VisibilityRulesService) {
|
constructor(public visibilityRulesService: VisibilityRulesService) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,11 +53,84 @@ export class FinalPreviewComponent implements OnInit {
|
||||||
language: persist.language,
|
language: persist.language,
|
||||||
type: undefined,
|
type: undefined,
|
||||||
status: persist.status,
|
status: persist.status,
|
||||||
definition: persist.definition,
|
definition: this.buildDescriptionTemplateDefinition(persist.definition),
|
||||||
users: persist.users
|
users: persist.users
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private buildDescriptionTemplateDefinition(persist: DescriptionTemplateDefinitionPersist) : DescriptionTemplateDefinition{
|
||||||
|
if (persist == null) return null;
|
||||||
|
return {
|
||||||
|
pages: persist.pages.map(x => this.buildDescriptionTemplatePage(x))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildDescriptionTemplatePage(persist: DescriptionTemplatePagePersist) : DescriptionTemplatePage{
|
||||||
|
if (persist == null) return null;
|
||||||
|
return {
|
||||||
|
id: persist.id,
|
||||||
|
ordinal: persist.ordinal,
|
||||||
|
title: persist.title,
|
||||||
|
sections: persist.sections.map(x => this.buildDescriptionTemplateSection(x)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildDescriptionTemplateSection(persist: DescriptionTemplateSectionPersist) : DescriptionTemplateSection{
|
||||||
|
if (persist == null) return null;
|
||||||
|
return {
|
||||||
|
id: persist.id,
|
||||||
|
ordinal: persist.ordinal,
|
||||||
|
defaultVisibility: persist.defaultVisibility,
|
||||||
|
multiplicity: persist.multiplicity,
|
||||||
|
title: persist.title,
|
||||||
|
description: persist.description,
|
||||||
|
sections: persist.sections.map(x => this.buildDescriptionTemplateSection(x)),
|
||||||
|
fieldSets: persist.fieldSets.map(x => this.buildDescriptionTemplateFieldSet(x)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildDescriptionTemplateFieldSet(persist: DescriptionTemplateFieldSetPersist) : DescriptionTemplateFieldSet{
|
||||||
|
if (persist == null) return null;
|
||||||
|
return {
|
||||||
|
id: persist.id,
|
||||||
|
ordinal: persist.ordinal,
|
||||||
|
numbering: '',
|
||||||
|
title: persist.title,
|
||||||
|
description: persist.description,
|
||||||
|
extendedDescription: persist.extendedDescription,
|
||||||
|
additionalInformation: persist.additionalInformation,
|
||||||
|
multiplicity: {
|
||||||
|
max: persist.multiplicity.max, min: persist.multiplicity.min,
|
||||||
|
placeholder: persist.multiplicity.placeholder, tableView: persist.multiplicity.tableView
|
||||||
|
},
|
||||||
|
hasCommentField: persist.hasCommentField,
|
||||||
|
fields: persist.fields.map(x => this.buildDescriptionTemplateField(x)),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private buildDescriptionTemplateField (persist: DescriptionTemplateFieldPersist) : DescriptionTemplateField{
|
||||||
|
if (persist == null) return null;
|
||||||
|
let convertedField: DescriptionTemplateField ={
|
||||||
|
id: persist.id,
|
||||||
|
ordinal: persist.ordinal,
|
||||||
|
schematics: persist.schematics,
|
||||||
|
defaultValue: persist.defaultValue,
|
||||||
|
visibilityRules: persist.visibilityRules,
|
||||||
|
validations: persist.validations,
|
||||||
|
includeInExport: persist.includeInExport,
|
||||||
|
data: persist.data,
|
||||||
|
}
|
||||||
|
|
||||||
|
if (persist.data.fieldType === DescriptionTemplateFieldType.REFERENCE_TYPES) {
|
||||||
|
convertedField.data = persist.data;
|
||||||
|
(convertedField.data as DescriptionTemplateReferenceTypeData).referenceType = {
|
||||||
|
id: (persist.data as DescriptionTemplateReferenceTypeFieldPersist).referenceTypeId
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
convertedField.data = persist.data;
|
||||||
|
}
|
||||||
|
return convertedField;
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.generatePreviewForm();
|
this.generatePreviewForm();
|
||||||
|
|
|
@ -13,10 +13,10 @@
|
||||||
</div>
|
</div>
|
||||||
<div *ngIf="!fieldSet?.multiplicity?.tableView" class="col-12">
|
<div *ngIf="!fieldSet?.multiplicity?.tableView" class="col-12">
|
||||||
<div class="row" *ngFor="let fieldSetItemPropertiesControl of propertiesFormGroup?.get('items')?.controls">
|
<div class="row" *ngFor="let fieldSetItemPropertiesControl of propertiesFormGroup?.get('items')?.controls">
|
||||||
<div class="col" *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[fieldSet.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value]">
|
<div class="col" *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[fieldSet.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value] ?? true">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div *ngFor="let field of fieldSet.fields; let i = index;" class="col-12 compositeField">
|
<div *ngFor="let field of fieldSet.fields; let i = index;" class="col-12 compositeField">
|
||||||
<ng-container *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[field.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value]">
|
<ng-container *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[field.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value] ?? true">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<h5 *ngIf="placeholderTitle" class="col-auto font-weight-bold">{{field.label}}</h5>
|
<h5 *ngIf="placeholderTitle" class="col-auto font-weight-bold">{{field.label}}</h5>
|
||||||
</div>
|
</div>
|
||||||
|
@ -48,9 +48,9 @@
|
||||||
<th class="actions"></th>
|
<th class="actions"></th>
|
||||||
</tr>
|
</tr>
|
||||||
<ng-container *ngFor="let fieldSetItemPropertiesControl of propertiesFormGroup?.get('items')?.controls; let j = index">
|
<ng-container *ngFor="let fieldSetItemPropertiesControl of propertiesFormGroup?.get('items')?.controls; let j = index">
|
||||||
<tr *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[fieldSet.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value]">
|
<tr *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[fieldSet.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value] ?? true">
|
||||||
<td *ngFor="let field of fieldSet.fields;" class="text-wrap">
|
<td *ngFor="let field of fieldSet.fields;" class="text-wrap">
|
||||||
<ng-container *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[field.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value]">
|
<ng-container *ngIf="visibilityRulesService && visibilityRulesService.isVisibleMap[field.id + '_' + fieldSetItemPropertiesControl.get('ordinal').value] ?? true">
|
||||||
{{fieldSetItemPropertiesControl.get('fields').get(field.id).get('value').getRawValue()}}
|
{{fieldSetItemPropertiesControl.get('fields').get(field.id).get('value').getRawValue()}}
|
||||||
</ng-container>
|
</ng-container>
|
||||||
</td>
|
</td>
|
||||||
|
|
Loading…
Reference in New Issue