@dexteel/mesf-core 4.11.1 → 4.11.2

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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,13 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [4.11.2](https://github.com/dexteel/mesf-core-frontend/compare/v4.11.1...v4.11.2) (2024-05-09)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * **Assets Tree:** Fix bug when assets have parent assets with IsActive as false ([b27651e](https://github.com/dexteel/mesf-core-frontend/commit/b27651e6b6777b140fd0b0738408bfcc3fc42f14))
11
+
5
12
  ### [4.11.1](https://github.com/dexteel/mesf-core-frontend/compare/v4.11.0...v4.11.1) (2024-05-05)
6
13
 
7
14
 
@@ -4,4 +4,5 @@ export interface AssetCode {
4
4
  name: string;
5
5
  isLeaf: boolean | null;
6
6
  isActive: boolean | null;
7
+ children: AssetCode[];
7
8
  }
package/dist/index.esm.js CHANGED
@@ -4704,28 +4704,29 @@ var useAssetCodes = function () {
4704
4704
  }
4705
4705
  // Use our mapping to locate the parent element in our data array
4706
4706
  var parentEl = nodes[idMapping[el.parentId]];
4707
+ // Handle the case where the element has no parent
4708
+ if (!parentEl) {
4709
+ console.log(el);
4710
+ return;
4711
+ }
4707
4712
  // Add our current el to its parent's `children` array
4708
- parentEl.children = __spreadArray(__spreadArray([], (parentEl.children || []), true), [el], false);
4713
+ if (!parentEl['children']) {
4714
+ parentEl['children'] = [];
4715
+ }
4716
+ parentEl['children'] = __spreadArray(__spreadArray([], (parentEl['children'] || []), true), [el], false);
4709
4717
  });
4710
4718
  setAssetCodes(root);
4711
4719
  };
4712
4720
  var loadFilterAssets = function () {
4713
- var mydataSource = [];
4714
- allAssets.forEach(function (row) {
4715
- var code = TransformAssetCodeModel(row);
4716
- mydataSource = __spreadArray(__spreadArray([], mydataSource, true), [code], false);
4717
- });
4718
- buildTreeAssets(mydataSource);
4719
- };
4720
- var TransformAssetCodeModel = function (data) {
4721
- var model = {
4722
- id: data.AssetId,
4723
- parentId: data.ParentAssetId,
4724
- name: data.AssetName,
4725
- isLeaf: data.isLeaf,
4726
- isActive: true
4727
- };
4728
- return model;
4721
+ var nodes = allAssets.map(function (el) { return ({
4722
+ id: el.AssetId,
4723
+ parentId: el.ParentAssetId,
4724
+ name: el.AssetName,
4725
+ isLeaf: !!el.IsLeaf,
4726
+ isActive: true,
4727
+ children: []
4728
+ }); });
4729
+ buildTreeAssets(nodes);
4729
4730
  };
4730
4731
  return { loadFilterAssets: loadFilterAssets };
4731
4732
  };