Skip to content

Commit

Permalink
fix: checkbox remains checked on re-enabling the import field (#856)
Browse files Browse the repository at this point in the history
* make the 'dependent imports' checkbox always checked

* fix: make 'dependent imports' checkbox always checked for sage300 only

* fix: re-add check to show dependent import fields

* fix: checkbox remains checked on re-enabling the import field

* also enable the checkbox on dropdown change

* fix(linting): remove trailing whitespace

(cherry picked from commit 26b2ca4)
  • Loading branch information
JustARatherRidiculouslyLongUsername committed Jun 26, 2024
1 parent a38b68e commit e032ea2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ <h5 *ngIf="!isCloneSettingView" class="!tw-text-text-muted tw-text-14-px !tw-fon
{{brandingConfig.brandName}} Fields should be unique
</p>
</div>
<p-inputSwitch *ngIf="!isDestinationFixedImport" (onChange)="onShowWarningForDependentFields($event, expenseField)" [pTooltip]="isExpenseFieldDependent(expenseField.value) ? 'You cannot import dependent fields' : '' " (click)="updateDependentField(expenseField.value.source_field,expenseField.value.import_to_fyle)" formControlName="import_to_fyle" class="input-toggle-section tw-pl-4-px tw-pt-10-px"></p-inputSwitch>
<p-inputSwitch *ngIf="!isDestinationFixedImport" (onChange)="onSwitchChanged($event, expenseField)" [pTooltip]="isExpenseFieldDependent(expenseField.value) ? 'You cannot import dependent fields' : '' " (click)="updateDependentField(expenseField.value.source_field,expenseField.value.import_to_fyle)" formControlName="import_to_fyle" class="input-toggle-section tw-pl-4-px tw-pt-10-px"></p-inputSwitch>
</div>
<div class="tw-pt-26-px" *ngIf="expenseField.value.source_field==='PROJECT' && expenseField.value.import_to_fyle && expenseField.value.destination_field === dependentDestinationValue" [formGroup]="form">
<div class="tw-flex">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ export class ConfigurationImportFieldComponent implements OnInit {
(this.form.get('expenseFields') as FormArray).at(index)?.get('import_to_fyle')?.setValue(true);
}

if ( this.appName === AppName.SAGE300) {
this.form.controls.isDependentImportEnabled.setValue(true);
}

if (selectedValue === MappingSourceField.PROJECT && (this.form.get('expenseFields') as FormArray).at(index)?.get('source_field')?.value !== XeroFyleField.CUSTOMER && this.appName === AppName.XERO) {
this.isXeroProjectMapped = true;
this.xeroProjectMapping.emit(this.isXeroProjectMapped);
Expand Down Expand Up @@ -154,6 +158,13 @@ export class ConfigurationImportFieldComponent implements OnInit {
this.xeroProjectMapping.emit(this.isXeroProjectMapped);
}

onSwitchChanged(event: any, formGroup: AbstractControl): void {
this.onShowWarningForDependentFields(event, formGroup);
if (event.checked && this.appName === AppName.SAGE300) {
this.form.controls.isDependentImportEnabled.setValue(true);
}
}

onShowWarningForDependentFields(event: any, formGroup: AbstractControl): void {
if (!event.checked && formGroup.value.source_field === MappingSourceField.PROJECT) {
this.showWarningForDependentFields.emit();
Expand Down

0 comments on commit e032ea2

Please sign in to comment.