@zeedhi/common 1.97.5 → 1.97.6

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.
@@ -6979,29 +6979,36 @@ class GridEditable extends Grid {
6979
6979
  */
6980
6980
  addNewRow(row, position = 'end') {
6981
6981
  return __awaiter(this, void 0, void 0, function* () {
6982
- let data;
6983
- if (this.datasource instanceof MemoryDatasource) {
6984
- data = this.datasource.allData;
6985
- }
6986
- else {
6987
- data = this.datasource.data;
6988
- }
6989
- row[this.newRowIdentifier] = true;
6990
- if (position === 'start') {
6991
- data.unshift(row);
6992
- }
6993
- else {
6994
- data.push(row);
6995
- }
6982
+ const data = this.insertRowInDatasource(row, position);
6983
+ this.saveRowReference(row);
6996
6984
  yield this.datasource.updateData(data);
6997
- const id = row[this.datasource.uniqueKey];
6998
- if (id) {
6999
- this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
7000
- this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
7001
- }
7002
6985
  this.editing = true;
7003
6986
  });
7004
6987
  }
6988
+ saveRowReference(row) {
6989
+ const id = row[this.datasource.uniqueKey];
6990
+ if (id) {
6991
+ this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
6992
+ this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
6993
+ }
6994
+ }
6995
+ insertRowInDatasource(row, position) {
6996
+ let data;
6997
+ if (this.datasource instanceof MemoryDatasource) {
6998
+ data = this.datasource.allData;
6999
+ }
7000
+ else {
7001
+ data = this.datasource.data;
7002
+ }
7003
+ row[this.newRowIdentifier] = true;
7004
+ if (position === 'start') {
7005
+ data.unshift(row);
7006
+ }
7007
+ else {
7008
+ data.push(row);
7009
+ }
7010
+ return data;
7011
+ }
7005
7012
  /**
7006
7013
  * Gets the editable component name
7007
7014
  * @param key Row unique key
@@ -6986,29 +6986,36 @@
6986
6986
  */
6987
6987
  addNewRow(row, position = 'end') {
6988
6988
  return __awaiter(this, void 0, void 0, function* () {
6989
- let data;
6990
- if (this.datasource instanceof core.MemoryDatasource) {
6991
- data = this.datasource.allData;
6992
- }
6993
- else {
6994
- data = this.datasource.data;
6995
- }
6996
- row[this.newRowIdentifier] = true;
6997
- if (position === 'start') {
6998
- data.unshift(row);
6999
- }
7000
- else {
7001
- data.push(row);
7002
- }
6989
+ const data = this.insertRowInDatasource(row, position);
6990
+ this.saveRowReference(row);
7003
6991
  yield this.datasource.updateData(data);
7004
- const id = row[this.datasource.uniqueKey];
7005
- if (id) {
7006
- this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
7007
- this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
7008
- }
7009
6992
  this.editing = true;
7010
6993
  });
7011
6994
  }
6995
+ saveRowReference(row) {
6996
+ const id = row[this.datasource.uniqueKey];
6997
+ if (id) {
6998
+ this.editedRows = Object.assign(Object.assign({}, this.editedRows), { [id]: Object.assign({}, row) });
6999
+ this.addedRows = Object.assign(Object.assign({}, this.addedRows), { [id]: Object.assign({}, row) });
7000
+ }
7001
+ }
7002
+ insertRowInDatasource(row, position) {
7003
+ let data;
7004
+ if (this.datasource instanceof core.MemoryDatasource) {
7005
+ data = this.datasource.allData;
7006
+ }
7007
+ else {
7008
+ data = this.datasource.data;
7009
+ }
7010
+ row[this.newRowIdentifier] = true;
7011
+ if (position === 'start') {
7012
+ data.unshift(row);
7013
+ }
7014
+ else {
7015
+ data.push(row);
7016
+ }
7017
+ return data;
7018
+ }
7012
7019
  /**
7013
7020
  * Gets the editable component name
7014
7021
  * @param key Row unique key
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zeedhi/common",
3
- "version": "1.97.5",
3
+ "version": "1.97.6",
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": "d267b40c72f712231ae90bfb26907260ba75ece2"
46
+ "gitHead": "0776a456419f953c332c764c6cdf098b25660481"
47
47
  }
@@ -0,0 +1,8 @@
1
+ import { IDictionary } from '@zeedhi/core';
2
+ import { GridEditable } from './grid-editable';
3
+ export declare class GridEditableController {
4
+ private grid;
5
+ constructor(grid: GridEditable);
6
+ get hasAddedRows(): boolean;
7
+ isAddedRow({ row }: IDictionary): boolean;
8
+ }
@@ -173,6 +173,8 @@ export declare class GridEditable extends Grid implements IGridEditable {
173
173
  * @param position whether the new Row will be inserted at the beginning or end of the data array
174
174
  */
175
175
  addNewRow(row: IDictionary, position?: 'end' | 'start'): Promise<void>;
176
+ protected saveRowReference(row: IDictionary<any>): void;
177
+ protected insertRowInDatasource(row: IDictionary<any>, position: 'end' | 'start'): IDictionary<any>[];
176
178
  /**
177
179
  * Gets the editable component name
178
180
  * @param key Row unique key
@@ -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
+ }
@@ -0,0 +1,5 @@
1
+ import { ISelectDataValueOut } from './interfaces';
2
+ export declare class DataValueOutHelper {
3
+ private static getFormParent;
4
+ static setDataValueOut(select: ISelectDataValueOut, value: any): void;
5
+ }
@@ -0,0 +1,2 @@
1
+ export * from './interfaces';
2
+ export * from './data-value-out';
@@ -0,0 +1,8 @@
1
+ export interface ISelectDataValueOutItem {
2
+ column: string;
3
+ columnOnForm: string;
4
+ }
5
+ export interface ISelectDataValueOut {
6
+ dataValueOut?: ISelectDataValueOutItem[];
7
+ dataValueOutFormName?: string;
8
+ }
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Empty data error
3
+ */
4
+ export declare class EmptyDataError extends Error {
5
+ constructor();
6
+ }