description template final preview changes (in progress)

This commit is contained in:
amentis 2024-03-29 16:22:31 +02:00
parent ba26a1bd67
commit 2339b51c24
7 changed files with 64 additions and 13 deletions

View File

@ -66,7 +66,7 @@ public enum FieldType implements DatabaseEnum<String> {
public static boolean isTextType(FieldType fieldType){ public static boolean isTextType(FieldType fieldType){
return fieldType.equals(FieldType.FREE_TEXT) || fieldType.equals(FieldType.CHECK_BOX) || fieldType.equals(FieldType.TEXT_AREA) || return fieldType.equals(FieldType.FREE_TEXT) || fieldType.equals(FieldType.CHECK_BOX) || fieldType.equals(FieldType.TEXT_AREA) ||
fieldType.equals(FieldType.RICH_TEXT_AREA) || fieldType.equals(FieldType.UPLOAD) || fieldType.equals(FieldType.BOOLEAN_DECISION) || fieldType.equals(FieldType.RICH_TEXT_AREA) || fieldType.equals(FieldType.UPLOAD) || fieldType.equals(FieldType.BOOLEAN_DECISION) ||
fieldType.equals(FieldType.RADIO_BOX) || fieldType.equals(FieldType.CURRENCY) || fieldType.equals(FieldType.SELECT); fieldType.equals(FieldType.RADIO_BOX) || fieldType.equals(FieldType.CURRENCY);
} }
public static boolean isTextListType(FieldType fieldType){ public static boolean isTextListType(FieldType fieldType){

View File

@ -391,6 +391,19 @@
</property> </property>
</activation> </activation>
</profile> </profile>
<profile>
<id>cite-dev</id>
<repositories>
<repository>
<id>cite-maven</id>
<name>CITE Maven Repository</name>
<url>https://crepo.cite.gr/repository/cite-maven/</url>
</repository>
</repositories>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles> </profiles>
</project> </project>

View File

@ -31,6 +31,7 @@ import { DescriptionTemplateListingFiltersComponent } from "./listing/filters/de
import { ImportDescriptionTemplateDialogComponent } from './listing/import-description-template/import-description-template.dialog.component'; import { ImportDescriptionTemplateDialogComponent } from './listing/import-description-template/import-description-template.dialog.component';
import { DescriptionTemplateEditorReferenceTypeFieldComponent } from './editor/components/field-type/reference-type/description-template-editor-reference-type-field.component'; import { DescriptionTemplateEditorReferenceTypeFieldComponent } from './editor/components/field-type/reference-type/description-template-editor-reference-type-field.component';
import { DescriptionFormModule } from '@app/ui/description/editor/description-form/description-form.module'; import { DescriptionFormModule } from '@app/ui/description/editor/description-form/description-form.module';
import { FinalPreviewComponent } from './editor/components/final-preview/final-preview.component';
@NgModule({ @NgModule({
imports: [ imports: [
@ -70,7 +71,9 @@ import { DescriptionFormModule } from '@app/ui/description/editor/description-fo
DescriptionTemplateEditorLabelAndMultiplicityFieldComponent, DescriptionTemplateEditorLabelAndMultiplicityFieldComponent,
DescriptionTemplateEditorRadioBoxFieldComponent, DescriptionTemplateEditorRadioBoxFieldComponent,
DescriptionTemplateEditorExternalDatasetsFieldComponent, DescriptionTemplateEditorExternalDatasetsFieldComponent,
DescriptionTemplateEditorUploadFieldComponent DescriptionTemplateEditorUploadFieldComponent,
FinalPreviewComponent
] ]
}) })
export class DescriptionTemplateModule { } export class DescriptionTemplateModule { }

View File

@ -93,7 +93,6 @@ export class DescriptionTemplateEditorFieldComponent extends BaseComponent imple
switch (this.fieldType) { switch (this.fieldType) {
case DescriptionTemplateFieldType.TEXT_AREA: case DescriptionTemplateFieldType.TEXT_AREA:
case DescriptionTemplateFieldType.RICH_TEXT_AREA: case DescriptionTemplateFieldType.RICH_TEXT_AREA:
case DescriptionTemplateFieldType.UPLOAD:
case DescriptionTemplateFieldType.FREE_TEXT: case DescriptionTemplateFieldType.FREE_TEXT:
case DescriptionTemplateFieldType.BOOLEAN_DECISION: case DescriptionTemplateFieldType.BOOLEAN_DECISION:
case DescriptionTemplateFieldType.RADIO_BOX: case DescriptionTemplateFieldType.RADIO_BOX:

View File

@ -1,3 +1 @@
<app-dataset-description [form]="formGroup" [visibilityRules]="visibilityRules" *ngIf="formGroup"> <app-description-form *ngIf="formGroup" [propertiesFormGroup]="previewPropertiesFormGroup" [descriptionTemplate]="descriptionTemplate" [visibilityRulesService]="visibilityRulesService"></app-description-form>
</app-dataset-description>

View File

@ -1,5 +1,9 @@
import { Component, Input, OnInit } from '@angular/core'; import { Component, Input, OnInit, SimpleChanges } from '@angular/core';
import { Rule } from '@app/ui/description/editor/description-form/visibility-rules/models/rule'; import { UntypedFormGroup } from '@angular/forms';
import { DescriptionTemplate } from '@app/core/model/description-template/description-template';
import { DescriptionTemplatePersist } from '@app/core/model/description-template/description-template-persist';
import { Description } from '@app/core/model/description/description';
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';
@ -13,19 +17,53 @@ import { VisibilityRulesService } from '@app/ui/description/editor/description-f
export class FinalPreviewComponent implements OnInit { export class FinalPreviewComponent implements OnInit {
@Input() descriptionTempaltePersist = null; @Input() descriptionTemplatePersist: DescriptionTemplatePersist;
descriptionTemplate: DescriptionTemplate;
visibilityRules: Rule[] = []; previewPropertiesFormGroup
@Input() formGroup = null; @Input() formGroup = null;
constructor(private visibilityRulesService: VisibilityRulesService) { constructor(private visibilityRulesService: VisibilityRulesService) {
} }
private generatePreviewForm() {
this.descriptionTemplate = this.buildDescriptionTemplate(this.descriptionTemplatePersist);
const mockDescription: Description = {
descriptionTemplate: this.descriptionTemplate
}
const descriptionEditorModel = new DescriptionEditorModel().fromModel(mockDescription, mockDescription.descriptionTemplate);
this.previewPropertiesFormGroup = descriptionEditorModel.properties.buildForm() as UntypedFormGroup;
this.visibilityRulesService.setContext(this.descriptionTemplate.definition, this.previewPropertiesFormGroup);
}
private buildDescriptionTemplate(persist: DescriptionTemplatePersist) : DescriptionTemplate{
if (persist == null) return null;
return {
id: persist.id,
label: persist.label,
description: persist.description,
groupId: undefined,
version: undefined,
language: persist.language,
type: undefined,
status: persist.status,
definition: persist.definition,
users: persist.users
}
}
ngOnInit(): void { ngOnInit(): void {
this.visibilityRulesService.buildVisibilityRules(this.visibilityRules, this.formGroup); this.generatePreviewForm();
} }
// ngOnChanges(changes: SimpleChanges) {
// if(changes['descriptionTemplatePersist']) this.generatePreviewForm();
// }
} }

View File

@ -223,7 +223,7 @@
<div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)"> <div class="col-12" *ngIf="(selectedTocEntry.type === tocEntryEnumValues.Section) || (selectedTocEntry.type === tocEntryEnumValues.FieldSet)">
<app-description-template-editor-section-fieldset-component <app-description-template-editor-section-fieldset-component
[tocentry]="selectedTocEntry" [tocentry]="selectedTocEntry"
[viewOnly]="viewOnly" [viewOnly]="formGroup.disabled"
[datasetProfileId]="datasetProfileId" [datasetProfileId]="datasetProfileId"
[validationErrorModel]="editorModel.validationErrorModel" [validationErrorModel]="editorModel.validationErrorModel"
[validationRootPath]="selectedTocEntry.validationRootPath" [validationRootPath]="selectedTocEntry.validationRootPath"
@ -268,7 +268,7 @@
<div class="col-9"> <div class="col-9">
<div class="col"> <div class="col">
<div class="col-12"> <div class="col-12">
<app-final-preview-component [formGroup]="formGroup" [visibilityRules]="visibilityRules"> <app-final-preview-component [formGroup]="formGroup" [visibilityRules]="visibilityRules" [descriptionTemplatePersist]="formGroup.getRawValue()">
</app-final-preview-component> </app-final-preview-component>
</div> </div>