@zeedhi/common 1.70.0 → 1.71.0

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.
@@ -2869,9 +2869,9 @@ class ModalService {
2869
2869
  * Creates a new modal instance from JSON
2870
2870
  * @param modal modal structure
2871
2871
  */
2872
- static createFromJson(modalPath, local) {
2872
+ static createFromJson(modalPath, local, JSONCache) {
2873
2873
  return __awaiter(this, void 0, void 0, function* () {
2874
- const modal = yield Metadata.get(modalPath, local);
2874
+ const modal = yield Metadata.get(modalPath, local, JSONCache);
2875
2875
  return this.create(modal);
2876
2876
  });
2877
2877
  }
@@ -2948,37 +2948,6 @@ class LoadingService {
2948
2948
  }
2949
2949
  }
2950
2950
 
2951
- class JsonCacheService {
2952
- static saveJSONCache(jsonCollection) {
2953
- return __awaiter(this, void 0, void 0, function* () {
2954
- const jsonCollectionInCache = jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
2955
- const { path } = jsonItem;
2956
- const metadata = yield Metadata.get(path, true);
2957
- localStorage.setItem(path, JSON.stringify(metadata));
2958
- }));
2959
- yield Promise.all(jsonCollectionInCache);
2960
- });
2961
- }
2962
- static getJSONCache(path) {
2963
- const getMetadaFromCache = localStorage.getItem(path);
2964
- let metadataValueReturn = false;
2965
- if (typeof getMetadaFromCache === 'string') {
2966
- metadataValueReturn = JSON.parse(getMetadaFromCache);
2967
- }
2968
- return metadataValueReturn;
2969
- }
2970
- static clearJSONCache(jsonCollection) {
2971
- jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
2972
- const { path } = jsonItem;
2973
- localStorage.removeItem(path);
2974
- }));
2975
- }
2976
- }
2977
- /**
2978
- * jsons collection
2979
- */
2980
- JsonCacheService.jsonCollection = [];
2981
-
2982
2951
  /**
2983
2952
  * Base class for Dashboard component.
2984
2953
  */
@@ -4589,18 +4558,8 @@ class Frame extends ComponentRender {
4589
4558
  }
