aboutsummaryrefslogtreecommitdiff
path: root/node_modules/montage/ui/controller/array-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/montage/ui/controller/array-controller.js')
-rw-r--r--node_modules/montage/ui/controller/array-controller.js247
1 files changed, 125 insertions, 122 deletions
diff --git a/node_modules/montage/ui/controller/array-controller.js b/node_modules/montage/ui/controller/array-controller.js
index ec236b39..1768398f 100644
--- a/node_modules/montage/ui/controller/array-controller.js
+++ b/node_modules/montage/ui/controller/array-controller.js
@@ -21,13 +21,44 @@ var Montage = require("montage").Montage,
21*/ 21*/
22var ArrayController = exports.ArrayController = Montage.create(ObjectController, /** @lends module:montage/ui/controller/array-controller.ArrayController# */ { 22var ArrayController = exports.ArrayController = Montage.create(ObjectController, /** @lends module:montage/ui/controller/array-controller.ArrayController# */ {
23 23
24 didCreate: {
25 value: function() {
26 var self = this;
27
28 // TODO optimize this, try to use dependentProperties perhaps
29
30 this.addPropertyChangeListener("selections", function() {
31
32 var newSelectedIndexes = [];
33 self._selections.forEach(function(item, i) {
34 if (item) {
35 newSelectedIndexes.push(i);
36 }
37 });
38
39 // TODO this triggers an infinite loop
40 self.selectedIndexes = newSelectedIndexes;
41 });
42
43 this.addPropertyChangeListener("content", function() {
44 // TODO for right now assume that any content change invalidates the selection completely;
45 // we'll need to address this of course
46 self.selectedObjects = null;
47
48 if (self.automaticallyOrganizeObjects) {
49 self.organizeObjects();
50 }
51 });
52 }
53 },
54
24 /** 55 /**
25 @private 56 @private
26 */ 57 */
27 _content: { 58 _content: {
28 enumerable: false,
29 value: null 59 value: null
30 }, 60 },
61
31 /** 62 /**
32 The content managed by the ArrayController. 63 The content managed by the ArrayController.
33 @type {Function} 64 @type {Function}
@@ -44,11 +75,8 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController,
44 } 75 }
45 this._content = value; 76 this._content = value;
46 77
47 //TODO for right now assume that any content change invalidates the selection completely; we'll need to address this of course 78 },
48 this.selectedObjects = null; 79 serializable: true
49 this.organizeObjects();
50 this._initSelections();
51 }
52 }, 80 },
53 81
54 /** 82 /**
@@ -68,15 +96,16 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController,
68 }) 96 })
69 */ 97 */
70 delegate: { 98 delegate: {
71 value: null 99 value: null,
100 serializable: true
72 }, 101 },
73 102
74 /** 103 /**
75 @private 104 @private
76 */ 105 */
77 _organizedObjects: { 106 _organizedObjects: {
78 enumerable: false, 107 distinct: true,
79 value: null 108 value: []
80 }, 109 },
81 110
82 /** 111 /**
@@ -85,33 +114,25 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController,
85 @default null 114 @default null
86 */ 115 */
87 organizedObjects: { 116 organizedObjects: {
88 enumerable: false,
89 get: function() { 117 get: function() {
90
91 if (this._organizedObjects) {
92 return this._organizedObjects;
93 }
94
95 this.organizeObjects();
96
97 return this._organizedObjects; 118 return this._organizedObjects;
98 } 119 }
99 }, 120 },
100 121
101 /** 122 /**
102 Specifies whether the ArrayCollection's content is automatically organized (false, by default). 123 Specifies whether the ArrayCollection's content is automatically organized.
103 @type {Property} 124 @type {Property}
104 @default {Boolean} false 125 @default {Boolean} true
105 */ 126 */
106 automaticallyOrganizeObjects: { 127 automaticallyOrganizeObjects: {
107 value: false 128 value: true,
129 serializable: true
108 }, 130 },
109 131
110 /** 132 /**
111 @private 133 @private
112 */ 134 */
113 _sortFunction: { 135 _sortFunction: {
114 enumerable: false,
115 value: null 136 value: null
116 }, 137 },
117 138
@@ -136,14 +157,14 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController,
136 if (this.automaticallyOrganizeObjects) { 157 if (this.automaticallyOrganizeObjects) {
137 this.organizeObjects(); 158 this.organizeObjects();
138 } 159 }
139 } 160 },
161 serializable: true
140 }, 162 },
141 163
142 /** 164 /**
143 @private 165 @private
144 */ 166 */
145 _filterFunction: { 167 _filterFunction: {
146 enumerable: false,
147 value: null 168 value: null
148 }, 169 },
149 170
@@ -168,14 +189,14 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController,
168 if (this.automaticallyOrganizeObjects) { 189 if (this.automaticallyOrganizeObjects) {
169 this.organizeObjects(); 190 this.organizeObjects();
170 } 191 }
171 } 192 },
193 serializable: true
172 }, 194 },
173 195
174 /** 196 /**
175 @private 197 @private
176 */ 198 */
177 _startIndex: { 199 _startIndex: {
178 enumerable: false,
179 value: null 200 value: null
180 }, 201 },
181 202
@@ -186,7 +207,7 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController,
186 @version 1.0 207 @version 1.0
187 */ 208 */
188 startIndex: { 209 startIndex: {
189 enumerable: false, 210 serializable: true,
190 get: function() { 211 get: function() {
191 return this._startIndex; 212 return this._startIndex;
192 }, 213 },
@@ -219,7 +240,7 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController,
219 @version 1.0 240 @version 1.0
220 */ 241 */
221 endIndex: { 242 endIndex: {
222 enumerable: false, 243 serializable: true,
223 get: function() { 244 get: function() {
224 return this._endIndex; 245 return this._endIndex;
225 }, 246 },
@@ -241,24 +262,21 @@ var ArrayController = exports.ArrayController = Montage.create(ObjectController,
241 @private 262 @private
242 */ 263 */
243 _organizedObjectsIndexes: { 264 _organizedObjectsIndexes: {
244 value: null, 265 value: null
245 enumerable: false
246 }, 266 },
247 267
248 /* 268 /*
249 @private 269 @private
250 */ 270 */