Skip to content

Commit

Permalink
toogle input changes accross the app
Browse files Browse the repository at this point in the history
  • Loading branch information
DhaaraniCIT committed Jun 6, 2024
1 parent 1e0eb24 commit cf85ef5
Show file tree
Hide file tree
Showing 8 changed files with 83 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px tw-pt-8-px !tw-font-400 !tw-leading
<input type="text" class="tw-text-14-px tw-text-slightly-normal-text-color !tw-font-500 tw-w-300-px !tw-px-14-px !tw-py-10-px tw-border tw-border-solid !tw-border-separator tw-rounded-4-px" value="Category" disabled>
</div>
<div class="input-toggle-section tw-w-10-vw">
<p-inputSwitch formControlName="importCategories"></p-inputSwitch>
<app-toggle [form]="importSettingsForm" [formControllerName]="'importCategories'"></app-toggle>
</div>
</div>
<div class="tw-flex tw-pt-18-px">
Expand All @@ -57,7 +57,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px tw-pt-8-px !tw-font-400 !tw-leading
<input type="text" class="tw-text-14-px tw-text-slightly-normal-text-color !tw-font-500 tw-w-300-px !tw-px-14-px !tw-py-10-px tw-border tw-border-solid !tw-border-separator tw-rounded-4-px" value="Merchant" disabled>
</span>
<span class="input-toggle-section tw-w-10-vw">
<p-inputSwitch formControlName="importVendorAsMerchant"></p-inputSwitch>
<app-toggle [form]="importSettingsForm" [formControllerName]="'importVendorAsMerchant'"></app-toggle>
</span>
</div>
<div class="tw-flex tw-pt-18-px" *ngIf="isImportTaxVisible">
Expand All @@ -71,7 +71,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px tw-pt-8-px !tw-font-400 !tw-leading
<input type="text" class="tw-text-14-px tw-text-slightly-normal-text-color !tw-font-500 tw-w-300-px !tw-px-14-px !tw-py-10-px tw-border tw-border-solid !tw-border-separator tw-rounded-4-px" value="Tax Group" disabled>
</span>
<span class="input-toggle-section tw-w-10-vw">
<p-inputSwitch formControlName="importTaxCodes"></p-inputSwitch>
<app-toggle [form]="importSettingsForm" [formControllerName]="'importTaxCodes'"></app-toggle>
</span>
</div>
<div class="tw-flex tw-pl-48-px tw-pt-18-px" *ngIf="importSettingsForm.value?.importTaxCodes && isImportTaxVisible">
Expand Down Expand Up @@ -136,7 +136,9 @@ <h5 class="!tw-text-text-muted tw-text-14-px tw-pt-8-px !tw-font-400 !tw-leading
{{brandingConfig.brandName}} Fields should be unique
</p>
</div>
<p-inputSwitch (onChange)="showWarningForDependentFields($event, expenseField)" [pTooltip]="isExpenseFieldDependent(expenseField.value) ? 'You cannot import dependent fields' : '' " (iclick)="updateDependentField(expenseField.value.source_field,expenseField.value.import_to_fyle)" formControlName="import_to_fyle" class="tw-pl-32-px input-toggle-section"></p-inputSwitch>
<div class="tw-pl-32-px input-toggle-section">
<app-toggle [form]="importSettingsForm" [formControllerName]="'import_to_fyle'" [toolTipText]="isExpenseFieldDependent(expenseField.value) ? 'You cannot import dependent fields' : '' " (toggleChange)="showWarningForDependentFields($event, expenseField)" (toggleClick)="updateDependentField(expenseField.value.source_field,expenseField.value.import_to_fyle)"></app-toggle>
</div>
</div>
<div class="tw-pt-26-px" *ngIf="expenseField.value.source_field === 'PROJECT' && expenseField.value.destination_field === 'PROJECT' && expenseField.value.import_to_fyle" [formGroup]="importSettingsForm">
<div class="tw-flex">
Expand All @@ -162,7 +164,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px tw-pt-8-px !tw-font-400 !tw-leading
</div>
</ng-template>
</p-dropdown>
<p-inputSwitch class="tw-pl-32-px input-toggle-section" formControlName="dependentFieldImportToggle" [disabled]="true"></p-inputSwitch>
<app-toggle [form]="importSettingsForm" class="tw-pl-32-px input-toggle-section" [formControllerName]="'dependentFieldImportToggle'" [isDisabled]="true"></app-toggle>
</div>
<div class="tw-flex tw-pt-4" *ngIf="importSettingsForm.value.isDependentImportEnabled">
<div>
Expand All @@ -180,7 +182,7 @@ <h5 class="!tw-text-text-muted tw-text-14-px tw-pt-8-px !tw-font-400 !tw-leading
{{ option.display_name }} </div>
</ng-template>
</p-dropdown>
<p-inputSwitch class="tw-pl-32-px input-toggle-section" formControlName="dependentFieldImportToggle" [disabled]="true"></p-inputSwitch>
<app-toggle [form]="importSettingsForm" class="tw-pl-32-px input-toggle-section" [formControllerName]="'dependentFieldImportToggle'" [isDisabled]="true"></app-toggle>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<app-svg-icon [width]="'16px'" [height]="'16px'" [svgSource]="'info-circle-fill'" [styleClasses]="'tw-text-placeholder tw-ml-8-px'" [tooltipText]="'Enable this to export the reimbursable expenses from ' + brandingConfig.brandName + '. If not enabled, any out-of-pocket expenses will not be exported to QuickBooks Online'" [tooltipPosition]="'top'"></app-svg-icon>
</div>
<div>
<p-inputSwitch formControlName="reimbursableExpense"></p-inputSwitch>
<app-toggle [form]="exportSettingForm" [formControllerName]="'reimbursableExpense'"></app-toggle>
</div>
</div>
</div>
Expand Down Expand Up @@ -151,7 +151,7 @@
<app-svg-icon [width]="'16px'" [height]="'16px'" [svgSource]="'info-circle-fill'" [styleClasses]="'tw-text-placeholder tw-ml-8-px'" [tooltipText]="'Enable this to export the Non-Reimbursable expenses from ' + brandingConfig.brandName + '. If not enabled, any out-of-pocket expenses will not be exported to QuickBooks Online'" [tooltipPosition]="'top'"></app-svg-icon>
</div>
<div>
<p-inputSwitch formControlName="creditCardExpense"></p-inputSwitch>
<app-toggle [form]="exportSettingForm" [formControllerName]="'creditCardExpense'"></app-toggle>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<input type="text" class="tw-text-14-px tw-text-text-secondary !tw-font-500 tw-w-300-px !tw-px-14-px !tw-py-10-px tw-border tw-border-solid !tw-border-border-tertiary tw-rounded-4-px" value="{{ defaultField.source_field | snakeCaseToSpaceCase | titlecase }}" disabled>
</div>
<div class="input-toggle-section tw-w-10-vw tw-pt-10-px">
<p-inputSwitch [formControlName]="defaultField.formController"></p-inputSwitch>
<app-toggle [form]="form" [formControllerName]="defaultField.formController"></app-toggle>
</div>
</div>
</div>
Expand All @@ -49,7 +49,7 @@ <h5 *ngIf="!isCloneSettingView" class="!tw-text-text-muted tw-text-14-px !tw-fon
</div>
</div>
<div class="configuration--input-toggle-section">
<p-inputSwitch formControlName="import_to_fyle" [disabled]="(expenseField.value.destination_field === 'CUSTOMER' && appName === AppName.XERO && isXeroProjectMapped)" [tooltipPosition]="'top'" [pTooltip]="expenseField.value.destination_field === 'CUSTOMER' && appName === AppName.XERO && isXeroProjectMapped ? brandingXeroContent : ''"></p-inputSwitch>
<app-toggle [form]="form" [formControllerName]="'import_to_fyle'" [isDisabled]="(expenseField.value.destination_field === 'CUSTOMER' && appName === AppName.XERO && isXeroProjectMapped)" [toolTipText]="expenseField.value.destination_field === 'CUSTOMER' && appName === AppName.XERO && isXeroProjectMapped ? brandingXeroContent : ''"></app-toggle>
</div>
</div>
</div>
Expand Down Expand Up @@ -99,7 +99,9 @@ <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>
<div *ngIf="!isDestinationFixedImport" [ngClass]="{'input-toggle-section tw-pl-4-px tw-pt-10-px': !isDestinationFixedImport}">
<app-toggle [form]="form" [formControllerName]="'import_to_fyle'" [isDisabled]="false" (toggleChange)="onShowWarningForDependentFields($event, expenseField)" [toolTipText]="isExpenseFieldDependent(expenseField.value) ? 'You cannot import dependent fields' : ''" (toggleClick)="updateDependentField(expenseField.value.source_field,expenseField.value.import_to_fyle)"></app-toggle>
</div>
</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 Expand Up @@ -140,7 +142,9 @@ <h5 *ngIf="!isCloneSettingView" class="!tw-text-text-muted tw-text-14-px !tw-fon
</ng-template>
</p-dropdown>
</div>
<p-inputSwitch class="tw-pl-32-px input-toggle-section tw-pt-40-px" formControlName="dependentFieldImportToggle" [disabled]="true"></p-inputSwitch>
<div class="tw-pl-32-px input-toggle-section tw-pt-40-px">
<app-toggle [form]="form" [formControllerName]="'dependentFieldImportToggle'" [isDisabled]="true"></app-toggle>
</div>
</div>
<div *ngIf="appName === AppName.SAGE300" class="tw-flex tw-mt-24-px">
<label class="container tw-pl-24-px tw-text-14-px">Auto-Export Commitment based on the Cost Code and Cost Category.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ <h5 class="!tw-text-text-muted tw-text-14-px !tw-font-400 !tw-leading-4" [ngClas
</div>
</div>
<div *ngIf="!hideToggle" class="configuration--input-toggle-section">
<p-inputSwitch [formControlName]="formControllerName" [disabled]="disabled" [tooltipPosition]="'top'" [pTooltip]="disabled && appName === AppName.XERO ? brandingXeroContent : ''"></p-inputSwitch>
<app-toggle [form]="form" [formControllerName]="formControllerName" [isDisabled]="disabled" [toolTipText]="disabled && appName === AppName.XERO ? brandingXeroContent : ''"></app-toggle>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<div [formGroup]="form">
<p-inputSwitch [formControlName]="formControllerName" [disabled]="isDisabled"></p-inputSwitch>
<p-inputSwitch [formControlName]="formControllerName" [disabled]="isDisabled" [tooltipPosition]="'top'" [pTooltip]="toolTipText" (onChange)="onToggleChange()" (click)="onToggleClick()"></p-inputSwitch>
</div>
41 changes: 41 additions & 0 deletions src/app/shared/components/input/toggle/toggle.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.p-inputswitch {
@apply
tw-h-20-px tw-w-50-px #{!important};

&.p-focus .p-inputswitch-slider {
@apply tw-shadow-none #{!important};
}

.p-inputswitch-slider {
@apply
tw-bg-form-switch-bg tw-w-toggle-width tw-h-toggle-height #{!important};
&:before {
@apply
tw-mt-[-0.425rem] tw-w-14-px tw-h-14-px #{!important};
}
}

&.p-inputswitch-checked .p-inputswitch-slider {
@apply
tw-bg-mandatory-field-color tw-w-toggle-width tw-h-toggle-height #{!important};
&:before {
@apply
tw-translate-x-toggle-circle-translate #{!important};
}
&::after {
@apply
tw-content-toggle-text-yes tw-flex tw-justify-center tw-items-center tw-absolute tw-text-12-px tw-text-white tw-font-500 tw-left-8-px tw-bottom-0 #{!important};
}
}

&:not(.p-inputswitch-checked) .p-inputswitch-slider::after {
@apply
tw-content-toggle-text-no tw-flex tw-justify-center tw-items-center tw-absolute tw-text-12-px tw-text-white tw-font-500 tw-left-24-px tw-bottom-0 #{!important};
}
}

[data-theme='co'] {
.p-inputswitch .p-inputswitch-slider:before {
@apply tw-w-18-px tw-h-18-px tw-left-0 tw-mt-[-0.55rem] tw-ml-2-px #{!important};
}
}
23 changes: 21 additions & 2 deletions src/app/shared/components/input/toggle/toggle.component.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,38 @@
import { Component, Input, OnInit } from '@angular/core';
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { brandingContent } from 'src/app/branding/branding-config';
import { AppName } from 'src/app/core/models/enum/enum.model';

@Component({
selector: 'app-toggle',
templateUrl: './toggle.component.html',
styleUrls: ['./toggle.component.scss']
})
export class ToggleComponent {
export class ToggleComponent implements OnInit {

@Input() form: FormGroup;

@Input() formControllerName: string;

@Input() isDisabled: boolean;

@Input() toolTipText: string = '';

@Output() toggleChange = new EventEmitter();

@Output() toggleClick = new EventEmitter();

constructor() { }

onToggleChange() {
this.toggleChange.emit();
}

onToggleClick() {
this.toggleClick.emit();
}

ngOnInit(): void {
}

}
42 changes: 1 addition & 41 deletions src/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@import 'assets/themes/theme.scss';
@import 'assets/themes/co/c1dl.scss';
@import 'assets/themes/fyle/fdl.scss';
@import './app/shared/components/input/toggle/toggle.component.scss';



Expand Down Expand Up @@ -223,47 +224,6 @@ p {
}

// Toggle
.p-inputswitch {
@apply
tw-h-20-px tw-w-50-px #{!important};

&.p-focus .p-inputswitch-slider {
@apply tw-shadow-none #{!important};
}

.p-inputswitch-slider {
@apply
tw-bg-form-switch-bg tw-w-toggle-width tw-h-toggle-height #{!important};
&:before {
@apply
tw-mt-[-0.425rem] tw-w-14-px tw-h-14-px #{!important};
}
}

&.p-inputswitch-checked .p-inputswitch-slider {
@apply
tw-bg-mandatory-field-color tw-w-toggle-width tw-h-toggle-height #{!important};
&:before {
@apply
tw-translate-x-toggle-circle-translate #{!important};
}
&::after {
@apply
tw-content-toggle-text-yes tw-flex tw-justify-center tw-items-center tw-absolute tw-text-12-px tw-text-white tw-font-500 tw-left-8-px tw-bottom-0 #{!important};
}
}

&:not(.p-inputswitch-checked) .p-inputswitch-slider::after {
@apply
tw-content-toggle-text-no tw-flex tw-justify-center tw-items-center tw-absolute tw-text-12-px tw-text-white tw-font-500 tw-left-24-px tw-bottom-0 #{!important};
}
}

[data-theme='co'] {
.p-inputswitch .p-inputswitch-slider:before {
@apply tw-w-18-px tw-h-18-px tw-left-0 tw-mt-[-0.55rem] tw-ml-2-px #{!important};
}
}


// Radio Button
Expand Down

0 comments on commit cf85ef5

Please sign in to comment.