@ctzy-web-client/data-model 1.0.4 → 1.0.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.
Files changed (51) hide show
  1. package/package.json +33 -33
  2. package/es/SimpleOrm.mjs +0 -85
  3. package/es/_virtual/_rollupPluginBabelHelpers.mjs +0 -2830
  4. package/es/abstract/DataColumn.mjs +0 -65
  5. package/es/abstract/DataForm.mjs +0 -178
  6. package/es/abstract/DataModel.mjs +0 -223
  7. package/es/abstract/DataModelAdapter.mjs +0 -86
  8. package/es/abstract/DataTable.mjs +0 -339
  9. package/es/abstract/FilterColumn.mjs +0 -44
  10. package/es/abstract/FilterPanel.mjs +0 -392
  11. package/es/abstract/FormColumn.mjs +0 -27
  12. package/es/abstract/TableColumn.mjs +0 -34
  13. package/es/abstract/dataForm2.mjs +0 -178
  14. package/es/abstract/where/CombineCondition.mjs +0 -63
  15. package/es/abstract/where/Condition.mjs +0 -4
  16. package/es/abstract/where/SingleCondition.mjs +0 -22
  17. package/es/abstract/where/Where.mjs +0 -21
  18. package/es/decorator/constant.mjs +0 -11
  19. package/es/decorator/dataForm.mjs +0 -18
  20. package/es/decorator/dataTable.mjs +0 -18
  21. package/es/decorator/filterColumn.mjs +0 -21
  22. package/es/decorator/formColumn.mjs +0 -19
  23. package/es/decorator/tableColumn.mjs +0 -20
  24. package/es/factory.mjs +0 -14
  25. package/es/index.mjs +0 -14
  26. package/es/utils/index.mjs +0 -15
  27. package/lib/SimpleOrm.js +0 -89
  28. package/lib/_virtual/_rollupPluginBabelHelpers.js +0 -2948
  29. package/lib/abstract/DataColumn.js +0 -69
  30. package/lib/abstract/DataForm.js +0 -186
  31. package/lib/abstract/DataModel.js +0 -231
  32. package/lib/abstract/DataModelAdapter.js +0 -90
  33. package/lib/abstract/DataTable.js +0 -343
  34. package/lib/abstract/FilterColumn.js +0 -48
  35. package/lib/abstract/FilterPanel.js +0 -396
  36. package/lib/abstract/FormColumn.js +0 -31
  37. package/lib/abstract/TableColumn.js +0 -38
  38. package/lib/abstract/dataForm2.js +0 -186
  39. package/lib/abstract/where/CombineCondition.js +0 -67
  40. package/lib/abstract/where/Condition.js +0 -8
  41. package/lib/abstract/where/SingleCondition.js +0 -26
  42. package/lib/abstract/where/Where.js +0 -25
  43. package/lib/decorator/constant.js +0 -20
  44. package/lib/decorator/dataForm.js +0 -22
  45. package/lib/decorator/dataTable.js +0 -22
  46. package/lib/decorator/filterColumn.js +0 -25
  47. package/lib/decorator/formColumn.js +0 -23
  48. package/lib/decorator/tableColumn.js +0 -24
  49. package/lib/factory.js +0 -19
  50. package/lib/index.js +0 -36
  51. package/lib/utils/index.js +0 -19
