]> git.proxmox.com Git - extjs.git/blame - extjs/packages/core/src/data/matrix/Side.js
add extjs 6.0.1 sources
[extjs.git] / extjs / packages / core / src / data / matrix / Side.js
CommitLineData
6527f429
DM
1/**\r
2 * This class manages one side of a `Matrix`.\r
3 * @private\r
4 */\r
5Ext.define('Ext.data.matrix.Side', {\r
6 requires: [\r
7 'Ext.data.matrix.Slice'\r
8 ],\r
9\r
10 /**\r
11 * @property {Ext.data.matrix.Side} inverse\r
12 * Reference to the opposite side of the matrix.\r
13 * @readonly\r
14 */\r
15\r
16 constructor: function (matrix, index, role) {\r
17 var me = this;\r
18\r
19 /**\r
20 * @property {Ext.data.matrix.Matrix} matrix\r
21 * @readonly\r
22 */\r
23 me.matrix = matrix;\r
24\r
25 /**\r
26 * @property {Number} index\r
27 * Either 0 or 1 which is the index of our id value in an association entry.\r
28 * @readonly\r
29 */\r
30 me.index = index;\r
31\r
32 /**\r
33 * @property {Ext.data.schema.Role} role\r
34 * The role for this side of the matrix.\r
35 * @readonly\r
36 */\r
37 me.role = role;\r
38\r
39 /**\r
40 * @property {Object} slices\r
41 * Keyed by the id for this side of the matrix to yield a `Slice`.\r
42 * @readonly\r
43 */\r
44 me.slices = {};\r
45 },\r
46\r
47 commit: function() {\r
48 var slices = this.slices,\r
49 id;\r
50\r
51 for (id in slices) {\r
52 slices[id].commit();\r
53 }\r
54 },\r
55\r
56 get: function (id1, id2) {\r
57 var me = this,\r
58 slices = me.slices,\r
59 slice = slices[id1] ||\r
60 (slices[id1] = new Ext.data.matrix.Slice(me, id1));\r
61\r
62 return (id2 || id2 === 0) ? slice.members[id2] : slice;\r
63 },\r
64\r
65 update: function (id1, id2, state) {\r
66 var slice = this.get(id1);\r
67 return slice.update(id2, state);\r
68 },\r
69\r
70 updateId: function(oldId, newId) {\r
71 var slice = this.get(oldId);\r
72 if (slice) {\r
73 slice.updateId(newId);\r
74 }\r
75 },\r
76\r
77 destroy: function() {\r
78 var me = this,\r
79 slices = me.slices,\r
80 id;\r
81\r
82 for (id in slices) {\r
83 slices[id].destroy();\r
84 }\r
85\r
86 me.inverse = me.matrix = me.role = me.slices = null;\r
87 me.callParent();\r
88 }\r
89});\r