@elite.framework/ng.core 1.0.28 → 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) {
@@ -4341,32 +4375,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
4341
4375
 
4342
4376
  class InputSwitchTypeComponent extends FieldType {
4343
4377
  static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: InputSwitchTypeComponent, deps: null, target: i0.ɵɵFactoryTarget.Component });
4344
- 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: `
4345
- <!-- border border-gray-300 -->
4346
- <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
4347
- style=" border-radius: var(--p-inputtext-border-radius);">
4348
-
4349
- <label [for]="id" class="font-bold text-lg text-gray-800">
4350
- {{ (to.label ?? '') | translate }}
4351
- <span *ngIf="to.required" class="text-red-500">*</span>
4352
- </label>
4353
-
4354
- <p-toggleSwitch
4355
- [formControl]="formControl"
4356
- [formlyAttributes]="field"
4357
- [pTooltip]="field.props['tooltip']"
4358
- [styleClass]="''"
4359
- [inputId]="id"
4360
-
4361
- ></p-toggleSwitch>
4362
-
4363
-
4364
- <!-- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
4365
- {{ (to.label ?? '') | translate}}
4366
- </label> -->
4367
- </div>
4368
- <!-- [style]="to.['style']" -->
4369
- <!-- [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" -->
4370
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 });
4371
4406
  }
4372
4407
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: InputSwitchTypeComponent, decorators: [{
@@ -4381,32 +4416,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
4381
4416
  FormlyAttributes,
4382
4417
  TranslateModule,
4383
4418
  TooltipModule],
4384
- template: `
4385
- <!-- border border-gray-300 -->
4386
- <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
4387
- style=" border-radius: var(--p-inputtext-border-radius);">
4388
-
4389
- <label [for]="id" class="font-bold text-lg text-gray-800">
4390
- {{ (to.label ?? '') | translate }}
4391
- <span *ngIf="to.required" class="text-red-500">*</span>
4392
- </label>
4393
-
4394
- <p-toggleSwitch
4395
- [formControl]="formControl"
4396
- [formlyAttributes]="field"
4397
- [pTooltip]="field.props['tooltip']"
4398
- [styleClass]="''"
4399
- [inputId]="id"
4400
-
4401
- ></p-toggleSwitch>
4402
-
4403
-
4404
- <!-- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
4405
- {{ (to.label ?? '') | translate}}
4406
- </label> -->
4407
- </div>
4408
- <!-- [style]="to.['style']" -->
4409
- <!-- [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" -->
4410
4446
  `,
4411
4447
  changeDetection: ChangeDetectionStrategy.OnPush,
4412
4448
  }]
@@ -5475,7 +5511,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
5475
5511
  args: [{
5476
5512
  selector: 'formly-clickable-label-type',
5477
5513
  standalone: true,
5478
- // imports:[NgIf],
5479
5514
  template: `
5480
5515
 
5481
5516
  <a class="cursor-pointer hover:underline hover:text-blue-600 font-bold"
@@ -5517,7 +5552,7 @@ const provideFormly = provideFormlyCore([
5517
5552
  { name: 'generic-selector', component: GenericSelectorTypeComponent, wrappers: ['form-field'] },
5518
5553
  { name: 'switch', component: InputSwitchTypeComponent, wrappers: ['form-field-no'] },
5519
5554
  { name: 'username-with-domain', component: UsernameWithDomainComponent, wrappers: ['form-field'] },
5520
- { name: 'custom-switch', component: CustomSwitchFieldComponent, wrappers: ['form-field'] },
5555
+ { name: 'custom-switch', component: CustomSwitchFieldComponent, wrappers: ['form-field-no'] },
5521
5556
  { name: 'Formly-Split', component: FormlySplitButtonComponent, wrappers: ['form-field'] },
5522
5557
  { name: 'Button-Selection', component: FormlySelectionButtonComponent, wrappers: ['form-field'] },
5523
5558
  { name: 'avatar-label-button', component: FormlyAvatarLabelComponent, },
@@ -5941,6 +5976,7 @@ class BaseCrud {
5941
5976
  currentFilters = {};
5942
5977
  mode = '';
5943
5978
  scrollHeight = '400px';
5979
+ swalService = inject(SwalService$1);
5944
5980
  dialogRef;
5945
5981
  dialogVisible = false;
5946
5982
  drawerVisible = false;
@@ -5986,15 +6022,6 @@ class BaseCrud {
5986
6022
  }
5987
6023
  this.loadPage(0, 10);
5988
6024
  }
5989
- // toQueryParams(obj: any): Record<string, string> {
5990
- // const params: Record<string, string> = {};
5991
- // for (const [key, value] of Object.entries(obj)) {
5992
- // if (value !== null && value !== undefined) {
5993
- // params[key] = String(value);
5994
- // }
5995
- // }
5996
- // return params;
5997
- // }
5998
6025
  visibleChange(value) {
5999
6026
  if (this.mode == 'view') {
6000
6027
  this.dialogVisible = value;
@@ -6117,15 +6144,26 @@ class BaseCrud {
6117
6144
  this.loadPage(0, this.rows);
6118
6145
  });
6119
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
+ // }
6120
6154
  onDelete(item) {
6121
- if (!confirm('هل تريد الحذف فعلاً؟'))
6122
- return;
6123
6155
  const id = item[this.idField];
6124
- this.service.delete(id).subscribe(() => {
6125
- 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
+ }
6126
6165
  });
6127
6166
  }
6128
- // ✅ Generate table columns from formFields
6129
6167
  get columns() {
6130
6168
  const flattenFields = (fields) => {
6131
6169
  return fields.flatMap(field => {