luca 0.8 → 0.8.2
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 +5 -1
- data/lib/luca/rails/version.rb +1 -1
- data/src/components/fields/button_field.coffee +4 -3
- data/src/components/fields/checkbox_array.coffee +64 -0
- data/src/components/form_view.coffee +10 -0
- data/src/components/grid_view.coffee +26 -15
- data/src/core/container.coffee +1 -0
- data/src/framework.coffee +2 -2
- data/src/stylesheets/components/grid_view.scss +8 -8
- data/src/stylesheets/containers/tab_view.scss +4 -0
- data/src/templates/components/grid_view.luca +5 -5
- 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 +13 -4
- data/vendor/assets/javascripts/luca-ui-spec.js +140 -22
- data/vendor/assets/javascripts/luca-ui.js +140 -22
- data/vendor/assets/javascripts/luca-ui.min.js +3 -3
- data/vendor/assets/stylesheets/luca-ui-bootstrap.css +18 -16
- data/vendor/assets/stylesheets/luca-ui-spec.css +18 -16
- data/vendor/assets/stylesheets/luca-ui.css +18 -16
- metadata +5 -2
data/CHANGELOG
CHANGED
@@ -1,3 +1,7 @@
|
|
1
1
|
0.7.3:
|
2
2
|
- Models being loaded by the FormView will now call
|
3
|
-
beforeFormLoad methods if they exist on those models
|
3
|
+
beforeFormLoad methods if they exist on those models
|
4
|
+
0.8.1
|
5
|
+
- Adds many style fixes for GridView
|
6
|
+
- Fixes style conflicts for Bootstrap grid-* css selectors
|
7
|
+
- Adds getForm() and getModel() methods to Luca.Field classes that belong to a form
|
data/lib/luca/rails/version.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
Luca.fields.ButtonField = Luca.core.Field.extend
|
2
2
|
form_field: true
|
3
|
-
|
3
|
+
|
4
4
|
readOnly: true
|
5
5
|
|
6
|
-
events:
|
6
|
+
events:
|
7
7
|
"click input" : "click_handler"
|
8
8
|
|
9
9
|
hooks:[
|
@@ -11,7 +11,7 @@ Luca.fields.ButtonField = Luca.core.Field.extend
|
|
11
11
|
]
|
12
12
|
|
13
13
|
className: 'luca-ui-field luca-ui-button-field'
|
14
|
-
|
14
|
+
|
15
15
|
template: 'fields/button_field'
|
16
16
|
|
17
17
|
click_handler: (e)->
|
@@ -34,6 +34,7 @@ Luca.fields.ButtonField = Luca.core.Field.extend
|
|
34
34
|
@input_class ||= @class
|
35
35
|
@icon_class ||= ""
|
36
36
|
@icon_class = "icon-#{ @icon_class }" if @icon_class.length and !@icon_class.match(/^icon-/)
|
37
|
+
@icon_class += " icon-white" if @white
|
37
38
|
|
38
39
|
setValue: ()-> true
|
39
40
|
|
@@ -0,0 +1,64 @@
|
|
1
|
+
Luca.fields.CheckboxArray = Luca.core.Field.extend
|
2
|
+
|
3
|
+
template: "fields/checkbox_array"
|
4
|
+
|
5
|
+
events:
|
6
|
+
"click input" : "clickHandler"
|
7
|
+
|
8
|
+
initialize: (@options={})->
|
9
|
+
_.extend @, @options
|
10
|
+
_.extend @, Luca.modules.Deferrable
|
11
|
+
_.bindAll @, "populateCheckboxes", "clickHandler", "_updateModel"
|
12
|
+
|
13
|
+
Luca.core.Field::initialize.apply @, arguments
|
14
|
+
|
15
|
+
@input_id ||= _.uniqueId('field')
|
16
|
+
@input_name ||= @name
|
17
|
+
@label ||= @name
|
18
|
+
@valueField ||= "id"
|
19
|
+
@displayField ||= "name"
|
20
|
+
@selectedItems = []
|
21
|
+
|
22
|
+
afterInitialize: (@options={})->
|
23
|
+
try
|
24
|
+
@configure_collection()
|
25
|
+
catch e
|
26
|
+
console.log "Error Configuring Collection", @, e.message
|
27
|
+
|
28
|
+
@collection.bind "reset", @populateCheckboxes
|
29
|
+
|
30
|
+
afterRender: ()->
|
31
|
+
if @collection?.models?.length > 0
|
32
|
+
@populateCheckboxes()
|
33
|
+
else
|
34
|
+
@collection.trigger("reset")
|
35
|
+
|
36
|
+
clickHandler: (event)->
|
37
|
+
checkbox = event.target
|
38
|
+
if checkbox.checked
|
39
|
+
@selectedItems.push(checkbox.value)
|
40
|
+
else
|
41
|
+
if @selectedItems.indexOf(checkbox.value) isnt -1
|
42
|
+
@selectedItems = _.without(@selectedItems, [checkbox.value])
|
43
|
+
|
44
|
+
@_updateModel()
|
45
|
+
|
46
|
+
populateCheckboxes: ()->
|
47
|
+
controls = $(@el).find('.controls')
|
48
|
+
controls.empty()
|
49
|
+
@selectedItems = @getModel().get(@name)
|
50
|
+
@collection.each (model)=>
|
51
|
+
value = model.get(@valueField)
|
52
|
+
label = model.get(@displayField)
|
53
|
+
input_id = _.uniqueId('field')
|
54
|
+
controls.append(Luca.templates["fields/checkbox_array_item"]({label: label, value: value, input_id: input_id, input_name: @input_name}))
|
55
|
+
@$("##{input_id}").attr("checked", "checked") unless @selectedItems.indexOf(value) is -1
|
56
|
+
|
57
|
+
$(@container).append(@$el)
|
58
|
+
|
59
|
+
_updateModel: ()->
|
60
|
+
attributes = {}
|
61
|
+
attributes[@name] = @selectedItems
|
62
|
+
@getModel().set(attributes)
|
63
|
+
|
64
|
+
Luca.register "checkbox_array", "Luca.fields.CheckboxArray"
|
@@ -93,8 +93,15 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
93
93
|
_( @components ).each (component)->
|
94
94
|
component.container = container
|
95
95
|
|
96
|
+
afterComponents: ()->
|
97
|
+
Luca.core.Container::afterComponents?.apply(@, arguments)
|
98
|
+
@eachField (field)=>
|
99
|
+
field.getForm = ()=> @
|
100
|
+
field.getModel = ()=> @currentModel()
|
101
|
+
|
96
102
|
render: ()->
|
97
103
|
$( @container ).append( @$el )
|
104
|
+
@
|
98
105
|
|
99
106
|
wrapper: ()->
|
100
107
|
@$el.parents('.luca-ui-form-view-wrapper')
|
@@ -108,6 +115,9 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
108
115
|
toolbar = Luca.util.lazyComponent(toolbar)
|
109
116
|
toolbar.render()
|
110
117
|
|
118
|
+
eachField: (iterator)->
|
119
|
+
_( @getFields() ).map( iterator )
|
120
|
+
|
111
121
|
getField: (name)->
|
112
122
|
_( @getFields('name', name) ).first()
|
113
123
|
|
@@ -1,13 +1,15 @@
|
|
1
1
|
Luca.components.GridView = Luca.View.extend
|
2
|
+
autoBindEventHandlers: true
|
3
|
+
|
2
4
|
events:
|
3
|
-
"dblclick .
|
4
|
-
"click .
|
5
|
+
"dblclick .luca-ui-g-row" : "double_click_handler"
|
6
|
+
"click .luca-ui-g-row": "click_handler"
|
5
7
|
|
6
|
-
className: 'luca-ui-
|
8
|
+
className: 'luca-ui-g-view'
|
7
9
|
|
8
10
|
scrollable: true
|
9
11
|
|
10
|
-
emptyText: 'No Results To display'
|
12
|
+
emptyText: 'No Results To display.'
|
11
13
|
|
12
14
|
# available options are striped, condensed, bordered
|
13
15
|
# or any combination of these, split up by space
|
@@ -23,6 +25,8 @@ Luca.components.GridView = Luca.View.extend
|
|
23
25
|
"after:collection:load"
|
24
26
|
]
|
25
27
|
|
28
|
+
rowClass: "luca-ui-g-row"
|
29
|
+
|
26
30
|
initialize: (@options={})->
|
27
31
|
_.extend @, @options
|
28
32
|
_.extend @, Luca.modules.Deferrable
|
@@ -40,11 +44,11 @@ Luca.components.GridView = Luca.View.extend
|
|
40
44
|
beforeRender: ()->
|
41
45
|
@trigger "before:grid:render", @
|
42
46
|
|
43
|
-
@$el.addClass 'scrollable-
|
47
|
+
@$el.addClass 'scrollable-g-view' if @scrollable
|
44
48
|
|
45
49
|
@$el.html Luca.templates["components/grid_view"]()
|
46
50
|
|
47
|
-
@table = $('table.luca-ui-
|
51
|
+
@table = $('table.luca-ui-g-view', @el)
|
48
52
|
@header = $("thead", @table)
|
49
53
|
@body = $("tbody", @table)
|
50
54
|
@footer = $("tfoot", @table)
|
@@ -74,19 +78,24 @@ Luca.components.GridView = Luca.View.extend
|
|
74
78
|
toolbar.container = @toolbarContainers( toolbar.position )
|
75
79
|
toolbar.render()
|
76
80
|
|
81
|
+
defaultWidth: 756
|
82
|
+
defaultHeight: 285
|
83
|
+
|
77
84
|
setDimensions: (offset)->
|
78
|
-
@height ||=
|
85
|
+
@height ||= @defaultHeight
|
79
86
|
|
80
|
-
$('.
|
87
|
+
$('.luca-ui-g-view-body', @el).height( @height )
|
81
88
|
$('tbody.scrollable', @el).height( @height - 23 )
|
82
89
|
|
83
90
|
@container_width = do => $(@container).width()
|
84
|
-
|
91
|
+
|
92
|
+
@width = if @container_width > 0 then @container_width else @defaultWidth
|
93
|
+
@width = _([@width, (@maxWidth || @width)]).max()
|
85
94
|
|
86
95
|
#@width += offset if offset
|
87
96
|
|
88
|
-
$('.
|
89
|
-
$('.
|
97
|
+
$('.luca-ui-g-view-body', @el).width( @width )
|
98
|
+
$('.luca-ui-g-view-body table', @el).width( @width )
|
90
99
|
|
91
100
|
@setDefaultColumnWidths()
|
92
101
|
|
@@ -94,8 +103,8 @@ Luca.components.GridView = Luca.View.extend
|
|
94
103
|
difference = newWidth - @width
|
95
104
|
@width = newWidth
|
96
105
|
|
97
|
-
$('.
|
98
|
-
$('.
|
106
|
+
$('.luca-ui-g-view-body', @el).width( @width )
|
107
|
+
$('.luca-ui-g-view-body table', @el).width( @width )
|
99
108
|
|
100
109
|
if @columns.length > 0
|
101
110
|
distribution = difference / @columns.length
|
@@ -167,6 +176,8 @@ Luca.components.GridView = Luca.View.extend
|
|
167
176
|
@$ "[data-record-id=#{ id }]", 'table'
|
168
177
|
|
169
178
|
render_row: (row,row_index)->
|
179
|
+
rowClass = @rowClass
|
180
|
+
|
170
181
|
model_id = if row?.get and row?.attributes then row.get('id') else ''
|
171
182
|
|
172
183
|
@trigger "before:render:row", row, row_index
|
@@ -183,7 +194,7 @@ Luca.components.GridView = Luca.View.extend
|
|
183
194
|
if @alternateRowClasses
|
184
195
|
altClass = if row_index % 2 is 0 then "even" else "odd"
|
185
196
|
|
186
|
-
@body?.append("<tr data-record-id='#{ model_id }' data-row-index='#{ row_index }' class='
|
197
|
+
@body?.append("<tr data-record-id='#{ model_id }' data-row-index='#{ row_index }' class='#{ rowClass } #{ altClass }' id='row-#{ row_index }'>#{ cells }</tr>")
|
187
198
|
|
188
199
|
cell_renderer: (row, column, columnIndex )->
|
189
200
|
if _.isFunction column.renderer
|
@@ -206,7 +217,7 @@ Luca.components.GridView = Luca.View.extend
|
|
206
217
|
record = @collection.at( rowIndex )
|
207
218
|
@trigger "row:click", @, record, rowIndex
|
208
219
|
|
209
|
-
$(
|
220
|
+
$(".#{ @rowClass }", @body ).removeClass('selected-row')
|
210
221
|
me.addClass('selected-row')
|
211
222
|
|
212
223
|
Luca.register "grid_view","Luca.components.GridView"
|
data/src/core/container.coffee
CHANGED
@@ -182,6 +182,7 @@ Luca.core.Container = Luca.View.extend
|
|
182
182
|
console.log "Error Rendering Component #{ component.name || component.cid }", component
|
183
183
|
console.log e.message
|
184
184
|
console.log e.stack
|
185
|
+
throw e unless Luca.silenceRenderErrors? is true
|
185
186
|
|
186
187
|
#### Container Activation
|
187
188
|
#
|
data/src/framework.coffee
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
_.mixin( _.string )
|
2
2
|
|
3
3
|
window.Luca =
|
4
|
-
VERSION: "0.8"
|
4
|
+
VERSION: "0.8.2"
|
5
5
|
core: {}
|
6
6
|
containers: {}
|
7
7
|
components: {}
|
8
8
|
modules: {}
|
9
|
-
fields: {}
|
10
9
|
util: {}
|
10
|
+
fields: {}
|
11
11
|
registry:
|
12
12
|
classes: {}
|
13
13
|
namespaces:["Luca.containers","Luca.components"]
|
@@ -1,17 +1,17 @@
|
|
1
1
|
|
2
|
-
.scrollable-
|
2
|
+
.scrollable-g-view {
|
3
3
|
/* define height and width of scrollable area. Add 16px to width for scrollbar */
|
4
|
-
.
|
4
|
+
.luca-ui-g-view-body {
|
5
5
|
clear: both;
|
6
6
|
overflow: auto;
|
7
7
|
}
|
8
8
|
|
9
9
|
/* Reset overflow value to hidden for all non-IE browsers. */
|
10
|
-
.
|
10
|
+
.luca-ui-g-view-body {
|
11
11
|
overflow: hidden;
|
12
12
|
}
|
13
|
-
|
14
|
-
.
|
13
|
+
|
14
|
+
.luca-ui-g-view-body .empty-text-wrapper {
|
15
15
|
display: block;
|
16
16
|
margin: 10px auto;
|
17
17
|
width: 30%;
|
@@ -22,12 +22,12 @@
|
|
22
22
|
}
|
23
23
|
}
|
24
24
|
/* define width of table. IE browsers only */
|
25
|
-
.
|
25
|
+
.luca-ui-g-view-body table {
|
26
26
|
}
|
27
27
|
|
28
28
|
/* define width of table. Add 16px to width for scrollbar. */
|
29
29
|
/* All other non-IE browsers. */
|
30
|
-
.
|
30
|
+
.luca-ui-g-view-body table {
|
31
31
|
}
|
32
32
|
|
33
33
|
/* set table header to a fixed position. WinIE 6.x only */
|
@@ -93,7 +93,7 @@
|
|
93
93
|
|
94
94
|
}
|
95
95
|
|
96
|
-
.
|
96
|
+
.luca-ui-g-view-footer {
|
97
97
|
.toolbar-container {
|
98
98
|
float: left;
|
99
99
|
width: 100%;
|
@@ -1,9 +1,9 @@
|
|
1
|
-
.luca-ui-
|
2
|
-
.
|
1
|
+
.luca-ui-g-view-wrapper
|
2
|
+
.g-view-header
|
3
3
|
.toolbar-container.top
|
4
|
-
.
|
5
|
-
%table.luca-ui-
|
4
|
+
.luca-ui-g-view-body
|
5
|
+
%table.luca-ui-g-view.scrollable-table{:width=>"100%",:cellpadding=>0,:cellspacing=>0}
|
6
6
|
%thead.fixed
|
7
7
|
%tbody.scrollable
|
8
|
-
.
|
8
|
+
.luca-ui-g-view-footer
|
9
9
|
.toolbar-container.bottom
|
@@ -3,13 +3,13 @@
|
|
3
3
|
_.mixin(_.string);
|
4
4
|
|
5
5
|
window.Luca = {
|
6
|
-
VERSION: "0.8",
|
6
|
+
VERSION: "0.8.2",
|
7
7
|
core: {},
|
8
8
|
containers: {},
|
9
9
|
components: {},
|
10
10
|
modules: {},
|
11
|
-
fields: {},
|
12
11
|
util: {},
|
12
|
+
fields: {},
|
13
13
|
registry: {
|
14
14
|
classes: {},
|
15
15
|
namespaces: ["Luca.containers", "Luca.components"]
|
@@ -236,7 +236,7 @@
|
|
236
236
|
}).call(this);
|
237
237
|
(function() {
|
238
238
|
Luca.templates || (Luca.templates = {});
|
239
|
-
Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-
|
239
|
+
Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-g-view-wrapper\'>\n <div class=\'g-view-header\'>\n <div class=\'toolbar-container top\'></div>\n </div>\n <div class=\'luca-ui-g-view-body\'>\n <table cellpadding=\'0\' cellspacing=\'0\' class=\'luca-ui-g-view scrollable-table\' width=\'100%\'>\n <thead class=\'fixed\'></thead>\n <tbody class=\'scrollable\'></tbody>\n </table>\n </div>\n <div class=\'luca-ui-g-view-footer\'>\n <div class=\'toolbar-container bottom\'></div>\n </div>\n</div>\n');}return __p.join('');};
|
240
240
|
}).call(this);
|
241
241
|
(function() {
|
242
242
|
Luca.templates || (Luca.templates = {});
|
@@ -266,6 +266,14 @@
|
|
266
266
|
Luca.templates || (Luca.templates = {});
|
267
267
|
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
268
|
}).call(this);
|
269
|
+
(function() {
|
270
|
+
Luca.templates || (Luca.templates = {});
|
271
|
+
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('');};
|
272
|
+
}).call(this);
|
273
|
+
(function() {
|
274
|
+
Luca.templates || (Luca.templates = {});
|
275
|
+
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('');};
|
276
|
+
}).call(this);
|
269
277
|
(function() {
|
270
278
|
Luca.templates || (Luca.templates = {});
|
271
279
|
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('');};
|
@@ -913,7 +921,8 @@
|
|
913
921
|
} catch (e) {
|
914
922
|
console.log("Error Rendering Component " + (component.name || component.cid), component);
|
915
923
|
console.log(e.message);
|
916
|
-
|
924
|
+
console.log(e.stack);
|
925
|
+
if ((Luca.silenceRenderErrors != null) !== true) throw e;
|
917
926
|
}
|
918
927
|
});
|
919
928
|
},
|
@@ -3,13 +3,13 @@
|
|
3
3
|
_.mixin(_.string);
|
4
4
|
|
5
5
|
window.Luca = {
|
6
|
-
VERSION: "0.8",
|
6
|
+
VERSION: "0.8.2",
|
7
7
|
core: {},
|
8
8
|
containers: {},
|
9
9
|
components: {},
|
10
10
|
modules: {},
|
11
|
-
fields: {},
|
12
11
|
util: {},
|
12
|
+
fields: {},
|
13
13
|
registry: {
|
14
14
|
classes: {},
|
15
15
|
namespaces: ["Luca.containers", "Luca.components"]
|
@@ -236,7 +236,7 @@
|
|
236
236
|
}).call(this);
|
237
237
|
(function() {
|
238
238
|
Luca.templates || (Luca.templates = {});
|
239
|
-
Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-
|
239
|
+
Luca.templates["components/grid_view"] = function(obj){var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('<div class=\'luca-ui-g-view-wrapper\'>\n <div class=\'g-view-header\'>\n <div class=\'toolbar-container top\'></div>\n </div>\n <div class=\'luca-ui-g-view-body\'>\n <table cellpadding=\'0\' cellspacing=\'0\' class=\'luca-ui-g-view scrollable-table\' width=\'100%\'>\n <thead class=\'fixed\'></thead>\n <tbody class=\'scrollable\'></tbody>\n </table>\n </div>\n <div class=\'luca-ui-g-view-footer\'>\n <div class=\'toolbar-container bottom\'></div>\n </div>\n</div>\n');}return __p.join('');};
|
240
240
|
}).call(this);
|
241
241
|
(function() {
|
242
242
|
Luca.templates || (Luca.templates = {});
|
@@ -266,6 +266,14 @@
|
|
266
266
|
Luca.templates || (Luca.templates = {});
|
267
267
|
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
268
|
}).call(this);
|
269
|
+
(function() {
|
270
|
+
Luca.templates || (Luca.templates = {});
|
271
|
+
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('');};
|
272
|
+
}).call(this);
|
273
|
+
(function() {
|
274
|
+
Luca.templates || (Luca.templates = {});
|
275
|
+
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('');};
|
276
|
+
}).call(this);
|
269
277
|
(function() {
|
270
278
|
Luca.templates || (Luca.templates = {});
|
271
279
|
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('');};
|
@@ -913,7 +921,8 @@
|
|
913
921
|
} catch (e) {
|
914
922
|
console.log("Error Rendering Component " + (component.name || component.cid), component);
|
915
923
|
console.log(e.message);
|
916
|
-
|
924
|
+
console.log(e.stack);
|
925
|
+
if ((Luca.silenceRenderErrors != null) !== true) throw e;
|
917
926
|
}
|
918
927
|
});
|
919
928
|
},
|
@@ -1917,8 +1926,9 @@
|
|
1917
1926
|
this.input_class || (this.input_class = this["class"]);
|
1918
1927
|
this.icon_class || (this.icon_class = "");
|
1919
1928
|
if (this.icon_class.length && !this.icon_class.match(/^icon-/)) {
|
1920
|
-
|
1929
|
+
this.icon_class = "icon-" + this.icon_class;
|
1921
1930
|
}
|
1931
|
+
if (this.white) return this.icon_class += " icon-white";
|
1922
1932
|
},
|
1923
1933
|
setValue: function() {
|
1924
1934
|
return true;
|
@@ -1927,6 +1937,89 @@
|
|
1927
1937
|
|
1928
1938
|
Luca.register("button_field", "Luca.fields.ButtonField");
|
1929
1939
|
|
1940
|
+
}).call(this);
|
1941
|
+
(function() {
|
1942
|
+
|
1943
|
+
Luca.fields.CheckboxArray = Luca.core.Field.extend({
|
1944
|
+
template: "fields/checkbox_array",
|
1945
|
+
events: {
|
1946
|
+
"click input": "clickHandler"
|
1947
|
+
},
|
1948
|
+
initialize: function(options) {
|
1949
|
+
this.options = options != null ? options : {};
|
1950
|
+
_.extend(this, this.options);
|
1951
|
+
_.extend(this, Luca.modules.Deferrable);
|
1952
|
+
_.bindAll(this, "populateCheckboxes", "clickHandler", "_updateModel");
|
1953
|
+
Luca.core.Field.prototype.initialize.apply(this, arguments);
|
1954
|
+
this.input_id || (this.input_id = _.uniqueId('field'));
|
1955
|
+
this.input_name || (this.input_name = this.name);
|
1956
|
+
this.label || (this.label = this.name);
|
1957
|
+
this.valueField || (this.valueField = "id");
|
1958
|
+
this.displayField || (this.displayField = "name");
|
1959
|
+
return this.selectedItems = [];
|
1960
|
+
},
|
1961
|
+
afterInitialize: function(options) {
|
1962
|
+
this.options = options != null ? options : {};
|
1963
|
+
try {
|
1964
|
+
this.configure_collection();
|
1965
|
+
} catch (e) {
|
1966
|
+
console.log("Error Configuring Collection", this, e.message);
|
1967
|
+
}
|
1968
|
+
return this.collection.bind("reset", this.populateCheckboxes);
|
1969
|
+
},
|
1970
|
+
afterRender: function() {
|
1971
|
+
var _ref, _ref2;
|
1972
|
+
if (((_ref = this.collection) != null ? (_ref2 = _ref.models) != null ? _ref2.length : void 0 : void 0) > 0) {
|
1973
|
+
return this.populateCheckboxes();
|
1974
|
+
} else {
|
1975
|
+
return this.collection.trigger("reset");
|
1976
|
+
}
|
1977
|
+
},
|
1978
|
+
clickHandler: function(event) {
|
1979
|
+
var checkbox;
|
1980
|
+
checkbox = event.target;
|
1981
|
+
if (checkbox.checked) {
|
1982
|
+
this.selectedItems.push(checkbox.value);
|
1983
|
+
} else {
|
1984
|
+
if (this.selectedItems.indexOf(checkbox.value) !== -1) {
|
1985
|
+
this.selectedItems = _.without(this.selectedItems, [checkbox.value]);
|
1986
|
+
}
|
1987
|
+
}
|
1988
|
+
return this._updateModel();
|
1989
|
+
},
|
1990
|
+
populateCheckboxes: function() {
|
1991
|
+
var controls,
|
1992
|
+
_this = this;
|
1993
|
+
controls = $(this.el).find('.controls');
|
1994
|
+
controls.empty();
|
1995
|
+
this.selectedItems = this.getModel().get(this.name);
|
1996
|
+
this.collection.each(function(model) {
|
1997
|
+
var input_id, label, value;
|
1998
|
+
value = model.get(_this.valueField);
|
1999
|
+
label = model.get(_this.displayField);
|
2000
|
+
input_id = _.uniqueId('field');
|
2001
|
+
controls.append(Luca.templates["fields/checkbox_array_item"]({
|
2002
|
+
label: label,
|
2003
|
+
value: value,
|
2004
|
+
input_id: input_id,
|
2005
|
+
input_name: _this.input_name
|
2006
|
+
}));
|
2007
|
+
if (_this.selectedItems.indexOf(value) !== -1) {
|
2008
|
+
return _this.$("#" + input_id).attr("checked", "checked");
|
2009
|
+
}
|
2010
|
+
});
|
2011
|
+
return $(this.container).append(this.$el);
|
2012
|
+
},
|
2013
|
+
_updateModel: function() {
|
2014
|
+
var attributes;
|
2015
|
+
attributes = {};
|
2016
|
+
attributes[this.name] = this.selectedItems;
|
2017
|
+
return this.getModel().set(attributes);
|
2018
|
+
}
|
2019
|
+
});
|
2020
|
+
|
2021
|
+
Luca.register("checkbox_array", "Luca.fields.CheckboxArray");
|
2022
|
+
|
1930
2023
|
}).call(this);
|
1931
2024
|
(function() {
|
1932
2025
|
|
@@ -2334,8 +2427,24 @@
|
|
2334
2427
|
return component.container = container;
|
2335
2428
|
});
|
2336
2429
|
},
|
2430
|
+
afterComponents: function() {
|
2431
|
+
var _ref,
|
2432
|
+
_this = this;
|
2433
|
+
if ((_ref = Luca.core.Container.prototype.afterComponents) != null) {
|
2434
|
+
_ref.apply(this, arguments);
|
2435
|
+
}
|
2436
|
+
return this.eachField(function(field) {
|
2437
|
+
field.getForm = function() {
|
2438
|
+
return _this;
|
2439
|
+
};
|
2440
|
+
return field.getModel = function() {
|
2441
|
+
return _this.currentModel();
|
2442
|
+
};
|
2443
|
+
});
|
2444
|
+
},
|
2337
2445
|
render: function() {
|
2338
|
-
|
2446
|
+
$(this.container).append(this.$el);
|
2447
|
+
return this;
|
2339
2448
|
},
|
2340
2449
|
wrapper: function() {
|
2341
2450
|
return this.$el.parents('.luca-ui-form-view-wrapper');
|
@@ -2352,6 +2461,9 @@
|
|
2352
2461
|
return toolbar.render();
|
2353
2462
|
});
|
2354
2463
|
},
|
2464
|
+
eachField: function(iterator) {
|
2465
|
+
return _(this.getFields()).map(iterator);
|
2466
|
+
},
|
2355
2467
|
getField: function(name) {
|
2356
2468
|
return _(this.getFields('name', name)).first();
|
2357
2469
|
},
|
@@ -2482,15 +2594,17 @@
|
|
2482
2594
|
(function() {
|
2483
2595
|
|
2484
2596
|
Luca.components.GridView = Luca.View.extend({
|
2597
|
+
autoBindEventHandlers: true,
|
2485
2598
|
events: {
|
2486
|
-
"dblclick .
|
2487
|
-
"click .
|
2599
|
+
"dblclick .luca-ui-g-row": "double_click_handler",
|
2600
|
+
"click .luca-ui-g-row": "click_handler"
|
2488
2601
|
},
|
2489
|
-
className: 'luca-ui-
|
2602
|
+
className: 'luca-ui-g-view',
|
2490
2603
|
scrollable: true,
|
2491
|
-
emptyText: 'No Results To display',
|
2604
|
+
emptyText: 'No Results To display.',
|
2492
2605
|
tableStyle: 'striped',
|
2493
2606
|
hooks: ["before:grid:render", "before:render:header", "before:render:row", "after:grid:render", "row:double:click", "row:click", "after:collection:load"],
|
2607
|
+
rowClass: "luca-ui-g-row",
|
2494
2608
|
initialize: function(options) {
|
2495
2609
|
var _this = this;
|
2496
2610
|
this.options = options != null ? options : {};
|
@@ -2508,9 +2622,9 @@
|
|
2508
2622
|
var _ref,
|
2509
2623
|
_this = this;
|
2510
2624
|
this.trigger("before:grid:render", this);
|
2511
|
-
if (this.scrollable) this.$el.addClass('scrollable-
|
2625
|
+
if (this.scrollable) this.$el.addClass('scrollable-g-view');
|
2512
2626
|
this.$el.html(Luca.templates["components/grid_view"]());
|
2513
|
-
this.table = $('table.luca-ui-
|
2627
|
+
this.table = $('table.luca-ui-g-view', this.el);
|
2514
2628
|
this.header = $("thead", this.table);
|
2515
2629
|
this.body = $("tbody", this.table);
|
2516
2630
|
this.footer = $("tfoot", this.table);
|
@@ -2536,17 +2650,20 @@
|
|
2536
2650
|
return toolbar.render();
|
2537
2651
|
});
|
2538
2652
|
},
|
2653
|
+
defaultWidth: 756,
|
2654
|
+
defaultHeight: 285,
|
2539
2655
|
setDimensions: function(offset) {
|
2540
2656
|
var _this = this;
|
2541
|
-
this.height || (this.height =
|
2542
|
-
$('.
|
2657
|
+
this.height || (this.height = this.defaultHeight);
|
2658
|
+
$('.luca-ui-g-view-body', this.el).height(this.height);
|
2543
2659
|
$('tbody.scrollable', this.el).height(this.height - 23);
|
2544
2660
|
this.container_width = (function() {
|
2545
2661
|
return $(_this.container).width();
|
2546
2662
|
})();
|
2547
|
-
this.width = this.container_width > 0 ? this.container_width :
|
2548
|
-
|
2549
|
-
$('.
|
2663
|
+
this.width = this.container_width > 0 ? this.container_width : this.defaultWidth;
|
2664
|
+
this.width = _([this.width, this.maxWidth || this.width]).max();
|
2665
|
+
$('.luca-ui-g-view-body', this.el).width(this.width);
|
2666
|
+
$('.luca-ui-g-view-body table', this.el).width(this.width);
|
2550
2667
|
return this.setDefaultColumnWidths();
|
2551
2668
|
},
|
2552
2669
|
resize: function(newWidth) {
|
@@ -2554,8 +2671,8 @@
|
|
2554
2671
|
_this = this;
|
2555
2672
|
difference = newWidth - this.width;
|
2556
2673
|
this.width = newWidth;
|
2557
|
-
$('.
|
2558
|
-
$('.
|
2674
|
+
$('.luca-ui-g-view-body', this.el).width(this.width);
|
2675
|
+
$('.luca-ui-g-view-body table', this.el).width(this.width);
|
2559
2676
|
if (this.columns.length > 0) {
|
2560
2677
|
distribution = difference / this.columns.length;
|
2561
2678
|
return _(this.columns).each(function(col, index) {
|
@@ -2636,8 +2753,9 @@
|
|
2636
2753
|
return this.$("[data-record-id=" + id + "]", 'table');
|
2637
2754
|
},
|
2638
2755
|
render_row: function(row, row_index) {
|
2639
|
-
var altClass, cells, model_id, _ref,
|
2756
|
+
var altClass, cells, model_id, rowClass, _ref,
|
2640
2757
|
_this = this;
|
2758
|
+
rowClass = this.rowClass;
|
2641
2759
|
model_id = (row != null ? row.get : void 0) && (row != null ? row.attributes : void 0) ? row.get('id') : '';
|
2642
2760
|
this.trigger("before:render:row", row, row_index);
|
2643
2761
|
cells = _(this.columns).map(function(column, col_index) {
|
@@ -2651,7 +2769,7 @@
|
|
2651
2769
|
if (this.alternateRowClasses) {
|
2652
2770
|
altClass = row_index % 2 === 0 ? "even" : "odd";
|
2653
2771
|
}
|
2654
|
-
return (_ref = this.body) != null ? _ref.append("<tr data-record-id='" + model_id + "' data-row-index='" + row_index + "' class='
|
2772
|
+
return (_ref = this.body) != null ? _ref.append("<tr data-record-id='" + model_id + "' data-row-index='" + row_index + "' class='" + rowClass + " " + altClass + "' id='row-" + row_index + "'>" + cells + "</tr>") : void 0;
|
2655
2773
|
},
|
2656
2774
|
cell_renderer: function(row, column, columnIndex) {
|
2657
2775
|
var source;
|
@@ -2677,7 +2795,7 @@
|
|
2677
2795
|
rowIndex = my.data('row-index');
|
2678
2796
|
record = this.collection.at(rowIndex);
|
2679
2797
|
this.trigger("row:click", this, record, rowIndex);
|
2680
|
-
$(
|
2798
|
+
$("." + this.rowClass, this.body).removeClass('selected-row');
|
2681
2799
|
return me.addClass('selected-row');
|
2682
2800
|
}
|
2683
2801
|
});
|