luca 0.8.06 → 0.8.59
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.
- data/CHANGELOG +32 -1
- data/Guardfile +14 -9
- data/app.rb +1 -0
- data/assets/javascripts/sandbox/config.coffee +1 -1
- data/assets/javascripts/sandbox/views/pages/pages_controller.coffee +6 -0
- data/lib/luca/rails/version.rb +1 -1
- data/spec/framework_spec.coffee +33 -1
- data/src/components/application.coffee +1 -3
- data/src/components/base_toolbar.coffee +5 -6
- data/src/components/collection_inspector.coffee +2 -0
- data/src/components/collection_loader_view.coffee +7 -6
- data/src/components/controller.coffee +3 -1
- data/src/components/development_console.coffee +7 -4
- data/src/components/fields/button_field.coffee +2 -5
- data/src/components/fields/checkbox_array.coffee +64 -0
- data/src/components/fields/checkbox_field.coffee +7 -10
- data/src/components/fields/file_upload_field.coffee +3 -6
- data/src/components/fields/hidden_field.coffee +4 -10
- data/src/components/fields/select_field.coffee +15 -18
- data/src/components/fields/text_area_field.coffee +5 -8
- data/src/components/fields/text_field.coffee +7 -14
- data/src/components/fields/type_ahead_field.coffee +4 -6
- data/src/components/form_button_toolbar.coffee +4 -4
- data/src/components/form_view.coffee +24 -10
- data/src/components/grid_view.coffee +80 -42
- data/src/components/record_manager.coffee +21 -22
- data/src/components/template.coffee +6 -8
- data/src/containers/card_view.coffee +2 -4
- data/src/containers/column_view.coffee +10 -12
- data/src/containers/modal_view.coffee +7 -9
- data/src/containers/panel_view.coffee +4 -4
- data/src/containers/split_view.coffee +3 -5
- data/src/containers/tab_view.coffee +3 -2
- data/src/containers/viewport.coffee +2 -3
- data/src/core/container.coffee +4 -4
- data/src/core/field.coffee +14 -13
- data/src/core/model.coffee +1 -1
- data/src/core/view.coffee +12 -3
- data/src/framework.coffee +134 -17
- data/src/managers/collection_manager.coffee +1 -1
- data/src/stylesheets/components/development_console.scss +5 -0
- data/src/templates/fields/checkbox_array.luca +5 -0
- data/src/templates/fields/checkbox_array_item.luca +4 -0
- data/vendor/assets/javascripts/luca-ui-base.js +155 -43
- data/vendor/assets/javascripts/luca-ui-spec.js +385 -133
- data/vendor/assets/javascripts/luca-ui.js +344 -132
- data/vendor/assets/javascripts/luca-ui.min.js +3 -3
- data/vendor/assets/stylesheets/luca-ui-bootstrap.css +4 -1
- data/vendor/assets/stylesheets/luca-ui-spec.css +4 -1
- data/vendor/assets/stylesheets/luca-ui.css +4 -1
- metadata +6 -2
@@ -1,25 +1,26 @@
|
|
1
1
|
(function() {
|
2
|
-
|
3
|
-
_.mixin(_.string);
|
2
|
+
var DefineProxy;
|
4
3
|
|
5
4
|
window.Luca = {
|
6
|
-
VERSION: "0.8.
|
5
|
+
VERSION: "0.8.59",
|
7
6
|
core: {},
|
8
7
|
containers: {},
|
9
8
|
components: {},
|
10
9
|
modules: {},
|
11
|
-
fields: {},
|
12
10
|
util: {},
|
13
|
-
|
14
|
-
classes: {},
|
15
|
-
namespaces: ["Luca.containers", "Luca.components"]
|
16
|
-
},
|
11
|
+
fields: {},
|
17
12
|
component_cache: {
|
18
13
|
cid_index: {},
|
19
14
|
name_index: {}
|
15
|
+
},
|
16
|
+
registry: {
|
17
|
+
classes: {},
|
18
|
+
namespaces: ["Luca.containers", "Luca.components"]
|
20
19
|
}
|
21
20
|
};
|
22
21
|
|
22
|
+
Luca.enableGlobalObserver = false;
|
23
|
+
|
23
24
|
Luca.enableBootstrap = true;
|
24
25
|
|
25
26
|
Luca.isBackboneModel = function(obj) {
|
@@ -53,28 +54,35 @@
|
|
53
54
|
return Luca.component_cache.cid_index[lookup_id];
|
54
55
|
};
|
55
56
|
|
56
|
-
Luca.util.
|
57
|
+
Luca.util.resolve = function(accessor, source_object) {
|
57
58
|
return _(accessor.split(/\./)).inject(function(obj, key) {
|
58
59
|
return obj = obj != null ? obj[key] : void 0;
|
59
60
|
}, source_object);
|
60
61
|
};
|
61
62
|
|
63
|
+
Luca.util.nestedValue = Luca.util.resolve;
|
64
|
+
|
65
|
+
Luca.util.classify = function(string) {
|
66
|
+
if (string == null) string = "";
|
67
|
+
return _.string.camelize(_.string.capitalize(string));
|
68
|
+
};
|
69
|
+
|
62
70
|
Luca.registry.lookup = function(ctype) {
|
63
|
-
var c, className, parents;
|
71
|
+
var c, className, parents, _ref;
|
64
72
|
c = Luca.registry.classes[ctype];
|
65
73
|
if (c != null) return c;
|
66
|
-
className =
|
74
|
+
className = Luca.util.classify(ctype);
|
67
75
|
parents = _(Luca.registry.namespaces).map(function(namespace) {
|
68
76
|
return Luca.util.nestedValue(namespace, window || global);
|
69
77
|
});
|
70
|
-
return
|
78
|
+
return (_ref = _(parents).chain().map(function(parent) {
|
71
79
|
return parent[className];
|
72
|
-
})));
|
80
|
+
}).compact().value()) != null ? _ref[0] : void 0;
|
73
81
|
};
|
74
82
|
|
75
83
|
Luca.util.lazyComponent = function(config) {
|
76
84
|
var componentClass, constructor, ctype;
|
77
|
-
ctype = config.ctype;
|
85
|
+
ctype = config.ctype || config.type;
|
78
86
|
componentClass = Luca.registry.lookup(ctype);
|
79
87
|
if (!componentClass) {
|
80
88
|
throw "Invalid Component Type: " + ctype + ". Did you forget to register it?";
|
@@ -86,8 +94,8 @@
|
|
86
94
|
Luca.register = function(component, constructor_class) {
|
87
95
|
var exists;
|
88
96
|
exists = Luca.registry.classes[component];
|
89
|
-
if (exists != null) {
|
90
|
-
|
97
|
+
if ((exists != null) && !(window.TestRun != null)) {
|
98
|
+
return console.log("Attempting to register component with the signature " + component + ". Already exists");
|
91
99
|
} else {
|
92
100
|
return Luca.registry.classes[component] = constructor_class;
|
93
101
|
}
|
@@ -115,6 +123,102 @@
|
|
115
123
|
}
|
116
124
|
};
|
117
125
|
|
126
|
+
Luca.template = function(template_name, variables) {
|
127
|
+
var jst, luca, needle, template, _ref;
|
128
|
+
window.JST || (window.JST = {});
|
129
|
+
luca = (_ref = Luca.templates) != null ? _ref[template_name] : void 0;
|
130
|
+
jst = typeof JST !== "undefined" && JST !== null ? JST[template_name] : void 0;
|
131
|
+
if (!((luca != null) || (jst != null))) {
|
132
|
+
needle = new RegExp("" + template_name + "$");
|
133
|
+
luca = _(Luca.templates).detect(function(fn, template_id) {
|
134
|
+
return needle.exec(template_id);
|
135
|
+
});
|
136
|
+
jst = _(JST).detect(function(fn, template_id) {
|
137
|
+
return needle.exec(template_id);
|
138
|
+
});
|
139
|
+
}
|
140
|
+
if (!(luca || jst)) throw "Could not find template with " + template_name;
|
141
|
+
template = luca || jst;
|
142
|
+
if (variables != null) return template(variables);
|
143
|
+
return template;
|
144
|
+
};
|
145
|
+
|
146
|
+
DefineProxy = (function() {
|
147
|
+
|
148
|
+
function DefineProxy(componentName) {
|
149
|
+
var parts;
|
150
|
+
this.namespace = window || global;
|
151
|
+
this.componentId = this.componentName = componentName;
|
152
|
+
if (componentName.match(/\./)) {
|
153
|
+
this.namespaced = true;
|
154
|
+
parts = componentName.split('.');
|
155
|
+
this.componentId = parts.pop();
|
156
|
+
this.namespace = parts.join('.');
|
157
|
+
Luca.registry.addNamespace(parts.join('.'));
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
DefineProxy.prototype["in"] = function(namespace) {
|
162
|
+
this.namespace = namespace;
|
163
|
+
return this;
|
164
|
+
};
|
165
|
+
|
166
|
+
DefineProxy.prototype.from = function(superClassName) {
|
167
|
+
this.superClassName = superClassName;
|
168
|
+
return this;
|
169
|
+
};
|
170
|
+
|
171
|
+
DefineProxy.prototype["extends"] = function(superClassName) {
|
172
|
+
this.superClassName = superClassName;
|
173
|
+
return this;
|
174
|
+
};
|
175
|
+
|
176
|
+
DefineProxy.prototype.extend = function(superClassName) {
|
177
|
+
this.superClassName = superClassName;
|
178
|
+
return this;
|
179
|
+
};
|
180
|
+
|
181
|
+
DefineProxy.prototype["with"] = function(properties) {
|
182
|
+
var at;
|
183
|
+
at = this.namespaced ? Luca.util.resolve(this.namespace, window || global) : window || global;
|
184
|
+
if (this.namespaced && _.isUndefined(at)) {
|
185
|
+
eval("window." + this.namespace + " = {}");
|
186
|
+
at = Luca.util.resolve(this.namespace, window || global);
|
187
|
+
}
|
188
|
+
at[this.componentId] = Luca.extend(this.superClassName, this.componentName, properties);
|
189
|
+
Luca.register(_.string.underscored(this.componentId), this.componentName);
|
190
|
+
return at[this.componentId];
|
191
|
+
};
|
192
|
+
|
193
|
+
return DefineProxy;
|
194
|
+
|
195
|
+
})();
|
196
|
+
|
197
|
+
Luca.define = function(componentName) {
|
198
|
+
return new DefineProxy(componentName);
|
199
|
+
};
|
200
|
+
|
201
|
+
Luca.component = Luca.define;
|
202
|
+
|
203
|
+
Luca.extend = function(superClassName, childName, properties) {
|
204
|
+
var superClass;
|
205
|
+
if (properties == null) properties = {};
|
206
|
+
superClass = Luca.util.resolve(superClassName, window || global);
|
207
|
+
if (!_.isFunction(superClass != null ? superClass.extend : void 0)) {
|
208
|
+
throw "" + superClassName + " is not a valid component to extend from";
|
209
|
+
}
|
210
|
+
properties._className = childName;
|
211
|
+
properties._superClass = function() {
|
212
|
+
superClass._className || (superClass._className = superClassName);
|
213
|
+
return superClass;
|
214
|
+
};
|
215
|
+
return superClass.extend(properties);
|
216
|
+
};
|
217
|
+
|
218
|
+
_.mixin({
|
219
|
+
component: Luca.define
|
220
|
+
});
|
221
|
+
|
118
222
|
$((function() {
|
119
223
|
return $('body').addClass('luca-ui-enabled');
|
120
224
|
})());
|
@@ -266,6 +370,14 @@
|
|
266
370
|
Luca.templates || (Luca.templates = {});
|
267
371
|
Luca.templates["fields/button_field_link"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<a class=\'btn ', input_class ,'\'>\n '); if(icon_class.length) { __p.push('\n <i class=\'', icon_class ,'\'></i>\n '); } __p.push('\n ', input_value ,'\n</a>\n');}return __p.join('');};
|
268
372
|
}).call(this);
|
373
|
+
(function() {
|
374
|
+
Luca.templates || (Luca.templates = {});
|
375
|
+
Luca.templates["fields/checkbox_array"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'form-horizontal\'>\n <div class=\'control-group\'>\n <label for=\'', input_id ,'\'>\n ', label ,'\n </label>\n <div class=\'controls\'></div>\n </div>\n</div>\n');}return __p.join('');};
|
376
|
+
}).call(this);
|
377
|
+
(function() {
|
378
|
+
Luca.templates || (Luca.templates = {});
|
379
|
+
Luca.templates["fields/checkbox_array_item"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n <input id=\'', input_id ,'\' name=\'', input_name ,'\' type=\'checkbox\' value=\'', value ,'\' />\n ', label ,'\n</label>\n');}return __p.join('');};
|
380
|
+
}).call(this);
|
269
381
|
(function() {
|
270
382
|
Luca.templates || (Luca.templates = {});
|
271
383
|
Luca.templates["fields/checkbox_field"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<label for=\'', input_id ,'\'>\n ', label ,'\n <input name=\'', input_name ,'\' style=\'', inputStyles ,'\' type=\'checkbox\' value=\'', input_value ,'\' />\n</label>\n'); if(helperText) { __p.push('\n<p class=\'helper-text help-block\'>\n ', helperText ,'\n</p>\n'); } __p.push('\n');}return __p.join('');};
|
@@ -360,6 +472,7 @@
|
|
360
472
|
});
|
361
473
|
definition.render = function() {
|
362
474
|
var _this = this;
|
475
|
+
if (this.layoutTemplate != null) this.$el.html();
|
363
476
|
if (this.deferrable) {
|
364
477
|
this.trigger("before:render", this);
|
365
478
|
this.deferrable.bind(this.deferrable_event, _.once(function() {
|
@@ -382,10 +495,19 @@
|
|
382
495
|
return this;
|
383
496
|
}
|
384
497
|
};
|
385
|
-
return Luca.View.originalExtend.
|
498
|
+
return Luca.View.originalExtend.call(this, definition);
|
386
499
|
};
|
387
500
|
|
388
501
|
_.extend(Luca.View.prototype, {
|
502
|
+
applyStyles: function(styles) {
|
503
|
+
var setting, value;
|
504
|
+
if (styles == null) styles = {};
|
505
|
+
for (setting in styles) {
|
506
|
+
value = styles[setting];
|
507
|
+
this.$el.css(setting, value);
|
508
|
+
}
|
509
|
+
return this;
|
510
|
+
},
|
389
511
|
debug: function() {
|
390
512
|
var message, _i, _len, _results;
|
391
513
|
if (!(this.debugMode || (window.LucaDebugMode != null))) return;
|
@@ -397,7 +519,7 @@
|
|
397
519
|
return _results;
|
398
520
|
},
|
399
521
|
trigger: function() {
|
400
|
-
if (Luca.enableGlobalObserver) {
|
522
|
+
if (Luca.enableGlobalObserver && this.observeEvents === true) {
|
401
523
|
Luca.ViewObserver || (Luca.ViewObserver = new Luca.Observer({
|
402
524
|
type: "view"
|
403
525
|
}));
|
@@ -436,7 +558,7 @@
|
|
436
558
|
parts = eventId.split(':');
|
437
559
|
prefix = parts.shift();
|
438
560
|
parts = _(parts).map(function(p) {
|
439
|
-
return _.capitalize(p);
|
561
|
+
return _.string.capitalize(p);
|
440
562
|
});
|
441
563
|
fn = prefix + parts.join('');
|
442
564
|
return _this.bind(eventId, function() {
|
@@ -477,7 +599,7 @@
|
|
477
599
|
}).call(this);
|
478
600
|
(function() {
|
479
601
|
|
480
|
-
Luca.Model
|
602
|
+
_.component('Luca.Model')["extends"]('Backbone.Model')["with"]({
|
481
603
|
initialize: function() {
|
482
604
|
var attr, dependencies, _ref, _results,
|
483
605
|
_this = this;
|
@@ -743,7 +865,7 @@
|
|
743
865
|
}).call(this);
|
744
866
|
(function() {
|
745
867
|
|
746
|
-
Luca.core.Field
|
868
|
+
_.component('Luca.core.Field')["extends"]('Luca.View')["with"]({
|
747
869
|
className: 'luca-ui-text-field luca-ui-field',
|
748
870
|
isField: true,
|
749
871
|
template: 'fields/text_field',
|
@@ -802,7 +924,7 @@
|
|
802
924
|
}).call(this);
|
803
925
|
(function() {
|
804
926
|
|
805
|
-
Luca.core.Container
|
927
|
+
_.component('Luca.core.Container')["extends"]('Luca.View')["with"]({
|
806
928
|
className: 'luca-ui-container',
|
807
929
|
componentClass: 'luca-ui-panel',
|
808
930
|
isContainer: true,
|
@@ -913,7 +1035,8 @@
|
|
913
1035
|
} catch (e) {
|
914
1036
|
console.log("Error Rendering Component " + (component.name || component.cid), component);
|
915
1037
|
console.log(e.message);
|
916
|
-
|
1038
|
+
console.log(e.stack);
|
1039
|
+
if ((Luca.silenceRenderErrors != null) !== true) throw e;
|
917
1040
|
}
|
918
1041
|
});
|
919
1042
|
},
|
@@ -1008,8 +1131,6 @@
|
|
1008
1131
|
}
|
1009
1132
|
});
|
1010
1133
|
|
1011
|
-
Luca.register("container", "Luca.core.Container");
|
1012
|
-
|
1013
1134
|
}).call(this);
|
1014
1135
|
(function() {
|
1015
1136
|
var instances;
|
@@ -1095,7 +1216,7 @@
|
|
1095
1216
|
|
1096
1217
|
CollectionManager.prototype.guessCollectionClass = function(key) {
|
1097
1218
|
var classified, guess;
|
1098
|
-
classified =
|
1219
|
+
classified = Luca.util.classify(key);
|
1099
1220
|
guess = (this.collectionNamespace || (window || global))[classified];
|
1100
1221
|
guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
|
1101
1222
|
return guess;
|
@@ -1209,7 +1330,7 @@
|
|
1209
1330
|
}).call(this);
|
1210
1331
|
(function() {
|
1211
1332
|
|
1212
|
-
Luca.containers.SplitView
|
1333
|
+
_.component('Luca.containers.SplitView')["extends"]('Luca.core.Container')["with"]({
|
1213
1334
|
layout: '100',
|
1214
1335
|
componentType: 'split_view',
|
1215
1336
|
containerTemplate: 'containers/basic',
|
@@ -1217,12 +1338,10 @@
|
|
1217
1338
|
componentClass: 'luca-ui-panel'
|
1218
1339
|
});
|
1219
1340
|
|
1220
|
-
Luca.register('split_view', "Luca.containers.SplitView");
|
1221
|
-
|
1222
1341
|
}).call(this);
|
1223
1342
|
(function() {
|
1224
1343
|
|
1225
|
-
Luca.containers.ColumnView
|
1344
|
+
_.component('Luca.containers.ColumnView')["extends"]('Luca.core.Container')["with"]({
|
1226
1345
|
componentType: 'column_view',
|
1227
1346
|
className: 'luca-ui-column-view',
|
1228
1347
|
components: [],
|
@@ -1269,12 +1388,10 @@
|
|
1269
1388
|
}
|
1270
1389
|
});
|
1271
1390
|
|
1272
|
-
Luca.register('column_view', "Luca.containers.ColumnView");
|
1273
|
-
|
1274
1391
|
}).call(this);
|
1275
1392
|
(function() {
|
1276
1393
|
|
1277
|
-
Luca.containers.CardView
|
1394
|
+
_.component("Luca.containers.CardView")["extends"]("Luca.core.Container")["with"]({
|
1278
1395
|
componentType: 'card_view',
|
1279
1396
|
className: 'luca-ui-card-view-wrapper',
|
1280
1397
|
activeCard: 0,
|
@@ -1378,12 +1495,10 @@
|
|
1378
1495
|
}
|
1379
1496
|
});
|
1380
1497
|
|
1381
|
-
Luca.register('card_view', "Luca.containers.CardView");
|
1382
|
-
|
1383
1498
|
}).call(this);
|
1384
1499
|
(function() {
|
1385
1500
|
|
1386
|
-
Luca.containers.ModalView
|
1501
|
+
_.component('Luca.containers.ModalView')["extends"]('Luca.core.Container')["with"]({
|
1387
1502
|
componentType: 'modal_view',
|
1388
1503
|
className: 'luca-ui-modal-view',
|
1389
1504
|
components: [],
|
@@ -1465,12 +1580,10 @@
|
|
1465
1580
|
}
|
1466
1581
|
});
|
1467
1582
|
|
1468
|
-
Luca.register("modal_view", "Luca.containers.ModalView");
|
1469
|
-
|
1470
1583
|
}).call(this);
|
1471
1584
|
(function() {
|
1472
1585
|
|
1473
|
-
Luca.containers.PanelView
|
1586
|
+
_.component('Luca.containers.PanelView')["extends"]('Luca.core.Container')["with"]({
|
1474
1587
|
className: 'luca-ui-panel',
|
1475
1588
|
initialize: function(options) {
|
1476
1589
|
this.options = options != null ? options : {};
|
@@ -1503,7 +1616,7 @@
|
|
1503
1616
|
}).call(this);
|
1504
1617
|
(function() {
|
1505
1618
|
|
1506
|
-
Luca.containers.TabView
|
1619
|
+
_.component('Luca.containers.TabView')["extends"]('Luca.containers.CardView')["with"]({
|
1507
1620
|
events: {
|
1508
1621
|
"click ul.nav-tabs li": "select"
|
1509
1622
|
},
|
@@ -1520,7 +1633,7 @@
|
|
1520
1633
|
return this.bind("after:card:switch", this.highlightSelectedTab);
|
1521
1634
|
},
|
1522
1635
|
activeTabSelector: function() {
|
1523
|
-
return this.tabSelectors().eq(this.activeCard);
|
1636
|
+
return this.tabSelectors().eq(this.activeCard || this.activeTab || this.activeItem);
|
1524
1637
|
},
|
1525
1638
|
prepareLayout: function() {
|
1526
1639
|
var _this = this;
|
@@ -1583,7 +1696,7 @@
|
|
1583
1696
|
}).call(this);
|
1584
1697
|
(function() {
|
1585
1698
|
|
1586
|
-
Luca.containers.Viewport
|
1699
|
+
_.component('Luca.containers.Viewport').extend('Luca.containers.CardView')["with"]({
|
1587
1700
|
activeItem: 0,
|
1588
1701
|
className: 'luca-ui-viewport',
|
1589
1702
|
fullscreen: true,
|
@@ -1593,7 +1706,6 @@
|
|
1593
1706
|
if (this.fullscreen) return $('html,body').addClass('luca-ui-fullscreen');
|
1594
1707
|
},
|
1595
1708
|
render: function() {
|
1596
|
-
console.log("Rendering Viewport");
|
1597
1709
|
return this.$el.addClass('luca-ui-viewport');
|
1598
1710
|
}
|
1599
1711
|
});
|
@@ -1606,7 +1718,8 @@
|
|
1606
1718
|
}).call(this);
|
1607
1719
|
(function() {
|
1608
1720
|
|
1609
|
-
Luca.components.Template
|
1721
|
+
_.component('Luca.components.Template')["extends"]('Luca.View')["with"]({
|
1722
|
+
templateContainer: "Luca.templates",
|
1610
1723
|
initialize: function(options) {
|
1611
1724
|
this.options = options != null ? options : {};
|
1612
1725
|
Luca.View.prototype.initialize.apply(this, arguments);
|
@@ -1617,7 +1730,6 @@
|
|
1617
1730
|
return this.templateContainer = eval("(window || global)." + this.templateContainer);
|
1618
1731
|
}
|
1619
1732
|
},
|
1620
|
-
templateContainer: "Luca.templates",
|
1621
1733
|
beforeRender: function() {
|
1622
1734
|
if (_.isUndefined(this.templateContainer)) this.templateContainer = JST;
|
1623
1735
|
return this.$el.html(this.markup || this.templateContainer[this.template](this.options));
|
@@ -1627,12 +1739,10 @@
|
|
1627
1739
|
}
|
1628
1740
|
});
|
1629
1741
|
|
1630
|
-
Luca.register("template", "Luca.components.Template");
|
1631
|
-
|
1632
1742
|
}).call(this);
|
1633
1743
|
(function() {
|
1634
1744
|
|
1635
|
-
Luca.Application
|
1745
|
+
_.component('Luca.Application')["extends"]('Luca.containers.Viewport')["with"]({
|
1636
1746
|
components: [
|
1637
1747
|
{
|
1638
1748
|
ctype: 'controller',
|
@@ -1701,7 +1811,6 @@
|
|
1701
1811
|
return (_ref = Luca.containers.Viewport.prototype.beforeRender) != null ? _ref.apply(this, arguments) : void 0;
|
1702
1812
|
},
|
1703
1813
|
boot: function() {
|
1704
|
-
console.log("Sup?");
|
1705
1814
|
return this.trigger("ready");
|
1706
1815
|
},
|
1707
1816
|
collection: function() {
|
@@ -1724,7 +1833,7 @@
|
|
1724
1833
|
}).call(this);
|
1725
1834
|
(function() {
|
1726
1835
|
|
1727
|
-
Luca.components.Toolbar
|
1836
|
+
_.component('Luca.components.Toolbar')["extends"]('Luca.core.Container')["with"]({
|
1728
1837
|
className: 'luca-ui-toolbar',
|
1729
1838
|
position: 'bottom',
|
1730
1839
|
initialize: function(options) {
|
@@ -1742,12 +1851,17 @@
|
|
1742
1851
|
}
|
1743
1852
|
});
|
1744
1853
|
|
1745
|
-
|
1854
|
+
}).call(this);
|
1855
|
+
(function() {
|
1856
|
+
|
1857
|
+
_.component('Luca.components.CollectionInspector')["extends"]('Luca.View')["with"]({
|
1858
|
+
name: "collection_inspector"
|
1859
|
+
});
|
1746
1860
|
|
1747
1861
|
}).call(this);
|
1748
1862
|
(function() {
|
1749
1863
|
|
1750
|
-
Luca.components.CollectionLoaderView
|
1864
|
+
_.component('Luca.components.CollectionLoaderView')["extends"]('Luca.components.Template')["with"]({
|
1751
1865
|
className: 'luca-ui-collection-loader-view',
|
1752
1866
|
template: "components/collection_loader_view",
|
1753
1867
|
initialize: function(options) {
|
@@ -1763,12 +1877,13 @@
|
|
1763
1877
|
setupBindings: function() {
|
1764
1878
|
var _this = this;
|
1765
1879
|
this.manager.bind("collection_loaded", function(name) {
|
1766
|
-
var loaded, progress, total;
|
1880
|
+
var collectionName, loaded, progress, total;
|
1767
1881
|
loaded = _this.manager.loadedCollectionsCount();
|
1768
1882
|
total = _this.manager.totalCollectionsCount();
|
1769
1883
|
progress = parseInt((loaded / total) * 100);
|
1884
|
+
collectionName = _.string.titleize(_.string.humanize(name));
|
1770
1885
|
_this.modalContainer().find('.progress .bar').attr("style", "width: " + progress + "%;");
|
1771
|
-
return _this.modalContainer().find('.message').html("Loaded " +
|
1886
|
+
return _this.modalContainer().find('.message').html("Loaded " + collectionName + "...");
|
1772
1887
|
});
|
1773
1888
|
return this.manager.bind("all_collections_loaded", function() {
|
1774
1889
|
_this.modalContainer().find('.message').html("All done!");
|
@@ -1779,12 +1894,10 @@
|
|
1779
1894
|
}
|
1780
1895
|
});
|
1781
1896
|
|
1782
|
-
Luca.register("collection_loader_view", "Luca.components.CollectionLoaderView");
|
1783
|
-
|
1784
1897
|
}).call(this);
|
1785
1898
|
(function() {
|
1786
1899
|
|
1787
|
-
Luca.components.Controller
|
1900
|
+
_.component('Luca.components.Controller')["extends"]('Luca.containers.CardView')["with"]({
|
1788
1901
|
initialize: function(options) {
|
1789
1902
|
var _ref;
|
1790
1903
|
this.options = options;
|
@@ -1822,7 +1935,7 @@
|
|
1822
1935
|
}).call(this);
|
1823
1936
|
(function() {
|
1824
1937
|
|
1825
|
-
Luca.components.DevelopmentConsole
|
1938
|
+
_.component('Luca.components.DevelopmentConsole')["extends"]('Luca.View')["with"]({
|
1826
1939
|
name: "development_console",
|
1827
1940
|
className: 'luca-ui-development-console',
|
1828
1941
|
initialize: function(options) {
|
@@ -1857,10 +1970,10 @@
|
|
1857
1970
|
},
|
1858
1971
|
returnValue: function(val) {
|
1859
1972
|
if (val == null) return "undefined";
|
1860
|
-
return val != null ? val.toString() : void 0;
|
1973
|
+
return (val != null ? val.toString() : void 0) || "";
|
1861
1974
|
},
|
1862
1975
|
parseLine: function(line) {
|
1863
|
-
_
|
1976
|
+
line = _.string.strip(line);
|
1864
1977
|
line = line.replace(/^return/, ' ');
|
1865
1978
|
return "return " + line;
|
1866
1979
|
},
|
@@ -1885,8 +1998,7 @@
|
|
1885
1998
|
}).call(this);
|
1886
1999
|
(function() {
|
1887
2000
|
|
1888
|
-
Luca.fields.ButtonField
|
1889
|
-
form_field: true,
|
2001
|
+
_.component('Luca.fields.ButtonField')["extends"]('Luca.core.Field')["with"]({
|
1890
2002
|
readOnly: true,
|
1891
2003
|
events: {
|
1892
2004
|
"click input": "click_handler"
|
@@ -1926,13 +2038,93 @@
|
|
1926
2038
|
}
|
1927
2039
|
});
|
1928
2040
|
|
1929
|
-
|
2041
|
+
}).call(this);
|
2042
|
+
(function() {
|
2043
|
+
|
2044
|
+
_.component('Luca.fields.CheckboxArray')["extends"]('Luca.core.Field')["with"]({
|
2045
|
+
template: "fields/checkbox_array",
|
2046
|
+
events: {
|
2047
|
+
"click input": "clickHandler"
|
2048
|
+
},
|
2049
|
+
initialize: function(options) {
|
2050
|
+
this.options = options != null ? options : {};
|
2051
|
+
_.extend(this, this.options);
|
2052
|
+
_.extend(this, Luca.modules.Deferrable);
|
2053
|
+
_.bindAll(this, "populateCheckboxes", "clickHandler", "_updateModel");
|
2054
|
+
Luca.core.Field.prototype.initialize.apply(this, arguments);
|
2055
|
+
this.input_id || (this.input_id = _.uniqueId('field'));
|
2056
|
+
this.input_name || (this.input_name = this.name);
|
2057
|
+
this.label || (this.label = this.name);
|
2058
|
+
this.valueField || (this.valueField = "id");
|
2059
|
+
this.displayField || (this.displayField = "name");
|
2060
|
+
return this.selectedItems = [];
|
2061
|
+
},
|
2062
|
+
afterInitialize: function(options) {
|
2063
|
+
this.options = options != null ? options : {};
|
2064
|
+
try {
|
2065
|
+
this.configure_collection();
|
2066
|
+
} catch (e) {
|
2067
|
+
console.log("Error Configuring Collection", this, e.message);
|
2068
|
+
}
|
2069
|
+
return this.collection.bind("reset", this.populateCheckboxes);
|
2070
|
+
},
|
2071
|
+
afterRender: function() {
|
2072
|
+
var _ref, _ref2;
|
2073
|
+
if (((_ref = this.collection) != null ? (_ref2 = _ref.models) != null ? _ref2.length : void 0 : void 0) > 0) {
|
2074
|
+
return this.populateCheckboxes();
|
2075
|
+
} else {
|
2076
|
+
return this.collection.trigger("reset");
|
2077
|
+
}
|
2078
|
+
},
|
2079
|
+
clickHandler: function(event) {
|
2080
|
+
var checkbox;
|
2081
|
+
checkbox = event.target;
|
2082
|
+
if (checkbox.checked) {
|
2083
|
+
this.selectedItems.push(checkbox.value);
|
2084
|
+
} else {
|
2085
|
+
if (this.selectedItems.indexOf(checkbox.value) !== -1) {
|
2086
|
+
this.selectedItems = _.without(this.selectedItems, [checkbox.value]);
|
2087
|
+
}
|
2088
|
+
}
|
2089
|
+
return this._updateModel();
|
2090
|
+
},
|
2091
|
+
populateCheckboxes: function() {
|
2092
|
+
var controls,
|
2093
|
+
_this = this;
|
2094
|
+
controls = $(this.el).find('.controls');
|
2095
|
+
controls.empty();
|
2096
|
+
if (!_.isUndefined(this.getModel())) {
|
2097
|
+
this.selectedItems = this.getModel().get(this.name);
|
2098
|
+
}
|
2099
|
+
this.collection.each(function(model) {
|
2100
|
+
var input_id, label, value;
|
2101
|
+
value = model.get(_this.valueField);
|
2102
|
+
label = model.get(_this.displayField);
|
2103
|
+
input_id = _.uniqueId('field');
|
2104
|
+
controls.append(Luca.templates["fields/checkbox_array_item"]({
|
2105
|
+
label: label,
|
2106
|
+
value: value,
|
2107
|
+
input_id: input_id,
|
2108
|
+
input_name: _this.input_name
|
2109
|
+
}));
|
2110
|
+
if (_this.selectedItems.indexOf(value) !== -1) {
|
2111
|
+
return _this.$("#" + input_id).attr("checked", "checked");
|
2112
|
+
}
|
2113
|
+
});
|
2114
|
+
return $(this.container).append(this.$el);
|
2115
|
+
},
|
2116
|
+
_updateModel: function() {
|
2117
|
+
var attributes;
|
2118
|
+
attributes = {};
|
2119
|
+
attributes[this.name] = this.selectedItems;
|
2120
|
+
return this.getModel().set(attributes);
|
2121
|
+
}
|
2122
|
+
});
|
1930
2123
|
|
1931
2124
|
}).call(this);
|
1932
2125
|
(function() {
|
1933
2126
|
|
1934
|
-
Luca.fields.CheckboxField
|
1935
|
-
form_field: true,
|
2127
|
+
_.component('Luca.fields.CheckboxField')["extends"]('Luca.core.Field')["with"]({
|
1936
2128
|
events: {
|
1937
2129
|
"change input": "change_handler"
|
1938
2130
|
},
|
@@ -1969,13 +2161,10 @@
|
|
1969
2161
|
}
|
1970
2162
|
});
|
1971
2163
|
|
1972
|
-
Luca.register("checkbox_field", "Luca.fields.CheckboxField");
|
1973
|
-
|
1974
2164
|
}).call(this);
|
1975
2165
|
(function() {
|
1976
2166
|
|
1977
|
-
Luca.fields.FileUploadField
|
1978
|
-
form_field: true,
|
2167
|
+
_.component('Luca.fields.FileUploadField')["extends"]('Luca.core.Field')["with"]({
|
1979
2168
|
template: 'fields/file_upload_field',
|
1980
2169
|
initialize: function(options) {
|
1981
2170
|
this.options = options != null ? options : {};
|
@@ -1989,13 +2178,10 @@
|
|
1989
2178
|
}
|
1990
2179
|
});
|
1991
2180
|
|
1992
|
-
Luca.register("file_upload_field", "Luca.fields.FileUploadField");
|
1993
|
-
|
1994
2181
|
}).call(this);
|
1995
2182
|
(function() {
|
1996
2183
|
|
1997
|
-
Luca.fields.HiddenField
|
1998
|
-
form_field: true,
|
2184
|
+
_.component('Luca.fields.HiddenField')["extends"]('Luca.core.Field')["with"]({
|
1999
2185
|
template: 'fields/hidden_field',
|
2000
2186
|
initialize: function(options) {
|
2001
2187
|
this.options = options != null ? options : {};
|
@@ -2009,13 +2195,10 @@
|
|
2009
2195
|
}
|
2010
2196
|
});
|
2011
2197
|
|
2012
|
-
Luca.register("hidden_field", "Luca.fields.HiddenField");
|
2013
|
-
|
2014
2198
|
}).call(this);
|
2015
2199
|
(function() {
|
2016
2200
|
|
2017
|
-
Luca.fields.SelectField
|
2018
|
-
form_field: true,
|
2201
|
+
_.component('Luca.fields.SelectField')["extends"]('Luca.core.Field')["with"]({
|
2019
2202
|
events: {
|
2020
2203
|
"change select": "change_handler"
|
2021
2204
|
},
|
@@ -2106,13 +2289,10 @@
|
|
2106
2289
|
}
|
2107
2290
|
});
|
2108
2291
|
|
2109
|
-
Luca.register("select_field", "Luca.fields.SelectField");
|
2110
|
-
|
2111
2292
|
}).call(this);
|
2112
2293
|
(function() {
|
2113
2294
|
|
2114
|
-
Luca.fields.TextAreaField
|
2115
|
-
form_field: true,
|
2295
|
+
_.component('Luca.fields.TextAreaField')["extends"]('Luca.core.Field')["with"]({
|
2116
2296
|
events: {
|
2117
2297
|
"keydown input": "keydown_handler",
|
2118
2298
|
"blur input": "blur_handler",
|
@@ -2154,13 +2334,10 @@
|
|
2154
2334
|
}
|
2155
2335
|
});
|
2156
2336
|
|
2157
|
-
Luca.register("text_area_field", "Luca.fields.TextAreaField");
|
2158
|
-
|
2159
2337
|
}).call(this);
|
2160
2338
|
(function() {
|
2161
2339
|
|
2162
|
-
Luca.fields.TextField
|
2163
|
-
form_field: true,
|
2340
|
+
_.component('Luca.fields.TextField')["extends"]('Luca.core.Field')["with"]({
|
2164
2341
|
events: {
|
2165
2342
|
"keydown input": "keydown_handler",
|
2166
2343
|
"blur input": "blur_handler",
|
@@ -2201,13 +2378,10 @@
|
|
2201
2378
|
}
|
2202
2379
|
});
|
2203
2380
|
|
2204
|
-
Luca.register("text_field", "Luca.fields.TextField");
|
2205
|
-
|
2206
2381
|
}).call(this);
|
2207
2382
|
(function() {
|
2208
2383
|
|
2209
|
-
Luca.fields.TypeAheadField
|
2210
|
-
form_field: true,
|
2384
|
+
_.component('Luca.fields.TypeAheadField')["extends"]('Luca.fields.TextField')["with"]({
|
2211
2385
|
className: 'luca-ui-field',
|
2212
2386
|
afterInitialize: function() {
|
2213
2387
|
this.input_id || (this.input_id = _.uniqueId('field'));
|
@@ -2219,7 +2393,7 @@
|
|
2219
2393
|
}).call(this);
|
2220
2394
|
(function() {
|
2221
2395
|
|
2222
|
-
Luca.components.FormButtonToolbar
|
2396
|
+
_.component('Luca.components.FormButtonToolbar')["extends"]('Luca.components.Toolbar')["with"]({
|
2223
2397
|
className: 'luca-ui-form-toolbar form-actions',
|
2224
2398
|
position: 'bottom',
|
2225
2399
|
includeReset: false,
|
@@ -2246,12 +2420,10 @@
|
|
2246
2420
|
}
|
2247
2421
|
});
|
2248
2422
|
|
2249
|
-
Luca.register("form_button_toolbar", "Luca.components.FormButtonToolbar");
|
2250
|
-
|
2251
2423
|
}).call(this);
|
2252
2424
|
(function() {
|
2253
2425
|
|
2254
|
-
Luca.components.FormView
|
2426
|
+
_.component("Luca.components.FormView")["extends"]('Luca.core.Container')["with"]({
|
2255
2427
|
tagName: 'form',
|
2256
2428
|
className: 'luca-ui-form-view',
|
2257
2429
|
hooks: ["before:submit", "before:reset", "before:load", "before:load:new", "before:load:existing", "after:submit", "after:reset", "after:load", "after:load:new", "after:load:existing", "after:submit:success", "after:submit:fatal_error", "after:submit:error"],
|
@@ -2335,8 +2507,24 @@
|
|
2335
2507
|
return component.container = container;
|
2336
2508
|
});
|
2337
2509
|
},
|
2510
|
+
afterComponents: function() {
|
2511
|
+
var _ref,
|
2512
|
+
_this = this;
|
2513
|
+
if ((_ref = Luca.core.Container.prototype.afterComponents) != null) {
|
2514
|
+
_ref.apply(this, arguments);
|
2515
|
+
}
|
2516
|
+
return this.eachField(function(field) {
|
2517
|
+
field.getForm = function() {
|
2518
|
+
return _this;
|
2519
|
+
};
|
2520
|
+
return field.getModel = function() {
|
2521
|
+
return _this.currentModel();
|
2522
|
+
};
|
2523
|
+
});
|
2524
|
+
},
|
2338
2525
|
render: function() {
|
2339
|
-
|
2526
|
+
$(this.container).append(this.$el);
|
2527
|
+
return this;
|
2340
2528
|
},
|
2341
2529
|
wrapper: function() {
|
2342
2530
|
return this.$el.parents('.luca-ui-form-view-wrapper');
|
@@ -2353,6 +2541,9 @@
|
|
2353
2541
|
return toolbar.render();
|
2354
2542
|
});
|
2355
2543
|
},
|
2544
|
+
eachField: function(iterator) {
|
2545
|
+
return _(this.getFields()).map(iterator);
|
2546
|
+
},
|
2356
2547
|
getField: function(name) {
|
2357
2548
|
return _(this.getFields('name', name)).first();
|
2358
2549
|
},
|
@@ -2390,7 +2581,7 @@
|
|
2390
2581
|
}
|
2391
2582
|
},
|
2392
2583
|
reset: function() {
|
2393
|
-
return this.loadModel(this.current_model);
|
2584
|
+
if (this.current_model != null) return this.loadModel(this.current_model);
|
2394
2585
|
},
|
2395
2586
|
clear: function() {
|
2396
2587
|
var _this = this;
|
@@ -2423,7 +2614,7 @@
|
|
2423
2614
|
if ((options.silent != null) !== true) return this.syncFormWithModel();
|
2424
2615
|
},
|
2425
2616
|
getValues: function(options) {
|
2426
|
-
options
|
2617
|
+
if (options == null) options = {};
|
2427
2618
|
if (options.reject_blank == null) options.reject_blank = true;
|
2428
2619
|
if (options.skip_buttons == null) options.skip_buttons = true;
|
2429
2620
|
return _(this.getFields()).inject(function(memo, field) {
|
@@ -2432,8 +2623,10 @@
|
|
2432
2623
|
key = field.input_name || field.name;
|
2433
2624
|
skip = false;
|
2434
2625
|
if (options.skip_buttons && field.ctype === "button_field") skip = true;
|
2435
|
-
if (
|
2436
|
-
|
2626
|
+
if (_.string.isBlank(value)) {
|
2627
|
+
if (options.reject_blank && !field.send_blanks) skip = true;
|
2628
|
+
if (field.input_name === "id") skip = true;
|
2629
|
+
}
|
2437
2630
|
if (skip !== true) memo[key] = value;
|
2438
2631
|
return memo;
|
2439
2632
|
}, {});
|
@@ -2477,56 +2670,75 @@
|
|
2477
2670
|
}
|
2478
2671
|
});
|
2479
2672
|
|
2480
|
-
Luca.register('form_view', 'Luca.components.FormView');
|
2481
|
-
|
2482
2673
|
}).call(this);
|
2483
2674
|
(function() {
|
2484
2675
|
|
2485
|
-
Luca.components.GridView
|
2676
|
+
_.component('Luca.components.GridView').extend('Luca.View')["with"]({
|
2486
2677
|
autoBindEventHandlers: true,
|
2487
2678
|
events: {
|
2488
|
-
"dblclick
|
2489
|
-
"click
|
2679
|
+
"dblclick table tbody tr": "double_click_handler",
|
2680
|
+
"click table tbody tr": "click_handler"
|
2490
2681
|
},
|
2491
2682
|
className: 'luca-ui-g-view',
|
2683
|
+
rowClass: "luca-ui-g-row",
|
2684
|
+
wrapperClass: "luca-ui-g-view-wrapper",
|
2685
|
+
additionalWrapperClasses: [],
|
2686
|
+
wrapperStyles: {},
|
2492
2687
|
scrollable: true,
|
2493
2688
|
emptyText: 'No Results To display.',
|
2494
2689
|
tableStyle: 'striped',
|
2690
|
+
defaultHeight: 285,
|
2691
|
+
defaultWidth: 756,
|
2692
|
+
maxWidth: void 0,
|
2495
2693
|
hooks: ["before:grid:render", "before:render:header", "before:render:row", "after:grid:render", "row:double:click", "row:click", "after:collection:load"],
|
2496
|
-
rowClass: "luca-ui-g-row",
|
2497
2694
|
initialize: function(options) {
|
2498
2695
|
var _this = this;
|
2499
2696
|
this.options = options != null ? options : {};
|
2500
2697
|
_.extend(this, this.options);
|
2501
2698
|
_.extend(this, Luca.modules.Deferrable);
|
2502
2699
|
Luca.View.prototype.initialize.apply(this, arguments);
|
2503
|
-
_.bindAll(this, "double_click_handler", "click_handler");
|
2504
2700
|
this.configure_collection();
|
2505
|
-
|
2701
|
+
this.collection.bind("reset", function(collection) {
|
2506
2702
|
_this.refresh();
|
2507
2703
|
return _this.trigger("after:collection:load", collection);
|
2508
2704
|
});
|
2705
|
+
return this.collection.bind("change", function(model) {
|
2706
|
+
var cells, rowEl;
|
2707
|
+
rowEl = _this.getRowEl(model.id || model.get('id') || model.cid);
|
2708
|
+
cells = _this.render_row(model, _this.indexOf(model), {
|
2709
|
+
cellsOnly: true
|
2710
|
+
});
|
2711
|
+
return $(rowEl).html(cells);
|
2712
|
+
});
|
2509
2713
|
},
|
2510
2714
|
beforeRender: function() {
|
2511
|
-
var _ref,
|
2512
|
-
_this = this;
|
2513
2715
|
this.trigger("before:grid:render", this);
|
2514
|
-
if (this.scrollable) this.$el.addClass('scrollable-g-view');
|
2515
2716
|
this.$el.html(Luca.templates["components/grid_view"]());
|
2516
|
-
this.table =
|
2517
|
-
this.header =
|
2518
|
-
this.body =
|
2519
|
-
this.footer =
|
2520
|
-
|
2521
|
-
|
2522
|
-
return _this.table.addClass("table-" + style);
|
2523
|
-
});
|
2717
|
+
this.table = this.$('table.luca-ui-g-view');
|
2718
|
+
this.header = this.$("thead");
|
2719
|
+
this.body = this.$("tbody");
|
2720
|
+
this.footer = this.$("tfoot");
|
2721
|
+
this.wrapper = this.$("." + this.wrapperClass);
|
2722
|
+
this.applyCssClasses();
|
2524
2723
|
if (this.scrollable) this.setDimensions();
|
2525
2724
|
this.renderHeader();
|
2526
2725
|
this.emptyMessage();
|
2527
2726
|
this.renderToolbars();
|
2528
2727
|
return $(this.container).append(this.$el);
|
2529
2728
|
},
|
2729
|
+
applyCssClasses: function() {
|
2730
|
+
var _ref,
|
2731
|
+
_this = this;
|
2732
|
+
if (this.scrollable) this.$el.addClass('scrollable-g-view');
|
2733
|
+
_(this.additionalWrapperClasses).each(function(containerClass) {
|
2734
|
+
var _ref;
|
2735
|
+
return (_ref = _this.wrapper) != null ? _ref.addClass(containerClass) : void 0;
|
2736
|
+
});
|
2737
|
+
if (Luca.enableBootstrap) this.table.addClass('table');
|
2738
|
+
return _((_ref = this.tableStyle) != null ? _ref.split(" ") : void 0).each(function(style) {
|
2739
|
+
return _this.table.addClass("table-" + style);
|
2740
|
+
});
|
2741
|
+
},
|
2530
2742
|
toolbarContainers: function(position) {
|
2531
2743
|
if (position == null) position = "bottom";
|
2532
2744
|
return $(".toolbar-container." + position, this.el);
|
@@ -2539,20 +2751,18 @@
|
|
2539
2751
|
return toolbar.render();
|
2540
2752
|
});
|
2541
2753
|
},
|
2542
|
-
defaultWidth: 756,
|
2543
|
-
defaultHeight: 285,
|
2544
2754
|
setDimensions: function(offset) {
|
2545
2755
|
var _this = this;
|
2546
2756
|
this.height || (this.height = this.defaultHeight);
|
2547
|
-
|
2548
|
-
|
2757
|
+
this.$('.luca-ui-g-view-body').height(this.height);
|
2758
|
+
this.$('tbody.scrollable').height(this.height - 23);
|
2549
2759
|
this.container_width = (function() {
|
2550
2760
|
return $(_this.container).width();
|
2551
2761
|
})();
|
2552
|
-
this.width = this.container_width > 0 ? this.container_width : this.defaultWidth;
|
2762
|
+
this.width || (this.width = this.container_width > 0 ? this.container_width : this.defaultWidth);
|
2553
2763
|
this.width = _([this.width, this.maxWidth || this.width]).max();
|
2554
|
-
|
2555
|
-
|
2764
|
+
this.$('.luca-ui-g-view-body').width(this.width);
|
2765
|
+
this.$('.luca-ui-g-view-body table').width(this.width);
|
2556
2766
|
return this.setDefaultColumnWidths();
|
2557
2767
|
},
|
2558
2768
|
resize: function(newWidth) {
|
@@ -2560,8 +2770,8 @@
|
|
2560
2770
|
_this = this;
|
2561
2771
|
difference = newWidth - this.width;
|
2562
2772
|
this.width = newWidth;
|
2563
|
-
|
2564
|
-
|
2773
|
+
this.$('.luca-ui-g-view-body').width(this.width);
|
2774
|
+
this.$('.luca-ui-g-view-body table').width(this.width);
|
2565
2775
|
if (this.columns.length > 0) {
|
2566
2776
|
distribution = difference / this.columns.length;
|
2567
2777
|
return _(this.columns).each(function(col, index) {
|
@@ -2641,9 +2851,10 @@
|
|
2641
2851
|
getRowEl: function(id) {
|
2642
2852
|
return this.$("[data-record-id=" + id + "]", 'table');
|
2643
2853
|
},
|
2644
|
-
render_row: function(row, row_index) {
|
2645
|
-
var altClass, cells, model_id, rowClass, _ref,
|
2854
|
+
render_row: function(row, row_index, options) {
|
2855
|
+
var altClass, cells, content, model_id, rowClass, _ref,
|
2646
2856
|
_this = this;
|
2857
|
+
if (options == null) options = {};
|
2647
2858
|
rowClass = this.rowClass;
|
2648
2859
|
model_id = (row != null ? row.get : void 0) && (row != null ? row.attributes : void 0) ? row.get('id') : '';
|
2649
2860
|
this.trigger("before:render:row", row, row_index);
|
@@ -2654,11 +2865,14 @@
|
|
2654
2865
|
display = _.isUndefined(value) ? "" : value;
|
2655
2866
|
return "<td style='" + style + "' class='column-" + col_index + "'>" + display + "</td>";
|
2656
2867
|
});
|
2868
|
+
if (options.cellsOnly) return cells;
|
2657
2869
|
altClass = '';
|
2658
2870
|
if (this.alternateRowClasses) {
|
2659
2871
|
altClass = row_index % 2 === 0 ? "even" : "odd";
|
2660
2872
|
}
|
2661
|
-
|
2873
|
+
content = "<tr data-record-id='" + model_id + "' data-row-index='" + row_index + "' class='" + rowClass + " " + altClass + "' id='row-" + row_index + "'>" + cells + "</tr>";
|
2874
|
+
if (options.contentOnly === true) return content;
|
2875
|
+
return (_ref = this.body) != null ? _ref.append(content) : void 0;
|
2662
2876
|
},
|
2663
2877
|
cell_renderer: function(row, column, columnIndex) {
|
2664
2878
|
var source;
|
@@ -2689,12 +2903,10 @@
|
|
2689
2903
|
}
|
2690
2904
|
});
|
2691
2905
|
|
2692
|
-
Luca.register("grid_view", "Luca.components.GridView");
|
2693
|
-
|
2694
2906
|
}).call(this);
|
2695
2907
|
(function() {
|
2696
2908
|
|
2697
|
-
Luca.components.RecordManager
|
2909
|
+
_.component('Luca.components.RecordManager').extend('Luca.containers.CardView')["with"]({
|
2698
2910
|
events: {
|
2699
2911
|
"click .record-manager-grid .edit-link": "edit_handler",
|
2700
2912
|
"click .record-manager-filter .filter-button": "filter_handler",
|
@@ -3975,7 +4187,47 @@
|
|
3975
4187
|
});
|
3976
4188
|
});
|
3977
4189
|
|
3978
|
-
describe
|
4190
|
+
describe("Luca Component Definition", function() {
|
4191
|
+
beforeEach(function() {
|
4192
|
+
return Luca.define("Luca.random.ComponentDefinition")["extends"]("Luca.View")["with"]({
|
4193
|
+
property: "value"
|
4194
|
+
});
|
4195
|
+
});
|
4196
|
+
it("should create the namespace for us", function() {
|
4197
|
+
return expect(Luca.random).toBeDefined();
|
4198
|
+
});
|
4199
|
+
it("should automatically register the namespace in the registry", function() {
|
4200
|
+
return expect(Luca.registry.namespaces).toContain('Luca.random');
|
4201
|
+
});
|
4202
|
+
it("should automatically register the component in the registry", function() {
|
4203
|
+
return expect(Luca.registry.lookup("component_definition")).toBeDefined();
|
4204
|
+
});
|
4205
|
+
it("should reference the name of the extending class", function() {
|
4206
|
+
var instance;
|
4207
|
+
instance = new Luca.random.ComponentDefinition;
|
4208
|
+
return expect(instance._className).toEqual("Luca.random.ComponentDefinition");
|
4209
|
+
});
|
4210
|
+
it("should reference the extended class", function() {
|
4211
|
+
var instance;
|
4212
|
+
instance = new Luca.random.ComponentDefinition;
|
4213
|
+
return expect(instance._superClass()).toEqual(Luca.View);
|
4214
|
+
});
|
4215
|
+
it("should reference the name of the extended class", function() {
|
4216
|
+
var instance;
|
4217
|
+
instance = new Luca.random.ComponentDefinition;
|
4218
|
+
return expect(instance._superClass()._className).toEqual('Luca.View');
|
4219
|
+
});
|
4220
|
+
it("should use the backbone.extend functionality properly", function() {
|
4221
|
+
var instance;
|
4222
|
+
instance = new Luca.random.ComponentDefinition;
|
4223
|
+
return expect(instance.property).toEqual("value");
|
4224
|
+
});
|
4225
|
+
return it("should alias to _.component", function() {
|
4226
|
+
var proxy;
|
4227
|
+
proxy = _.component('Luca.random.ComponentDefition');
|
4228
|
+
return expect(proxy["with"]).toBeDefined();
|
4229
|
+
});
|
4230
|
+
});
|
3979
4231
|
|
3980
4232
|
}).call(this);
|
3981
4233
|
(function() {
|