@zeedhi/common 1.84.0 → 1.85.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.
@@ -5540,13 +5540,7 @@ class Iterable extends ComponentRender {
5540
5540
  * Get pagination length
5541
5541
  */
5542
5542
  get paginationLength() {
5543
- let { limit, total } = this.datasource;
5544
- limit = Number(limit);
5545
- total = Number(total);
5546
- if (!limit || Number.isNaN(total) || Number.isNaN(limit)) {
5547
- return 0;
5548
- }
5549
- return Math.ceil(total / limit);
5543
+ return this.datasource.getPaginationLength();
5550
5544
  }
5551
5545
  /**
5552
5546
  * Return cells with conditions applied for each row
@@ -6638,11 +6632,12 @@ class GridEditable extends Grid {
6638
6632
  const { data, page } = this.datasource;
6639
6633
  const allData = this.datasource.allData || data;
6640
6634
  Promise.resolve(allData);
6641
- allData.forEach((row, index) => {
6642
- if (row[this.newRowIdentifier]) {
6635
+ for (let index = allData.length - 1; index >= 0; index -= 1) {
6636
+ const row = allData[index];
6637
+ if (this.addedRows[row[this.datasource.uniqueKey]]) {
6643
6638
  allData.splice(index, 1);
6644
6639
  }
6645
- });
6640
+ }
6646
6641
  yield this.datasource.updateData(allData);
6647
6642
  yield this.datasource.get();
6648
6643
  yield this.datasource.setPage(page);
@@ -6665,6 +6660,7 @@ class GridEditable extends Grid {
6665
6660
  const response = yield Promise.all(this.getEditedRows(revalidate).map((row) => this.addDataRow(row)));
6666
6661
  this.editing = false;
6667
6662
  this.editedRows = {};
6663
+ this.addedRows = {};
6668
6664
  this.invalidComponents = {};
6669
6665
  this.addedRows = {};
6670
6666
  yield this.datasource.get();
@@ -6679,11 +6675,8 @@ class GridEditable extends Grid {
6679
6675
  getEditedRows(revalidate = false) {
6680
6676
  const editedRows = [];
6681
6677
  Object.keys(this.editedRows).forEach((key) => {
6682
- this.addedRows = {};
6683
6678
  const row = Object.assign(Object.assign({}, this.editedRows[key].originalRow), this.editedRows[key]);
6684
6679
  delete row.originalRow;
6685
- if (row[this.newRowIdentifier])
6686
- this.addedRows[key] = row;
6687
6680
  delete row[this.newRowIdentifier];
6688
6681
  Object.keys(row).forEach((attr) => {
6689
6682
  if (Object.prototype.hasOwnProperty.call(row, `${attr}_original`)) {
@@ -6738,7 +6731,8 @@ class GridEditable extends Grid {
6738
6731
  yield this.datasource.updateData(data);
6739
6732
  const id = row[this.datasource.uniqueKey];
6740
6733
  if (id) {
6741
- this.editedRows[id] = row;
6734
+ this.editedRows[id] = Object.assign({}, row);
6735
+ this.addedRows[id] = Object.assign({}, row);
6742
6736
  }
6743
6737
  this.editing = true;
6744
6738
  });
@@ -5547,13 +5547,7 @@
5547
5547
  * Get pagination length
5548
5548
  */
5549
5549
  get paginationLength() {
5550
- let { limit, total } = this.datasource;
5551
- limit = Number(limit);
5552
- total = Number(total);
5553
- if (!limit || Number.isNaN(total) || Number.isNaN(limit)) {
5554
- return 0;
5555
- }
5556
- return Math.ceil(total / limit);
5550
+ return this.datasource.getPaginationLength();
5557
5551
  }
5558
5552
  /**
5559
5553
  * Return cells with conditions applied for each row
@@ -6645,11 +6639,12 @@
6645
6639
  const { data, page } = this.datasource;
6646
6640
  const allData = this.datasource.allData || data;
6647
6641
  Promise.resolve(allData);
6648
- allData.forEach((row, index) => {
6649
- if (row[this.newRowIdentifier]) {
6642
+ for (let index = allData.length - 1; index >= 0; index -= 1) {
6643
+ const row = allData[index];
6644
+ if (this.addedRows[row[this.datasource.uniqueKey]]) {
6650
6645
  allData.splice(index, 1);
6651
6646
  }
6652
- });
6647
+ }
6653
6648
  yield this.datasource.updateData(allData);
6654
6649
  yield this.datasource.get();
6655
6650
  yield this.datasource.setPage(page);
@@ -6672,6 +6667,7 @@
6672
6667
  const response = yield Promise.all(this.getEditedRows(revalidate).map((row) => this.addDataRow(row)));
6673
6668
  this.editing = false;
6674
6669
  this.editedRows = {};
6670
+ this.addedRows = {};
6675
6671
  this.invalidComponents = {};
6676
6672
  this.addedRows = {};
6677
6673
  yield this.datasource.get();
@@ -6686,11 +6682,8 @@
6686
6682
  getEditedRows(revalidate = false) {
6687
6683
  const editedRows = [];
6688
6684
  Object.keys(this.editedRows).forEach((key) => {
6689
- this.addedRows = {};
6690
6685
  const row = Object.assign(Object.assign({}, this.editedRows[key].originalRow), this.editedRows[key]);
6691
6686
  delete row.originalRow;
6692
- if (row[this.newRowIdentifier])
6693
- this.addedRows[key] = row;
6694
6687
  delete row[this.newRowIdentifier];
6695
6688
  Object.keys(row).forEach((attr) => {
6696
6689
  if (Object.prototype.hasOwnProperty.call(row, `${attr}_original`)) {
@@ -6745,7 +6738,8 @@
6745
6738
  yield this.datasource.updateData(data);
6746
6739
  const id = row[this.datasource.uniqueKey];
6747
6740
  if (id) {
6748
- this.editedRows[id] = row;
6741
+ this.editedRows[id] = Object.assign({}, row);
6742
+ this.addedRows[id] = Object.assign({}, row);
6749
6743
  }
6750
6744
  this.editing = true;
6751
6745
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.84.0",
3
+ "version": "1.85.0",
4
4
  "description": "Zeedhi Common",
5
5
  "author": "Zeedhi <zeedhi@teknisa.com>",
6
6
  "license": "ISC",
@@ -43,5 +43,5 @@
43
43
  "lodash.times": "4.3.*",
44
44
  "mockdate": "3.0.*"
45
45
  },
46
- "gitHead": "98ba15335f7f421c7856de217ebbea4a8506af95"
46
+ "gitHead": "8324a7087a2b3daa9349bb5551bc1c708ad1c38f"
47
47
  }
@@ -0,0 +1,12 @@
1
+ export interface IJSONObject {
2
+ path: string;
3
+ }
4
+ export declare class JsonCacheService {
5
+ /**
6
+ * jsons collection
7
+ */
8
+ static jsonCollection: IJSONObject[];
9
+ static saveJSONCache(jsonCollection: IJSONObject[]): Promise<void>;
10
+ static getJSONCache(path: string): any;
11
+ static clearJSONCache(jsonCollection: IJSONObject[]): void;
12
+ }