1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 | import {
|
8 | Events
|
9 | } from './indexEvents';
|
10 |
|
11 |
|
12 | import {
|
13 | rowDataFunObj
|
14 | } from './row-data';
|
15 |
|
16 | import {
|
17 | rowGetDataFunObj
|
18 | } from './row-getData';
|
19 |
|
20 | import {
|
21 | rowGetMetaFunObj
|
22 | } from './row-getMeta';
|
23 |
|
24 | import {
|
25 | rowGetSimpleDataFunObj
|
26 | } from './row-getSimpleData';
|
27 |
|
28 | import {
|
29 | rowInitFunObj
|
30 | } from './row-init';
|
31 |
|
32 | import {
|
33 | rowMetaFunObj
|
34 | } from './row-meta';
|
35 |
|
36 | import {
|
37 | rowRefFunObj
|
38 | } from './row-ref';
|
39 |
|
40 | import {
|
41 | rowRowSelectFunObj
|
42 | } from './row-rowSelect';
|
43 |
|
44 | import {
|
45 | rowSimpleDataFunObj
|
46 | } from './row-simpleData';
|
47 |
|
48 | import {
|
49 | rowUtilFunObj
|
50 | } from './row-util';
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 | class Row extends Events {
|
60 | constructor(options) {
|
61 | super();
|
62 | var self = this;
|
63 | |
64 |
|
65 |
|
66 |
|
67 | this.rowId = options['id'] || Row.getRandomRowId()
|
68 | |
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 | this.status = Row.STATUS.NEW
|
79 | |
80 |
|
81 |
|
82 |
|
83 | this.parent = options['parent']
|
84 |
|
85 | this.data = {}
|
86 |
|
87 | this.metaChange = {}
|
88 |
|
89 | this.valueChange = {};
|
90 |
|
91 | this.currentRowChange = ko.observable(1);
|
92 |
|
93 | this.selected = ko.pureComputed({
|
94 | read: function() {
|
95 | var index = this.parent.getRowIndex(this);
|
96 | var selectindices = this.parent.getSelectedIndices();
|
97 | return selectindices.indexOf(index) != -1;
|
98 | },
|
99 | owner: this
|
100 |
|
101 | })
|
102 |
|
103 | this.focused = ko.pureComputed({
|
104 | read: function() {
|
105 | var index = this.parent.getRowIndex(this);
|
106 | var focusIndex = this.parent.getFocusIndex()
|
107 | return focusIndex == index;
|
108 | },
|
109 | owner: this
|
110 |
|
111 | })
|
112 | this.init();
|
113 | }
|
114 | }
|
115 | const RowProto = Row.prototype;
|
116 | Object.assign(RowProto, rowDataFunObj);
|
117 | Object.assign(RowProto, rowGetDataFunObj);
|
118 | Object.assign(RowProto, rowGetMetaFunObj);
|
119 | Object.assign(RowProto, rowGetSimpleDataFunObj);
|
120 | Object.assign(RowProto, rowInitFunObj);
|
121 | Object.assign(RowProto, rowMetaFunObj);
|
122 | Object.assign(RowProto, rowRefFunObj);
|
123 | Object.assign(RowProto, rowRowSelectFunObj);
|
124 | Object.assign(RowProto, rowSimpleDataFunObj);
|
125 | Object.assign(RowProto, rowUtilFunObj);
|
126 |
|
127 | Row.STATUS = {
|
128 | NORMAL: 'nrm',
|
129 | UPDATE: 'upd',
|
130 | NEW: 'new',
|
131 | DELETE: 'del',
|
132 | FALSE_DELETE: 'fdel'
|
133 | }
|
134 |
|
135 |
|
136 |
|
137 |
|
138 |
|
139 | Row.getRandomRowId = function() {
|
140 | var _id = setTimeout(function() {})
|
141 | return _id + '';
|
142 | };
|
143 |
|
144 |
|
145 |
|
146 | export {
|
147 | Row
|
148 | }
|