@elite.framework/ng.core 1.0.28 → 1.0.30

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 Swal from 'sweetalert2';
63
64
  import * as i2$4 from 'primeng/datepicker';
64
65
  import { DatePickerModule } from 'primeng/datepicker';
65
66
  import { TabsModule } from 'primeng/tabs';
@@ -76,7 +77,6 @@ import * as i2$6 from 'primeng/textarea';
76
77
  import { TextareaModule } from 'primeng/textarea';
77
78
  import * as i3$4 from 'primeng/radiobutton';
78
79
  import { RadioButtonModule } from 'primeng/radiobutton';
79
- import Swal from 'sweetalert2';
80
80
 
81
81
  class ODataQueryBuilderComponent {
82
82
  set entityFields(fields) {
@@ -1811,31 +1811,29 @@ class CustomSwitchFieldComponent extends FieldType {
1811
1811
  this.model[key] = this.formControl.value ? 1 : 2;
1812
1812
  }
1813
1813
  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 });
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
+ <label [for]="id" class="font-bold text-lg text-gray-800">
1820
+ {{ (to.label ?? '') | translate }}
1821
+
1822
+ <span *ngIf="to.required" class="text-red-500">*</span>
1823
+ </label>
1824
+
1825
+ <!-- التبديل نفسه -->
1826
+ <p-toggleSwitch
1827
+ [formControl]="formControl"
1828
+ [inputId]="id"
1829
+ [pTooltip]="field.props['tooltip']"
1830
+ [styleClass]="''"
1831
+ (onChange)="updateModel($event.checked)"
1832
+ ></p-toggleSwitch>
1833
+
1834
+ </div>
1835
+
1836
+ `, 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
1837
  }
1840
1838
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: CustomSwitchFieldComponent, decorators: [{
1841
1839
  type: Component,
@@ -1850,30 +1848,28 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
1850
1848
  TooltipModule,
1851
1849
  Tooltip
1852
1850
  ],
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
-
1851
+ template: `
1852
+ <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
1853
+ style=" border-radius: var(--p-inputtext-border-radius);">
1854
+
1855
+
1856
+ <label [for]="id" class="font-bold text-lg text-gray-800">
1857
+ {{ (to.label ?? '') | translate }}
1858
+
1859
+ <span *ngIf="to.required" class="text-red-500">*</span>
1860
+ </label>
1861
+
1862
+ <!-- التبديل نفسه -->
1863
+ <p-toggleSwitch
1864
+ [formControl]="formControl"
1865
+ [inputId]="id"
1866
+ [pTooltip]="field.props['tooltip']"
1867
+ [styleClass]="''"
1868
+ (onChange)="updateModel($event.checked)"
1869
+ ></p-toggleSwitch>
1870
+
1871
+ </div>
1872
+
1877
1873
  `,
1878
1874
  changeDetection: ChangeDetectionStrategy.OnPush,
1879
1875
  }]
@@ -3187,9 +3183,82 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
3187
3183
  type: Input
3188
3184
  }] } });
3189
3185
 
3186
+ // app/shared/services/swal.service.ts
3187
+ class SwalService {
3188
+ /** رسالة تأكيد قبل تنفيذ إجراء */
3189
+ confirm(title = 'هل أنت متأكد؟', text = 'لن يمكنك التراجع عن هذا الإجراء', confirmButtonText = 'نعم', cancelButtonText = 'إلغاء') {
3190
+ return Swal.fire({
3191
+ icon: 'warning',
3192
+ title,
3193
+ text,
3194
+ showCancelButton: true,
3195
+ confirmButtonText,
3196
+ cancelButtonText,
3197
+ // reverseButtons: true,
3198
+ customClass: {
3199
+ container: 'swal2-container' // ✅ أضف هذه الفئة
3200
+ }
3201
+ });
3202
+ }
3203
+ /** رسالة نجاح */
3204
+ success(title, text, timer = 2000) {
3205
+ return Swal.fire({
3206
+ icon: 'success',
3207
+ title,
3208
+ text,
3209
+ timer,
3210
+ showConfirmButton: false,
3211
+ customClass: {
3212
+ container: 'swal2-container' // ✅ أضف هذه الفئة
3213
+ }
3214
+ });
3215
+ }
3216
+ /** رسالة خطأ */
3217
+ error(title, text, footer) {
3218
+ return Swal.fire({
3219
+ icon: 'error',
3220
+ title,
3221
+ text,
3222
+ footer,
3223
+ customClass: {
3224
+ container: 'swal2-container' // ✅ أضف هذه الفئة
3225
+ }
3226
+ });
3227
+ }
3228
+ /** رسالة معلومات */
3229
+ info(title, text) {
3230
+ return Swal.fire({
3231
+ icon: 'info',
3232
+ title,
3233
+ text,
3234
+ });
3235
+ }
3236
+ /** عرض نافذة SweetAlert2 بأي خيارات تريد */
3237
+ alert(options) {
3238
+ return Swal.fire(options);
3239
+ }
3240
+ /** Toast بسيط قابل لإعادة الاستخدام */
3241
+ toast(title, icon = 'info', position = 'top-end', timer = 3000) {
3242
+ const Toast = Swal.mixin({
3243
+ toast: true,
3244
+ position,
3245
+ timer,
3246
+ showConfirmButton: false,
3247
+ });
3248
+ Toast.fire({ icon, title });
3249
+ }
3250
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: SwalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
3251
+ static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: SwalService, providedIn: 'root' });
3252
+ }
3253
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: SwalService, decorators: [{
3254
+ type: Injectable,
3255
+ args: [{ providedIn: 'root' }]
3256
+ }] });
3257
+
3190
3258
  class GenericCrudTableComponent {
3191
3259
  genericTable;
3192
3260
  translate = inject(TranslateService);
3261
+ swalService = inject(SwalService);
3193
3262
  home = { icon: 'pi pi-home', routerLink: '/' };
3194
3263
  data = [];
3195
3264
  formFields_ = []; // <-- هنا
@@ -3333,32 +3402,68 @@ class GenericCrudTableComponent {
3333
3402
  }
3334
3403
  }
3335
3404
  beforeSave = (record) => record;
3405
+ // onSubmit() {
3406
+ // if (this.form.invalid) return;
3407
+ // this.loading = true;
3408
+ // this.errorMessage = null;
3409
+ // const service = this.service /* as CrudService<T> */;
3410
+ // const id = this.isEditMode ? (this.model as any)[this.idField] : null;
3411
+ // const recordToSave = this.beforeSave({ ...this.model });
3412
+ // const operation$: Observable<any> = this.isEditMode
3413
+ // ? service.update(id, recordToSave)
3414
+ // : service.create(recordToSave);
3415
+ // // operation$.pipe(takeUntil(this.destroy$)).subscribe({
3416
+ // operation$.subscribe({
3417
+ // next: () => {
3418
+ // // this.ref.close(true); // نجاح العملية
3419
+ // this.visibleChange.emit(false)
3420
+ // // this.pageChange.emit({ first, rows ,sort, filters });
3421
+ // this.applySearch('');
3422
+ // // this.me
3423
+ // },
3424
+ // error: (err:any) => {
3425
+ // this.loading = false;
3426
+ // this.errorMessage = err.error?.title ||
3427
+ // err.message ||
3428
+ // 'حدث خطأ أثناء الحفظ. يرجى المحاولة مرة أخرى.';
3429
+ // }
3430
+ // });
3431
+ // }
3336
3432
  onSubmit() {
3337
3433
  if (this.form.invalid)
3338
3434
  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
- }
3435
+ // أول شيء نطلب تأكيد من المستخدم
3436
+ this.swalService.confirm(this.isEditMode ? 'تأكيد التعديل' : 'تأكيد الحفظ', this.isEditMode
3437
+ ? 'هل تريد حفظ التعديلات على هذا السجل؟'
3438
+ : 'هل تريد حفظ هذا السجل؟', 'نعم', 'إلغاء').then((result) => {
3439
+ if (!result.isConfirmed)
3440
+ return;
3441
+ this.loading = true;
3442
+ this.errorMessage = null;
3443
+ const service = this.service;
3444
+ const id = this.isEditMode ? this.model[this.idField] : null;
3445
+ const recordToSave = this.beforeSave({ ...this.model });
3446
+ const operation$ = this.isEditMode
3447
+ ? service.update(id, recordToSave)
3448
+ : service.create(recordToSave);
3449
+ operation$.subscribe({
3450
+ next: () => {
3451
+ this.loading = false;
3452
+ // رسالة نجاح
3453
+ this.swalService.success(this.isEditMode ? 'تم التعديل بنجاح' : 'تم الحفظ بنجاح');
3454
+ this.visibleChange.emit(false);
3455
+ this.applySearch('');
3456
+ },
3457
+ error: (err) => {
3458
+ this.loading = false;
3459
+ const msg = err.error?.title ||
3460
+ err.message ||
3461
+ 'حدث خطأ أثناء الحفظ. يرجى المحاولة مرة أخرى.';
3462
+ this.errorMessage = msg;
3463
+ // ❌ رسالة خطأ
3464
+ this.swalService.error('فشل الحفظ', msg);
3465
+ }
3466
+ });
3362
3467
  });
3363
3468
  }
3364
3469
  trackByIdx(index, item) {
@@ -4341,32 +4446,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
4341
4446
 
4342
4447
  class InputSwitchTypeComponent extends FieldType {
4343
4448
  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" -->
4449
+ 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: `
4450
+ <!-- border border-gray-300 -->
4451
+ <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
4452
+ style=" border-radius: var(--p-inputtext-border-radius);">
4453
+
4454
+ <label [for]="id" class="font-bold text-lg text-gray-800">
4455
+ {{ (to.label ?? '') | translate }}
4456
+
4457
+ <span *ngIf="to.required" class="text-red-500">*</span>
4458
+ </label>
4459
+
4460
+ <p-toggleSwitch
4461
+ [formControl]="formControl"
4462
+ [formlyAttributes]="field"
4463
+ [pTooltip]="field.props['tooltip']"
4464
+ [styleClass]="''"
4465
+ [inputId]="id"
4466
+
4467
+ ></p-toggleSwitch>
4468
+
4469
+
4470
+ <!-- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
4471
+ {{ (to.label ?? '') | translate}}
4472
+ </label> -->
4473
+ </div>
4474
+ <!-- [style]="to.['style']" -->
4475
+ <!-- [disabled]="to.disabled ?? false" -->
4370
4476
  `, 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
4477
  }
4372
4478
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: InputSwitchTypeComponent, decorators: [{
@@ -4381,32 +4487,33 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
4381
4487
  FormlyAttributes,
4382
4488
  TranslateModule,
4383
4489
  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" -->
4490
+ template: `
4491
+ <!-- border border-gray-300 -->
4492
+ <div class="flex items-center justify-between rtl:flex-row-reverse w-full px-2 py-1"
4493
+ style=" border-radius: var(--p-inputtext-border-radius);">
4494
+
4495
+ <label [for]="id" class="font-bold text-lg text-gray-800">
4496
+ {{ (to.label ?? '') | translate }}
4497
+
4498
+ <span *ngIf="to.required" class="text-red-500">*</span>
4499
+ </label>
4500
+
4501
+ <p-toggleSwitch
4502
+ [formControl]="formControl"
4503
+ [formlyAttributes]="field"
4504
+ [pTooltip]="field.props['tooltip']"
4505
+ [styleClass]="''"
4506
+ [inputId]="id"
4507
+
4508
+ ></p-toggleSwitch>
4509
+
4510
+
4511
+ <!-- <label [for]="id" class="font-bold text-lg text-gray-800 mr-2 whitespace-nowrap">
4512
+ {{ (to.label ?? '') | translate}}
4513
+ </label> -->
4514
+ </div>
4515
+ <!-- [style]="to.['style']" -->
4516
+ <!-- [disabled]="to.disabled ?? false" -->
4410
4517
  `,
4411
4518
  changeDetection: ChangeDetectionStrategy.OnPush,
4412
4519
  }]
@@ -5475,7 +5582,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
5475
5582
  args: [{
5476
5583
  selector: 'formly-clickable-label-type',
5477
5584
  standalone: true,
5478
- // imports:[NgIf],
5479
5585
  template: `