4590
4559
  getMetadata() {
4591
4560
  return __awaiter(this, void 0, void 0, function* () {
4592
- let page;
4593
4561
  try {
4594
- if (this.JSONCache) {
4595
- page = JsonCacheService.getJSONCache(this.path);
4596
- if (page === false) {
4597
- yield JsonCacheService.saveJSONCache([{ path: this.path }]);
4598
- page = yield this.requestPage();
4599
- }
4600
- }
4601
- else {
4602
- page = yield this.requestPage();
4603
- }
4562
+ const page = yield this.requestPage();
4604
4563
  if (typeof page !== 'object')
4605
4564
  throw new Error();
4606
4565
  this.metadata = merge(page, this.override);
@@ -4640,7 +4599,7 @@ class Frame extends ComponentRender {
4640
4599
  if (this.type === 'post') {
4641
4600
  return Metadata.post(this.path, this.params);
4642
4601
  }
4643
- return Metadata.get(this.path, this.local);
4602
+ return Metadata.get(this.path, this.local, this.JSONCache);
4644
4603
  }
4645
4604
  const url = Metadata.getMetadataUrl(this.path, this.local);
4646
4605
  const cache = yield caches.open(Frame.cacheName);
@@ -11609,6 +11568,7 @@ class TreeGrid extends Grid {
11609
11568
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
11610
11569
  this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
11611
11570
  this.flat = this.getInitValue('flat', props.flat, this.flat);
11571
+ this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
11612
11572
  this.detach = this.getInitValue('detach', props.detach, this.detach);
11613
11573
  this.treeDataStructure = new TreeDataStructure(this);
11614
11574
  this.createAccessors();
@@ -11727,7 +11687,9 @@ class TreeGrid extends Grid {
11727
11687
  * @param isSelected row is selected
11728
11688
  */
11729
11689
  selectRow(row, isSelected) {
11730
- const childrenRows = !this.flat ? this.treeDataStructure.getChildren(row) : [];
11690
+ const childrenRows = !this.flat
11691
+ ? this.treeDataStructure.getChildren(row)
11692
+ : [];
11731
11693
  const rows = [row, ...childrenRows];
11732
11694
  if (isSelected) {
11733
11695
  this.selectedRows = this.removeDuplicates(this.selectedRows.concat(rows), this.datasource.uniqueKey);
@@ -11770,7 +11732,9 @@ class TreeGrid extends Grid {
11770
11732
  selectParents(row) {
11771
11733
  if (row[this.parentField]) {
11772
11734
  const parentRow = this.treeDataStructure.getRowData(row).tree__parent;
11773
- const every = this.treeDataStructure.getChildren(parentRow).every((item) => {
11735
+ const every = this.treeDataStructure
11736
+ .getChildren(parentRow)
11737
+ .every((item) => {
11774
11738
  const index = this.treeDataStructure.findDataIndex(this.selectedRows, item[this.datasource.uniqueKey]);
11775
11739
  if (index > -1)
11776
11740
  return true;
@@ -13438,4 +13402,4 @@ const AutoNumeric = require('@zeedhi/autonumeric/dist/autoNumeric');
13438
13402
  const packageContent = require('../package.json');
13439
13403
  VersionService.addPackageVersion(packageContent.name, packageContent.version);
13440
13404
 
13441
- export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, Header, Icon, Icons, Image, Increment, Input, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, JsonCacheService, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };
13405
+ export { Alert, AlertService, ApexChart, AutoNumeric, Badge, Breadcrumbs, Button, ButtonGroup, CSVReport, Card, Carousel, Checkbox, CheckboxMultiple, ChildNotFoundError, Chip, CodeEditor, Col, CollapseCard, Column, ColumnNotFoundError, Component, ComponentRender, Container, Currency, Dashboard, Date$1 as Date, DateRange, Dialog, DialogService, Divider, Dropdown, FileInput, Footer, Form, Frame, FramePage, Grid, GridColumn, GridColumnEditable, GridEditable, Header, Icon, Icons, Image, Increment, Input, Iterable, IterableColumnsButton, IterableColumnsButtonController, IterableComponentRender, IterablePageComponent, IterablePageInfo, IterablePageSize, IterablePagination, List, ListGroup, ListItem, Loading, LoadingService, Login, LoginButton, MasterDetail, Menu, MenuButton, MenuGroup, MenuLink, MenuSeparator, Modal, ModalCloseButton, ModalService, Month, Number$1 as Number, PDFReport, Password, Progress, Radio, RangeSlider, Report, Row, Search, Select, SelectMultiple, SelectTree, SelectTreeMultiple, SelectableList, SpeedDial, Steppers, SvgMap, Switch, Tab, Table, Tabs, Tag, Text, TextInput, Textarea, Time, Toggleable, Tooltip, Tree, TreeDataStructure, TreeGrid, TreeGridEditable, WatchURL, XLS2Report, XLS3Report, XLSReport, initTheme };
@@ -2876,9 +2876,9 @@
2876
2876
  * Creates a new modal instance from JSON
2877
2877
  * @param modal modal structure
2878
2878
  */
2879
- static createFromJson(modalPath, local) {
2879
+ static createFromJson(modalPath, local, JSONCache) {
2880
2880
  return __awaiter(this, void 0, void 0, function* () {
2881
- const modal = yield core.Metadata.get(modalPath, local);
2881
+ const modal = yield core.Metadata.get(modalPath, local, JSONCache);
2882
2882
  return this.create(modal);
2883
2883
  });
2884
2884
  }
@@ -2955,37 +2955,6 @@
2955
2955
  }
2956
2956
  }
2957
2957
 
2958
- class JsonCacheService {
2959
- static saveJSONCache(jsonCollection) {
2960
- return __awaiter(this, void 0, void 0, function* () {
2961
- const jsonCollectionInCache = jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
2962
- const { path } = jsonItem;
2963
- const metadata = yield core.Metadata.get(path, true);
2964
- localStorage.setItem(path, JSON.stringify(metadata));
2965
- }));
2966
- yield Promise.all(jsonCollectionInCache);
2967
- });
2968
- }
2969
- static getJSONCache(path) {
2970
- const getMetadaFromCache = localStorage.getItem(path);
2971
- let metadataValueReturn = false;
2972
- if (typeof getMetadaFromCache === 'string') {
2973
- metadataValueReturn = JSON.parse(getMetadaFromCache);
2974
- }
2975
- return metadataValueReturn;
2976
- }
2977
- static clearJSONCache(jsonCollection) {
2978
- jsonCollection.map((jsonItem) => __awaiter(this, void 0, void 0, function* () {
2979
- const { path } = jsonItem;
2980
- localStorage.removeItem(path);
2981
- }));
2982
- }
2983
- }
2984
- /**
2985
- * jsons collection
2986
- */
2987
- JsonCacheService.jsonCollection = [];
2988
-
2989
2958
  /**
2990
2959
  * Base class for Dashboard component.
2991
2960
  */
@@ -4596,18 +4565,8 @@
4596
4565
  }
4597
4566
  getMetadata() {
4598
4567
  return __awaiter(this, void 0, void 0, function* () {
4599
- let page;
4600
4568
  try {
4601
- if (this.JSONCache) {
4602
- page = JsonCacheService.getJSONCache(this.path);
4603
- if (page === false) {
4604
- yield JsonCacheService.saveJSONCache([{ path: this.path }]);
4605
- page = yield this.requestPage();
4606
- }
4607
- }
4608
- else {
4609
- page = yield this.requestPage();
4610
- }
4569
+ const page = yield this.requestPage();
4611
4570
  if (typeof page !== 'object')
4612
4571
  throw new Error();
4613
4572
  this.metadata = merge__default["default"](page, this.override);
@@ -4647,7 +4606,7 @@
4647
4606
  if (this.type === 'post') {
4648
4607
  return core.Metadata.post(this.path, this.params);
4649
4608
  }
4650
- return core.Metadata.get(this.path, this.local);
4609
+ return core.Metadata.get(this.path, this.local, this.JSONCache);
4651
4610
  }
4652
4611
  const url = core.Metadata.getMetadataUrl(this.path, this.local);
4653
4612
  const cache = yield caches.open(Frame.cacheName);
@@ -11616,6 +11575,7 @@
11616
11575
  this.parentField = this.getInitValue('parentField', props.parentField, this.parentField);
11617
11576
  this.fetchOnDemand = this.getInitValue('fetchOnDemand', props.fetchOnDemand, this.fetchOnDemand);
11618
11577
  this.flat = this.getInitValue('flat', props.flat, this.flat);
11578
+ this.fieldHasChild = this.getInitValue('fieldHasChild', props.fieldHasChild, this.fieldHasChild);
11619
11579
  this.detach = this.getInitValue('detach', props.detach, this.detach);
11620
11580
  this.treeDataStructure = new TreeDataStructure(this);
11621
11581
  this.createAccessors();
@@ -11734,7 +11694,9 @@
11734
11694
  * @param isSelected row is selected
11735
11695
  */
11736
11696
  selectRow(row, isSelected) {
11737
- const childrenRows = !this.flat ? this.treeDataStructure.getChildren(row) : [];
11697
+ const childrenRows = !this.flat
11698
+ ? this.treeDataStructure.getChildren(row)
11699
+ : [];
11738
11700
  const rows = [row, ...childrenRows];
11739
11701
  if (isSelected) {
11740
11702
  this.selectedRows = this.removeDuplicates(this.selectedRows.concat(rows), this.datasource.uniqueKey);
@@ -11777,7 +11739,9 @@
11777
11739
  selectParents(row) {
11778
11740
  if (row[this.parentField]) {
11779
11741
  const parentRow = this.treeDataStructure.getRowData(row).tree__parent;
11780
- const every = this.treeDataStructure.getChildren(parentRow).every((item) => {
11742
+ const every = this.treeDataStructure
11743
+ .getChildren(parentRow)
11744
+ .every((item) => {
11781
11745
  const index = this.treeDataStructure.findDataIndex(this.selectedRows, item[this.datasource.uniqueKey]);
11782
11746
  if (index > -1)
11783
11747
  return true;
@@ -13499,7 +13463,6 @@
13499
13463
  exports.IterablePageInfo = IterablePageInfo;
13500
13464
  exports.IterablePageSize = IterablePageSize;
13501
13465
  exports.IterablePagination = IterablePagination;
13502
- exports.JsonCacheService = JsonCacheService;
13503
13466
  exports.List = List;
13504
13467
  exports.ListGroup = ListGroup;
13505
13468
  exports.ListItem = ListItem;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.70.0",
3
+ "version": "1.71.0",
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": "5d3e8cfdd580a87208edf3d4033e2a974161fd1a"
42
+ "gitHead": "6e0e1cef3955cae7029ad947eb8c83fe589621b7"
43
43
  }
@@ -5,6 +5,7 @@ export interface ITreeGrid extends IGrid {
5
5
  parentField?: string;
6
6
  openLevelOnLoad?: number | boolean;
7
7
  fetchOnDemand?: boolean;
8
+ fieldHasChild?: string;
8
9
  flat?: boolean;
9
10
  detach?: boolean;
10
11
  }
@@ -19,6 +19,10 @@ export declare class TreeGrid extends Grid implements ITreeGrid {
19
19
  * Defines if the tree will be fetch data only when opening a level
20
20
  */
21
21
  fetchOnDemand: boolean;
22
+ /**
23
+ * Defines if the node tree has child
24
+ */
25
+ fieldHasChild?: string;
22
26
  /**
23
27
  * Defines if should wait and not execute GET method when Datasource is created
24
28
  */
@@ -2,4 +2,3 @@ export * from './zd-alert/alert-service';
2
2
  export * from './zd-dialog/dialog-service';
3
3
  export * from './zd-modal/modal-service';
4
4
  export * from './zd-loading/loading-service';
5
- export * from './zd-json-cache/json-cache-service';
@@ -16,7 +16,7 @@ export declare class ModalService {
16
16
  * Creates a new modal instance from JSON
17
17
  * @param modal modal structure
18
18
  */
19
- static createFromJson(modalPath: string, local?: boolean): Promise<Modal>;
19
+ static createFromJson(modalPath: string, local?: boolean, JSONCache?: boolean): Promise<Modal>;
20
20
  /**
21
21
  * Creates a new modal instance from JSON
22
22
  * @param modal modal structure