Compare commits
2 Commits
db595708f7
...
60ee6a0c24
| Author | SHA1 | Date | |
|---|---|---|---|
| 60ee6a0c24 | |||
| 112d558986 |
+3
-3
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
"$schema": "./node_modules/@angular/service-worker/config/schema.json",
|
||||||
"appData": {
|
"appData": {
|
||||||
"appVersion": "0.0.23",
|
"appVersion": "0.0.24",
|
||||||
"buildDate": "2026-05-16T17:49:14.877Z",
|
"buildDate": "2026-05-16T20:25:55.273Z",
|
||||||
"buildNumber": 23
|
"buildNumber": 24
|
||||||
},
|
},
|
||||||
"assetGroups": [
|
"assetGroups": [
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -70,8 +70,6 @@
|
|||||||
"build": "ng build",
|
"build": "ng build",
|
||||||
"build:tis": "ng build --configuration tis",
|
"build:tis": "ng build --configuration tis",
|
||||||
"ng": "ng",
|
"ng": "ng",
|
||||||
"prebuild": "node scripts/update-ngsw-appdata.js",
|
|
||||||
"prebuild:tis": "node scripts/tis/update-tis-ngsw-appdata.js",
|
|
||||||
"prestart": "node aspnetcore-https",
|
"prestart": "node aspnetcore-https",
|
||||||
"start": "run-script-os",
|
"start": "run-script-os",
|
||||||
"start:tis": " ng serve --configuration tis",
|
"start:tis": " ng serve --configuration tis",
|
||||||
|
|||||||
@@ -13,6 +13,8 @@
|
|||||||
name="wages"
|
name="wages"
|
||||||
label="اجرت"
|
label="اجرت"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{{ initialValues?.payload?.profit }}
|
||||||
<app-amount-percentage-input
|
<app-amount-percentage-input
|
||||||
[percentageControl]="form.controls.payload.controls.commission_percentage"
|
[percentageControl]="form.controls.payload.controls.commission_percentage"
|
||||||
[amountControl]="form.controls.payload.controls.commission"
|
[amountControl]="form.controls.payload.controls.commission"
|
||||||
|
|||||||
@@ -31,16 +31,16 @@ export class PosGoldPayloadFormComponent extends AbstractForm<
|
|||||||
IPosOrderItem<IGoldPayload>,
|
IPosOrderItem<IGoldPayload>,
|
||||||
IPosOrderItem<IGoldPayload>
|
IPosOrderItem<IGoldPayload>
|
||||||
> {
|
> {
|
||||||
override defaultValues: Partial<IPosOrderItem<IGoldPayload>> = {
|
// override defaultValues: Partial<IPosOrderItem<IGoldPayload>> = {
|
||||||
unit_price: 200_000_000,
|
// unit_price: 200_000_000,
|
||||||
quantity: 2,
|
// quantity: 2,
|
||||||
payload: {
|
// payload: {
|
||||||
// commission: 10_000,
|
// // commission: 10_000,
|
||||||
// wages: 10_000,
|
// // wages: 10_000,
|
||||||
// profit: 10_000,
|
// // profit: 10_000,
|
||||||
karat: 'KARAT_18' as TGoldKarat,
|
// karat: 'KARAT_18' as TGoldKarat,
|
||||||
} as any,
|
// } as any,
|
||||||
};
|
// };
|
||||||
|
|
||||||
@Output() onSubmitForm = new EventEmitter<IGoldPayload>();
|
@Output() onSubmitForm = new EventEmitter<IGoldPayload>();
|
||||||
@Output() onChangeTotalAmount = new EventEmitter<number>();
|
@Output() onChangeTotalAmount = new EventEmitter<number>();
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
<p-inputgroup>
|
<p-inputgroup>
|
||||||
@if (selectedType.value === "amount") {
|
@if (selectedType.value === "amount") {
|
||||||
<p-inputnumber
|
<p-inputnumber
|
||||||
|
#amountInput
|
||||||
[attr.id]="name"
|
[attr.id]="name"
|
||||||
[formControl]="amountControl"
|
[formControl]="amountControl"
|
||||||
[attr.name]="name"
|
[attr.name]="name"
|
||||||
@@ -31,6 +32,7 @@
|
|||||||
/>
|
/>
|
||||||
} @else {
|
} @else {
|
||||||
<input
|
<input
|
||||||
|
#percentageInput
|
||||||
pInputText
|
pInputText
|
||||||
[attr.id]="name"
|
[attr.id]="name"
|
||||||
[formControl]="percentageControl"
|
[formControl]="percentageControl"
|
||||||
|
|||||||
+34
-11
@@ -8,18 +8,20 @@ import {
|
|||||||
Component,
|
Component,
|
||||||
ContentChild,
|
ContentChild,
|
||||||
DestroyRef,
|
DestroyRef,
|
||||||
|
ElementRef,
|
||||||
EventEmitter,
|
EventEmitter,
|
||||||
inject,
|
inject,
|
||||||
Input,
|
Input,
|
||||||
Output,
|
Output,
|
||||||
signal,
|
signal,
|
||||||
TemplateRef,
|
TemplateRef,
|
||||||
|
ViewChild,
|
||||||
} from '@angular/core';
|
} from '@angular/core';
|
||||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||||
import { InputGroup } from 'primeng/inputgroup';
|
import { InputGroup } from 'primeng/inputgroup';
|
||||||
import { InputGroupAddon } from 'primeng/inputgroupaddon';
|
import { InputGroupAddon } from 'primeng/inputgroupaddon';
|
||||||
import { InputNumberModule } from 'primeng/inputnumber';
|
import { InputNumber, InputNumberModule } from 'primeng/inputnumber';
|
||||||
import { InputText } from 'primeng/inputtext';
|
import { InputText } from 'primeng/inputtext';
|
||||||
import { Select } from 'primeng/select';
|
import { Select } from 'primeng/select';
|
||||||
|
|
||||||
@@ -70,6 +72,8 @@ export class AmountPercentageInputComponent {
|
|||||||
@Output() blur = new EventEmitter<void>();
|
@Output() blur = new EventEmitter<void>();
|
||||||
|
|
||||||
@ContentChild('labelSuffix', { static: false }) labelSuffix!: TemplateRef<any> | null;
|
@ContentChild('labelSuffix', { static: false }) labelSuffix!: TemplateRef<any> | null;
|
||||||
|
@ViewChild('amountInput') amountInput?: InputNumber;
|
||||||
|
@ViewChild('percentageInput') percentageInput?: ElementRef<HTMLInputElement>;
|
||||||
|
|
||||||
private readonly toastService = inject(ToastService);
|
private readonly toastService = inject(ToastService);
|
||||||
|
|
||||||
@@ -107,7 +111,12 @@ export class AmountPercentageInputComponent {
|
|||||||
return value >= min && value <= max;
|
return value >= min && value <= max;
|
||||||
}
|
}
|
||||||
|
|
||||||
private showOutOfRangeToast(value: number, isPercentageType: boolean, min = 0, max = Number.MAX_SAFE_INTEGER) {
|
private showOutOfRangeToast(
|
||||||
|
value: number,
|
||||||
|
isPercentageType: boolean,
|
||||||
|
min = 0,
|
||||||
|
max = Number.MAX_SAFE_INTEGER,
|
||||||
|
) {
|
||||||
if (value < min) {
|
if (value < min) {
|
||||||
this.toastService.warn({
|
this.toastService.warn({
|
||||||
text: `مقدار ${this.label} باید بیشتر از ${this.getRangeLabel(min, isPercentageType)} باشد.`,
|
text: `مقدار ${this.label} باید بیشتر از ${this.getRangeLabel(min, isPercentageType)} باشد.`,
|
||||||
@@ -120,6 +129,18 @@ export class AmountPercentageInputComponent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private resetAmountInputView(value: number) {
|
||||||
|
const inputEl = this.amountInput?.input?.nativeElement;
|
||||||
|
if (!inputEl) return;
|
||||||
|
inputEl.value = value ? value.toLocaleString('en-US') : '0';
|
||||||
|
}
|
||||||
|
|
||||||
|
private resetPercentageInputView(value: number) {
|
||||||
|
const inputEl = this.percentageInput?.nativeElement;
|
||||||
|
if (!inputEl) return;
|
||||||
|
inputEl.value = `${value}`;
|
||||||
|
}
|
||||||
|
|
||||||
private getAmountRange() {
|
private getAmountRange() {
|
||||||
const min = this.minAmount ?? 0;
|
const min = this.minAmount ?? 0;
|
||||||
const maxFromInput = this.maxAmount;
|
const maxFromInput = this.maxAmount;
|
||||||
@@ -138,7 +159,8 @@ export class AmountPercentageInputComponent {
|
|||||||
const percentageValue = this.parseValue(rawValue);
|
const percentageValue = this.parseValue(rawValue);
|
||||||
if (!this.isInRange(percentageValue, min, max)) {
|
if (!this.isInRange(percentageValue, min, max)) {
|
||||||
this.showOutOfRangeToast(percentageValue, true, min, max);
|
this.showOutOfRangeToast(percentageValue, true, min, max);
|
||||||
this.percentageControl.setValue(this.lastValidPercentage, { emitEvent: false });
|
this.percentageControl.setValue(this.lastValidPercentage);
|
||||||
|
this.resetPercentageInputView(this.lastValidPercentage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -146,8 +168,8 @@ export class AmountPercentageInputComponent {
|
|||||||
const amountValue = (this.baseAmount * percentageValue) / 100;
|
const amountValue = (this.baseAmount * percentageValue) / 100;
|
||||||
this.lastValidAmount = Number.isFinite(amountValue) ? amountValue : 0;
|
this.lastValidAmount = Number.isFinite(amountValue) ? amountValue : 0;
|
||||||
|
|
||||||
this.percentageControl.setValue(this.lastValidPercentage, { emitEvent: false });
|
this.percentageControl.setValue(this.lastValidPercentage);
|
||||||
this.amountControl.setValue(this.lastValidAmount, { emitEvent: false });
|
this.amountControl.setValue(this.lastValidAmount);
|
||||||
this.preparedLabel.set(this.prepareLabel(true));
|
this.preparedLabel.set(this.prepareLabel(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -156,7 +178,8 @@ export class AmountPercentageInputComponent {
|
|||||||
const amountValue = this.parseValue(rawValue);
|
const amountValue = this.parseValue(rawValue);
|
||||||
if (!this.isInRange(amountValue, min, max)) {
|
if (!this.isInRange(amountValue, min, max)) {
|
||||||
this.showOutOfRangeToast(amountValue, false, min, max);
|
this.showOutOfRangeToast(amountValue, false, min, max);
|
||||||
this.amountControl.setValue(this.lastValidAmount, { emitEvent: false });
|
this.amountControl.setValue(this.lastValidAmount);
|
||||||
|
this.resetAmountInputView(this.lastValidAmount);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,8 +189,8 @@ export class AmountPercentageInputComponent {
|
|||||||
: '0';
|
: '0';
|
||||||
this.lastValidPercentage = this.parseValue(percentageValue);
|
this.lastValidPercentage = this.parseValue(percentageValue);
|
||||||
|
|
||||||
this.amountControl.setValue(this.lastValidAmount, { emitEvent: false });
|
this.amountControl.setValue(this.lastValidAmount);
|
||||||
this.percentageControl.setValue(percentageValue, { emitEvent: false });
|
this.percentageControl.setValue(percentageValue);
|
||||||
this.preparedLabel.set(this.prepareLabel(false));
|
this.preparedLabel.set(this.prepareLabel(false));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,7 +202,7 @@ export class AmountPercentageInputComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
const isPercentageType = this.defaultType === 'percentage';
|
const isPercentageType = this.amountControl.value ? false : true;
|
||||||
|
|
||||||
this.selectedType.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => {
|
this.selectedType.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => {
|
||||||
this.preparedLabel.set(this.prepareLabel(value === 'percentage'));
|
this.preparedLabel.set(this.prepareLabel(value === 'percentage'));
|
||||||
@@ -199,7 +222,6 @@ export class AmountPercentageInputComponent {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
this.selectedType.setValue(isPercentageType ? 'percentage' : 'amount', { emitEvent: false });
|
|
||||||
this.lastValidAmount = this.parseValue(this.amountControl.value);
|
this.lastValidAmount = this.parseValue(this.amountControl.value);
|
||||||
this.lastValidPercentage = this.parseValue(this.percentageControl.value);
|
this.lastValidPercentage = this.parseValue(this.percentageControl.value);
|
||||||
if (isPercentageType) {
|
if (isPercentageType) {
|
||||||
@@ -207,10 +229,11 @@ export class AmountPercentageInputComponent {
|
|||||||
} else {
|
} else {
|
||||||
this.syncFromAmount(this.amountControl.value);
|
this.syncFromAmount(this.amountControl.value);
|
||||||
}
|
}
|
||||||
|
this.selectedType.setValue(isPercentageType ? 'percentage' : 'amount');
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges() {
|
ngOnChanges() {
|
||||||
const isPercentageType = this.selectedType.value === 'percentage';
|
const isPercentageType = this.amountControl.value ? false : true;
|
||||||
if (isPercentageType) {
|
if (isPercentageType) {
|
||||||
this.syncFromPercentage(this.percentageControl.value);
|
this.syncFromPercentage(this.percentageControl.value);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ import { Button } from 'primeng/button';
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-height: 0;
|
min-height: 0;
|
||||||
padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
|
// padding-bottom: calc(0.75rem + env(safe-area-inset-bottom));
|
||||||
-webkit-overflow-scrolling: touch;
|
-webkit-overflow-scrolling: touch;
|
||||||
overscroll-behavior: contain;
|
overscroll-behavior: contain;
|
||||||
}
|
}
|
||||||
@@ -133,6 +133,8 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha
|
|||||||
|
|
||||||
private originalParent: Node | null = null;
|
private originalParent: Node | null = null;
|
||||||
private readonly defaultDrawerZIndex = 1102;
|
private readonly defaultDrawerZIndex = 1102;
|
||||||
|
private previousBodyOverflow = '';
|
||||||
|
private previousBodyTouchAction = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly elementRef: ElementRef<HTMLElement>,
|
private readonly elementRef: ElementRef<HTMLElement>,
|
||||||
@@ -145,15 +147,20 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha
|
|||||||
this.originalParent = host.parentNode;
|
this.originalParent = host.parentNode;
|
||||||
this.renderer.appendChild(this.document.body, host);
|
this.renderer.appendChild(this.document.body, host);
|
||||||
this.syncZIndex();
|
this.syncZIndex();
|
||||||
|
this.toggleBodyScrollLock(this.visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (changes['visible'] && this.visible) {
|
if (changes['visible'] && this.visible) {
|
||||||
this.syncZIndex();
|
this.syncZIndex();
|
||||||
}
|
}
|
||||||
|
if (changes['visible']) {
|
||||||
|
this.toggleBodyScrollLock(this.visible);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnDestroy() {
|
ngOnDestroy() {
|
||||||
|
this.toggleBodyScrollLock(false);
|
||||||
this.removeDrawer();
|
this.removeDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,6 +174,7 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha
|
|||||||
onVisibilityChange(nextValue: boolean) {
|
onVisibilityChange(nextValue: boolean) {
|
||||||
this.visible = nextValue;
|
this.visible = nextValue;
|
||||||
this.visibleChange.emit(nextValue);
|
this.visibleChange.emit(nextValue);
|
||||||
|
this.toggleBodyScrollLock(nextValue);
|
||||||
if (nextValue) {
|
if (nextValue) {
|
||||||
this.syncZIndex();
|
this.syncZIndex();
|
||||||
}
|
}
|
||||||
@@ -181,6 +189,28 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private toggleBodyScrollLock(locked: boolean) {
|
||||||
|
const body = this.document.body;
|
||||||
|
if (!body) return;
|
||||||
|
|
||||||
|
if (locked) {
|
||||||
|
if (!this.previousBodyOverflow) {
|
||||||
|
this.previousBodyOverflow = body.style.overflow || '';
|
||||||
|
}
|
||||||
|
if (!this.previousBodyTouchAction) {
|
||||||
|
this.previousBodyTouchAction = body.style.touchAction || '';
|
||||||
|
}
|
||||||
|
this.renderer.setStyle(body, 'overflow', 'hidden');
|
||||||
|
this.renderer.setStyle(body, 'touch-action', 'none');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.renderer.setStyle(body, 'overflow', this.previousBodyOverflow);
|
||||||
|
this.renderer.setStyle(body, 'touch-action', this.previousBodyTouchAction);
|
||||||
|
this.previousBodyOverflow = '';
|
||||||
|
this.previousBodyTouchAction = '';
|
||||||
|
}
|
||||||
|
|
||||||
private syncZIndex() {
|
private syncZIndex() {
|
||||||
const host = this.elementRef.nativeElement;
|
const host = this.elementRef.nativeElement;
|
||||||
const siblingDrawers = Array.from(
|
const siblingDrawers = Array.from(
|
||||||
|
|||||||
Reference in New Issue
Block a user