5480
5586
 
5481
5587
  <a class="cursor-pointer hover:underline hover:text-blue-600 font-bold"
@@ -5517,7 +5623,7 @@ const provideFormly = provideFormlyCore([
5517
5623
  { name: 'generic-selector', component: GenericSelectorTypeComponent, wrappers: ['form-field'] },
5518
5624
  { name: 'switch', component: InputSwitchTypeComponent, wrappers: ['form-field-no'] },
5519
5625
  { name: 'username-with-domain', component: UsernameWithDomainComponent, wrappers: ['form-field'] },
5520
- { name: 'custom-switch', component: CustomSwitchFieldComponent, wrappers: ['form-field'] },
5626
+ { name: 'custom-switch', component: CustomSwitchFieldComponent, wrappers: ['form-field-no'] },
5521
5627
  { name: 'Formly-Split', component: FormlySplitButtonComponent, wrappers: ['form-field'] },
5522
5628
  { name: 'Button-Selection', component: FormlySelectionButtonComponent, wrappers: ['form-field'] },
5523
5629
  { name: 'avatar-label-button', component: FormlyAvatarLabelComponent, },
@@ -5941,6 +6047,7 @@ class BaseCrud {
5941
6047
  currentFilters = {};
5942
6048
  mode = '';
5943
6049
  scrollHeight = '400px';
6050
+ swalService = inject(SwalService);
5944
6051
  dialogRef;
5945
6052
  dialogVisible = false;
5946
6053
  drawerVisible = false;
@@ -5986,15 +6093,6 @@ class BaseCrud {
5986
6093
  }
5987
6094
  this.loadPage(0, 10);
5988
6095
  }
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
6096
  visibleChange(value) {
5999
6097
  if (this.mode == 'view') {
6000
6098
  this.dialogVisible = value;
@@ -6117,15 +6215,26 @@ class BaseCrud {
6117
6215
  this.loadPage(0, this.rows);
6118
6216
  });
6119
6217
  }
6218
+ // onDelete(item: any): void {
6219
+ // if (!confirm('هل تريد الحذف فعلاً؟')) return;
6220
+ // const id = (item as any)[this.idField];
6221
+ // this.service.delete(id).subscribe(() => {
6222
+ // this.loadPage(0, this.rows);
6223
+ // });
6224
+ // }
6120
6225
  onDelete(item) {
6121
- if (!confirm('هل تريد الحذف فعلاً؟'))
6122
- return;
6123
6226
  const id = item[this.idField];
6124
- this.service.delete(id).subscribe(() => {
6125
- this.loadPage(0, this.rows);
6227
+ this.swalService.confirm('تأكيد الحذف', 'هل تريد حذف هذا السجل فعلاً؟', 'نعم، احذف', 'إلغاء').then((result) => {
6228
+ if (result.isConfirmed) {
6229
+ this.service.delete(id).subscribe(() => {
6230
+ this.loadPage(0, this.rows);
6231
+ this.swalService.success('تم الحذف بنجاح');
6232
+ }, () => {
6233
+ this.swalService.error('فشل الحذف', 'حدث خطأ أثناء الحذف');
6234
+ });
6235
+ }
6126
6236
  });
6127
6237
  }
6128
- // ✅ Generate table columns from formFields
6129
6238
  get columns() {
6130
6239
  const flattenFields = (fields) => {
6131
6240
  return fields.flatMap(field => {
@@ -6869,78 +6978,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImpor
6869
6978
  args: [REQUEST]
6870
6979
  }] }] });
6871
6980
 
6872
- // app/shared/services/swal.service.ts
6873
- class SwalService {
6874
- /** رسالة تأكيد قبل تنفيذ إجراء */
6875
- confirm(title = 'هل أنت متأكد؟', text = 'لن يمكنك التراجع عن هذا الإجراء', confirmButtonText = 'نعم', cancelButtonText = 'إلغاء') {
6876
- return Swal.fire({
6877
- icon: 'warning',
6878
- title,
6879
- text,
6880
- showCancelButton: true,
6881
- confirmButtonText,
6882
- cancelButtonText,
6883
- // reverseButtons: true,
6884
- customClass: {
6885
- container: 'swal2-container' // ✅ أضف هذه الفئة
6886
- }
6887
- });
6888
- }
6889
- /** رسالة نجاح */
6890
- success(title, text, timer = 2000) {
6891
- return Swal.fire({
6892
- icon: 'success',
6893
- title,
6894
- text,
6895
- timer,
6896
- showConfirmButton: false,
6897
- customClass: {
6898
- container: 'swal2-container' // ✅ أضف هذه الفئة
6899
- }
6900
- });
6901
- }
6902
- /** رسالة خطأ */
6903
- error(title, text, footer) {
6904
- return Swal.fire({
6905
- icon: 'error',
6906
- title,
6907
- text,
6908
- footer,
6909
- customClass: {
6910
- container: 'swal2-container' // ✅ أضف هذه الفئة
6911
- }
6912
- });
6913
- }
6914
- /** رسالة معلومات */
6915
- info(title, text) {
6916
- return Swal.fire({
6917
- icon: 'info',
6918
- title,
6919
- text,
6920
- });
6921
- }
6922
- /** عرض نافذة SweetAlert2 بأي خيارات تريد */
6923
- alert(options) {
6924
- return Swal.fire(options);
6925
- }
6926
- /** Toast بسيط قابل لإعادة الاستخدام */
6927
- toast(title, icon = 'info', position = 'top-end', timer = 3000) {
6928
- const Toast = Swal.mixin({
6929
- toast: true,
6930
- position,
6931
- timer,
6932
- showConfirmButton: false,
6933
- });
6934
- Toast.fire({ icon, title });
6935
- }
6936
- static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: SwalService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
6937
- static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: SwalService, providedIn: 'root' });
6938
- }
6939
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.1.4", ngImport: i0, type: SwalService, decorators: [{
6940
- type: Injectable,
6941
- args: [{ providedIn: 'root' }]
6942
- }] });
6943
-
6944
6981
  /*
6945
6982
  * Public API Surface of @framework/ng.core
6946
6983
  */