Skip to content

Commit

Permalink
fix: form value bug fixes (#1022)
Browse files Browse the repository at this point in the history
  • Loading branch information
DhaaraniCIT committed Oct 17, 2024
1 parent d1f26ef commit 57fb635
Show file tree
Hide file tree
Showing 18 changed files with 73 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/app/core/models/common/advanced-settings.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export class SkipExportModel {

static setConditionFields(response: ExpenseFilterResponse, conditionArray: ConditionField[], conditionFieldOptions: ConditionField[]) {
response.results.forEach((element) => {
const type = conditionFieldOptions?.filter( (fieldOption) => fieldOption.field_name === element.condition);
const type = conditionFieldOptions?.filter( (fieldOption) => fieldOption.field_name.toLowerCase() === element.condition.toLowerCase());
const selectedConditionOption : ConditionField = type[0];
conditionArray.push(selectedConditionOption);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,15 +86,16 @@ <h4 class="tw-text-form-label-text-color tw-mb-12-px">Preview of the Description
[skipExportForm]="skipExportForm"
[expenseFilter]="expenseFilters"
[conditionFieldOptions]="conditionFieldOptions"
(deleteSkipExportForm)="deleteExpenseFilter($event)">
(deleteSkipExportForm)="deleteExpenseFilter($event)"
(invalidSkipExportForm)="invalidSkipExportForm($event)">
</app-configuration-skip-export>
</div>
</div>
</div>
<app-configuration-step-footer
[ctaText] = "!isSaveInProgress ? (isOnboarding ? ConfigurationCtaText.SAVE_AND_CONTINUE : ConfigurationCtaText.SAVE) : ConfigurationCtaText.SAVING"
[showBackButton] = "isOnboarding"
[isButtonDisabled]="!advancedSettingForm.valid || !skipExportForm.valid || !getSkipExportValue()"
[isButtonDisabled]="!advancedSettingForm.valid || !skipExportForm.valid || !getSkipExportValue() || isSkipExportFormInvalid"
(save)="save()"
(navigateToPreviousStep)="navigateBack()">
</app-configuration-step-footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export class BusinessCentralAdvancedSettingsComponent implements OnInit {

readonly brandingConfig = brandingConfig;

isSkipExportFormInvalid: boolean;

constructor(
private advancedSettingsService: BusinessCentralAdvancedSettingsService,
private helper: HelperService,
Expand All @@ -70,6 +72,10 @@ export class BusinessCentralAdvancedSettingsComponent implements OnInit {
private router: Router
) { }

invalidSkipExportForm($event: boolean) {
this.isSkipExportFormInvalid = $event;
}

getSkipExportValue() {
if (this.advancedSettingForm.controls.skipExport) {
if (this.skipExportForm.controls.condition1.value) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@
#skipExportChild
[enableSkipExport]="advancedSettingsForm.get('skipSelectiveExpenses')?.value"
[skipExportForm]="skipExportForm"
(skipExportFormChange)="updateForm($event)">
(skipExportFormChange)="updateForm($event)"
(invalidSkipExportForm)="invalidSkipExportForm($event)">
</app-skip-export>
</div>
</div>
Expand Down Expand Up @@ -238,6 +239,6 @@
</div>
</div>
</div>
<app-configuration-step-footer (navigateToPreviousStep)="navigateToPreviousStep()" [ctaText] = "!saveInProgress ? (isOnboarding ? ConfigurationCtaText.SAVE_AND_CONTINUE : ConfigurationCtaText.SAVE) : ConfigurationCtaText.SAVING" (save)="save()" [isButtonDisabled]="!advancedSettingsForm.valid || (advancedSettingsForm.get('skipSelectiveExpenses')?.value ? !skipExportForm.valid : false)" [showBackButton]="isOnboarding ? true : false"></app-configuration-step-footer>
<app-configuration-step-footer (navigateToPreviousStep)="navigateToPreviousStep()" [ctaText] = "!saveInProgress ? (isOnboarding ? ConfigurationCtaText.SAVE_AND_CONTINUE : ConfigurationCtaText.SAVE) : ConfigurationCtaText.SAVING" (save)="save()" [isButtonDisabled]="isSkipExportFormInvalid || !advancedSettingsForm.valid || (advancedSettingsForm.get('skipSelectiveExpenses')?.value ? !skipExportForm.valid : false)" [showBackButton]="isOnboarding ? true : false"></app-configuration-step-footer>
</form>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import { DestinationAttribute } from 'src/app/core/models/db/destination-attribu
})

export class IntacctAdvancedSettingsComponent implements OnInit {
isSkipExportFormInvalid: boolean;

@ViewChild('skipExportChild') skipExportChild: SkipExportComponent;

Expand Down Expand Up @@ -129,6 +130,10 @@ export class IntacctAdvancedSettingsComponent implements OnInit {
private mappingService: SiMappingsService
) { }

invalidSkipExportForm($event: boolean) {
this.isSkipExportFormInvalid = $event;
}

navigateToPreviousStep(): void {
this.router.navigate([`/integrations/intacct/onboarding/import_settings`]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,9 @@ export class IntacctC1ImportSettingsComponent implements OnInit {
}

closeModel() {
this.customFieldControl.patchValue({
source_field: null
});
this.customFieldForm.reset();
this.showDialog = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ export class IntacctImportSettingsComponent implements OnInit {
}

closeModel() {
this.customFieldControl.patchValue({
source_field: null
});
this.customFieldForm.reset();
this.showDialog = false;
}
Expand Down Expand Up @@ -343,7 +346,7 @@ export class IntacctImportSettingsComponent implements OnInit {
this.importSettingsForm.controls.costTypes.setValidators(Validators.required);
} else {
this.importSettingsForm.controls.costCodes.disable();
this.importSettingsForm.controls.costTypes.disable();
this.importSettingsForm.controls.costTypes.disable();
this.importSettingsForm.controls.costCodes.clearValidators();
this.importSettingsForm.controls.costTypes.clearValidators();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ <h4 class="tw-text-form-label-text-color tw-mb-12-px">{{brandingContent.previewD
[skipExportForm]="skipExportForm"
[expenseFilter]="expenseFilters"
[conditionFieldOptions]="conditionFieldOptions"
(deleteSkipExportForm)="deleteExpenseFilter($event)">
(deleteSkipExportForm)="deleteExpenseFilter($event)"
(invalidSkipExportForm)="invalidSkipExportForm($event)">
</app-configuration-skip-export>
</div>
</div>
Expand Down Expand Up @@ -246,7 +247,7 @@ <h4 class="tw-text-form-label-text-color tw-mb-12-px">{{brandingContent.previewD
</div>
<app-configuration-step-footer
[ctaText] = "!isSaveInProgress ? (isOnboarding ? ConfigurationCtaText.SAVE_AND_CONTINUE : ConfigurationCtaText.SAVE) : ConfigurationCtaText.SAVING"
[isButtonDisabled]="!advancedSettingForm.valid"
[isButtonDisabled]="!advancedSettingForm.valid || isSkipExportFormInvalid"
[showBackButton]="isOnboarding ? true : false"
(save)="save()"
(navigateToPreviousStep)="navigateToPreviousStep()">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ export class NetsuiteAdvancedSettingsComponent implements OnInit {

readonly brandingContent = brandingContent.netsuite.configuration.advancedSettings;

isSkipExportFormInvalid: boolean;

constructor(
private advancedSettingsService: NetsuiteAdvancedSettingsService,
private configurationService: ConfigurationService,
Expand All @@ -107,6 +109,10 @@ export class NetsuiteAdvancedSettingsComponent implements OnInit {
return brandingConfig.brandId === 'co' ? ' \(optional\)' : '';
}

invalidSkipExportForm($event: boolean) {
this.isSkipExportFormInvalid = $event;
}

getCreateVendorLabel(): string {
if (this.workspaceGeneralSettings.employee_field_mapping === EmployeeFieldMapping.VENDOR) {
return brandingConfig.brandId === 'co' ? EmployeeFieldMapping.VENDOR.toLowerCase() : new TitleCasePipe().transform(EmployeeFieldMapping.VENDOR);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,15 @@ <h4 class="tw-text-form-label-text-color tw-mb-12-px">{{brandingContent.previewD
[skipExportForm]="skipExportForm"
[expenseFilter]="expenseFilters"
[conditionFieldOptions]="conditionFieldOptions"
(deleteSkipExportForm)="deleteExpenseFilter($event)">
(deleteSkipExportForm)="deleteExpenseFilter($event)"
(invalidSkipExportForm)="invalidSkipExportForm($event)">
</app-configuration-skip-export>
</div>
</div>
</div>
<app-configuration-step-footer
[ctaText] = "!isSaveInProgress ? (isOnboarding ? ConfigurationCtaText.SAVE_AND_CONTINUE : ConfigurationCtaText.SAVE) : ConfigurationCtaText.SAVING"
[isButtonDisabled]="!advancedSettingForm.valid"
[isButtonDisabled]="!advancedSettingForm.valid || isSkipExportFormInvalid"
[showBackButton]="isOnboarding ? true : false"
(save)="save()"
(navigateToPreviousStep)="navigateToPreviousStep()"></app-configuration-step-footer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export class QboAdvancedSettingsComponent implements OnInit {

readonly brandingContent = brandingContent.configuration.advancedSettings;

isSkipExportFormInvalid: boolean;

constructor(
private advancedSettingsService: QboAdvancedSettingsService,
private configurationService: ConfigurationService,
Expand All @@ -94,6 +96,10 @@ export class QboAdvancedSettingsComponent implements OnInit {
this.router.navigate([`/integrations/qbo/onboarding/import_settings`]);
}

invalidSkipExportForm($event: boolean) {
this.isSkipExportFormInvalid = $event;
}

private saveSkipExportFields(): void {
if (!this.skipExportForm.valid) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ <h4 class="tw-text-form-label-text-color tw-mb-12-px">Preview of the Description
[skipExportForm]="skipExportForm"
[expenseFilter]="expenseFilters"
[conditionFieldOptions]="conditionFieldOptions"
(deleteSkipExportForm)="deleteExpenseFilter($event)">
(deleteSkipExportForm)="deleteExpenseFilter($event)"
(invalidSkipExportForm)="invalidSkipExportForm($event)">
</app-configuration-skip-export>
</div>
</div>
Expand All @@ -94,6 +95,6 @@ <h4 class="tw-text-form-label-text-color tw-mb-12-px">Preview of the Description
(save)="save()"
[showBackButton] = "isOnboarding"
(navigateToPreviousStep)="navigateBack()"
[isButtonDisabled]="!advancedSettingForm.valid || !skipExportForm.valid || !getSkipExportValue()"></app-configuration-step-footer>
[isButtonDisabled]="!advancedSettingForm.valid || !skipExportForm.valid || !getSkipExportValue() || isSkipExportFormInvalid"></app-configuration-step-footer>
</form>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ export class Sage300AdvancedSettingsComponent implements OnInit {

readonly brandingConfig = brandingConfig;

isSkipExportFormInvalid: boolean;

constructor(
private advancedSettingsService: Sage300AdvancedSettingsService,
private helper: HelperService,
Expand All @@ -79,6 +81,10 @@ export class Sage300AdvancedSettingsComponent implements OnInit {
private router: Router
) { }

invalidSkipExportForm($event: boolean) {
this.isSkipExportFormInvalid = $event;
}

private formatMemoPreview(): void {
const time = Date.now();
const today = new Date(time);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ export class Sage300ImportSettingsComponent implements OnInit {
}

closeModel() {
this.customFieldControl.patchValue({
source_field: null
});
this.customFieldForm.reset();
this.showCustomFieldDialog = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@
[form]="advancedSettingForm"
[isFieldMandatory]="true"
[formControllerName]="'billPaymentAccount'"
[dropdownDisplayKey]="'value'"
[dropdownDisplayKey]="'name'"
[tooltipText]="'Once the payment for the reimbursable expense is complete in ' + brandingConfig.brandName + ', the payment entries will be posted to the selected Payment account in Xero.'">
</app-clone-setting-field>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export class ConfigurationSkipExportComponent implements OnInit {

@Output() deleteSkipExportForm = new EventEmitter<number>();

@Output() invalidSkipExportForm = new EventEmitter<boolean>();

isLoading: boolean = true;

showExpenseFilters: boolean;
Expand Down Expand Up @@ -90,7 +92,7 @@ export class ConfigurationSkipExportComponent implements OnInit {

private setConditionFields(response: ExpenseFilterResponse, conditionArray: ConditionField[]) {
response.results.forEach((element) => {
const type = this.conditionFieldOptions.filter( (fieldOption) => fieldOption.field_name === element.condition);
const type = this.conditionFieldOptions.filter( (fieldOption) => fieldOption.field_name.toLowerCase() === element.condition.toLowerCase());
const selectedConditionOption : ConditionField = type[0];
conditionArray.push(selectedConditionOption);
});
Expand Down Expand Up @@ -209,11 +211,12 @@ export class ConfigurationSkipExportComponent implements OnInit {
if (this.showAdditionalCondition) {
if (condition1.valid && condition2.valid) {
if (condition1.value?.field_name === condition2.value?.field_name) {
this.skipExportForm.controls.operator2.setValue(null);
this.invalidSkipExportForm.emit(true);
return true;
}
}
}
this.invalidSkipExportForm.emit(false);
return false;
}

Expand Down Expand Up @@ -244,6 +247,7 @@ export class ConfigurationSkipExportComponent implements OnInit {
}

setDefaultOperatorOptions(conditionField: string) {
conditionField = conditionField.toLowerCase();
const operatorList = [];
if (
conditionField === 'claim_number' ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@
</p-dropdown>
<app-mandatory-error-message *ngIf="skipExportForm.controls.condition2.touched && !skipExportForm.controls.condition2.valid"
[customErrorMessage]="'Please select the condition'"></app-mandatory-error-message>
<app-mandatory-error-message *ngIf="checkValidationCondition()"
[customErrorMessage]="'Condition selected should be distinct.'"></app-mandatory-error-message>
</div>
<div class="tw-mr-24-px">
<p-dropdown appendTo="body" [options]="operatorFieldOptions2" formControlName="operator2" placeholder="Select Operator"></p-dropdown>
Expand All @@ -117,9 +119,6 @@
<app-svg-icon [svgSource]="'bin'" [width]="'24px'" [height]="'24px'" [styleClasses]="'tw-text-sub-text-color tw-text-center tw-cursor-pointer'" [tooltipText]="'Remove Condition'" (iconClick)="remCondition()"></app-svg-icon>
</div>
</div>
<div class=" tw-text-mandatory-field-color" *ngIf="checkValidationCondition()">
<p>*Condition selected should be distinct.</p>
</div>
</div>
<div class="tw-flex items-center tw-text-mandatory-field-color tw-pt-12-px tw-pb-24-px" *ngIf="showAddButton">
<app-svg-icon [svgSource]="'plus-square-medium'" [width]="'18px'" [height]="'18px'" (iconClick)="updateAdditionalFilterVisibility(true)"></app-svg-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { forkJoin } from 'rxjs';
import { constructPayload1, constructPayload2 } from 'src/app/core/models/intacct/misc/skip-export.model';
import { ConditionField, CustomOperatorOption, ExpenseFilterResponse, JoinOptions, SkipExport } from 'src/app/core/models/intacct/intacct-configuration/advanced-settings.model';
import { SiAdvancedSettingService } from 'src/app/core/services/si/si-configuration/si-advanced-setting.service';
import { RxwebValidators } from '@rxweb/reactive-form-validators';

@Component({
selector: 'app-skip-export',
Expand All @@ -18,6 +19,8 @@ export class SkipExportComponent implements OnInit {

@Output() skipExportFormChange = new EventEmitter<FormGroup>();

@Output() invalidSkipExportForm = new EventEmitter<boolean>();

isLoading: boolean = true;

expenseFilters: SkipExport[];
Expand Down Expand Up @@ -125,7 +128,7 @@ export class SkipExportComponent implements OnInit {

private setConditionFields(response: ExpenseFilterResponse, conditionArray: ConditionField[]) {
response.results.forEach((element) => {
const type = this.conditionFieldOptions.filter( (fieldOption) => fieldOption.field_name === element.condition);
const type = this.conditionFieldOptions.filter((fieldOption) => fieldOption.field_name.toLowerCase() === element.condition.toLowerCase());
const selectedConditionOption : ConditionField = type[0];
conditionArray.push(selectedConditionOption);
});
Expand Down Expand Up @@ -226,7 +229,7 @@ export class SkipExportComponent implements OnInit {
this.showAddButton = !show;
if (this.showAdditionalCondition) {
this.skipExportForm.controls.join_by.setValidators(Validators.required);
this.skipExportForm.controls.condition2.setValidators(Validators.required);
this.skipExportForm.controls.condition2.setValidators([Validators.required, RxwebValidators.unique()]);
this.skipExportForm.controls.operator2.setValidators(Validators.required);
if (this.valueOption2.length===0) {
this.skipExportForm.controls.value2.setValidators(Validators.required);
Expand Down Expand Up @@ -254,11 +257,12 @@ export class SkipExportComponent implements OnInit {
if (this.showAdditionalCondition) {
if (condition1.valid && condition2.valid) {
if (condition1.value?.field_name === condition2.value?.field_name) {
this.skipExportForm.controls.operator2.setValue(null);
this.invalidSkipExportForm.emit(true);
return true;
}
}
}
this.invalidSkipExportForm.emit(false);
return false;
}

Expand Down Expand Up @@ -382,6 +386,7 @@ export class SkipExportComponent implements OnInit {
}

setDefaultOperatorOptions(conditionField: string) {
conditionField = conditionField.toLowerCase();
const operatorList = [];
if (
conditionField === 'claim_number' ||
Expand Down Expand Up @@ -567,7 +572,7 @@ export class SkipExportComponent implements OnInit {
if (response.count === 2) {
this.showAdditionalCondition = true;
this.showAddButton = false;
this.skipExportForm.controls.condition2.setValidators(Validators.required);
this.skipExportForm.controls.condition2.setValidators([Validators.required, RxwebValidators.unique()]);
this.skipExportForm.controls.operator2.setValidators(Validators.required);
this.skipExportForm.controls.join_by.setValidators(Validators.required);
if (!this.valueOption2.length && !(selectedOperator2 === 'is_empty' || selectedOperator2 === 'is_not_empty')) {
Expand Down

0 comments on commit 57fb635

Please sign in to comment.