Skip to content

Commit

Permalink
memo field fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DhaaraniCIT committed Jun 4, 2024
1 parent c2b87ad commit 1d57bde
Show file tree
Hide file tree
Showing 12 changed files with 68 additions and 18 deletions.
7 changes: 5 additions & 2 deletions src/app/core/models/common/advanced-settings.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AdvancedSettingsModel {
return ['employee_email', 'merchant', 'purpose', 'category', 'spent_on', 'report_number', 'expense_link'];
}

static formatMemoPreview(memoStructure: string[], defaultMemoOptions: string[]): string {
static formatMemoPreview(memoStructure: string[], defaultMemoOptions: string[]): [string, string[]] {
const time = Date.now();
const today = new Date(time);

Expand All @@ -87,19 +87,22 @@ export class AdvancedSettingsModel {
};
let memoPreviewText = '';
const memo: string[] = [];
const originMemo: string[] = [];
memoStructure.forEach((field, index) => {
if (field in previewValues) {
const defaultIndex = defaultMemoOptions.indexOf(memoStructure[index]);
memo[defaultIndex] = previewValues[field];
originMemo[defaultIndex] = field;
}
});
memoStructure = originMemo.filter(item => item.trim() !== '');
memo.forEach((field, index) => {
memoPreviewText += field;
if (index + 1 !== memo.length) {
memoPreviewText = memoPreviewText + ' - ';
}
});
return memoPreviewText;
return [memoPreviewText, memoStructure];
}

static filterAdminEmails = (emailToSearch: string[], adminEmails: EmailOption[]) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { NetsuiteDefaultLevelOptions, NetsuitePaymentSyncDirection, QBOPaymentSy
import { AdvancedSettingValidatorRule, AdvancedSettingsModel } from "../../common/advanced-settings.model";
import { HelperUtility } from "../../common/helper.model";
import { brandingConfig } from "src/app/branding/branding-config";
import { environment } from "src/environments/environment";


export type NetsuiteAdvancedSettingConfiguration = {
Expand Down Expand Up @@ -65,7 +66,7 @@ export type NetsuiteAdvancedSettingAddEmailModel = {

export class NetsuiteAdvancedSettingModel extends HelperUtility {
static getDefaultMemoOptions(): string[] {
return ['employee_email', 'purpose', 'category', 'spent_on', 'report_number'];
return ['employee_email', 'merchant', 'purpose', 'category', 'spent_on', 'report_number'];
}

static getPaymentSyncOptions(): SelectFormOption[] {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@
[options]="defaultMemoOptions"
[iconPath]="'list'"
[placeholder]="'Set description'"
[formControllerName]="'memoStructure'">
[formControllerName]="'memoStructure'"
(changeInMultiSelect)="onMultiSelectChange()">
</app-configuration-multi-select>
<div class="preview-text">
<h4 class="tw-text-form-label-text-color tw-mb-12-px">Preview of the Description Field</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,20 @@ export class BusinessCentralAdvancedSettingsComponent implements OnInit {
this.helper.handleSkipExportFormInAdvancedSettingsUpdates(this.skipExportForm, formWatcher, this.advancedSettingForm);
}

onMultiSelectChange() {
const memo = this.advancedSettingForm.controls.memoStructure.value;
const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoOptions)[1];
this.advancedSettingForm.controls.memoStructure.patchValue(changedMemo);
}

private createMemoStructureWatcher(): void {
this.memoStructure = this.advancedSettingForm.value.memoStructure;
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
const memo = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
this.memoPreviewText = memo[0];
this.advancedSettingForm.controls.memoStructure.patchValue(memo[1]);
this.advancedSettingForm.controls.memoStructure.valueChanges.subscribe((memoChanges) => {
this.memoStructure = memoChanges;
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions)[0];
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,8 @@
[options]="defaultMemoOptions"
[iconPath]="'list'"
[placeholder]="'Set description'"
[formControllerName]="'memoStructure'">
[formControllerName]="'memoStructure'"
(changeInMultiSelect)="onMultiSelectChange()">
</app-configuration-multi-select>
<div class="preview-text">
<h4 class="tw-text-form-label-text-color tw-mb-12-px">{{brandingContent.previewDescriptionFieldLabel}}</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,19 @@ export class NetsuiteAdvancedSettingsComponent implements OnInit {
return this.workspaceGeneralSettings.reimbursable_expenses_object && this.workspaceGeneralSettings.reimbursable_expenses_object !== NetsuiteReimbursableExpensesObject.JOURNAL_ENTRY;
}

onMultiSelectChange() {
const memo = this.advancedSettingForm.controls.memoStructure.value;
const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoOptions)[1];
this.advancedSettingForm.controls.memoStructure.patchValue(changedMemo);
}

private createMemoStructureWatcher(): void {
this.memoStructure = this.advancedSetting.configuration.memo_structure;
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
const memo: [string, string[]] = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
this.memoPreviewText = memo[0];
this.advancedSettingForm.controls.memoStructure.patchValue(memo[1]);
this.advancedSettingForm.controls.memoStructure.valueChanges.subscribe((memoChanges) => {
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(memoChanges, this.defaultMemoOptions);
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(memoChanges, this.defaultMemoOptions)[0];
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,8 @@
[iconPath]="'list'"
[placeholder]="'Set description'"
[formControllerName]="'memoStructure'"
[isCloneSettingView]="true">
[isCloneSettingView]="true"
(changeInMultiSelect)="onMultiSelectChange()">
</app-configuration-multi-select>
</div>
<div class="clone-setting--dependent-field tw-text-14-px tw-font-400 tw-text-text-muted !tw-pl-40-px">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,11 +340,19 @@ export class QboCloneSettingsComponent implements OnInit {
});
}

onMultiSelectChange() {
const memo = this.advancedSettingForm.controls.memoStructure.value;
const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoOptions)[1];
this.advancedSettingForm.controls.memoStructure.patchValue(changedMemo);
}

private createMemoStructureWatcher(): void {
this.memoStructure = this.cloneSetting.advanced_configurations.workspace_general_settings.memo_structure;
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
const memo = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
this.memoPreviewText = memo[0];
this.advancedSettingForm.controls.memoStructure.patchValue(memo[1]);
this.advancedSettingForm.controls.memoStructure.valueChanges.subscribe((memoChanges) => {
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(memoChanges, this.defaultMemoOptions);
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(memoChanges, this.defaultMemoOptions)[0];
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@
[options]="defaultMemoOptions"
[iconPath]="'list'"
[placeholder]="'Set description'"
[formControllerName]="'memoStructure'">
[formControllerName]="'memoStructure'"
(changeInMultiSelect)="onMultiSelectChange()">
</app-configuration-multi-select>
<div class="preview-text">
<h4 class="tw-text-form-label-text-color tw-mb-12-px">{{brandingContent.previewDescriptionFieldLabel}}</h4>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,14 +170,23 @@ export class QboAdvancedSettingsComponent implements OnInit {
return !this.workspaceGeneralSettings.import_vendors_as_merchants && (this.workspaceGeneralSettings.corporate_credit_card_expenses_object === QBOCorporateCreditCardExpensesObject.CREDIT_CARD_PURCHASE || this.workspaceGeneralSettings.corporate_credit_card_expenses_object === QBOCorporateCreditCardExpensesObject.DEBIT_CARD_EXPENSE || this.workspaceGeneralSettings.name_in_journal_entry === NameInJournalEntry.MERCHANT);
}

onMultiSelectChange() {
const memo = this.advancedSettingForm.controls.memoStructure.value;
const changedMemo = AdvancedSettingsModel.formatMemoPreview(memo, this.defaultMemoOptions)[1];
this.advancedSettingForm.controls.memoStructure.patchValue(changedMemo);
}

private createMemoStructureWatcher(): void {
this.memoStructure = this.advancedSetting.workspace_general_settings.memo_structure;
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
this.memoStructure = this.advancedSettingForm.value.memoStructure;
const memo = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions);
this.memoPreviewText = memo[0];
this.advancedSettingForm.controls.memoStructure.patchValue(memo[1]);
this.advancedSettingForm.controls.memoStructure.valueChanges.subscribe((memoChanges) => {
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(memoChanges, this.defaultMemoOptions);
this.memoPreviewText = AdvancedSettingsModel.formatMemoPreview(this.memoStructure, this.defaultMemoOptions)[0];
});
}


skipExportWatcher(): void {
const skipExportFormWatcherFields: SkipExportValidatorRule = {
condition1: ['operator1', 'value1'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ <h5 class="!tw-text-text-muted tw-text-14-px !tw-font-400 !tw-leading-4" [innerH
</div>
</div>
<div class="tw-pl-34-px">
<p-multiSelect [options]="options" styleClass="tw-z-2 tw-py-8-px tw-px-12-px" [formControlName]="formControllerName" [defaultLabel]="placeholder" [ngClass]="[form.controls[formControllerName].invalid && isFieldMandatory ? 'error-box' : 'normal-box']" [dropdownIcon]="'pi pi-chevron-down ' + brandingConfig.brandId">
<p-multiSelect [options]="options" styleClass="tw-z-2 tw-py-8-px tw-px-12-px" [formControlName]="formControllerName" [defaultLabel]="placeholder"
[ngClass]="[form.controls[formControllerName].invalid && isFieldMandatory ? 'error-box' : 'normal-box']"
[dropdownIcon]="'pi pi-chevron-down ' + brandingConfig.brandId"
(onChange)="onMultiSelectChange()">
<ng-template let-value pTemplate="selectedItems" >
<div *ngIf="form.value[formControllerName]?.length>0" class="tw-flex">
<p *ngFor="let name of value;let i = index">{{ name | titlecase | snakeCaseToSpaceCase }}<span *ngIf="i !== value?.length-1">,&nbsp;</span></p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { brandingConfig } from 'src/app/branding/branding-config';

Expand Down Expand Up @@ -31,6 +31,8 @@ export class ConfigurationMultiSelectComponent implements OnInit {

@Input() isCloneSettingView: boolean;

@Output() changeInMultiSelect = new EventEmitter();

currentlyDragging: string | null;

selected: any[];
Expand All @@ -43,6 +45,10 @@ export class ConfigurationMultiSelectComponent implements OnInit {
private formBuilder: FormBuilder
) { }

onMultiSelectChange() {
this.changeInMultiSelect.emit();
}

// DragStart(memo: string) {
// This.currentlyDragging = memo;
// }
Expand Down

0 comments on commit 1d57bde

Please sign in to comment.