@messaia/cdk 13.0.0 → 13.0.3

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.
@@ -2532,7 +2532,7 @@ class GenericFormBaseComponent extends BaseComponent {
2532
2532
  /* Send the data to the server */
2533
2533
  this.create().subscribe({
2534
2534
  next: (response) => {
2535
- this.id = response.id;
2535
+ this.id = response?.id;
2536
2536
  this.onAfterSubmit(action, response);
2537
2537
  if (form) {
2538
2538
  Object.keys(form.controls).forEach(key => {
@@ -2592,15 +2592,7 @@ class GenericFormBaseComponent extends BaseComponent {
2592
2592
  isFormValid(form = null) {
2593
2593
  /* Print some debug information */
2594
2594
  if (this.debug) {
2595
- console.log('Form:', form);
2596
- Object.keys(form.controls).forEach(key => {
2597
- const controlErrors = form.controls[key].errors;
2598
- if (controlErrors != null) {
2599
- Object.keys(controlErrors).forEach(keyError => {
2600
- console.log('Key control: ' + key + ', keyError: ' + keyError + ', err value: ', controlErrors[keyError]);
2601
- });
2602
- }
2603
- });
2595
+ this.debugForm(form);
2604
2596
  }
2605
2597
  /* If the form ist not valid.. */
2606
2598
  if (!form.valid) {
@@ -2670,6 +2662,21 @@ class GenericFormBaseComponent extends BaseComponent {
2670
2662
  control.markAsTouched();
2671
2663
  }
2672
2664
  }
2665
+ /**
2666
+ * Shows form errors
2667
+ * @param form
2668
+ */
2669
+ debugForm(form = null) {
2670
+ console.log('Form:', form);
2671
+ Object.keys(form.controls).forEach(key => {
2672
+ const controlErrors = form.controls[key].errors;
2673
+ if (controlErrors != null) {
2674
+ Object.keys(controlErrors).forEach(keyError => {
2675
+ console.log('Key control: ' + key + ', keyError: ' + keyError + ', err value: ', controlErrors[keyError]);
2676
+ });
2677
+ }
2678
+ });
2679
+ }
2673
2680
  /**
2674
2681
  * Loads the previous URL in the history list.
2675
2682
  * @param action
@@ -4374,27 +4381,8 @@ class GenericListComponent extends BaseComponent {
4374
4381
  });
4375
4382
  }
4376
4383
  if (this.dynamicTable) {
4377
- /* Add checkbox column */
4378
- if (this.selectable) {
4379
- this.columns.unshift({ name: 'select', type: TableColumnType.Checkbox, disable: (row) => !this.selectableItem(row), cellNgClass: (row) => this.selectColumnNgClass(row) });
4380
- }
4381
- /* Add duplicate menu */
4382
- if (this.duplicable) {
4383
- this.actionMenus.unshift({ title: $localize `:@@duplicate:Duplicate`, event: (row) => this.duplicate(row) });
4384
- }
4385
- /* Add download menu */
4386
- if (this.downloadable) {
4387
- this.actionMenus.unshift({ title: $localize `:@@download:Download`, event: (row) => this.download(row), hide: (row) => !this.canDownloadItem(row) });
4388
- }
4389
- /* Add delete menu */
4390
- if (this.deleteable) {
4391
- this.toolbarMenus.unshift({ title: $localize `:@@deleteSelected:Delete selected`, event: (_) => this.deleteItems() });
4392
- this.actionMenus.unshift({ title: $localize `:@@delete:Delete`, event: (row) => this.deleteItem(row), hide: (row) => !this.canDeleteItem(row) });
4393
- }
4394
- /* Add edit menu */
4395
- if (this.editable) {
4396
- this.actionMenus.unshift({ title: $localize `:@@edit:Edit`, event: (row) => this.edit(row) });
4397
- }
4384
+ /* Add menu items for each row */
4385
+ this.addRowMenuItems();
4398
4386
  /* Check if the action column already exists */
4399
4387
  var actionColmun = this.columns?.find(x => x.name == 'action');
4400
4388
  /* If so, just add the menu items to it */
@@ -4534,7 +4522,6 @@ class GenericListComponent extends BaseComponent {
4534
4522
  }
4535
4523
  /**
4536
4524
  * Deletes an item from the database.
4537
- * @param ids the IDs of the items to delete
4538
4525
  */
4539
4526
  deleteItems() {
4540
4527
  if (this.dataSource.selectionModel.hasValue()) {
@@ -4552,8 +4539,7 @@ class GenericListComponent extends BaseComponent {
4552
4539
  }
4553
4540
  /**
4554
4541
  * Toggles a property
4555
- * @param id
4556
- * @param enabled
4542
+ * @param item
4557
4543
  * @param property
4558
4544
  */
4559
4545
  toggle(item, property = 'enabled') {
@@ -4607,6 +4593,32 @@ class GenericListComponent extends BaseComponent {
4607
4593
  include(...inc) {
4608
4594
  inc?.forEach(x => this.includes.push(x));
4609
4595
  }
4596
+ /**
4597
+ * Add row menu items
4598
+ */
4599
+ addRowMenuItems() {
4600
+ /* Add checkbox column */
4601
+ if (this.selectable) {
4602
+ this.columns.unshift({ name: 'select', type: TableColumnType.Checkbox, disable: (row) => !this.selectableItem(row), cellNgClass: (row) => this.selectColumnNgClass(row) });
4603
+ }
4604
+ /* Add duplicate menu */
4605
+ if (this.duplicable) {
4606
+ this.actionMenus.unshift({ title: $localize `:@@duplicate:Duplicate`, event: (row) => this.duplicate(row) });
4607
+ }
4608
+ /* Add download menu */
4609
+ if (this.downloadable) {
4610
+ this.actionMenus.unshift({ title: $localize `:@@download:Download`, event: (row) => this.download(row), hide: (row) => !this.canDownloadItem(row) });
4611
+ }
4612
+ /* Add delete menu */
4613
+ if (this.deleteable) {
4614
+ this.toolbarMenus.unshift({ title: $localize `:@@deleteSelected:Delete selected`, event: (_) => this.deleteItems() });
4615
+ this.actionMenus.unshift({ title: $localize `:@@delete:Delete`, event: (row) => this.deleteItem(row), hide: (row) => !this.canDeleteItem(row) });
4616
+ }
4617
+ /* Add edit menu */
4618
+ if (this.editable) {
4619
+ this.actionMenus.unshift({ title: $localize `:@@edit:Edit`, event: (row) => this.edit(row) });
4620
+ }
4621
+ }
4610
4622
  /**
4611
4623
  * Check if the item is deleteable
4612
4624
  */
@@ -11394,6 +11406,14 @@ class GenericReactiveFormComponent extends GenericFormBaseComponent {
11394
11406
  this.form = this.formBuilder.formGroup(this.item, this.formBuilderConfig);
11395
11407
  this.onAfterFormBuild();
11396
11408
  }
11409
+ /**
11410
+ * Shows form errors
11411
+ * @param form
11412
+ */
11413
+ debugForm(form = null) {
11414
+ super.debugForm(form);
11415
+ console.log(this.form.getErrorSummary(false));
11416
+ }
11397
11417
  }
11398
11418
  /** @nocollapse */ /** @nocollapse */ GenericReactiveFormComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.1.3", ngImport: i0, type: GenericReactiveFormComponent, deps: "invalid", target: i0.ɵɵFactoryTarget.Directive });
11399
11419
  /** @nocollapse */ /** @nocollapse */ GenericReactiveFormComponent.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.1.3", type: GenericReactiveFormComponent, usesInheritance: true, ngImport: i0 });