@elite.framework/ng.core 1.0.27 → 1.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -60,6 +60,7 @@ import * as i2$3 from 'primeng/table';
60
60
  import { TableModule } from 'primeng/table';
61
61
  import * as i5$2 from 'primeng/drawer';
62
62
  import { DrawerModule, Drawer } from 'primeng/drawer';
63
+ import { SwalService as SwalService$1 } from '@framework/ng.core';
63
64
  import * as i2$4 from 'primeng/datepicker';
64
65
  import { DatePickerModule } from 'primeng/datepicker';
65
66
  import { TabsModule } from 'primeng/tabs';
@@ -1811,31 +1812,29 @@ class CustomSwitchFieldComponent extends FieldType {
1811
1812
  this.model[key] = this.formControl.value ? 1 : 2;
1812
1813
  }
1813
1814
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CustomSwitchFieldComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
1814
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: CustomSwitchFieldComponent, isStandalone: true, selector: "formly-field-custom-switch", usesInheritance: true, ngImport: i0, template: `
1815
- <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
1816
- style=" border-radius: var(--p-inputtext-border-radius);">
1817
-
1818
-
1819
- <!-- التبديل نفسه -->
1820
- <p-toggleSwitch
1821
- [formControl]="formControl"
1822
- [inputId]="id"
1823
- [pTooltip]="field.props['tooltip']"
1824
- [styleClass]="''"
1825
- (onChange)="updateModel($event.checked)"
1826
- ></p-toggleSwitch>
1827
-
1828
- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
1829
- {{ (to.label ?? '') | translate}}
1830
- </label>
1831
-
1832
- <!-- حالة التبديل تحت التبديل -->
1833
- <!-- <span class="text-sm font-medium" [class.text-green-600]="formControl.value" [class.text-gray-500]="!formControl.value">
1834
- {{ formControl.value ? 'فعال' : 'غير فعال' }}
1835
- </span> -->
1836
- </div>
1837
-
1838
- `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: FormsModule }, { kind: "component", type: ToggleSwitch, selector: "p-toggleswitch, p-toggleSwitch, p-toggle-switch", inputs: ["styleClass", "tabindex", "inputId", "readonly", "trueValue", "falseValue", "ariaLabel", "size", "ariaLabelledBy", "autofocus"], outputs: ["onChange"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i1$5.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo"] }, { kind: "pipe", type: i1$3.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1815
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: CustomSwitchFieldComponent, isStandalone: true, selector: "formly-field-custom-switch", usesInheritance: true, ngImport: i0, template: `
1816
+ <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
1817
+ style=" border-radius: var(--p-inputtext-border-radius);">
1818
+
1819
+
1820
+ <label [for]="id" class="font-bold text-lg text-gray-800">
1821
+ {{ (to.label ?? '') | translate }}
1822
+
1823
+ <span *ngIf="to.required" class="text-red-500">*</span>
1824
+ </label>
1825
+
1826
+ <!-- التبديل نفسه -->
1827
+ <p-toggleSwitch
1828
+ [formControl]="formControl"
1829
+ [inputId]="id"
1830
+ [pTooltip]="field.props['tooltip']"
1831
+ [styleClass]="''"
1832
+ (onChange)="updateModel($event.checked)"
1833
+ ></p-toggleSwitch>
1834
+
1835
+ </div>
1836
+
1837
+ `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: FormsModule }, { kind: "component", type: ToggleSwitch, selector: "p-toggleswitch, p-toggleSwitch, p-toggle-switch", inputs: ["styleClass", "tabindex", "inputId", "readonly", "trueValue", "falseValue", "ariaLabel", "size", "ariaLabelledBy", "autofocus"], outputs: ["onChange"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i1$5.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo"] }, { kind: "pipe", type: i1$3.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
1839
1838
  }
1840
1839
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CustomSwitchFieldComponent, decorators: [{
1841
1840
  type: Component,
@@ -1850,30 +1849,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
1850
1849
  TooltipModule,
1851
1850
  Tooltip
1852
1851
  ],
1853
- template: `
1854
- <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
1855
- style=" border-radius: var(--p-inputtext-border-radius);">
1856
-
1857
-
1858
- <!-- التبديل نفسه -->
1859
- <p-toggleSwitch
1860
- [formControl]="formControl"
1861
- [inputId]="id"
1862
- [pTooltip]="field.props['tooltip']"
1863
- [styleClass]="''"
1864
- (onChange)="updateModel($event.checked)"
1865
- ></p-toggleSwitch>
1866
-
1867
- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
1868
- {{ (to.label ?? '') | translate}}
1869
- </label>
1870
-
1871
- <!-- حالة التبديل تحت التبديل -->
1872
- <!-- <span class="text-sm font-medium" [class.text-green-600]="formControl.value" [class.text-gray-500]="!formControl.value">
1873
- {{ formControl.value ? 'فعال' : 'غير فعال' }}
1874
- </span> -->
1875
- </div>
1876
-
1852
+ template: `
1853
+ <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
1854
+ style=" border-radius: var(--p-inputtext-border-radius);">
1855
+
1856
+
1857
+ <label [for]="id" class="font-bold text-lg text-gray-800">
1858
+ {{ (to.label ?? '') | translate }}
1859
+
1860
+ <span *ngIf="to.required" class="text-red-500">*</span>
1861
+ </label>
1862
+
1863
+ <!-- التبديل نفسه -->
1864
+ <p-toggleSwitch
1865
+ [formControl]="formControl"
1866
+ [inputId]="id"
1867
+ [pTooltip]="field.props['tooltip']"
1868
+ [styleClass]="''"
1869
+ (onChange)="updateModel($event.checked)"
1870
+ ></p-toggleSwitch>
1871
+
1872
+ </div>
1873
+
1877
1874
  `,
1878
1875
  changeDetection: ChangeDetectionStrategy.OnPush,
1879
1876
  }]
@@ -3190,6 +3187,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
3190
3187
  class GenericCrudTableComponent {
3191
3188
  genericTable;
3192
3189
  translate = inject(TranslateService);
3190
+ swalService = inject(SwalService$1);
3193
3191
  home = { icon: 'pi pi-home', routerLink: '/' };
3194
3192
  data = [];
3195
3193
  formFields_ = []; // <-- هنا
@@ -3333,32 +3331,68 @@ class GenericCrudTableComponent {
3333
3331
  }
3334
3332
  }
3335
3333
  beforeSave = (record) => record;
3334
+ // onSubmit() {
3335
+ // if (this.form.invalid) return;
3336
+ // this.loading = true;
3337
+ // this.errorMessage = null;
3338
+ // const service = this.service /* as CrudService<T> */;
3339
+ // const id = this.isEditMode ? (this.model as any)[this.idField] : null;
3340
+ // const recordToSave = this.beforeSave({ ...this.model });
3341
+ // const operation$: Observable<any> = this.isEditMode
3342
+ // ? service.update(id, recordToSave)
3343
+ // : service.create(recordToSave);
3344
+ // // operation$.pipe(takeUntil(this.destroy$)).subscribe({
3345
+ // operation$.subscribe({
3346
+ // next: () => {
3347
+ // // this.ref.close(true); // نجاح العملية
3348
+ // this.visibleChange.emit(false)
3349
+ // // this.pageChange.emit({ first, rows ,sort, filters });
3350
+ // this.applySearch('');
3351
+ // // this.me
3352
+ // },
3353
+ // error: (err:any) => {
3354
+ // this.loading = false;
3355
+ // this.errorMessage = err.error?.title ||
3356
+ // err.message ||
3357
+ // 'حدث خطأ أثناء الحفظ. يرجى المحاولة مرة أخرى.';
3358
+ // }
3359
+ // });
3360
+ // }
3336
3361
  onSubmit() {
3337
3362
  if (this.form.invalid)
3338
3363
  return;
3339
- this.loading = true;
3340
- this.errorMessage = null;
3341
- const service = this.service /* as CrudService<T> */;
3342
- const id = this.isEditMode ? this.model[this.idField] : null;
3343
- const recordToSave = this.beforeSave({ ...this.model });
3344
- const operation$ = this.isEditMode
3345
- ? service.update(id, recordToSave)
3346
- : service.create(recordToSave);
3347
- // operation$.pipe(takeUntil(this.destroy$)).subscribe({
3348
- operation$.subscribe({
3349
- next: () => {
3350
- // this.ref.close(true); // نجاح العملية
3351
- this.visibleChange.emit(false);
3352
- // this.pageChange.emit({ first, rows ,sort, filters });
3353
- this.applySearch('');
3354
- // this.me
3355
- },
3356
- error: (err) => {
3357
- this.loading = false;
3358
- this.errorMessage = err.error?.title ||
3359
- err.message ||
3360
- 'حدث خطأ أثناء الحفظ. يرجى المحاولة مرة أخرى.';
3361
- }
3364
+ // أول شيء نطلب تأكيد من المستخدم
3365
+ this.swalService.confirm(this.isEditMode ? 'تأكيد التعديل' : 'تأكيد الحفظ', this.isEditMode
3366
+ ? 'هل تريد حفظ التعديلات على هذا السجل؟'
3367
+ : 'هل تريد حفظ هذا السجل؟', 'نعم', 'إلغاء').then((result) => {
3368
+ if (!result.isConfirmed)
3369
+ return;
3370
+ this.loading = true;
3371
+ this.errorMessage = null;
3372
+ const service = this.service;
3373
+ const id = this.isEditMode ? this.model[this.idField] : null;
3374
+ const recordToSave = this.beforeSave({ ...this.model });
3375
+ const operation$ = this.isEditMode
3376
+ ? service.update(id, recordToSave)
3377
+ : service.create(recordToSave);
3378
+ operation$.subscribe({
3379
+ next: () => {
3380
+ this.loading = false;
3381
+ // رسالة نجاح
3382
+ this.swalService.success(this.isEditMode ? 'تم التعديل بنجاح' : 'تم الحفظ بنجاح');
3383
+ this.visibleChange.emit(false);
3384
+ this.applySearch('');
3385
+ },
3386
+ error: (err) => {
3387
+ this.loading = false;
3388
+ const msg = err.error?.title ||
3389
+ err.message ||
3390
+ 'حدث خطأ أثناء الحفظ. يرجى المحاولة مرة أخرى.';
3391
+ this.errorMessage = msg;
3392
+ // ❌ رسالة خطأ
3393
+ this.swalService.error('فشل الحفظ', msg);
3394
+ }
3395
+ });
3362
3396
  });
3363
3397
  }
3364
3398
  trackByIdx(index, item) {
@@ -3974,6 +4008,7 @@ class GenericSelectorTypeComponent extends FieldType {
3974
4008
  this.selectedItem = items;
3975
4009
  if (withSetValue == true) {
3976
4010
  this.formControl.setValue(items.map((c) => c[vf]));
4011
+ this.cdr.detectChanges();
3977
4012
  }
3978
4013
  else {
3979
4014
  if (this.props.change) {
@@ -3992,6 +4027,7 @@ class GenericSelectorTypeComponent extends FieldType {
3992
4027
  // debugger
3993
4028
  if (withSetValue == true) {
3994
4029
  this.formControl.setValue(item?.[vf]);
4030
+ this.cdr.detectChanges();
3995
4031
  }
3996
4032
  else {
3997
4033
  if (this.props.change) {
@@ -4339,32 +4375,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
4339
4375
 
4340
4376
  class InputSwitchTypeComponent extends FieldType {
4341
4377
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: InputSwitchTypeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
4342
- static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: InputSwitchTypeComponent, isStandalone: true, selector: "formly-field-primeng-input-switch", usesInheritance: true, ngImport: i0, template: `
4343
- <!-- border border-gray-300 -->
4344
- <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
4345
- style=" border-radius: var(--p-inputtext-border-radius);">
4346
-
4347
- <label [for]="id" class="font-bold text-lg text-gray-800">
4348
- {{ (to.label ?? '') | translate }}
4349
- <span *ngIf="to.required" class="text-red-500">*</span>
4350
- </label>
4351
-
4352
- <p-toggleSwitch
4353
- [formControl]="formControl"
4354
- [formlyAttributes]="field"
4355
- [pTooltip]="field.props['tooltip']"
4356
- [styleClass]="''"
4357
- [inputId]="id"
4358
-
4359
- ></p-toggleSwitch>
4360
-
4361
-
4362
- <!-- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
4363
- {{ (to.label ?? '') | translate}}
4364
- </label> -->
4365
- </div>
4366
- <!-- [style]="to.['style']" -->
4367
- <!-- [disabled]="to.disabled ?? false" -->
4378
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "20.1.4", type: InputSwitchTypeComponent, isStandalone: true, selector: "formly-field-primeng-input-switch", usesInheritance: true, ngImport: i0, template: `
4379
+ <!-- border border-gray-300 -->
4380
+ <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
4381
+ style=" border-radius: var(--p-inputtext-border-radius);">
4382
+
4383
+ <label [for]="id" class="font-bold text-lg text-gray-800">
4384
+ {{ (to.label ?? '') | translate }}
4385
+
4386
+ <span *ngIf="to.required" class="text-red-500">*</span>
4387
+ </label>
4388
+
4389
+ <p-toggleSwitch
4390
+ [formControl]="formControl"
4391
+ [formlyAttributes]="field"
4392
+ [pTooltip]="field.props['tooltip']"
4393
+ [styleClass]="''"
4394
+ [inputId]="id"
4395
+
4396
+ ></p-toggleSwitch>
4397
+
4398
+
4399
+ <!-- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
4400
+ {{ (to.label ?? '') | translate}}
4401
+ </label> -->
4402
+ </div>
4403
+ <!-- [style]="to.['style']" -->
4404
+ <!-- [disabled]="to.disabled ?? false" -->
4368
4405
  `, isInline: true, dependencies: [{ kind: "ngmodule", type: CommonModule }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "ngmodule", type: ReactiveFormsModule }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.FormControlDirective, selector: "[formControl]", inputs: ["formControl", "disabled", "ngModel"], outputs: ["ngModelChange"], exportAs: ["ngForm"] }, { kind: "ngmodule", type: FormsModule }, { kind: "component", type: ToggleSwitch, selector: "p-toggleswitch, p-toggleSwitch, p-toggle-switch", inputs: ["styleClass", "tabindex", "inputId", "readonly", "trueValue", "falseValue", "ariaLabel", "size", "ariaLabelledBy", "autofocus"], outputs: ["onChange"] }, { kind: "directive", type: FormlyAttributes, selector: "[formlyAttributes]", inputs: ["formlyAttributes", "id"] }, { kind: "ngmodule", type: TranslateModule }, { kind: "ngmodule", type: TooltipModule }, { kind: "directive", type: i1$5.Tooltip, selector: "[pTooltip]", inputs: ["tooltipPosition", "tooltipEvent", "positionStyle", "tooltipStyleClass", "tooltipZIndex", "escape", "showDelay", "hideDelay", "life", "positionTop", "positionLeft", "autoHide", "fitContent", "hideOnEscape", "pTooltip", "tooltipDisabled", "tooltipOptions", "appendTo"] }, { kind: "pipe", type: i1$3.TranslatePipe, name: "translate" }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
4369
4406
  }
4370
4407
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: InputSwitchTypeComponent, decorators: [{
@@ -4379,32 +4416,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
4379
4416
  FormlyAttributes,
4380
4417
  TranslateModule,
4381
4418
  TooltipModule],
4382
- template: `
4383
- <!-- border border-gray-300 -->
4384
- <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
4385
- style=" border-radius: var(--p-inputtext-border-radius);">
4386
-
4387
- <label [for]="id" class="font-bold text-lg text-gray-800">
4388
- {{ (to.label ?? '') | translate }}
4389
- <span *ngIf="to.required" class="text-red-500">*</span>
4390
- </label>
4391
-
4392
- <p-toggleSwitch
4393
- [formControl]="formControl"
4394
- [formlyAttributes]="field"
4395
- [pTooltip]="field.props['tooltip']"
4396
- [styleClass]="''"
4397
- [inputId]="id"
4398
-
4399
- ></p-toggleSwitch>
4400
-
4401
-
4402
- <!-- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
4403
- {{ (to.label ?? '') | translate}}
4404
- </label> -->
4405
- </div>
4406
- <!-- [style]="to.['style']" -->
4407
- <!-- [disabled]="to.disabled ?? false" -->
4419
+ template: `
4420
+ <!-- border border-gray-300 -->
4421
+ <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
4422
+ style=" border-radius: var(--p-inputtext-border-radius);">
4423
+
4424
+ <label [for]="id" class="font-bold text-lg text-gray-800">
4425
+ {{ (to.label ?? '') | translate }}
4426
+
4427
+ <span *ngIf="to.required" class="text-red-500">*</span>
4428
+ </label>
4429
+
4430
+ <p-toggleSwitch
4431
+ [formControl]="formControl"
4432
+ [formlyAttributes]="field"
4433
+ [pTooltip]="field.props['tooltip']"
4434
+ [styleClass]="''"
4435
+ [inputId]="id"
4436
+
4437
+ ></p-toggleSwitch>
4438
+
4439
+
4440
+ <!-- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
4441
+ {{ (to.label ?? '') | translate}}
4442
+ </label> -->
4443
+ </div>
4444
+ <!-- [style]="to.['style']" -->
4445
+ <!-- [disabled]="to.disabled ?? false" -->
4408
4446
  `,
4409
4447
  changeDetection: ChangeDetectionStrategy.OnPush,
4410
4448
  }]
@@ -5473,7 +5511,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
5473
5511
  args: [{
5474
5512
  selector: 'formly-clickable-label-type',
5475
5513
  standalone: true,
5476
- // imports:[NgIf],
5477
5514
  template: `
5478
5515
 
5479
5516
  <a class="cursor-pointer hover:underline hover:text-blue-600 font-bold"
@@ -5515,7 +5552,7 @@ const provideFormly = provideFormlyCore([
5515
5552
  { name: 'generic-selector', component: GenericSelectorTypeComponent, wrappers: ['form-field'] },
5516
5553
  { name: 'switch', component: InputSwitchTypeComponent, wrappers: ['form-field-no'] },
5517
5554
  { name: 'username-with-domain', component: UsernameWithDomainComponent, wrappers: ['form-field'] },
5518
- { name: 'custom-switch', component: CustomSwitchFieldComponent, wrappers: ['form-field'] },
5555
+ { name: 'custom-switch', component: CustomSwitchFieldComponent, wrappers: ['form-field-no'] },
5519
5556
  { name: 'Formly-Split', component: FormlySplitButtonComponent, wrappers: ['form-field'] },
5520
5557
  { name: 'Button-Selection', component: FormlySelectionButtonComponent, wrappers: ['form-field'] },
5521
5558
  { name: 'avatar-label-button', component: FormlyAvatarLabelComponent, },
@@ -5939,6 +5976,7 @@ class BaseCrud {
5939
5976
  currentFilters = {};
5940
5977
  mode = '';
5941
5978
  scrollHeight = '400px';
5979
+ swalService = inject(SwalService$1);
5942
5980
  dialogRef;
5943
5981
  dialogVisible = false;
5944
5982
  drawerVisible = false;
@@ -5984,15 +6022,6 @@ class BaseCrud {
5984
6022
  }
5985
6023
  this.loadPage(0, 10);
5986
6024
  }
5987
- // toQueryParams(obj: any): Record<string, string> {
5988
- // const params: Record<string, string> = {};
5989
- // for (const [key, value] of Object.entries(obj)) {
5990
- // if (value !== null && value !== undefined) {
5991
- // params[key] = String(value);
5992
- // }
5993
- // }
5994
- // return params;
5995
- // }
5996
6025
  visibleChange(value) {
5997
6026
  if (this.mode == 'view') {
5998
6027
  this.dialogVisible = value;
@@ -6115,15 +6144,26 @@ class BaseCrud {
6115
6144
  this.loadPage(0, this.rows);
6116
6145
  });
6117
6146
  }
6147
+ // onDelete(item: any): void {
6148
+ // if (!confirm('هل تريد الحذف فعلاً؟')) return;
6149
+ // const id = (item as any)[this.idField];
6150
+ // this.service.delete(id).subscribe(() => {
6151
+ // this.loadPage(0, this.rows);
6152
+ // });
6153
+ // }
6118
6154
  onDelete(item) {
6119
- if (!confirm('هل تريد الحذف فعلاً؟'))
6120
- return;
6121
6155
  const id = item[this.idField];
6122
- this.service.delete(id).subscribe(() => {
6123
- this.loadPage(0, this.rows);
6156
+ this.swalService.confirm('تأكيد الحذف', 'هل تريد حذف هذا السجل فعلاً؟', 'نعم، احذف', 'إلغاء').then((result) => {
6157
+ if (result.isConfirmed) {
6158
+ this.service.delete(id).subscribe(() => {
6159
+ this.loadPage(0, this.rows);
6160
+ this.swalService.success('تم الحذف بنجاح');
6161
+ }, () => {
6162
+ this.swalService.error('فشل الحذف', 'حدث خطأ أثناء الحذف');
6163
+ });
6164
+ }
6124
6165
  });
6125
6166
  }
6126
- // ✅ Generate table columns from formFields
6127
6167
  get columns() {
6128
6168
  const flattenFields = (fields) => {
6129
6169
  return fields.flatMap(field => {