create apiEnum components
This commit is contained in:
@@ -20,6 +20,7 @@ export class GuildGoodCategoriesListComponent extends AbstractList<IGoodCategori
|
||||
@Input() header: IColumn[] = [
|
||||
{ field: 'id', header: 'شناسه' },
|
||||
{ field: 'name', header: 'عنوان' },
|
||||
{ field: 'goods_count', header: 'تعداد کالاها' },
|
||||
{
|
||||
field: 'created_at',
|
||||
header: 'تاریخ ایجاد',
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<uikit-field [label]="label" [control]="control" [showLabel]="showLabel" [showErrors]="showErrors">
|
||||
<p-select
|
||||
[loading]="loading()"
|
||||
[options]="items()"
|
||||
optionLabel="name"
|
||||
[optionValue]="selectOptionValue"
|
||||
[formControl]="control"
|
||||
[showClear]="showClear"
|
||||
[filter]="true"
|
||||
appendTo="body"
|
||||
/>
|
||||
</uikit-field>
|
||||
@@ -0,0 +1,33 @@
|
||||
import { IPaginatedResponse } from '@/core/models/service.model';
|
||||
import { AbstractSelectComponent } from '@/shared/abstractClasses';
|
||||
import { UikitFieldComponent } from '@/uikit';
|
||||
import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule } from '@angular/forms';
|
||||
import { Select } from 'primeng/select';
|
||||
import { IGoodCategoriesResponse } from '../../models';
|
||||
import { GuildGoodCategoriesService } from '../../services/goodCategories.service';
|
||||
|
||||
@Component({
|
||||
selector: 'admin-guild-categories-select',
|
||||
templateUrl: './select.component.html',
|
||||
imports: [UikitFieldComponent, Select, ReactiveFormsModule],
|
||||
})
|
||||
export class GuildCategoriesSelectComponent extends AbstractSelectComponent<
|
||||
IGoodCategoriesResponse,
|
||||
IPaginatedResponse<IGoodCategoriesResponse>
|
||||
> {
|
||||
@Input() override showClear: boolean = false;
|
||||
@Input() label: string = '';
|
||||
@Input() guildId!: string;
|
||||
private readonly service = inject(GuildGoodCategoriesService);
|
||||
|
||||
ngOnChanges() {
|
||||
if (this.guildId) {
|
||||
this.getData();
|
||||
}
|
||||
}
|
||||
|
||||
getDataService() {
|
||||
return this.service.getAll(this.guildId);
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@
|
||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||
<app-input label="کد" [control]="form.controls.code" name="code" />
|
||||
|
||||
{{ editMode }}
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="form.disabled" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
|
||||
@@ -1,7 +1,17 @@
|
||||
<p-dialog header="فرم صنف" [(visible)]="visible" [modal]="true" [style]="{ width: '500px' }" [closable]="true">
|
||||
<form [formGroup]="form" (submit)="submit()" class="flex flex-col gap-4">
|
||||
<app-input label="عنوان" [control]="form.controls.name" name="name" />
|
||||
<app-input label="شناسه عمومی" [control]="form.controls.sku" name="sku" />
|
||||
<admin-guild-categories-select
|
||||
[guildId]="guildId"
|
||||
label="دستهبندی"
|
||||
[control]="form.controls.category_id"
|
||||
name="category_id"
|
||||
/>
|
||||
<app-enum-select type="unitType" [control]="form.controls.unit_type" />
|
||||
<app-enum-select type="goodPricingModel" [control]="form.controls.pricing_model" />
|
||||
<app-input label="توضیحات" [control]="form.controls.description" name="description" />
|
||||
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="form.disabled" (onCancel)="close()" />
|
||||
<app-form-footer-actions [submitLabel]="'ذخیره'" [loading]="submitLoading()" (onCancel)="close()" />
|
||||
</form>
|
||||
</p-dialog>
|
||||
|
||||
@@ -5,13 +5,22 @@ import { Component, inject, Input } from '@angular/core';
|
||||
import { ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { Dialog } from 'primeng/dialog';
|
||||
|
||||
import { EnumSelectComponent } from '@/shared/apiEnum/select.component';
|
||||
import { IGuildGoodRequest, IGuildGoodsResponse } from '../../models';
|
||||
import { GuildGoodsService } from '../../services/goods.service';
|
||||
import { GuildCategoriesSelectComponent } from '../categories/select.component';
|
||||
|
||||
@Component({
|
||||
selector: 'admin-guild-good-form',
|
||||
templateUrl: './form.component.html',
|
||||
imports: [ReactiveFormsModule, Dialog, InputComponent, FormFooterActionsComponent],
|
||||
imports: [
|
||||
ReactiveFormsModule,
|
||||
Dialog,
|
||||
InputComponent,
|
||||
FormFooterActionsComponent,
|
||||
EnumSelectComponent,
|
||||
GuildCategoriesSelectComponent,
|
||||
],
|
||||
})
|
||||
export class GuildGoodCategoryFormComponent extends AbstractFormDialog<
|
||||
IGuildGoodRequest,
|
||||
@@ -24,6 +33,11 @@ export class GuildGoodCategoryFormComponent extends AbstractFormDialog<
|
||||
|
||||
form = this.fb.group({
|
||||
name: [this.initialValues?.name || '', [Validators.required]],
|
||||
sku: [this.initialValues?.sku || '', [Validators.required]],
|
||||
unit_type: [this.initialValues?.unit_type || '', [Validators.required]],
|
||||
pricing_model: [this.initialValues?.pricing_model || '', [Validators.required]],
|
||||
category_id: [this.initialValues?.category.id || '', [Validators.required]],
|
||||
description: [this.initialValues?.description || ''],
|
||||
});
|
||||
|
||||
override submitForm(payload: IGuildGoodRequest) {
|
||||
|
||||
@@ -9,6 +9,16 @@
|
||||
[loading]="loading()"
|
||||
[showDetails]="true"
|
||||
[showAdd]="true"
|
||||
[showEdit]="true"
|
||||
[fullHeight]="fullHeight"
|
||||
(onEdit)="onEditClick($event)"
|
||||
(onAdd)="openAddForm()"
|
||||
/>
|
||||
<admin-guild-good-form [(visible)]="visibleForm" (onSubmit)="refresh()" />
|
||||
<admin-guild-good-form
|
||||
[guildId]="guildId"
|
||||
[(visible)]="visibleForm"
|
||||
[initialValues]="selectedItemForEdit() || undefined"
|
||||
[categoryId]="selectedItemForEdit()?.id"
|
||||
[editMode]="editMode()"
|
||||
(onSubmit)="refresh()"
|
||||
/>
|
||||
|
||||
@@ -5,6 +5,8 @@ export interface IGuildGoodsRawResponse {
|
||||
name: string;
|
||||
sku: string;
|
||||
category: ISummary;
|
||||
unit_type: string;
|
||||
pricing_model: string;
|
||||
description?: string;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
@@ -14,5 +16,8 @@ export interface IGuildGoodsResponse extends IGuildGoodsRawResponse {}
|
||||
export interface IGuildGoodRequest {
|
||||
name: string;
|
||||
sku: string;
|
||||
category_id: string;
|
||||
unit_type: string;
|
||||
pricing_model: string;
|
||||
description?: string;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import { PartnersService } from '../services/main.service';
|
||||
templateUrl: './select.component.html',
|
||||
imports: [UikitFieldComponent, Select, Button, ReactiveFormsModule, GuildFormComponent],
|
||||
})
|
||||
export class InventoryBankAccountSelectComponent extends AbstractSelectComponent<
|
||||
export class PartnerSelectComponent extends AbstractSelectComponent<
|
||||
IPartnerResponse,
|
||||
IPaginatedResponse<IPartnerResponse>
|
||||
> {
|
||||
|
||||
Reference in New Issue
Block a user