This commit is contained in:
2026-08-27 06:06:30 +00:00
parent 43204e8441
commit 311464e593
32 changed files with 98 additions and 117 deletions
@@ -68,7 +68,7 @@ export class BundleDetailComponent {
private snackBar = inject(MatSnackBar); private snackBar = inject(MatSnackBar);
private ser = inject(BundleService); private ser = inject(BundleService);
private productSer = inject(ProductService); private productSer = inject(ProductService);
menuCategoriesResource = this.menuCategoryService.list(undefined); menuCategoriesResource = this.menuCategoryService.list();
menuCategories = computed(() => this.menuCategoriesResource.value() ?? []); menuCategories = computed(() => this.menuCategoriesResource.value() ?? []);
saleCategoriesResource = this.saleCategoryService.list(); saleCategoriesResource = this.saleCategoryService.list();
saleCategories = computed(() => this.saleCategoriesResource.value() ?? []); saleCategories = computed(() => this.saleCategoriesResource.value() ?? []);
@@ -42,7 +42,7 @@ export class BundleListComponent {
private bundleService = inject(BundleService); private bundleService = inject(BundleService);
private toCsv = inject(ToCsvService); private toCsv = inject(ToCsvService);
menuCategoriesResource = this.menuCategoryService.list(undefined); menuCategoriesResource = this.menuCategoryService.list();
listResource = this.bundleService.list(); listResource = this.bundleService.list();
menuCategoryFilter = signal<string>(''); menuCategoryFilter = signal<string>('');
+2 -3
View File
@@ -1,16 +1,15 @@
import { MenuCategory } from '../core/menu-category'; import { MenuCategory } from '../core/menu-category';
import { ProductQuery } from '../core/product-query';
import { SaleCategory } from '../core/sale-category'; import { SaleCategory } from '../core/sale-category';
export class BundleItem { export class BundleItem {
id?: string; sku: ProductQuery | undefined;
itemId: string;
name: string; name: string;
salePrice: number; salePrice: number;
quantity: number; quantity: number;
printInBill: boolean; printInBill: boolean;
public constructor(init?: Partial<BundleItem>) { public constructor(init?: Partial<BundleItem>) {
this.itemId = '';
this.name = ''; this.name = '';
this.salePrice = 0; this.salePrice = 0;
this.quantity = 0; this.quantity = 0;
+4 -4
View File
@@ -20,9 +20,9 @@ export class CustomerService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<Customer | undefined> { get(id: Signal<string | null>): HttpResourceRef<Customer | undefined> {
return httpResource<Customer>(() => { return httpResource<Customer>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
@@ -86,9 +86,9 @@ export class CustomerService {
.pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<Customer>; .pipe(catchError(this.log.handleError(serviceName, 'delete'))) as Observable<Customer>;
} }
autocomplete(query: Signal<string | null> | string | null): HttpResourceRef<Customer[] | undefined> { autocomplete(query: Signal<string | null>): HttpResourceRef<Customer[] | undefined> {
return httpResource<Customer[]>(() => { return httpResource<Customer[]>(() => {
const qVal = typeof query === 'function' ? query() : query; const qVal = query();
return `${url}/query?q=${qVal ?? ''}`; return `${url}/query?q=${qVal ?? ''}`;
}); });
} }
+2 -2
View File
@@ -16,9 +16,9 @@ export class DeviceService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<Device | undefined> { get(id: Signal<string | null>): HttpResourceRef<Device | undefined> {
return httpResource<Device>(() => { return httpResource<Device>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
@@ -20,21 +20,21 @@ export class GuestBookService {
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get( get(
id: Signal<string | null> | string | null, id: Signal<string | null>,
type: Signal<GuestBookType> | GuestBookType | string = '', type?: Signal<GuestBookType | string>,
): HttpResourceRef<GuestBook | undefined> { ): HttpResourceRef<GuestBook | undefined> {
return httpResource<GuestBook>(() => { return httpResource<GuestBook>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
const typeVal = typeof type === 'function' ? type() : type; const typeVal = type ? type() : '';
const options = { params: new HttpParams().set('t', typeVal) }; const options = { params: new HttpParams().set('t', typeVal) };
const getUrl: string = idVal === null || idVal === undefined ? url : `${url}/${idVal}`; const getUrl: string = idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
return { url: getUrl, ...options }; return { url: getUrl, ...options };
}); });
} }
list(date: Signal<string | null> | string | null): HttpResourceRef<GuestBookList | undefined> { list(date: Signal<string | null>): HttpResourceRef<GuestBookList | undefined> {
return httpResource<GuestBookList>(() => { return httpResource<GuestBookList>(() => {
const dateVal = typeof date === 'function' ? date() : date; const dateVal = date();
const options = { params: new HttpParams().set('q', dateVal === null ? '' : dateVal) }; const options = { params: new HttpParams().set('q', dateVal === null ? '' : dateVal) };
return { url: `${url}/list`, ...options }; return { url: `${url}/list`, ...options };
}); });
@@ -19,20 +19,21 @@ export class MenuCategoryService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<MenuCategory | undefined> { get(id: Signal<string | null>): HttpResourceRef<MenuCategory | undefined> {
return httpResource<MenuCategory>(() => { return httpResource<MenuCategory>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
list(shouldHaveActiveProducts: boolean | undefined): HttpResourceRef<MenuCategory[] | undefined> { list(shouldHaveActiveProducts?: Signal<boolean | undefined>): HttpResourceRef<MenuCategory[] | undefined> {
return httpResource<MenuCategory[]>(() => { return httpResource<MenuCategory[]>(() => {
const options = { params: new HttpParams() }; let params = new HttpParams();
if (shouldHaveActiveProducts) { const active = shouldHaveActiveProducts ? shouldHaveActiveProducts() : undefined;
options.params = options.params.set('p', 'true'); if (active) {
params = params.set('p', 'true');
} }
return { url: `${url}/list`, ...options }; return { url: `${url}/list`, params };
}); });
} }
@@ -19,9 +19,9 @@ export class ModifierCategoryService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<ModifierCategory | undefined> { get(id: Signal<string | null>): HttpResourceRef<ModifierCategory | undefined> {
return httpResource<ModifierCategory>(() => { return httpResource<ModifierCategory>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
+2 -2
View File
@@ -18,9 +18,9 @@ export class ModifierService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<Modifier | undefined> { get(id: Signal<string | null>): HttpResourceRef<Modifier | undefined> {
return httpResource<Modifier>(() => { return httpResource<Modifier>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
+2 -2
View File
@@ -19,9 +19,9 @@ export class PrinterService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<Printer | undefined> { get(id: Signal<string | null>): HttpResourceRef<Printer | undefined> {
return httpResource<Printer>(() => { return httpResource<Printer>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
@@ -69,7 +69,7 @@ export class ProductDetailComponent {
saleCategoriesResource = this.saleCategoryService.list(); saleCategoriesResource = this.saleCategoryService.list();
menuCategoriesResource = this.menuCategoryService.list(undefined); menuCategoriesResource = this.menuCategoryService.list();
itemResource = this.ser.get(this.id); itemResource = this.ser.get(this.id);
@@ -48,7 +48,7 @@ export class ProductListComponent {
private toCsv = inject(ToCsvService); private toCsv = inject(ToCsvService);
private ser = inject(ProductService); private ser = inject(ProductService);
menuCategoriesResource = this.menuCategoryService.list(undefined); menuCategoriesResource = this.menuCategoryService.list();
listResource = this.ser.list(); listResource = this.ser.list();
+6 -6
View File
@@ -19,9 +19,9 @@ export class ProductService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<Product | undefined> { get(id: Signal<string | null>): HttpResourceRef<Product | undefined> {
return httpResource<Product>(() => { return httpResource<Product>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
@@ -30,16 +30,16 @@ export class ProductService {
return httpResource<Product[]>(() => `${url}/list`); return httpResource<Product[]>(() => `${url}/list`);
} }
listOfSaleCategory(id: Signal<string | null> | string): HttpResourceRef<ProductQuery[] | undefined> { listOfSaleCategory(id: Signal<string | null>): HttpResourceRef<ProductQuery[] | undefined> {
return httpResource<ProductQuery[]>(() => { return httpResource<ProductQuery[]>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return `${url}/query?sc=${idVal ?? ''}`; return `${url}/query?sc=${idVal ?? ''}`;
}); });
} }
listIsActiveOfCategory(id: Signal<string | null> | string): HttpResourceRef<ProductQuery[] | undefined> { listIsActiveOfCategory(id: Signal<string | null>): HttpResourceRef<ProductQuery[] | undefined> {
return httpResource<ProductQuery[]>(() => { return httpResource<ProductQuery[]>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return `${url}/query?mc=${idVal ?? ''}`; return `${url}/query?mc=${idVal ?? ''}`;
}); });
} }
+2 -2
View File
@@ -19,9 +19,9 @@ export class RegimeService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<number | null> | number | null): HttpResourceRef<Regime | undefined> { get(id: Signal<number | null>): HttpResourceRef<Regime | undefined> {
return httpResource<Regime>(() => { return httpResource<Regime>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined || isNaN(idVal) ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined || isNaN(idVal) ? url : `${url}/${idVal}`;
}); });
} }
+2 -2
View File
@@ -19,9 +19,9 @@ export class RoleService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<Role | undefined> { get(id: Signal<string | null>): HttpResourceRef<Role | undefined> {
return httpResource<Role>(() => { return httpResource<Role>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
@@ -19,9 +19,9 @@ export class SaleCategoryService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<SaleCategory | undefined> { get(id: Signal<string | null>): HttpResourceRef<SaleCategory | undefined> {
return httpResource<SaleCategory>(() => { return httpResource<SaleCategory>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
+2 -1
View File
@@ -1,3 +1,4 @@
import { Customer } from '../../core/customer';
import { Table } from '../../core/table'; import { Table } from '../../core/table';
import { User } from '../../core/user'; import { User } from '../../core/user';
import { GuestBook } from '../../guest-book/guest-book'; import { GuestBook } from '../../guest-book/guest-book';
@@ -17,7 +18,7 @@ export class Bill {
kotId: string; kotId: string;
billId: string; billId: string;
table: Table; table: Table;
customer: { id: string; name: string } | null; customer: Customer | null;
guest: GuestBook; guest: GuestBook;
reason: string; reason: string;
voucherType: VoucherType; voucherType: VoucherType;
@@ -137,7 +137,7 @@ export class BillsComponent implements OnInit {
const dialogRef = this.dialog.open(ChooseCustomerComponent, { const dialogRef = this.dialog.open(ChooseCustomerComponent, {
maxWidth: '100%', maxWidth: '100%',
width: '50%', width: '50%',
data: this.bs.bill.customer?.id, data: this.bs.bill.customer,
}); });
dialogRef.afterClosed().subscribe((result: boolean | Customer) => { dialogRef.afterClosed().subscribe((result: boolean | Customer) => {
@@ -1,5 +1,5 @@
import { CdkScrollableModule } from '@angular/cdk/scrolling'; import { CdkScrollableModule } from '@angular/cdk/scrolling';
import { Component, inject, signal, computed, effect, debounced } from '@angular/core'; import { Component, inject, computed, debounced, linkedSignal, signal } from '@angular/core';
import { form, FormField } from '@angular/forms/signals'; import { form, FormField } from '@angular/forms/signals';
import { MatAutocompleteSelectedEvent, MatAutocompleteModule } from '@angular/material/autocomplete'; import { MatAutocompleteSelectedEvent, MatAutocompleteModule } from '@angular/material/autocomplete';
import { MatButtonModule } from '@angular/material/button'; import { MatButtonModule } from '@angular/material/button';
@@ -14,6 +14,7 @@ import { Customer } from '../../core/customer';
import { CustomerService } from '../../customers/customer.service'; import { CustomerService } from '../../customers/customer.service';
export interface ChooseCustomerFormData { export interface ChooseCustomerFormData {
id: string;
name: string; name: string;
phone: string; phone: string;
address: string; address: string;
@@ -40,59 +41,36 @@ export interface ChooseCustomerFormData {
], ],
}) })
export class ChooseCustomerComponent { export class ChooseCustomerComponent {
data = inject(MAT_DIALOG_DATA); data = inject<Customer | null>(MAT_DIALOG_DATA); // Customer ID
private ser = inject(CustomerService); private ser = inject(CustomerService);
dialogRef = inject<MatDialogRef<ChooseCustomerComponent>>(MatDialogRef); dialogRef = inject<MatDialogRef<ChooseCustomerComponent>>(MatDialogRef);
formModel = signal<ChooseCustomerFormData>({
name: '', item = signal<Customer>(this.data ?? new Customer());
phone: '',
address: '', formModel = linkedSignal<Customer, ChooseCustomerFormData>({
printInBill: false, source: () => this.item(),
discounts: [], computation: (data) => ({
id: data.id,
name: data.name,
phone: data.phone,
address: data.address ?? '',
printInBill: data.printInBill,
discounts: data.discounts.map((x) => ({
discount: x.discount ? x.discount * 100 : null,
})),
}),
}); });
form = form(this.formModel); form = form(this.formModel);
item: Customer = new Customer();
phoneSignal = computed(() => { phoneSignal = computed(() => {
const p = this.formModel().phone; return this.formModel().phone;
return p === this.item.phone ? '' : p;
}); });
debouncedPhone = debounced(this.phoneSignal, 150); debouncedPhone = debounced(this.phoneSignal, 150);
customersResource = this.ser.autocomplete(computed(() => this.debouncedPhone.value())); customersResource = this.ser.autocomplete(this.debouncedPhone.value);
customers = computed(() => { customers = computed(() => { return this.customersResource.value() ?? [] });
if (!this.debouncedPhone.value()) return [];
return this.customersResource.value() ?? [];
});
constructor() {
const data = this.data;
if (data) {
const res = this.ser.get(data);
effect(() => {
const x = res.value();
if (x) {
this.showItem(x);
}
});
}
}
showItem(item: Customer) {
this.item = item;
this.formModel.set({
name: item.name,
phone: item.phone,
address: item.address ?? '',
printInBill: item.printInBill,
discounts: item.discounts.map((x) => ({
discount: x.discount ? x.discount * 100 : null,
})),
});
}
save() { save() {
const customer = this.getItem(); const customer = this.getItem();
@@ -109,7 +87,7 @@ export class ChooseCustomerComponent {
selected(event: MatAutocompleteSelectedEvent): void { selected(event: MatAutocompleteSelectedEvent): void {
const customer: Customer = event.option.value; const customer: Customer = event.option.value;
this.showItem(customer); this.item.set(customer);
} }
getItem(): Customer { getItem(): Customer {
@@ -117,16 +95,15 @@ export class ChooseCustomerComponent {
const array = formModel.discounts; const array = formModel.discounts;
return new Customer({ return new Customer({
...this.item, id: formModel.id,
id: this.item.phone.trim() !== formModel.phone?.trim() ? '' : this.item.id,
name: formModel.name ?? '', name: formModel.name ?? '',
phone: formModel.phone ?? '', phone: formModel.phone ?? '',
address: formModel.address ?? '', address: formModel.address ?? '',
printInBill: formModel.printInBill ?? false, printInBill: formModel.printInBill ?? false,
discounts: this.item.discounts.map((item, index) => { discounts: formModel.discounts.map((item, index) => {
const array_item = array?.[index]; const array_item = array?.[index];
return { return {
...item, ...this.item().discounts?.[index],
discount: discount:
array_item && array_item?.discount ? Math.max(Math.min(round(array_item.discount / 100, 5), 100), 0) : 0, array_item && array_item?.discount ? Math.max(Math.min(round(array_item.discount / 100, 5), 100), 0) : 0,
}; };
@@ -1,5 +1,5 @@
import { httpResource, HttpResourceRef } from '@angular/common/http'; import { httpResource, HttpResourceRef } from '@angular/common/http';
import { Injectable, inject, Injector } from '@angular/core'; import { Injectable, inject, Injector, Signal } from '@angular/core';
import { DiscountItem } from './discount-item'; import { DiscountItem } from './discount-item';
@@ -11,8 +11,11 @@ const url = '/api/customer-discounts';
export class CustomerDiscountsService { export class CustomerDiscountsService {
private injector = inject(Injector); private injector = inject(Injector);
list(id: string | undefined): HttpResourceRef<DiscountItem[] | undefined> { list(id: Signal<string | undefined>): HttpResourceRef<DiscountItem[] | undefined> {
return httpResource<DiscountItem[]>(() => (id === undefined ? url : `${url}/${id}`), { return httpResource<DiscountItem[]>(() => {
const idVal = id();
return idVal === undefined ? url : `${url}/${idVal}`;
}, {
injector: this.injector, injector: this.injector,
}); });
} }
@@ -1,4 +1,4 @@
import { Component, inject, computed } from '@angular/core'; import { Component, inject, computed, signal } from '@angular/core';
import { MatCardModule } from '@angular/material/card'; import { MatCardModule } from '@angular/material/card';
import { MatRippleModule } from '@angular/material/core'; import { MatRippleModule } from '@angular/material/core';
import { MatDialog } from '@angular/material/dialog'; import { MatDialog } from '@angular/material/dialog';
@@ -87,7 +87,7 @@ export class SalesHomeComponent {
if (this.discountAllowed()) { if (this.discountAllowed()) {
const dialogRef = this.dialog.open(DiscountComponent, { const dialogRef = this.dialog.open(DiscountComponent, {
// width: '750px', // width: '750px',
data: this.customerDiscountsService.list(this.bs.bill.customer?.id), data: this.customerDiscountsService.list(signal(this.bs.bill.customer?.id)),
}); });
return dialogRef.afterClosed(); return dialogRef.afterClosed();
} }
@@ -13,7 +13,7 @@ import { MenuCategoryService } from '../../menu-category/menu-category.service';
}) })
export class MenuCategoriesComponent { export class MenuCategoriesComponent {
private menuCategoryService = inject(MenuCategoryService); private menuCategoryService = inject(MenuCategoryService);
listResource = this.menuCategoryService.list(undefined); listResource = this.menuCategoryService.list();
list = computed(() => this.listResource.value() ?? []); list = computed(() => this.listResource.value() ?? []);
} }
@@ -19,9 +19,9 @@ export class SectionPrinterService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<SectionPrinter[] | undefined> { get(id: Signal<string | null>): HttpResourceRef<SectionPrinter[] | undefined> {
return httpResource<SectionPrinter[]>(() => { return httpResource<SectionPrinter[]>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
+2 -2
View File
@@ -19,9 +19,9 @@ export class SectionService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<Section | undefined> { get(id: Signal<string | null>): HttpResourceRef<Section | undefined> {
return httpResource<Section>(() => { return httpResource<Section>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
@@ -20,9 +20,9 @@ export class SettleOptionService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<SettleOption | undefined> { get(id: Signal<string | null>): HttpResourceRef<SettleOption | undefined> {
return httpResource<SettleOption>(() => { return httpResource<SettleOption>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
+2 -2
View File
@@ -20,10 +20,10 @@ export class TableService {
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
private injector = inject(Injector); private injector = inject(Injector);
get(id: Signal<string | null> | string | null): HttpResourceRef<Table | undefined> { get(id: Signal<string | null>): HttpResourceRef<Table | undefined> {
return httpResource<Table>( return httpResource<Table>(
() => { () => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}, },
{ injector: this.injector }, { injector: this.injector },
+2 -2
View File
@@ -19,9 +19,9 @@ export class TaxService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<Tax | undefined> { get(id: Signal<string | null>): HttpResourceRef<Tax | undefined> {
return httpResource<Tax>(() => { return httpResource<Tax>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }
@@ -76,7 +76,7 @@ export class TemporalProductDetailComponent {
saleCategoriesResource = this.saleCategoryService.list(); saleCategoriesResource = this.saleCategoryService.list();
menuCategoriesResource = this.menuCategoryService.list(undefined); menuCategoriesResource = this.menuCategoryService.list();
itemResource = this.ser.get(this.id); itemResource = this.ser.get(this.id);
@@ -42,7 +42,7 @@ export class TemporalProductListComponent {
private temporalProductService = inject(TemporalProductService); private temporalProductService = inject(TemporalProductService);
saleCategoriesResource = this.saleCategoryService.list(); saleCategoriesResource = this.saleCategoryService.list();
menuCategoriesResource = this.menuCategoryService.list(undefined); menuCategoriesResource = this.menuCategoryService.list();
listResource = this.temporalProductService.list(); listResource = this.temporalProductService.list();
menuCategoryFilter = signal<string>(''); menuCategoryFilter = signal<string>('');
@@ -18,9 +18,9 @@ export class TemporalProductService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string): HttpResourceRef<TemporalProduct | undefined> { get(id: Signal<string | null>): HttpResourceRef<TemporalProduct | undefined> {
return httpResource<TemporalProduct>(() => { return httpResource<TemporalProduct>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return `${url}/${idVal ?? ''}`; return `${url}/${idVal ?? ''}`;
}); });
} }
@@ -53,7 +53,7 @@ export class UpdateProductPricesComponent {
infoResource = this.ser.get(this.id, this.date); infoResource = this.ser.get(this.id, this.date);
menuCategoriesResource = this.menuCategoryService.list(undefined); menuCategoriesResource = this.menuCategoryService.list();
info = computed(() => this.infoResource.value() ?? new UpdateProductPrices()); info = computed(() => this.infoResource.value() ?? new UpdateProductPrices());
dataSource = computed(() => this.info().items); dataSource = computed(() => this.info().items);
+2 -2
View File
@@ -19,9 +19,9 @@ export class UserService {
private http = inject(HttpClient); private http = inject(HttpClient);
private log = inject(ErrorLoggerService); private log = inject(ErrorLoggerService);
get(id: Signal<string | null> | string | null): HttpResourceRef<User | undefined> { get(id: Signal<string | null>): HttpResourceRef<User | undefined> {
return httpResource<User>(() => { return httpResource<User>(() => {
const idVal = typeof id === 'function' ? id() : id; const idVal = id();
return idVal === null || idVal === undefined ? url : `${url}/${idVal}`; return idVal === null || idVal === undefined ? url : `${url}/${idVal}`;
}); });
} }