diff --git a/ngsw-config.json b/ngsw-config.json index 9f2ec7a..11911f7 100644 --- a/ngsw-config.json +++ b/ngsw-config.json @@ -1,9 +1,9 @@ { "$schema": "./node_modules/@angular/service-worker/config/schema.json", "appData": { - "appVersion": "0.0.23", - "buildDate": "2026-05-16T17:49:14.877Z", - "buildNumber": 23 + "appVersion": "0.0.24", + "buildDate": "2026-05-16T20:25:55.273Z", + "buildNumber": 24 }, "assetGroups": [ { diff --git a/package.json b/package.json index 39adfe5..1fa7dbf 100644 --- a/package.json +++ b/package.json @@ -70,8 +70,8 @@ "build": "ng build", "build:tis": "ng build --configuration tis", "ng": "ng", - "prebuild": "node scripts/update-ngsw-appdata.js", - "prebuild:tis": "node scripts/tis/update-tis-ngsw-appdata.js", + // "prebuild": "node scripts/update-ngsw-appdata.js", + // "prebuild:tis": "node scripts/tis/update-tis-ngsw-appdata.js", "prestart": "node aspnetcore-https", "start": "run-script-os", "start:tis": " ng serve --configuration tis", diff --git a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.html b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.html index 12f9763..9338a7c 100644 --- a/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.html +++ b/src/app/domains/pos/modules/landing/components/payloads/gold/form.component.html @@ -13,6 +13,8 @@ name="wages" label="اجرت" /> + + {{ initialValues?.payload?.profit }} , IPosOrderItem > { - override defaultValues: Partial> = { - unit_price: 200_000_000, - quantity: 2, - payload: { - // commission: 10_000, - // wages: 10_000, - // profit: 10_000, - karat: 'KARAT_18' as TGoldKarat, - } as any, - }; + // override defaultValues: Partial> = { + // unit_price: 200_000_000, + // quantity: 2, + // payload: { + // // commission: 10_000, + // // wages: 10_000, + // // profit: 10_000, + // karat: 'KARAT_18' as TGoldKarat, + // } as any, + // }; @Output() onSubmitForm = new EventEmitter(); @Output() onChangeTotalAmount = new EventEmitter(); diff --git a/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.html b/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.html index 01b797f..fae0144 100644 --- a/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.html +++ b/src/app/shared/components/amountPercentageInput/amount-percentage-input.component.html @@ -19,6 +19,7 @@ @if (selectedType.value === "amount") { } @else { (); @ContentChild('labelSuffix', { static: false }) labelSuffix!: TemplateRef | null; + @ViewChild('amountInput') amountInput?: InputNumber; + @ViewChild('percentageInput') percentageInput?: ElementRef; private readonly toastService = inject(ToastService); @@ -107,7 +111,12 @@ export class AmountPercentageInputComponent { 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) { this.toastService.warn({ 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() { const min = this.minAmount ?? 0; const maxFromInput = this.maxAmount; @@ -138,7 +159,8 @@ export class AmountPercentageInputComponent { const percentageValue = this.parseValue(rawValue); if (!this.isInRange(percentageValue, 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; } @@ -146,8 +168,8 @@ export class AmountPercentageInputComponent { const amountValue = (this.baseAmount * percentageValue) / 100; this.lastValidAmount = Number.isFinite(amountValue) ? amountValue : 0; - this.percentageControl.setValue(this.lastValidPercentage, { emitEvent: false }); - this.amountControl.setValue(this.lastValidAmount, { emitEvent: false }); + this.percentageControl.setValue(this.lastValidPercentage); + this.amountControl.setValue(this.lastValidAmount); this.preparedLabel.set(this.prepareLabel(true)); } @@ -156,7 +178,8 @@ export class AmountPercentageInputComponent { const amountValue = this.parseValue(rawValue); if (!this.isInRange(amountValue, 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; } @@ -166,8 +189,8 @@ export class AmountPercentageInputComponent { : '0'; this.lastValidPercentage = this.parseValue(percentageValue); - this.amountControl.setValue(this.lastValidAmount, { emitEvent: false }); - this.percentageControl.setValue(percentageValue, { emitEvent: false }); + this.amountControl.setValue(this.lastValidAmount); + this.percentageControl.setValue(percentageValue); this.preparedLabel.set(this.prepareLabel(false)); } @@ -179,7 +202,7 @@ export class AmountPercentageInputComponent { } ngOnInit() { - const isPercentageType = this.defaultType === 'percentage'; + const isPercentageType = this.amountControl.value ? false : true; this.selectedType.valueChanges.pipe(takeUntilDestroyed(this.destroyRef)).subscribe((value) => { 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.lastValidPercentage = this.parseValue(this.percentageControl.value); if (isPercentageType) { @@ -207,10 +229,11 @@ export class AmountPercentageInputComponent { } else { this.syncFromAmount(this.amountControl.value); } + this.selectedType.setValue(isPercentageType ? 'percentage' : 'amount'); } ngOnChanges() { - const isPercentageType = this.selectedType.value === 'percentage'; + const isPercentageType = this.amountControl.value ? false : true; if (isPercentageType) { this.syncFromPercentage(this.percentageControl.value); } else { diff --git a/src/app/shared/components/dialog/light-bottomsheet.component.ts b/src/app/shared/components/dialog/light-bottomsheet.component.ts index 1924a0b..0d029cd 100644 --- a/src/app/shared/components/dialog/light-bottomsheet.component.ts +++ b/src/app/shared/components/dialog/light-bottomsheet.component.ts @@ -57,7 +57,7 @@ import { Button } from 'primeng/button'; flex-direction: column; flex: 1; 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; overscroll-behavior: contain; } @@ -133,6 +133,8 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha private originalParent: Node | null = null; private readonly defaultDrawerZIndex = 1102; + private previousBodyOverflow = ''; + private previousBodyTouchAction = ''; constructor( private readonly elementRef: ElementRef, @@ -145,15 +147,20 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha this.originalParent = host.parentNode; this.renderer.appendChild(this.document.body, host); this.syncZIndex(); + this.toggleBodyScrollLock(this.visible); } ngOnChanges(changes: SimpleChanges) { if (changes['visible'] && this.visible) { this.syncZIndex(); } + if (changes['visible']) { + this.toggleBodyScrollLock(this.visible); + } } ngOnDestroy() { + this.toggleBodyScrollLock(false); this.removeDrawer(); } @@ -167,6 +174,7 @@ export class SharedLightBottomsheetComponent implements OnInit, OnDestroy, OnCha onVisibilityChange(nextValue: boolean) { this.visible = nextValue; this.visibleChange.emit(nextValue); + this.toggleBodyScrollLock(nextValue); if (nextValue) { 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() { const host = this.elementRef.nativeElement; const siblingDrawers = Array.from(