aio-class 2.2.0 → 2.2.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/index.d.ts +79 -85
- package/index.js +115 -117
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/// <reference types="emscripten" />
|
|
2
1
|
/// <reference types="jquery" />
|
|
3
2
|
/// <reference types="jquery" />
|
|
4
3
|
import { AIOGeo } from 'aio-geo';
|
|
@@ -79,7 +78,7 @@ export declare const ArrayToObject: <T>(keys: T[], fn: (key: T) => any) => any;
|
|
|
79
78
|
export declare const TextFilter: (p: {
|
|
80
79
|
value: string | number;
|
|
81
80
|
chars?: {
|
|
82
|
-
[key: string]: boolean;
|
|
81
|
+
[key: string]: boolean | undefined;
|
|
83
82
|
};
|
|
84
83
|
number?: boolean;
|
|
85
84
|
symbol?: boolean;
|
|
@@ -210,94 +209,89 @@ export declare class EntityClass<T> {
|
|
|
210
209
|
setData?: (v: T[]) => void;
|
|
211
210
|
sorts?: I_sort<T>[];
|
|
212
211
|
});
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
212
|
+
getId: (row: T) => I_id;
|
|
213
|
+
setId: (row: T) => T;
|
|
214
|
+
getChilds: (row: T) => T[];
|
|
215
|
+
setChilds: (row: T, childs: T[] | undefined) => T;
|
|
217
216
|
private getRowDetailsByIds;
|
|
218
217
|
private getRowDetailByRowAndParents;
|
|
219
218
|
private removeChildOfParent;
|
|
220
219
|
private getRowByAddChild;
|
|
221
|
-
private
|
|
222
|
-
private
|
|
223
|
-
private
|
|
224
|
-
private
|
|
225
|
-
private
|
|
226
|
-
private
|
|
227
|
-
private
|
|
228
|
-
private
|
|
229
|
-
private
|
|
230
|
-
private
|
|
231
|
-
private
|
|
232
|
-
private
|
|
233
|
-
private
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
rows?: T[];
|
|
256
|
-
}) => {
|
|
257
|
-
rows: T[];
|
|
258
|
-
row: T;
|
|
259
|
-
};
|
|
260
|
-
editRow: (p: {
|
|
261
|
-
row: T;
|
|
262
|
-
rows?: T[];
|
|
263
|
-
}) => T[];
|
|
264
|
-
editById: (p: {
|
|
265
|
-
rowId: I_id;
|
|
266
|
-
change: Partial<T>;
|
|
267
|
-
rows?: T[];
|
|
268
|
-
}) => T[];
|
|
269
|
-
removeRow: (p: {
|
|
270
|
-
rowId: I_id;
|
|
271
|
-
rows?: T[];
|
|
272
|
-
}) => T[];
|
|
273
|
-
removeByRowIds: (p: {
|
|
274
|
-
rowIds: I_id[];
|
|
275
|
-
rows?: T[];
|
|
276
|
-
}) => T[];
|
|
277
|
-
reOrder: (p: {
|
|
278
|
-
fromId: I_id;
|
|
279
|
-
toId: I_id;
|
|
280
|
-
rows?: T[];
|
|
281
|
-
}) => T[];
|
|
282
|
-
reOrderByDir: (p: {
|
|
283
|
-
rowId: I_id;
|
|
284
|
-
dir: 1 | -1;
|
|
285
|
-
rows?: T[];
|
|
286
|
-
}) => T[];
|
|
287
|
-
moveTo: (p: {
|
|
288
|
-
fromIds: I_id[];
|
|
289
|
-
toId: I_id;
|
|
290
|
-
rows?: T[];
|
|
291
|
-
}) => T[];
|
|
292
|
-
editByTraverse: (p: {
|
|
293
|
-
callback: (row: T) => T | false;
|
|
294
|
-
rows?: T[];
|
|
295
|
-
}) => T[];
|
|
296
|
-
traverse: (p: {
|
|
297
|
-
callback: (row: T, detail: I_EntityRowDetail<T>) => false | undefined;
|
|
298
|
-
rows?: T[];
|
|
299
|
-
}) => void;
|
|
220
|
+
private _getRowDetail;
|
|
221
|
+
private _getFilteredTree;
|
|
222
|
+
private _getSortedTree;
|
|
223
|
+
private _addRow;
|
|
224
|
+
private _editRow;
|
|
225
|
+
private _editById;
|
|
226
|
+
private _removeRow;
|
|
227
|
+
private _removeByRowIds;
|
|
228
|
+
private _reOrder;
|
|
229
|
+
private _reOrderByDir;
|
|
230
|
+
private _moveTo;
|
|
231
|
+
private _editByTraverse;
|
|
232
|
+
private _traverse;
|
|
233
|
+
getRowDetail: (p: {
|
|
234
|
+
rowId?: I_id;
|
|
235
|
+
row?: T;
|
|
236
|
+
rows?: T[];
|
|
237
|
+
}) => false | I_EntityRowDetail<T>;
|
|
238
|
+
getFilteredTree: (p: {
|
|
239
|
+
filter: (row: T, detail: I_EntityRowDetail<T>) => boolean | undefined;
|
|
240
|
+
rows?: T[];
|
|
241
|
+
}) => T[];
|
|
242
|
+
getSortedTree: (p: {
|
|
243
|
+
sorts: I_sort<T>[];
|
|
244
|
+
rows?: T[];
|
|
245
|
+
}) => T[];
|
|
246
|
+
addRow: (p: {
|
|
247
|
+
row: T;
|
|
248
|
+
parentId?: I_id;
|
|
249
|
+
index?: number;
|
|
250
|
+
rows?: T[];
|
|
251
|
+
}) => {
|
|
252
|
+
rows: T[];
|
|
253
|
+
row: T;
|
|
300
254
|
};
|
|
255
|
+
editRow: (p: {
|
|
256
|
+
row: T;
|
|
257
|
+
rows?: T[];
|
|
258
|
+
}) => T[];
|
|
259
|
+
editById: (p: {
|
|
260
|
+
rowId: I_id;
|
|
261
|
+
change: Partial<T>;
|
|
262
|
+
rows?: T[];
|
|
263
|
+
}) => T[];
|
|
264
|
+
removeRow: (p: {
|
|
265
|
+
rowId: I_id;
|
|
266
|
+
rows?: T[];
|
|
267
|
+
}) => T[];
|
|
268
|
+
removeByRowIds: (p: {
|
|
269
|
+
rowIds: I_id[];
|
|
270
|
+
rows?: T[];
|
|
271
|
+
}) => T[];
|
|
272
|
+
reOrder: (p: {
|
|
273
|
+
fromId: I_id;
|
|
274
|
+
toId: I_id;
|
|
275
|
+
rows?: T[];
|
|
276
|
+
}) => T[];
|
|
277
|
+
reOrderByDir: (p: {
|
|
278
|
+
rowId: I_id;
|
|
279
|
+
dir: 1 | -1;
|
|
280
|
+
rows?: T[];
|
|
281
|
+
}) => T[];
|
|
282
|
+
moveTo: (p: {
|
|
283
|
+
fromIds: I_id[];
|
|
284
|
+
toId: I_id;
|
|
285
|
+
rows?: T[];
|
|
286
|
+
}) => T[];
|
|
287
|
+
editByTraverse: (p: {
|
|
288
|
+
callback: (row: T) => T | false;
|
|
289
|
+
rows?: T[];
|
|
290
|
+
}) => T[];
|
|
291
|
+
traverse: (p: {
|
|
292
|
+
callback: (row: T, detail: I_EntityRowDetail<T>) => false | undefined;
|
|
293
|
+
rows?: T[];
|
|
294
|
+
}) => void;
|
|
301
295
|
}
|
|
302
296
|
type I_color = any;
|
|
303
297
|
type I_color_type = 'rgb' | 'hex' | 'array';
|
package/index.js
CHANGED
|
@@ -242,7 +242,7 @@ export const EventHandler = (selector, event, action, type = 'bind') => {
|
|
|
242
242
|
element.addEventListener(fixedEvent, action);
|
|
243
243
|
}
|
|
244
244
|
};
|
|
245
|
-
export const Stall = (
|
|
245
|
+
export const Stall = (...args_1) => __awaiter(void 0, [...args_1], void 0, function* (stallTime = 3000) { return yield new Promise(resolve => setTimeout(resolve, stallTime)); });
|
|
246
246
|
export const DetectOS = () => {
|
|
247
247
|
const userAgent = window.navigator.userAgent;
|
|
248
248
|
const platform = window.navigator.platform;
|
|
@@ -1572,15 +1572,15 @@ export class EntityClass {
|
|
|
1572
1572
|
newChilds.splice(index === undefined ? newChilds.length : index, 0, row);
|
|
1573
1573
|
return this.setChilds(parentRow, newChilds);
|
|
1574
1574
|
};
|
|
1575
|
-
this.
|
|
1576
|
-
const fn = (
|
|
1575
|
+
this._getRowDetail = (p) => {
|
|
1576
|
+
const fn = (rows, rowId, parents, level, temp) => {
|
|
1577
1577
|
if (temp.res) {
|
|
1578
1578
|
return;
|
|
1579
1579
|
}
|
|
1580
|
-
for (let i = 0; i <
|
|
1580
|
+
for (let i = 0; i < rows.length; i++) {
|
|
1581
1581
|
const isFirstChild = i === 0;
|
|
1582
|
-
const isLastChild = i ===
|
|
1583
|
-
const row =
|
|
1582
|
+
const isLastChild = i === rows.length - 1;
|
|
1583
|
+
const row = rows[i];
|
|
1584
1584
|
const childs = this.getChilds(row);
|
|
1585
1585
|
if (this.getId(row).toString() === rowId.toString()) {
|
|
1586
1586
|
temp.res = this.getRowDetailByRowAndParents(row, i, parents, isFirstChild, isLastChild, level);
|
|
@@ -1594,13 +1594,17 @@ export class EntityClass {
|
|
|
1594
1594
|
}
|
|
1595
1595
|
};
|
|
1596
1596
|
let temp = { res: false };
|
|
1597
|
-
|
|
1597
|
+
if (p.rowId === undefined && p.row === undefined) {
|
|
1598
|
+
return false;
|
|
1599
|
+
}
|
|
1600
|
+
const rowId = p.rowId === undefined ? this.getId(p.row) : p.rowId;
|
|
1601
|
+
fn(p.rows, rowId, [], 0, temp);
|
|
1598
1602
|
return temp.res ? temp.res : false;
|
|
1599
1603
|
};
|
|
1600
|
-
this.
|
|
1604
|
+
this._getFilteredTree = (data, filter) => {
|
|
1601
1605
|
const getNodesDic = (data, filter) => {
|
|
1602
1606
|
const detailDic = {};
|
|
1603
|
-
this.
|
|
1607
|
+
this._traverse(data, (row, detail) => {
|
|
1604
1608
|
const res = filter(row, detail);
|
|
1605
1609
|
if (res === false) {
|
|
1606
1610
|
return false;
|
|
@@ -1636,27 +1640,27 @@ export class EntityClass {
|
|
|
1636
1640
|
const nodesDic = getNodesDic(data, filter);
|
|
1637
1641
|
return fn(data, [], 0);
|
|
1638
1642
|
};
|
|
1639
|
-
this.
|
|
1643
|
+
this._getSortedTree = (rows, sorts) => {
|
|
1640
1644
|
let sortedRows = SortArray(rows, sorts);
|
|
1641
1645
|
return sortedRows.map((o) => {
|
|
1642
1646
|
const childs = this.getChilds(o);
|
|
1643
1647
|
if (!childs || !childs.length) {
|
|
1644
1648
|
return o;
|
|
1645
1649
|
}
|
|
1646
|
-
const newChilds = this.
|
|
1650
|
+
const newChilds = this._getSortedTree(childs, sorts);
|
|
1647
1651
|
return this.setChilds(Object.assign({}, o), newChilds);
|
|
1648
1652
|
});
|
|
1649
1653
|
};
|
|
1650
|
-
this.
|
|
1654
|
+
this._addRow = (data, row, p) => {
|
|
1651
1655
|
const { parentId, index } = p;
|
|
1652
1656
|
const newRow = this.setId(row);
|
|
1653
1657
|
if (parentId !== undefined) {
|
|
1654
|
-
const detail = this.
|
|
1658
|
+
const detail = this._getRowDetail({ rows: data, rowId: parentId });
|
|
1655
1659
|
if (!detail) {
|
|
1656
1660
|
return { rows: data, row };
|
|
1657
1661
|
}
|
|
1658
1662
|
const parent = this.getRowByAddChild(detail.row, newRow);
|
|
1659
|
-
const newData = this.
|
|
1663
|
+
const newData = this._editRow(data, parent);
|
|
1660
1664
|
return { rows: newData, row: newRow };
|
|
1661
1665
|
}
|
|
1662
1666
|
else {
|
|
@@ -1665,50 +1669,50 @@ export class EntityClass {
|
|
|
1665
1669
|
return { rows: newData, row: newRow };
|
|
1666
1670
|
}
|
|
1667
1671
|
};
|
|
1668
|
-
this.
|
|
1672
|
+
this._editRow = (data, newRow) => {
|
|
1669
1673
|
const rowId = this.getId(newRow);
|
|
1670
|
-
const detail = this.
|
|
1674
|
+
const detail = this._getRowDetail({ rows: data, rowId });
|
|
1671
1675
|
const parentRow = detail.parentRow;
|
|
1672
1676
|
if (parentRow) {
|
|
1673
1677
|
const childs = this.getChilds(parentRow);
|
|
1674
1678
|
const newChilds = childs.map((o) => this.getId(o).toString() === rowId.toString() ? newRow : o);
|
|
1675
1679
|
const newParentRow = this.setChilds(parentRow, newChilds);
|
|
1676
|
-
return this.
|
|
1680
|
+
return this._editRow(data, newParentRow);
|
|
1677
1681
|
}
|
|
1678
1682
|
else {
|
|
1679
1683
|
return data.map((o) => this.getId(o).toString() === this.getId(newRow).toString() ? newRow : o);
|
|
1680
1684
|
}
|
|
1681
1685
|
};
|
|
1682
|
-
this.
|
|
1683
|
-
const detail = this.
|
|
1686
|
+
this._editById = (data, rowId, change) => {
|
|
1687
|
+
const detail = this._getRowDetail({ rows: data, rowId });
|
|
1684
1688
|
if (!detail) {
|
|
1685
1689
|
return data;
|
|
1686
1690
|
}
|
|
1687
1691
|
const newRow = Object.assign(Object.assign({}, detail.row), change);
|
|
1688
|
-
return this.
|
|
1692
|
+
return this._editRow(data, newRow);
|
|
1689
1693
|
};
|
|
1690
|
-
this.
|
|
1691
|
-
let detail = this.
|
|
1694
|
+
this._removeRow = (data, rowId) => {
|
|
1695
|
+
let detail = this._getRowDetail({ rows: data, rowId });
|
|
1692
1696
|
if (!detail) {
|
|
1693
1697
|
return data;
|
|
1694
1698
|
}
|
|
1695
1699
|
let parentRow = detail.parentRow;
|
|
1696
1700
|
if (parentRow) {
|
|
1697
1701
|
parentRow = this.removeChildOfParent(parentRow, rowId);
|
|
1698
|
-
return this.
|
|
1702
|
+
return this._editRow(data, parentRow);
|
|
1699
1703
|
}
|
|
1700
1704
|
else {
|
|
1701
1705
|
return data.filter((o) => this.getId(o).toString() !== rowId.toString());
|
|
1702
1706
|
}
|
|
1703
1707
|
};
|
|
1704
|
-
this.
|
|
1708
|
+
this._removeByRowIds = (data, rowIds) => {
|
|
1705
1709
|
let tempRows = [...data];
|
|
1706
1710
|
for (let i = 0; i < rowIds.length; i++) {
|
|
1707
|
-
tempRows = this.
|
|
1711
|
+
tempRows = this._removeRow(tempRows, rowIds[i]);
|
|
1708
1712
|
}
|
|
1709
1713
|
return tempRows;
|
|
1710
1714
|
};
|
|
1711
|
-
this.
|
|
1715
|
+
this._reOrder = (data, fromId, toId, pos) => {
|
|
1712
1716
|
if (fromId.toString() === toId.toString()) {
|
|
1713
1717
|
return data;
|
|
1714
1718
|
}
|
|
@@ -1739,20 +1743,20 @@ export class EntityClass {
|
|
|
1739
1743
|
//مبدا رو با آی دی جدید به پرنت مقصد در ایندکس ردیف مقصد اضافه کن
|
|
1740
1744
|
const newToParent = this.getRowByAddChild(toParent, fromRow, toIndex);
|
|
1741
1745
|
//دیتا رو با این ردیف جدید ویرایش کن
|
|
1742
|
-
let newData = this.
|
|
1746
|
+
let newData = this._editRow(data, newToParent);
|
|
1743
1747
|
//مبدا رو از دیتای جدید حذف کن
|
|
1744
|
-
return this.
|
|
1748
|
+
return this._removeRow(newData, fromDetail.rowId);
|
|
1745
1749
|
}
|
|
1746
1750
|
//اگر پرنت نداشت
|
|
1747
1751
|
else {
|
|
1748
1752
|
//مبدا رو با آی دی جدید به پرنت مقصد در ایندکس ردیف مقصد اضافه کن
|
|
1749
|
-
let newData = this.
|
|
1753
|
+
let newData = this._addRow(data, fromRow, { index: toIndex });
|
|
1750
1754
|
//مبدا رو از دیتای جدید حذف کن
|
|
1751
|
-
return this.
|
|
1755
|
+
return this._removeRow(newData.rows, fromDetail.rowId);
|
|
1752
1756
|
}
|
|
1753
1757
|
};
|
|
1754
|
-
this.
|
|
1755
|
-
const from = this.
|
|
1758
|
+
this._reOrderByDir = (data, rowId, dir) => {
|
|
1759
|
+
const from = this._getRowDetail({ rows: data, rowId });
|
|
1756
1760
|
if (!from) {
|
|
1757
1761
|
return data;
|
|
1758
1762
|
}
|
|
@@ -1762,9 +1766,9 @@ export class EntityClass {
|
|
|
1762
1766
|
}
|
|
1763
1767
|
const fromId = rowId;
|
|
1764
1768
|
const toId = this.getId(sibling);
|
|
1765
|
-
return this.
|
|
1769
|
+
return this._reOrder(data, fromId, toId, dir === 1 ? 'after' : 'before') || data;
|
|
1766
1770
|
};
|
|
1767
|
-
this.
|
|
1771
|
+
this._moveTo = (data, fromIds, toId) => {
|
|
1768
1772
|
const fn = (data, fromId, toId) => {
|
|
1769
1773
|
const details = this.getRowDetailsByIds(data, [fromId, toId]);
|
|
1770
1774
|
let toDetail = details[toId];
|
|
@@ -1779,14 +1783,14 @@ export class EntityClass {
|
|
|
1779
1783
|
if (isToChildOfFrom) {
|
|
1780
1784
|
return data;
|
|
1781
1785
|
}
|
|
1782
|
-
const newData = this.
|
|
1786
|
+
const newData = this._removeRow(data, fromId);
|
|
1783
1787
|
//اگر بروز نشه مشکل بوجود میاد
|
|
1784
|
-
toDetail = this.
|
|
1788
|
+
toDetail = this._getRowDetail({ rows: newData, rowId: toId });
|
|
1785
1789
|
if (!toDetail) {
|
|
1786
1790
|
return data;
|
|
1787
1791
|
}
|
|
1788
1792
|
const newToRow = this.getRowByAddChild(toDetail.row, fromDetail.row);
|
|
1789
|
-
return this.
|
|
1793
|
+
return this._editRow(newData, newToRow);
|
|
1790
1794
|
};
|
|
1791
1795
|
let rows = data;
|
|
1792
1796
|
for (let i = 0; i < fromIds.length; i++) {
|
|
@@ -1794,7 +1798,7 @@ export class EntityClass {
|
|
|
1794
1798
|
}
|
|
1795
1799
|
return rows;
|
|
1796
1800
|
};
|
|
1797
|
-
this.
|
|
1801
|
+
this._editByTraverse = (rows, callback) => {
|
|
1798
1802
|
const fn = (data, parentRow) => {
|
|
1799
1803
|
for (let i = 0; i < data.length; i++) {
|
|
1800
1804
|
let row = data[i];
|
|
@@ -1820,7 +1824,7 @@ export class EntityClass {
|
|
|
1820
1824
|
fn(rows);
|
|
1821
1825
|
return rows;
|
|
1822
1826
|
};
|
|
1823
|
-
this.
|
|
1827
|
+
this._traverse = (rows, callback) => {
|
|
1824
1828
|
const fn = (data, parentRows, level) => {
|
|
1825
1829
|
for (let i = 0; i < data.length; i++) {
|
|
1826
1830
|
let row = data[i];
|
|
@@ -1837,83 +1841,77 @@ export class EntityClass {
|
|
|
1837
1841
|
};
|
|
1838
1842
|
fn(rows, [], 0);
|
|
1839
1843
|
};
|
|
1840
|
-
this.
|
|
1841
|
-
|
|
1842
|
-
|
|
1843
|
-
|
|
1844
|
-
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1864
|
-
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
1878
|
-
|
|
1879
|
-
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1888
|
-
|
|
1889
|
-
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1910
|
-
|
|
1911
|
-
return res;
|
|
1912
|
-
},
|
|
1913
|
-
traverse: (p) => {
|
|
1914
|
-
const rows = p.rows || this.getData();
|
|
1915
|
-
this.traverse(rows, p.callback);
|
|
1916
|
-
}
|
|
1844
|
+
this.getRowDetail = (p) => {
|
|
1845
|
+
const rows = p.rows || this.getData();
|
|
1846
|
+
return this._getRowDetail({ rows, rowId: p.rowId, row: p.row });
|
|
1847
|
+
};
|
|
1848
|
+
this.getFilteredTree = (p) => {
|
|
1849
|
+
const rows = p.rows || this.getData();
|
|
1850
|
+
return this._getFilteredTree(rows, p.filter);
|
|
1851
|
+
};
|
|
1852
|
+
this.getSortedTree = (p) => {
|
|
1853
|
+
const rows = p.rows || this.getData();
|
|
1854
|
+
const res = this._getSortedTree(rows, p.sorts);
|
|
1855
|
+
this.setData(res);
|
|
1856
|
+
return res;
|
|
1857
|
+
};
|
|
1858
|
+
this.addRow = (p) => {
|
|
1859
|
+
const rows = p.rows || this.getData();
|
|
1860
|
+
const res = this._addRow(rows, p.row, p);
|
|
1861
|
+
this.setData(res.rows);
|
|
1862
|
+
return res;
|
|
1863
|
+
};
|
|
1864
|
+
this.editRow = (p) => {
|
|
1865
|
+
const rows = p.rows || this.getData();
|
|
1866
|
+
const res = this._editRow(rows, p.row);
|
|
1867
|
+
this.setData(res);
|
|
1868
|
+
return res;
|
|
1869
|
+
};
|
|
1870
|
+
this.editById = (p) => {
|
|
1871
|
+
const rows = p.rows || this.getData();
|
|
1872
|
+
const res = this._editById(rows, p.rowId, p.change);
|
|
1873
|
+
this.setData(res);
|
|
1874
|
+
return res;
|
|
1875
|
+
};
|
|
1876
|
+
this.removeRow = (p) => {
|
|
1877
|
+
const rows = p.rows || this.getData();
|
|
1878
|
+
const res = this._removeRow(rows, p.rowId);
|
|
1879
|
+
this.setData(res);
|
|
1880
|
+
return res;
|
|
1881
|
+
};
|
|
1882
|
+
this.removeByRowIds = (p) => {
|
|
1883
|
+
const rows = p.rows || this.getData();
|
|
1884
|
+
const res = this._removeByRowIds(rows, p.rowIds);
|
|
1885
|
+
this.setData(res);
|
|
1886
|
+
return res;
|
|
1887
|
+
};
|
|
1888
|
+
this.reOrder = (p) => {
|
|
1889
|
+
const rows = p.rows || this.getData();
|
|
1890
|
+
const res = this._reOrder(rows, p.fromId, p.toId);
|
|
1891
|
+
this.setData(res);
|
|
1892
|
+
return res;
|
|
1893
|
+
};
|
|
1894
|
+
this.reOrderByDir = (p) => {
|
|
1895
|
+
const rows = p.rows || this.getData();
|
|
1896
|
+
const res = this._reOrderByDir(rows, p.rowId, p.dir);
|
|
1897
|
+
this.setData(res);
|
|
1898
|
+
return res;
|
|
1899
|
+
};
|
|
1900
|
+
this.moveTo = (p) => {
|
|
1901
|
+
const rows = p.rows || this.getData();
|
|
1902
|
+
const res = this._moveTo(rows, p.fromIds, p.toId);
|
|
1903
|
+
this.setData(res);
|
|
1904
|
+
return res;
|
|
1905
|
+
};
|
|
1906
|
+
this.editByTraverse = (p) => {
|
|
1907
|
+
const rows = p.rows || this.getData();
|
|
1908
|
+
const res = this._editByTraverse(rows, p.callback);
|
|
1909
|
+
this.setData(res);
|
|
1910
|
+
return res;
|
|
1911
|
+
};
|
|
1912
|
+
this.traverse = (p) => {
|
|
1913
|
+
const rows = p.rows || this.getData();
|
|
1914
|
+
this._traverse(rows, p.callback);
|
|
1917
1915
|
};
|
|
1918
1916
|
this.map = p.map;
|
|
1919
1917
|
if (p.getData) {
|
|
@@ -1923,7 +1921,7 @@ export class EntityClass {
|
|
|
1923
1921
|
if (p.setData) {
|
|
1924
1922
|
let newData = v;
|
|
1925
1923
|
if (p.sorts && p.sorts.length) {
|
|
1926
|
-
newData = this.
|
|
1924
|
+
newData = this._getSortedTree(newData, p.sorts);
|
|
1927
1925
|
}
|
|
1928
1926
|
p.setData(newData);
|
|
1929
1927
|
}
|