plan blueprint editor > Required checkbox > disable and set to true when system field always required, fix delete conditions
This commit is contained in:
parent
ee7acec75b
commit
b3b8b1d0c4
|
@ -5,7 +5,7 @@
|
||||||
<div class="col-md col-12">
|
<div class="col-md col-12">
|
||||||
<app-navigation-breadcrumb />
|
<app-navigation-breadcrumb />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-auto mb-md-0 col-12 mb-2" *ngIf="!hideEditActions && canDelete">
|
<div class="col-md-auto mb-md-0 col-12 mb-2" *ngIf="canDelete">
|
||||||
<button [disabled]="isLocked" mat-button class="action-btn" type="button" (click)="delete()">
|
<button [disabled]="isLocked" mat-button class="action-btn" type="button" (click)="delete()">
|
||||||
<mat-icon>delete</mat-icon>
|
<mat-icon>delete</mat-icon>
|
||||||
{{'PLAN-BLUEPRINT-EDITOR.ACTIONS.DELETE' | translate}}
|
{{'PLAN-BLUEPRINT-EDITOR.ACTIONS.DELETE' | translate}}
|
||||||
|
@ -103,6 +103,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<div class="row align-items-center">
|
<div class="row align-items-center">
|
||||||
|
<!-- FIELD TYPE -->
|
||||||
<div class="col-12 col-xl-4">
|
<div class="col-12 col-xl-4">
|
||||||
<mat-form-field class="mt-3 w-100">
|
<mat-form-field class="mt-3 w-100">
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.CATEGORY' | translate}}</mat-label>
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.CATEGORY' | translate}}</mat-label>
|
||||||
|
@ -113,80 +114,92 @@
|
||||||
<mat-error *ngIf="field.get('category').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('category').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-12 col-xl-4" *ngIf="field.get('category').value === planBlueprintSectionFieldCategory.System">
|
@switch(field.get('category').value){
|
||||||
<mat-form-field class="mt-3 w-100">
|
@case(planBlueprintSectionFieldCategory.System){
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-TYPE' | translate}}</mat-label>
|
<div class="col-12 col-xl-4">
|
||||||
<mat-select [formControl]="field.get('systemFieldType')">
|
<mat-form-field class="mt-3 w-100">
|
||||||
<mat-option *ngFor="let systemFieldType of planBlueprintSystemFieldTypeEnum" [disabled]="systemFieldDisabled(systemFieldType)" [value]="systemFieldType">{{enumUtils.toPlanBlueprintSystemFieldTypeString(systemFieldType)}}</mat-option>
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-TYPE' | translate}}</mat-label>
|
||||||
</mat-select>
|
<mat-select [formControl]="field.get('systemFieldType')">
|
||||||
<mat-error *ngIf="field.get('systemFieldType').hasError('backendError')">{{field.get('systemFieldType').getError('backendError').message}}</mat-error>
|
<mat-option *ngFor="let systemFieldType of planBlueprintSystemFieldTypeEnum" [disabled]="systemFieldDisabled(systemFieldType)" [value]="systemFieldType">{{enumUtils.toPlanBlueprintSystemFieldTypeString(systemFieldType)}}</mat-option>
|
||||||
<mat-error *ngIf="field.get('systemFieldType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
</mat-select>
|
||||||
</mat-form-field>
|
<mat-error *ngIf="field.get('systemFieldType').hasError('backendError')">{{field.get('systemFieldType').getError('backendError').message}}</mat-error>
|
||||||
</div>
|
<mat-error *ngIf="field.get('systemFieldType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<div class="col-12 col-xl-4" *ngIf="field.get('category').value === planBlueprintSectionFieldCategory.Extra">
|
</mat-form-field>
|
||||||
<mat-form-field class="mt-3 w-100">
|
</div>
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label>
|
}
|
||||||
<mat-select [formControl]="field.get('dataType')">
|
@case(planBlueprintSectionFieldCategory.Extra){
|
||||||
<mat-option *ngFor="let extraFieldDataType of planBlueprintExtraFieldDataTypeEnum" [value]="extraFieldDataType">
|
<div class="col-12 col-xl-4">
|
||||||
{{enumUtils.toPlanBlueprintExtraFieldDataTypeString(extraFieldDataType)}}
|
<mat-form-field class="mt-3 w-100">
|
||||||
</mat-option>
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.DATA-TYPE' | translate}}</mat-label>
|
||||||
</mat-select>
|
<mat-select [formControl]="field.get('dataType')">
|
||||||
<mat-error *ngIf="field.get('dataType').hasError('backendError')">{{field.get('dataType').getError('backendError').message}}</mat-error>
|
<mat-option *ngFor="let extraFieldDataType of planBlueprintExtraFieldDataTypeEnum" [value]="extraFieldDataType">
|
||||||
<mat-error *ngIf="field.get('dataType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
{{enumUtils.toPlanBlueprintExtraFieldDataTypeString(extraFieldDataType)}}
|
||||||
</mat-form-field>
|
</mat-option>
|
||||||
</div>
|
</mat-select>
|
||||||
<div class="col-12 col-xl-4" *ngIf="field.get('category').value === planBlueprintSectionFieldCategory.ReferenceType">
|
<mat-error *ngIf="field.get('dataType').hasError('backendError')">{{field.get('dataType').getError('backendError').message}}</mat-error>
|
||||||
<mat-form-field class="mt-3 w-100">
|
<mat-error *ngIf="field.get('dataType').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
|
</mat-form-field>
|
||||||
<app-single-auto-complete placeholder="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}" [required]="true" [formControl]="field.get('referenceTypeId')" [configuration]="referenceTypeService.singleAutocompleteConfiguration"></app-single-auto-complete>
|
</div>
|
||||||
<mat-error *ngIf="field.get('referenceTypeId').hasError('backendError')">{{field.get('referenceTypeId').getError('backendError').message}}</mat-error>
|
}
|
||||||
<mat-error *ngIf="field.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
@case(planBlueprintSectionFieldCategory.ReferenceType){
|
||||||
</mat-form-field>
|
<div class="col-12 col-xl-4">
|
||||||
</div>
|
<mat-form-field class="mt-3 w-100">
|
||||||
<div class="col-12 col-xl-4" *ngIf="field.get('category').value != null">
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}</mat-label>
|
||||||
<mat-form-field class="mt-3 w-100">
|
<app-single-auto-complete placeholder="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.REFERENCE-TYPE' | translate}}" [required]="true" [formControl]="field.get('referenceTypeId')" [configuration]="referenceTypeService.singleAutocompleteConfiguration"></app-single-auto-complete>
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-LABEL' | translate}}</mat-label>
|
<mat-error *ngIf="field.get('referenceTypeId').hasError('backendError')">{{field.get('referenceTypeId').getError('backendError').message}}</mat-error>
|
||||||
<input matInput type="text" name="label" [formControl]="field.get('label')">
|
<mat-error *ngIf="field.get('referenceTypeId').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
<mat-error *ngIf="field.get('label').hasError('backendError')">{{field.get('label').getError('backendError').message}}</mat-error>
|
</mat-form-field>
|
||||||
<mat-error *ngIf="field.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
</div>
|
||||||
</mat-form-field>
|
}
|
||||||
</div>
|
}
|
||||||
<div class="col-12 col-xl-4" *ngIf="field.get('category').value != null">
|
@if(field.get('category').value != null){
|
||||||
<mat-form-field class="mt-3 w-100">
|
<div class="col-12 col-xl-4">
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-PLACEHOLDER' | translate}}</mat-label>
|
<mat-form-field class="mt-3 w-100">
|
||||||
<input matInput type="text" name="placeholder" [formControl]="field.get('placeholder')">
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-LABEL' | translate}}</mat-label>
|
||||||
<mat-error *ngIf="field.get('placeholder').hasError('backendError')">{{field.get('placeholder').getError('backendError').message}}</mat-error>
|
<input matInput type="text" name="label" [formControl]="field.get('label')">
|
||||||
<mat-error *ngIf="field.get('placeholder').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('label').hasError('backendError')">{{field.get('label').getError('backendError').message}}</mat-error>
|
||||||
</mat-form-field>
|
<mat-error *ngIf="field.get('label').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</div>
|
</mat-form-field>
|
||||||
<div class="col-12 col-xl-4" *ngIf="field.get('category').value != null">
|
</div>
|
||||||
<mat-form-field class="mt-3 w-100">
|
<div class="col-12 col-xl-4">
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-DESCRIPTION' | translate}}</mat-label>
|
<mat-form-field class="mt-3 w-100">
|
||||||
<input matInput type="text" name="description" [formControl]="field.get('description')">
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-PLACEHOLDER' | translate}}</mat-label>
|
||||||
<mat-error *ngIf="field.get('description').hasError('backendError')">{{field.get('description').getError('backendError').message}}</mat-error>
|
<input matInput type="text" name="placeholder" [formControl]="field.get('placeholder')">
|
||||||
<mat-error *ngIf="field.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('placeholder').hasError('backendError')">{{field.get('placeholder').getError('backendError').message}}</mat-error>
|
||||||
</mat-form-field>
|
<mat-error *ngIf="field.get('placeholder').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</div>
|
</mat-form-field>
|
||||||
<div class="col-12 order-xl-8" *ngIf="field.get('category').value != null">
|
</div>
|
||||||
<mat-form-field class="mt-3 w-100">
|
<div class="col-12 col-xl-4">
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}}</mat-label>
|
<mat-form-field class="mt-3 w-100">
|
||||||
<app-multiple-auto-complete placeholder="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}}" [required]="false" [separatorKeysCodes]="separatorKeysCodes" [formControl]="field.get('semantics')" [configuration]="semanticsService.multipleAutocompleteConfiguration">
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-DESCRIPTION' | translate}}</mat-label>
|
||||||
</app-multiple-auto-complete>
|
<input matInput type="text" name="description" [formControl]="field.get('description')">
|
||||||
<mat-error *ngIf="field.get('semantics').hasError('backendError')">{{field.get('semantics').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="field.get('description').hasError('backendError')">{{field.get('description').getError('backendError').message}}</mat-error>
|
||||||
<mat-error *ngIf="field.get('semantics').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('description').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-auto col-xl-2 section-field" *ngIf="field.get('category').value != null">
|
<div class="col-12 order-xl-8">
|
||||||
<mat-checkbox [disabled]="alwaysRequiredSystemFieldTypes.includes(field.get('systemFieldType')?.value) || formGroup.disabled" [checked]="field.get('required').value" (change)="field.get('required').setValue($event.checked)"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-REQUIRED' | translate}}</span></mat-checkbox>
|
<mat-form-field class="mt-3 w-100">
|
||||||
<mat-error *ngIf="field.get('required').hasError('backendError')">{{field.get('required').getError('backendError').message}}</mat-error>
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}}</mat-label>
|
||||||
<mat-error *ngIf="field.get('required').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<app-multiple-auto-complete placeholder="{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SEMANTICS' | translate}}" [required]="false" [separatorKeysCodes]="separatorKeysCodes" [formControl]="field.get('semantics')" [configuration]="semanticsService.multipleAutocompleteConfiguration">
|
||||||
</div>
|
</app-multiple-auto-complete>
|
||||||
|
<mat-error *ngIf="field.get('semantics').hasError('backendError')">{{field.get('semantics').getError('backendError').message}}</mat-error>
|
||||||
|
<mat-error *ngIf="field.get('semantics').hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
<div class="col-auto col-xl-2 section-field">
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
<div class="col-auto col-xl-2">
|
<div class="col-auto col-xl-2">
|
||||||
<div *ngIf="field.get('category').value === planBlueprintSectionFieldCategory.ReferenceType">
|
@if(field.get('category').value === planBlueprintSectionFieldCategory.ReferenceType){
|
||||||
<mat-checkbox [disabled]="formGroup.disabled" [checked]="field.get('multipleSelect').value" (change)="field.get('multipleSelect').setValue($event.checked)"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-MULTIPLE-SELECT' | translate}}</span></mat-checkbox>
|
<div>
|
||||||
<mat-error *ngIf="field.get('multipleSelect')?.hasError('backendError')">{{field.get('multipleSelect')?.getError('backendError').message}}</mat-error>
|
<mat-checkbox [formControl]="field.get('multipleSelect')"><span>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.FIELD-MULTIPLE-SELECT' | translate}}</span></mat-checkbox>
|
||||||
<mat-error *ngIf="field.get('multipleSelect')?.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
<mat-error *ngIf="field.get('multipleSelect')?.hasError('backendError')">{{field.get('multipleSelect')?.getError('backendError').message}}</mat-error>
|
||||||
</div>
|
<mat-error *ngIf="field.get('multipleSelect')?.hasError('required')">{{'GENERAL.VALIDATION.REQUIRED' | translate}}</mat-error>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -90,7 +90,7 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get canDelete(): boolean {
|
protected get canDelete(): boolean {
|
||||||
return !this.isTransient && this.hasPermission(this.authService.permissionEnum.DeletePlanBlueprint);
|
return !this.isDeleted && !this.isTransient && this.belongsToCurrentTenant && this.hasPermission(this.authService.permissionEnum.DeletePlanBlueprint);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected get canFinalize(): boolean {
|
protected get canFinalize(): boolean {
|
||||||
|
|
|
@ -23,6 +23,7 @@ export class PlanBlueprintEditorModel extends BaseEditorModel implements PlanBlu
|
||||||
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
public validationErrorModel: ValidationErrorModel = new ValidationErrorModel();
|
||||||
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
protected formBuilder: UntypedFormBuilder = new UntypedFormBuilder();
|
||||||
|
|
||||||
|
|
||||||
constructor() { super(); }
|
constructor() { super(); }
|
||||||
|
|
||||||
public fromModel(item: PlanBlueprint): PlanBlueprintEditorModel {
|
public fromModel(item: PlanBlueprint): PlanBlueprintEditorModel {
|
||||||
|
@ -372,7 +373,7 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
id: [{ value: this.id, disabled: disabled }, context.getValidation('id').validators],
|
||||||
|
|
||||||
category: [{ value: this.category, disabled: disabled }, context.getValidation('category').validators],
|
category: [{ value: this.category, disabled: disabled }, context.getValidation('category').validators],
|
||||||
|
@ -387,6 +388,19 @@ export class FieldInSectionEditorModel implements FieldInSectionPersist {
|
||||||
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
|
referenceTypeId: [{ value: this.referenceTypeId, disabled: disabled }, context.getValidation('referenceTypeId').validators],
|
||||||
multipleSelect: [{ value: this.multipleSelect, disabled: disabled }, context.getValidation('multipleSelect').validators],
|
multipleSelect: [{ value: this.multipleSelect, disabled: disabled }, context.getValidation('multipleSelect').validators],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
formGroup.get('systemFieldType').valueChanges.subscribe((systemFieldType: PlanBlueprintSystemFieldType) => {
|
||||||
|
const required = formGroup.get('required');
|
||||||
|
if(systemFieldType != null && FieldInSectionEditorModel.alwaysRequiredSystemFieldTypes.includes(systemFieldType)){
|
||||||
|
required.setValue(true);
|
||||||
|
required.disable();
|
||||||
|
} else {
|
||||||
|
if(required.disabled){
|
||||||
|
required.enable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
static createValidationContext(params: {
|
static createValidationContext(params: {
|
||||||
|
|
Loading…
Reference in New Issue