fix on blueprint-editor required system fields

This commit is contained in:
CITE\spapacharalampous 2024-09-09 12:45:38 +03:00
parent 3fdb4f58da
commit ec1410c23e
19 changed files with 91 additions and 15 deletions

View File

@ -187,9 +187,18 @@
</mat-form-field> </mat-form-field>
</div> </div>
<div class="col-auto col-xl-2 section-field"> <div class="col-auto col-xl-2 section-field">
@if (isMandatorySystemField(field?.value)) {
<app-noop-checkbox
[control]="field.get('required')"
label="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}"
tooltipText="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-REQUIRED' | translate}}"
></app-noop-checkbox>
}
@else {
<mat-checkbox [formControl]="field.get('required')"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}</span></mat-checkbox> <mat-checkbox [formControl]="field.get('required')"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}</span></mat-checkbox>
<mat-error *ngIf="field.get('required').hasError('backendError')">{{field.get('required').getError('backendError').message}}</mat-error> }
<mat-error *ngIf="field.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error> <mat-error *ngIf="field.get('required').hasError('backendError')">{{field.get('required').getError('backendError').message}}</mat-error>
<mat-error *ngIf="field.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
</div> </div>
} }
<div class="col-auto col-xl-2"> <div class="col-auto col-xl-2">

View File

@ -409,6 +409,12 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
(this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields').markAsDirty(); (this.formGroup.get('definition').get('sections') as FormArray).at(sectionIndex).get('fields').markAsDirty();
} }
isMandatorySystemField(field: FieldInSectionEditorModel): boolean {
return field != null &&
field.category == this.planBlueprintSectionFieldCategory.System &&
this.alwaysRequiredSystemFieldTypes.includes(field.systemFieldType);
}
//Description Templates //Description Templates
isDescriptionTemplateSelected(descriptionTemplateId: number): boolean { isDescriptionTemplateSelected(descriptionTemplateId: number): boolean {

View File

@ -393,7 +393,6 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
const required = formGroup.get('required'); const required = formGroup.get('required');
if(systemFieldType != null && FieldInSectionEditorModel.alwaysRequiredSystemFieldTypes.includes(systemFieldType)){ if(systemFieldType != null && FieldInSectionEditorModel.alwaysRequiredSystemFieldTypes.includes(systemFieldType)){
required.setValue(true); required.setValue(true);
required.disable();
} else { } else {
if(required.disabled){ if(required.disabled){
required.enable(); required.enable();

View File

@ -15,6 +15,7 @@ import { PlanBlueprintListingComponent } from './listing/plan-blueprint-listing.
import { PlanBlueprintListingFiltersComponent } from "./listing/filters/plan-blueprint-listing-filters.component"; import { PlanBlueprintListingFiltersComponent } from "./listing/filters/plan-blueprint-listing-filters.component";
import { ImportPlanBlueprintDialogComponent } from './listing/import-plan-blueprint/import-plan-blueprint.dialog.component'; import { ImportPlanBlueprintDialogComponent } from './listing/import-plan-blueprint/import-plan-blueprint.dialog.component';
import { DescriptionTemplatePreviewDialogModule } from '../description-template/description-template-preview/description-template-preview-dialog.module'; import { DescriptionTemplatePreviewDialogModule } from '../description-template/description-template-preview/description-template-preview-dialog.module';
import { CheckboxFieldModule } from '@common/modules/checkbox-field/checkbox-field.module';
@NgModule({ @NgModule({
imports: [ imports: [
@ -29,7 +30,8 @@ import { DescriptionTemplatePreviewDialogModule } from '../description-template/
TextFilterModule, TextFilterModule,
UserSettingsModule, UserSettingsModule,
CommonFormattingModule, CommonFormattingModule,
DescriptionTemplatePreviewDialogModule DescriptionTemplatePreviewDialogModule,
CheckboxFieldModule,
], ],
declarations: [ declarations: [
PlanBlueprintEditorComponent, PlanBlueprintEditorComponent,

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -1816,7 +1816,8 @@
"DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity", "DESCRIPTION-TEMPLATE-MIN-MULTIPLICITY": "Min Multiplicity",
"DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity", "DESCRIPTION-TEMPLATE-MAX-MULTIPLICITY": "Max Multiplicity",
"PREFILLING-SOURCES": "Prefilling Sources", "PREFILLING-SOURCES": "Prefilling Sources",
"ENABLE-PREFILLING-SOURCES": "Prefilling Sources" "ENABLE-PREFILLING-SOURCES": "Prefilling Sources",
"SYSTEM-FIELD-REQUIRED": "This is a required system field"
}, },
"ACTIONS": { "ACTIONS": {
"ADD-FIELD": "Add Field", "ADD-FIELD": "Add Field",

View File

@ -0,0 +1,21 @@
import { NgModule } from "@angular/core";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { CommonUiModule } from "@common/ui/common-ui.module";
import { NoopCheckboxComponent } from "./noop-checkbox/noop-checkbox.component";
@NgModule({
imports: [
CommonUiModule,
FormsModule,
ReactiveFormsModule,
],
declarations: [
NoopCheckboxComponent,
],
exports: [
NoopCheckboxComponent,
]
})
export class CheckboxFieldModule {
constructor() { }
}

View File

@ -0,0 +1,5 @@
<mat-checkbox *ngIf="control" color="secondary"
[formControl]="control"
[matTooltip]="tooltipText"
[matTooltipPosition]="tooltipPosition"
>{{label}}</mat-checkbox>

View File

@ -0,0 +1,23 @@
import { Component, Input } from "@angular/core";
import { FormControl } from "@angular/forms";
import { MAT_CHECKBOX_DEFAULT_OPTIONS } from "@angular/material/checkbox";
import { TooltipPosition } from "@angular/material/tooltip";
@Component({
selector: 'app-noop-checkbox',
templateUrl: 'noop-checkbox.component.html',
styleUrls: ['noop-checkbox.component.scss'],
providers: [
{
provide: MAT_CHECKBOX_DEFAULT_OPTIONS,
useValue: { clickAction: 'noop' },
}
]
})
export class NoopCheckboxComponent {
@Input() control: FormControl;
@Input() checked: boolean;
@Input() label: string;
@Input() tooltipText: string | null = null;
@Input() tooltipPosition: TooltipPosition = 'right';
}