checkbox fix visible state

This commit is contained in:
amentis 2024-04-29 13:39:50 +03:00
parent 2180bebc7f
commit bac8fa197e
3 changed files with 15 additions and 4 deletions

View File

@ -678,7 +678,7 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
saveAndClose(){ saveAndClose(){
this.formSubmit((data) => { this.formSubmit((data) => {
this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success); this.uiNotificationService.snackBarNotification(this.isNew ? this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-CREATION') : this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
this.refreshOnNavigateToData(data ? data.id : null); this.formGroup = null;
this.backToDmp(); this.backToDmp();
}); });
} }

View File

@ -82,7 +82,7 @@
</div> </div>
</div> </div>
<div *ngSwitchCase="descriptionTemplateFieldTypeEnum.CHECK_BOX" class="col-12"> <div *ngSwitchCase="descriptionTemplateFieldTypeEnum.CHECK_BOX" class="col-12">
<mat-checkbox [formControl]="propertiesFormGroup?.get(field.id).get('textValue')"> <mat-checkbox [checked]="propertiesFormGroup?.get(field.id).get('textValue').value == 'true'" [disabled]="propertiesFormGroup?.get(field.id).get('textValue').disabled"(change)="checkBoxChanged($event)">
{{field.data.label}}</mat-checkbox> {{field.data.label}}</mat-checkbox>
<mat-error *ngIf="propertiesFormGroup?.get(field.id).get('textValue').hasError('backendError')">{{propertiesFormGroup?.get(field.id).get('textValue').getError('backendError').message}}</mat-error> <mat-error *ngIf="propertiesFormGroup?.get(field.id).get('textValue').hasError('backendError')">{{propertiesFormGroup?.get(field.id).get('textValue').getError('backendError').message}}</mat-error>
</div> </div>
@ -119,7 +119,7 @@
<mat-label>{{ (field.data.label | translate)}}</mat-label> <mat-label>{{ (field.data.label | translate)}}</mat-label>
</button> </button>
<button *ngIf="propertiesFormGroup?.get(field.id).get('textValue').value && !filesToUpload" mat-button (click)="download()" type="button" class="attach-file-btn" [disabled]="propertiesFormGroup?.get(field.id).get('textValue').disabled"> <button *ngIf="propertiesFormGroup?.get(field.id).get('textValue').value && !filesToUpload" mat-button (click)="download()" type="button" class="attach-file-btn">
<mat-icon class="mr-2">download</mat-icon> <mat-icon class="mr-2">download</mat-icon>
<mat-label>{{ "TYPES.DATASET-PROFILE-UPLOAD-TYPE.DOWNLOAD" | translate }}</mat-label> <mat-label>{{ "TYPES.DATASET-PROFILE-UPLOAD-TYPE.DOWNLOAD" | translate }}</mat-label>
</button> </button>

View File

@ -2,6 +2,7 @@
import { COMMA, ENTER } from '@angular/cdk/keycodes'; import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, SimpleChanges } from '@angular/core'; import { ChangeDetectionStrategy, ChangeDetectorRef, Component, Input, OnInit, SimpleChanges } from '@angular/core';
import { UntypedFormControl, UntypedFormGroup } from '@angular/forms'; import { UntypedFormControl, UntypedFormGroup } from '@angular/forms';
import { MatCheckboxChange } from '@angular/material/checkbox';
import { MatDialog } from "@angular/material/dialog"; import { MatDialog } from "@angular/material/dialog";
import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type'; import { DescriptionTemplateFieldType } from '@app/core/common/enum/description-template-field-type';
import { DescriptionTemplateFieldValidationType } from '@app/core/common/enum/description-template-field-validation-type'; import { DescriptionTemplateFieldValidationType } from '@app/core/common/enum/description-template-field-validation-type';
@ -116,6 +117,15 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
} }
} }
checkBoxChanged(event: MatCheckboxChange){
if (event.checked){
this.propertiesFormGroup?.get(this.field.id).get('textValue').setValue("true");
} else{
this.propertiesFormGroup?.get(this.field.id).get('textValue').setValue("false");
}
this.visibilityRulesService.reloadVisibility();
}
private applyFieldType(){ private applyFieldType(){
this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required); this.isRequired = this.field.validations?.includes(DescriptionTemplateFieldValidationType.Required);
@ -164,7 +174,8 @@ export class DescriptionFormFieldComponent extends BaseComponent implements OnIn
// } // }
break; break;
case DescriptionTemplateFieldType.CHECK_BOX: case DescriptionTemplateFieldType.CHECK_BOX:
this.propertiesFormGroup?.get(this.field.id).get('textValue').setValue(this.propertiesFormGroup?.get(this.field.id).get('textValue').value === 'true'); if (this.propertiesFormGroup?.get(this.field.id).get('textValue').value == undefined) this.propertiesFormGroup?.get(this.field.id).get('textValue').setValue("false");
this.visibilityRulesService.reloadVisibility();
break; break;
} }