feat: refactor form components and improve invoice printing logic; enhance checkbox functionality and loading state management
This commit is contained in:
@@ -1,11 +1,9 @@
|
||||
import { brandingConfig } from '@/branding/branding.config';
|
||||
import { Component, computed, signal } from '@angular/core';
|
||||
import { ButtonDirective } from 'primeng/button';
|
||||
|
||||
@Component({
|
||||
selector: 'pos-about-page',
|
||||
templateUrl: './root.component.html',
|
||||
imports: [ButtonDirective],
|
||||
})
|
||||
export class PosAboutPageComponent {
|
||||
// private readonly swUpdate = inject(SwUpdate);
|
||||
|
||||
@@ -1,30 +1,32 @@
|
||||
<form [formGroup]="form" (submit)="submit()">
|
||||
<app-checkbox [control]="form.controls.business_name" name="business_name" label="نمایش عنوان کسبوکار" />
|
||||
<app-checkbox [control]="form.controls.complex_name" name="complex_name" label="نمایش عنوان شعبه" />
|
||||
<app-checkbox [control]="form.controls.pos_name" name="pos_name" label="نمایش عنوان پایانه فروش" />
|
||||
<app-checkbox [control]="form.controls.invoice_template" name="invoice_template" label="نمایش الگوی صورتحساب" />
|
||||
<app-checkbox [control]="form.controls.fiscal_id" name="fiscal_id" label="نمایش شماره منحصر به فرد مالیاتی" />
|
||||
<app-checkbox [control]="form.controls.economic_code" name="economic_code" label="نمایش شماره اقتصادی" />
|
||||
<app-checkbox [control]="form.controls.customer_name" name="customer_name" label="نمایش عنوان خریدار" />
|
||||
<app-checkbox [control]="form.controls.customer_mobile" name="customer_mobile" label="نمایش شماره موبایل خریدار" />
|
||||
<app-checkbox
|
||||
[control]="form.controls.customer_national_id"
|
||||
name="customer_national_id"
|
||||
label="نمایش کد ملی خریدار"
|
||||
/>
|
||||
<app-checkbox
|
||||
[control]="form.controls.customer_postal_code"
|
||||
name="customer_postal_code"
|
||||
label="نمایش کد پستی خریدار"
|
||||
/>
|
||||
<app-checkbox
|
||||
[control]="form.controls.customer_economic_code"
|
||||
name="customer_economic_code"
|
||||
label="نمایش شناسهملی / اقتصادی خریدار"
|
||||
/>
|
||||
<app-checkbox [control]="form.controls.payment_type" name="payment_type" label="نمایش نوع پرداخت" />
|
||||
<app-checkbox [control]="form.controls.show_payment_info" name="show_payment_info" label="نمایش جزییات پرداخت" />
|
||||
<app-checkbox [control]="form.controls.show_items" name="show_items" label="نمایش کالاهای خریداری شده" />
|
||||
@if (!loading()) {
|
||||
<form [formGroup]="form" (submit)="submit()">
|
||||
<app-checkbox [control]="form.controls.business_name" name="business_name" label="نمایش عنوان کسبوکار" />
|
||||
<app-checkbox [control]="form.controls.complex_name" name="complex_name" label="نمایش عنوان شعبه" />
|
||||
<app-checkbox [control]="form.controls.pos_name" name="pos_name" label="نمایش عنوان پایانه فروش" />
|
||||
<app-checkbox [control]="form.controls.invoice_template" name="invoice_template" label="نمایش الگوی صورتحساب" />
|
||||
<app-checkbox [control]="form.controls.fiscal_id" name="fiscal_id" label="نمایش شماره منحصر به فرد مالیاتی" />
|
||||
<app-checkbox [control]="form.controls.economic_code" name="economic_code" label="نمایش شماره اقتصادی" />
|
||||
<app-checkbox [control]="form.controls.customer_name" name="customer_name" label="نمایش عنوان خریدار" />
|
||||
<app-checkbox [control]="form.controls.customer_mobile" name="customer_mobile" label="نمایش شماره موبایل خریدار" />
|
||||
<app-checkbox
|
||||
[control]="form.controls.customer_national_id"
|
||||
name="customer_national_id"
|
||||
label="نمایش کد ملی خریدار"
|
||||
/>
|
||||
<app-checkbox
|
||||
[control]="form.controls.customer_postal_code"
|
||||
name="customer_postal_code"
|
||||
label="نمایش کد پستی خریدار"
|
||||
/>
|
||||
<app-checkbox
|
||||
[control]="form.controls.customer_economic_code"
|
||||
name="customer_economic_code"
|
||||
label="نمایش شناسهملی / اقتصادی خریدار"
|
||||
/>
|
||||
<app-checkbox [control]="form.controls.payment_type" name="payment_type" label="نمایش نوع پرداخت" />
|
||||
<app-checkbox [control]="form.controls.show_payment_info" name="show_payment_info" label="نمایش جزییات پرداخت" />
|
||||
<app-checkbox [control]="form.controls.show_items" name="show_items" label="نمایش کالاهای خریداری شده" />
|
||||
|
||||
<app-form-footer-actions (onSubmit)="submit()" (onCancel)="close()" />
|
||||
</form>
|
||||
<app-form-footer-actions (onCancel)="close()" />
|
||||
</form>
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AbstractForm } from '@/shared/abstractClasses';
|
||||
import { AppCheckboxComponent } from '@/shared/components/checkbox/checkbox.component';
|
||||
import { FormFooterActionsComponent } from '@/shared/components/formFooterActions/form-footer-actions.component';
|
||||
import { Component, inject } from '@angular/core';
|
||||
import { Component, inject, signal } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { IPosConfigPrintRequestPayload, IPosConfigPrintResponse } from './models';
|
||||
import { PosConfigPrintService } from './services/main.service';
|
||||
@@ -17,6 +17,8 @@ export class PosConfigPrintFormComponent extends AbstractForm<
|
||||
> {
|
||||
private readonly service = inject(PosConfigPrintService);
|
||||
|
||||
loading = signal(true);
|
||||
|
||||
initForm = () => {
|
||||
const form = this.fb.group({
|
||||
business_name: [true, []],
|
||||
@@ -40,8 +42,18 @@ export class PosConfigPrintFormComponent extends AbstractForm<
|
||||
|
||||
form = this.initForm();
|
||||
|
||||
submitForm() {
|
||||
override async ngOnInit() {
|
||||
this.loading.set(true);
|
||||
const initialValues = await this.service.get();
|
||||
console.log('initialValues', initialValues);
|
||||
|
||||
this.form.patchValue(initialValues);
|
||||
this.loading.set(false);
|
||||
}
|
||||
|
||||
override submitForm() {
|
||||
const formValue = this.form.value as IPosConfigPrintRequestPayload;
|
||||
this.toastService.success({ text: 'تغییرات با موفقیت اعمال شد.' });
|
||||
return this.service.submit(formValue);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user