small fixes plan blueprint editor
This commit is contained in:
parent
481e712edd
commit
83091ee428
|
@ -106,7 +106,7 @@
|
||||||
<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>
|
||||||
<mat-select [formControl]="field.get('category')" [disabled]="field.disabled" (selectionChange)="fieldCategoryChanged(sectionIndex, fieldIndex)">
|
<mat-select [formControl]="field.get('category')" (selectionChange)="fieldCategoryChanged(sectionIndex, fieldIndex)">
|
||||||
<mat-option *ngFor="let fieldCategory of planBlueprintFieldCategoryEnum" [value]="fieldCategory">{{enumUtils.toPlanBlueprintFieldCategoryString(fieldCategory)}}</mat-option>
|
<mat-option *ngFor="let fieldCategory of planBlueprintFieldCategoryEnum" [value]="fieldCategory">{{enumUtils.toPlanBlueprintFieldCategoryString(fieldCategory)}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="field.get('category').hasError('backendError')">{{field.get('category').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="field.get('category').hasError('backendError')">{{field.get('category').getError('backendError').message}}</mat-error>
|
||||||
|
@ -116,7 +116,7 @@
|
||||||
<div class="col-12 col-xl-4" *ngIf="field.get('category').value === planBlueprintSectionFieldCategory.System">
|
<div class="col-12 col-xl-4" *ngIf="field.get('category').value === planBlueprintSectionFieldCategory.System">
|
||||||
<mat-form-field class="mt-3 w-100">
|
<mat-form-field class="mt-3 w-100">
|
||||||
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-TYPE' | translate}}</mat-label>
|
<mat-label>{{'PLAN-BLUEPRINT-EDITOR.FIELDS.SYSTEM-FIELD-TYPE' | translate}}</mat-label>
|
||||||
<mat-select [formControl]="field.get('systemFieldType')" [disabled]="field.disabled">
|
<mat-select [formControl]="field.get('systemFieldType')">
|
||||||
<mat-option *ngFor="let systemFieldType of planBlueprintSystemFieldTypeEnum" [disabled]="systemFieldDisabled(systemFieldType)" [value]="systemFieldType">{{enumUtils.toPlanBlueprintSystemFieldTypeString(systemFieldType)}}</mat-option>
|
<mat-option *ngFor="let systemFieldType of planBlueprintSystemFieldTypeEnum" [disabled]="systemFieldDisabled(systemFieldType)" [value]="systemFieldType">{{enumUtils.toPlanBlueprintSystemFieldTypeString(systemFieldType)}}</mat-option>
|
||||||
</mat-select>
|
</mat-select>
|
||||||
<mat-error *ngIf="field.get('systemFieldType').hasError('backendError')">{{field.get('systemFieldType').getError('backendError').message}}</mat-error>
|
<mat-error *ngIf="field.get('systemFieldType').hasError('backendError')">{{field.get('systemFieldType').getError('backendError').message}}</mat-error>
|
||||||
|
|
|
@ -180,13 +180,9 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
|
||||||
|
|
||||||
prepareForm(data: PlanBlueprint) {
|
prepareForm(data: PlanBlueprint) {
|
||||||
try {
|
try {
|
||||||
const dataCopy = data ? JSON.parse(JSON.stringify(data)) : null;
|
this.editorModel = data ? new PlanBlueprintEditorModel().fromModel(data) : new PlanBlueprintEditorModel();
|
||||||
if(dataCopy && this.isClone) {
|
this.isDeleted = data ? data.isActive === IsActive.Inactive : false;
|
||||||
dataCopy.belongsToCurrentTenant = true;
|
this.belongsToCurrentTenant = this.isNew || data.belongsToCurrentTenant;
|
||||||
}
|
|
||||||
this.editorModel = dataCopy ? new PlanBlueprintEditorModel().fromModel(dataCopy) : new PlanBlueprintEditorModel();
|
|
||||||
this.isDeleted = dataCopy ? dataCopy.isActive === IsActive.Inactive : false;
|
|
||||||
this.belongsToCurrentTenant = this.isNew || dataCopy.belongsToCurrentTenant;
|
|
||||||
|
|
||||||
this.buildForm();
|
this.buildForm();
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ export class PlanBlueprintEditorModel extends BaseEditorModel implements PlanBlu
|
||||||
buildForm(context: ValidationContext = null, disabled: boolean = false, isNewOrClone: boolean = false): UntypedFormGroup {
|
buildForm(context: ValidationContext = null, disabled: boolean = false, isNewOrClone: boolean = false): UntypedFormGroup {
|
||||||
if (context == null) { context = this.createValidationContext(); }
|
if (context == null) { context = this.createValidationContext(); }
|
||||||
|
|
||||||
return this.formBuilder.group({
|
const formGroup = this.formBuilder.group({
|
||||||
id: [{ value: this.id, disabled }, context.getValidation('id').validators],
|
id: [{ value: this.id, disabled }, context.getValidation('id').validators],
|
||||||
label: [{ value: this.label, disabled }, context.getValidation('label').validators],
|
label: [{ value: this.label, disabled }, context.getValidation('label').validators],
|
||||||
code: [{ value: this.code, disabled: !isNewOrClone }, context.getValidation('code').validators],
|
code: [{ value: this.code, disabled: !isNewOrClone }, context.getValidation('code').validators],
|
||||||
|
@ -51,6 +51,7 @@ export class PlanBlueprintEditorModel extends BaseEditorModel implements PlanBlu
|
||||||
}),
|
}),
|
||||||
hash: [{ value: this.hash, disabled }, context.getValidation('hash').validators]
|
hash: [{ value: this.hash, disabled }, context.getValidation('hash').validators]
|
||||||
});
|
});
|
||||||
|
return formGroup;
|
||||||
}
|
}
|
||||||
|
|
||||||
createValidationContext(): ValidationContext {
|
createValidationContext(): ValidationContext {
|
||||||
|
|
|
@ -78,11 +78,14 @@ export class PlanBlueprintEditorResolver extends BaseEditorResolver {
|
||||||
tap(x => this.breadcrumbService.addIdResolvedValue(cloneid, x.label)),
|
tap(x => this.breadcrumbService.addIdResolvedValue(cloneid, x.label)),
|
||||||
takeUntil(this._destroyed),
|
takeUntil(this._destroyed),
|
||||||
map((blueprint: PlanBlueprint) => {
|
map((blueprint: PlanBlueprint) => {
|
||||||
blueprint.id = null;
|
return {
|
||||||
blueprint.hash = null;
|
...blueprint,
|
||||||
blueprint.code = null;
|
id: null,
|
||||||
blueprint.isActive = IsActive.Active;
|
hash: null,
|
||||||
return blueprint;
|
code: null,
|
||||||
|
isActive: IsActive.Active,
|
||||||
|
belongsToCurrentTenant: true
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
} else if (newversion != null) {
|
} else if (newversion != null) {
|
||||||
return this.planBlueprintService.getSingle(Guid.parse(newversion), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(newversion, x.label)), takeUntil(this._destroyed));
|
return this.planBlueprintService.getSingle(Guid.parse(newversion), fields).pipe(tap(x => this.breadcrumbService.addIdResolvedValue(newversion, x.label)), takeUntil(this._destroyed));
|
||||||
|
|
Loading…
Reference in New Issue