@zeedhi/common 1.64.0 → 1.64.1

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.
@@ -5579,34 +5579,38 @@ class Grid extends Iterable {
5579
5579
  });
5580
5580
  }
5581
5581
  getActionComponent(actionComponent, column, row, parentPath = '') {
5582
- var _a, _b, _c;
5582
+ var _a, _b, _c, _d;
5583
5583
  const rowKey = row[this.datasource.uniqueKey];
5584
5584
  const compName = actionComponent.name;
5585
5585
  const instanceName = `${compName}_${rowKey}`;
5586
5586
  const path = parentPath ? `${parentPath}.${compName}` : compName;
5587
5587
  const newComponent = merge({}, actionComponent, (_b = (_a = this.actionsApplied[rowKey]) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b[path]);
5588
- let compEvents = {};
5589
- if (newComponent.events) {
5590
- compEvents = Event.factory(newComponent.events);
5588
+ let newClickEvt;
5589
+ if ((_c = newComponent.events) === null || _c === void 0 ? void 0 : _c.click) {
5590
+ const compEvents = Event.factory(newComponent.events);
5591
+ if (typeof compEvents.click === 'function') {
5592
+ newClickEvt = ({ component, event, element }) => compEvents.click({
5593
+ component, event, element, row, column,
5594
+ });
5595
+ }
5591
5596
  }
5592
- const newEvents = Object.assign(Object.assign({}, compEvents), { click: ({ component, event, element }) => {
5593
- if (compEvents.click) {
5594
- compEvents.click({
5595
- component, event, element, row, column,
5596
- });
5597
- }
5598
- } });
5599
- const newChildren = (_c = newComponent.children) === null || _c === void 0 ? void 0 : _c.map((child) => this.getActionComponent(child, column, row, path));
5597
+ const newChildren = (_d = newComponent.children) === null || _d === void 0 ? void 0 : _d.map((child) => this.getActionComponent(child, column, row, path));
5600
5598
  newComponent.name = instanceName;
5601
5599
  newComponent.children = newChildren;
5602
- newComponent.events = newEvents;
5603
5600
  try {
5604
5601
  const updatedComponent = Object.assign({}, newComponent);
5605
5602
  delete updatedComponent.datasource;
5606
- Metadata.updateInstance(instanceName, updatedComponent);
5603
+ delete updatedComponent.events;
5604
+ const instance = Metadata.updateInstance(instanceName, updatedComponent);
5605
+ if (newClickEvt)
5606
+ instance.events.click = newClickEvt;
5607
5607
  }
5608
5608
  catch (e) {
5609
- // do nothing
5609
+ if (!newComponent.events) {
5610
+ newComponent.events = {};
5611
+ }
5612
+ if (newClickEvt)
5613
+ newComponent.events.click = newClickEvt;
5610
5614
  }
5611
5615
  return newComponent;
5612
5616
  }
@@ -5586,34 +5586,38 @@
5586
5586
  });
5587
5587
  }
5588
5588
  getActionComponent(actionComponent, column, row, parentPath = '') {
5589
- var _a, _b, _c;
5589
+ var _a, _b, _c, _d;
5590
5590
  const rowKey = row[this.datasource.uniqueKey];
5591
5591
  const compName = actionComponent.name;
5592
5592
  const instanceName = `${compName}_${rowKey}`;
5593
5593
  const path = parentPath ? `${parentPath}.${compName}` : compName;
5594
5594
  const newComponent = merge__default["default"]({}, actionComponent, (_b = (_a = this.actionsApplied[rowKey]) === null || _a === void 0 ? void 0 : _a[column.name]) === null || _b === void 0 ? void 0 : _b[path]);
5595
- let compEvents = {};
5596
- if (newComponent.events) {
5597
- compEvents = core.Event.factory(newComponent.events);
5595
+ let newClickEvt;
5596
+ if ((_c = newComponent.events) === null || _c === void 0 ? void 0 : _c.click) {
5597
+ const compEvents = core.Event.factory(newComponent.events);
5598
+ if (typeof compEvents.click === 'function') {
5599
+ newClickEvt = ({ component, event, element }) => compEvents.click({
5600
+ component, event, element, row, column,
5601
+ });
5602
+ }
5598
5603
  }
5599
- const newEvents = Object.assign(Object.assign({}, compEvents), { click: ({ component, event, element }) => {
5600
- if (compEvents.click) {
5601
- compEvents.click({
5602
- component, event, element, row, column,
5603
- });
5604
- }
5605
- } });
5606
- const newChildren = (_c = newComponent.children) === null || _c === void 0 ? void 0 : _c.map((child) => this.getActionComponent(child, column, row, path));
5604
+ const newChildren = (_d = newComponent.children) === null || _d === void 0 ? void 0 : _d.map((child) => this.getActionComponent(child, column, row, path));
5607
5605
  newComponent.name = instanceName;
5608
5606
  newComponent.children = newChildren;
5609
- newComponent.events = newEvents;
5610
5607
  try {
5611
5608
  const updatedComponent = Object.assign({}, newComponent);
5612
5609
  delete updatedComponent.datasource;
5613
- core.Metadata.updateInstance(instanceName, updatedComponent);
5610
+ delete updatedComponent.events;
5611
+ const instance = core.Metadata.updateInstance(instanceName, updatedComponent);
5612
+ if (newClickEvt)
5613
+ instance.events.click = newClickEvt;
5614
5614
  }
5615
5615
  catch (e) {
5616
- // do nothing
5616
+ if (!newComponent.events) {
5617
+ newComponent.events = {};
5618
+ }
5619
+ if (newClickEvt)
5620
+ newComponent.events.click = newClickEvt;
5617
5621
  }
5618
5622
  return newComponent;
5619
5623
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.64.0",
3
+ "version": "1.64.1",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -39,5 +39,5 @@
39
39
  "lodash.times": "^4.3.2",
40
40
  "mockdate": "^3.0.2"
41
41
  },
42
- "gitHead": "b6b5f30c0cad72871a9dfb193046d7523f34e302"
42
+ "gitHead": "459021cbc1875f83cec7a00c975aac8e9dba27c5"
43
43
  }