@@ -1,67 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var Condition = require('./Condition.js');
6
- var SingleCondition = require('./SingleCondition.js');
7
-
8
- class CombineCondition extends Condition.Condition {
9
- constructor(...args) {
10
- super(...args);
11
- this.conditions = [];
12
- }
13
- addCondition(fieldName, operator, value) {
14
- const condition = new SingleCondition.SingleCondition(fieldName, operator, value);
15
- if (this.conditions.length) {
16
- this.conditions.push("AND");
17
- }
18
- this.conditions.push(condition);
19
- return condition;
20
- }
21
- addOrCondition(fieldName, operator, value) {
22
- const condition = new SingleCondition.SingleCondition(fieldName, operator, value);
23
- if (this.conditions.length) {
24
- this.conditions.push("OR");
25
- }
26
- this.conditions.push(condition);
27
- return condition;
28
- }
29
- addGroup(group) {
30
- const _group = group || new CombineCondition();
31
- if (this.conditions.length) {
32
- this.conditions.push("AND");
33
- }
34
- this.conditions.push(_group);
35
- return _group;
36
- }
37
- addOrGroup(group) {
38
- const _group = group || new CombineCondition();
39
- if (this.conditions.length) {
40
- this.conditions.push("OR");
41
- }
42
- this.conditions.push(_group);
43
- return _group;
44
- }
45
- removeCondition(fieldName) {
46
- let index = this.conditions.findIndex((condition) => condition instanceof SingleCondition.SingleCondition && condition.f === fieldName);
47
- if (index === 0) {
48
- this.conditions.splice(index, 1);
49
- return;
50
- }
51
- this.conditions.splice(index - 1, 2);
52
- const combineConditions = this.conditions.filter((condition) => condition instanceof CombineCondition);
53
- for (let i = combineConditions.length - 1; i >= 0; i--) {
54
- const combineCondition = combineConditions[i];
55
- combineCondition.removeCondition(fieldName);
56
- if (!combineCondition.conditions.length) {
57
- const index2 = this.conditions.indexOf(combineCondition);
58
- this.conditions.splice(index2, 1);
59
- }
60
- }
61
- }
62
- toJSON() {
63
- return this.conditions.map((condition) => condition instanceof Condition.Condition ? condition.toJSON() : condition);
64
- }
65
- }
66
-
67
- exports.CombineCondition = CombineCondition;
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- class Condition {
6
- }
7
-
8
- exports.Condition = Condition;
@@ -1,26 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var Condition = require('./Condition.js');
6
-
7
- class SingleCondition extends Condition.Condition {
8
- constructor(f, o, v) {
9
- super();
10
- this.f = "";
11
- this.o = "=";
12
- this.v = "";
13
- this.f = f;
14
- this.v = v;
15
- this.o = o;
16
- }
17
- toJSON() {
18
- return {
19
- f: this.f,
20
- o: this.o,
21
- v: this.v
22
- };
23
- }
24
- }
25
-
26
- exports.SingleCondition = SingleCondition;
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var CombineCondition = require('./CombineCondition.js');
6
- var SingleCondition = require('./SingleCondition.js');
7
-
8
- class Where extends CombineCondition.CombineCondition {
9
- getCondition(fieldName) {
10
- let conditions = this.conditions.slice();
11
- for (let i = 0; i < conditions.length; i++) {
12
- const condition = conditions[i];
13
- if (condition instanceof CombineCondition.CombineCondition) {
14
- conditions = conditions.concat(condition.conditions);
15
- } else if (condition instanceof SingleCondition.SingleCondition) {
16
- if (condition.f === fieldName) {
17
- return condition;
18
- }
19
- }
20
- }
21
- return null;
22
- }
23
- }
24
-
25
- exports.Where = Where;
@@ -1,20 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const DATA_MODEL_DEFINE = {
6
- table: Symbol("DATA TABLE DEFINE"),
7
- form: Symbol("DATA FORM DEFINE")
8
- };
9
- const DATA_TABLE = "DATA_TABLE";
10
- const DATA_FORM = "DATA_FORM";
11
- const DATA_TABLE_COLUMNS = "DATA_TABLE_COLUMNS";
12
- const DATA_TABLE_FILTER_COLUMN = "DATA_TABLE_FILTER_COLUMN";
13
- const DATA_FORM_COLUMNS = "DATA_FORM_COLUMNS";
14
-
15
- exports.DATA_FORM = DATA_FORM;
16
- exports.DATA_FORM_COLUMNS = DATA_FORM_COLUMNS;
17
- exports.DATA_MODEL_DEFINE = DATA_MODEL_DEFINE;
18
- exports.DATA_TABLE = DATA_TABLE;
19
- exports.DATA_TABLE_COLUMNS = DATA_TABLE_COLUMNS;
20
- exports.DATA_TABLE_FILTER_COLUMN = DATA_TABLE_FILTER_COLUMN;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var constant = require('./constant.js');
6
- require('../abstract/DataForm.js');
7
-
8
- function dataForm(option) {
9
- return function decorator(classType) {
10
- if (classType.constructor !== Function) {
11
- throw new Error(`@dataForm \u53EA\u80FD\u7528\u4E8E\u7C7B\u7684\u6CE8\u89E3`);
12
- }
13
- let dataForm2 = classType[constant.DATA_FORM];
14
- if (dataForm2) {
15
- return;
16
- }
17
- dataForm2 = classType[constant.DATA_FORM] = option;
18
- return classType;
19
- };
20
- }
21
-
22
- exports["default"] = dataForm;
@@ -1,22 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var constant = require('./constant.js');
6
- require('../abstract/DataTable.js');
7
-
8
- function dataTable(option) {
9
- return function decorator(classType) {
10
- if (classType.constructor !== Function) {
11
- throw new Error(`@dataTable \u53EA\u80FD\u7528\u4E8E\u7C7B\u7684\u6CE8\u89E3`);
12
- }
13
- let dataTable2 = classType[constant.DATA_MODEL_DEFINE.table];
14
- if (dataTable2) {
15
- return;
16
- }
17
- classType[constant.DATA_TABLE] = option;
18
- return classType;
19
- };
20
- }
21
-
22
- exports["default"] = dataTable;
@@ -1,25 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var constant = require('./constant.js');
6
-
7
- function filterColumn(options) {
8
- return function(target, key, description) {
9
- if (arguments.length !== 3 || target.constructor === Function || typeof description.value === "function") {
10
- throw new Error(`@formColumn \u53EA\u80FD\u4F7F\u7528\u5728\u7C7B\u7684\u6210\u5458\u53D8\u91CF\u4E2D`);
11
- }
12
- target.constructor[constant.DATA_TABLE_FILTER_COLUMN] = target.constructor[constant.DATA_TABLE_FILTER_COLUMN] || [];
13
- const columns = target.constructor[constant.DATA_TABLE_FILTER_COLUMN];
14
- options = {
15
- name: key,
16
- attrName: key,
17
- closable: false,
18
- ...options
19
- };
20
- options.visible = !options.closable;
21
- columns.push(options);
22
- };
23
- }
24
-
25
- exports["default"] = filterColumn;
@@ -1,23 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var constant = require('./constant.js');
6
-
7
- function formColumn(option) {
8
- return function(target, key, description) {
9
- if (arguments.length !== 3 || target.constructor === Function || typeof description.value === "function") {
10
- throw new Error(`@formColumn \u53EA\u80FD\u4F7F\u7528\u5728\u7C7B\u7684\u6210\u5458\u53D8\u91CF\u4E2D`);
11
- }
12
- target.constructor[constant.DATA_FORM_COLUMNS] = target.constructor[constant.DATA_FORM_COLUMNS] || [];
13
- const columns = target.constructor[constant.DATA_FORM_COLUMNS];
14
- columns.push({
15
- name: key,
16
- submitName: option.name || key,
17
- ...option,
18
- attrName: key
19
- });
20
- };
21
- }
22
-
23
- exports["default"] = formColumn;
@@ -1,24 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var constant = require('./constant.js');
6
- require('../abstract/DataTable.js');
7
- require('../abstract/TableColumn.js');
8
-
9
- function tableColumn(option) {
10
- return function(target, key, description) {
11
- if (arguments.length !== 3 || target.constructor === Function || typeof description.value === "function") {
12
- throw new Error(`@tableColumn \u53EA\u80FD\u4F7F\u7528\u5728\u7C7B\u7684\u6210\u5458\u53D8\u91CF\u4E2D`);
13
- }
14
- target.constructor[constant.DATA_TABLE_COLUMNS] = target.constructor[constant.DATA_TABLE_COLUMNS] || [];
15
- const columns = target.constructor[constant.DATA_TABLE_COLUMNS];
16
- columns.push({
17
- name: key,
18
- attrName: key,
19
- ...option
20
- });
21
- };
22
- }
23
-
24
- exports["default"] = tableColumn;
package/lib/factory.js DELETED
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var constant = require('./decorator/constant.js');
6
- var DataTable = require('./abstract/DataTable.js');
7
- require('./abstract/dataForm2.js');
8
-
9
- const createDataTable = function(classType) {
10
- const baseDataTable = classType[constant.DATA_MODEL_DEFINE.table];
11
- return baseDataTable ? baseDataTable.clone() : new DataTable["default"]();
12
- };
13
- const createDataForm = function(classType) {
14
- const baseDataForm = classType[constant.DATA_MODEL_DEFINE.form];
15
- return baseDataForm ? baseDataForm.clone() : new dataForm();
16
- };
17
-
18
- exports.createDataForm = createDataForm;
19
- exports.createDataTable = createDataTable;
package/lib/index.js DELETED
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var DataTable = require('./abstract/DataTable.js');
6
- var DataForm = require('./abstract/DataForm.js');
7
- var FilterPanel = require('./abstract/FilterPanel.js');
8
- var DataModelAdapter = require('./abstract/DataModelAdapter.js');
9
- var dataTable = require('./decorator/dataTable.js');
10
- var dataForm = require('./decorator/dataForm.js');
11
- var tableColumn = require('./decorator/tableColumn.js');
12
- var formColumn = require('./decorator/formColumn.js');
13
- var SimpleOrm = require('./SimpleOrm.js');
14
- var filterColumn = require('./decorator/filterColumn.js');
15
- var CombineCondition = require('./abstract/where/CombineCondition.js');
16
- var SingleCondition = require('./abstract/where/SingleCondition.js');
17
- var Where = require('./abstract/where/Where.js');
18
- var factory = require('./factory.js');
19
-
20
-
21
-
22
- exports.DataTable = DataTable["default"];
23
- exports.DataForm = DataForm["default"];
24
- exports.FilterPanel = FilterPanel.FilterPanel;
25
- exports.DataModelAdapter = DataModelAdapter["default"];
26
- exports.dataTable = dataTable["default"];
27
- exports.dataForm = dataForm["default"];
28
- exports.tableColumn = tableColumn["default"];
29
- exports.formColumn = formColumn["default"];
30
- exports.SimpleOrm = SimpleOrm["default"];
31
- exports.filterColumn = filterColumn["default"];
32
- exports.CombineCondition = CombineCondition.CombineCondition;
33
- exports.SingleCondition = SingleCondition.SingleCondition;
34
- exports.Where = Where.Where;
35
- exports.createDataForm = factory.createDataForm;
36
- exports.createDataTable = factory.createDataTable;
@@ -1,19 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- const sortColumn = (columns, order) => {
6
- return [...columns].sort((a, b) => {
7
- const aIndex = order.indexOf(a.attrName);
8
- const bIndex = order.indexOf(b.attrName);
9
- if (aIndex === -1 && bIndex === -1) {
10
- return 0;
11
- }
12
- if (aIndex !== -1 && bIndex !== -1) {
13
- return aIndex - bIndex;
14
- }
15
- return aIndex === -1 ? 1 : -1;
16
- });
17
- };
18
-
19
- exports.sortColumn = sortColumn;