@zeedhi/common 1.84.0 → 1.84.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.
@@ -6638,11 +6638,12 @@ class GridEditable extends Grid {
6638
6638
  const { data, page } = this.datasource;
6639
6639
  const allData = this.datasource.allData || data;
6640
6640
  Promise.resolve(allData);
6641
- allData.forEach((row, index) => {
6642
- if (row[this.newRowIdentifier]) {
6641
+ for (let index = allData.length - 1; index >= 0; index -= 1) {
6642
+ const row = allData[index];
6643
+ if (this.addedRows[row[this.datasource.uniqueKey]]) {
6643
6644
  allData.splice(index, 1);
6644
6645
  }
6645
- });
6646
+ }
6646
6647
  yield this.datasource.updateData(allData);
6647
6648
  yield this.datasource.get();
6648
6649
  yield this.datasource.setPage(page);
@@ -6665,6 +6666,7 @@ class GridEditable extends Grid {
6665
6666
  const response = yield Promise.all(this.getEditedRows(revalidate).map((row) => this.addDataRow(row)));
6666
6667
  this.editing = false;
6667
6668
  this.editedRows = {};
6669
+ this.addedRows = {};
6668
6670
  this.invalidComponents = {};
6669
6671
  this.addedRows = {};
6670
6672
  yield this.datasource.get();
@@ -6679,11 +6681,8 @@ class GridEditable extends Grid {
6679
6681
  getEditedRows(revalidate = false) {
6680
6682
  const editedRows = [];
6681
6683
  Object.keys(this.editedRows).forEach((key) => {
6682
- this.addedRows = {};
6683
6684
  const row = Object.assign(Object.assign({}, this.editedRows[key].originalRow), this.editedRows[key]);
6684
6685
  delete row.originalRow;
6685
- if (row[this.newRowIdentifier])
6686
- this.addedRows[key] = row;
6687
6686
  delete row[this.newRowIdentifier];
6688
6687
  Object.keys(row).forEach((attr) => {
6689
6688
  if (Object.prototype.hasOwnProperty.call(row, `${attr}_original`)) {
@@ -6738,7 +6737,8 @@ class GridEditable extends Grid {
6738
6737
  yield this.datasource.updateData(data);
6739
6738
  const id = row[this.datasource.uniqueKey];
6740
6739
  if (id) {
6741
- this.editedRows[id] = row;
6740
+ this.editedRows[id] = Object.assign({}, row);
6741
+ this.addedRows[id] = Object.assign({}, row);
6742
6742
  }
6743
6743
  this.editing = true;
6744
6744
  });
@@ -6645,11 +6645,12 @@
6645
6645
  const { data, page } = this.datasource;
6646
6646
  const allData = this.datasource.allData || data;
6647
6647
  Promise.resolve(allData);
6648
- allData.forEach((row, index) => {
6649
- if (row[this.newRowIdentifier]) {
6648
+ for (let index = allData.length - 1; index >= 0; index -= 1) {
6649
+ const row = allData[index];
6650
+ if (this.addedRows[row[this.datasource.uniqueKey]]) {
6650
6651
  allData.splice(index, 1);
6651
6652
  }
6652
- });
6653
+ }
6653
6654
  yield this.datasource.updateData(allData);
6654
6655
  yield this.datasource.get();
6655
6656
  yield this.datasource.setPage(page);
@@ -6672,6 +6673,7 @@
6672
6673
  const response = yield Promise.all(this.getEditedRows(revalidate).map((row) => this.addDataRow(row)));
6673
6674
  this.editing = false;
6674
6675
  this.editedRows = {};
6676
+ this.addedRows = {};
6675
6677
  this.invalidComponents = {};
6676
6678
  this.addedRows = {};
6677
6679
  yield this.datasource.get();
@@ -6686,11 +6688,8 @@
6686
6688
  getEditedRows(revalidate = false) {
6687
6689
  const editedRows = [];
6688
6690
  Object.keys(this.editedRows).forEach((key) => {
6689
- this.addedRows = {};
6690
6691
  const row = Object.assign(Object.assign({}, this.editedRows[key].originalRow), this.editedRows[key]);
6691
6692
  delete row.originalRow;
6692
- if (row[this.newRowIdentifier])
6693
- this.addedRows[key] = row;
6694
6693
  delete row[this.newRowIdentifier];
6695
6694
  Object.keys(row).forEach((attr) => {
6696
6695
  if (Object.prototype.hasOwnProperty.call(row, `${attr}_original`)) {
@@ -6745,7 +6744,8 @@
6745
6744
  yield this.datasource.updateData(data);
6746
6745
  const id = row[this.datasource.uniqueKey];
6747
6746
  if (id) {
6748
- this.editedRows[id] = row;
6747
+ this.editedRows[id] = Object.assign({}, row);
6748
+ this.addedRows[id] = Object.assign({}, row);
6749
6749
  }
6750
6750
  this.editing = true;
6751
6751
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.84.0",
3
+ "version": "1.84.1",
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": "0b18124932a37bd921c9938b86371a7222e90f59"
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
+ }