luca 0.8.3 → 0.8.06
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 +1 -14
- data/Guardfile +9 -14
- data/lib/luca/rails/version.rb +1 -1
- data/src/components/collection_loader_view.coffee +1 -2
- data/src/components/form_view.coffee +2 -12
- data/src/core/container.coffee +0 -1
- data/src/core/view.coffee +1 -1
- data/src/framework.coffee +13 -19
- data/src/managers/collection_manager.coffee +1 -1
- data/vendor/assets/javascripts/luca-ui-base.js +14 -26
- data/vendor/assets/javascripts/luca-ui-spec.js +19 -134
- data/vendor/assets/javascripts/luca-ui.js +19 -134
- data/vendor/assets/javascripts/luca-ui.min.js +3 -3
- metadata +2 -5
- data/src/components/fields/checkbox_array.coffee +0 -64
- data/src/templates/fields/checkbox_array.luca +0 -5
- data/src/templates/fields/checkbox_array_item.luca +0 -4
data/CHANGELOG
CHANGED
@@ -1,16 +1,3 @@
|
|
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
|
4
|
-
|
5
|
-
0.8.1
|
6
|
-
- Adds many style fixes for GridView
|
7
|
-
- Fixes style conflicts for Bootstrap grid-* css selectors
|
8
|
-
- Adds getForm() and getModel() methods to Luca.Field classes that belong to a form
|
9
|
-
|
10
|
-
0.8.2
|
11
|
-
- Adds checkbox group field component ( thanks nick desteffen )
|
12
|
-
|
13
|
-
0.8.3
|
14
|
-
- Stop mixing in underscore.string onto the global underscore object
|
15
|
-
- the ctype property used to create objects from hashes, can now be named 'type'
|
16
|
-
- Adds Luca.util.classify function for converting strings into class names
|
3
|
+
beforeFormLoad methods if they exist on those models
|
data/Guardfile
CHANGED
@@ -5,23 +5,18 @@ javascript_path = File.join( assets_path, 'javascripts' )
|
|
5
5
|
stylesheets_path = File.join( assets_path, 'stylesheets' )
|
6
6
|
|
7
7
|
unless ENV['TEST_MODE']
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
watch(%r{^spec/.+$})
|
12
|
-
end
|
8
|
+
guard 'sprockets2', :clean=>false, :assets_path => javascript_path, :sprockets => App.sprockets, :precompile=>[/^luca-ui.+(coffee|js)$/], :digest => false, :gz => false do
|
9
|
+
watch(%r{^src/.+$})
|
10
|
+
watch(%r{^spec/.+$})
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
watch(%r{^src/stylesheets/.+$})
|
18
|
-
end
|
13
|
+
guard 'sprockets2', :clean=>false, :assets_path => stylesheets_path, :sprockets => App.sprockets, :precompile=>[/^luca-ui.+(scss|css)$/], :digest => false, :gz => false do
|
14
|
+
watch(%r{^src/stylesheets/.+$})
|
19
15
|
end
|
20
16
|
end
|
21
17
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
18
|
+
# TODO: Couldn't detect phantomjs
|
19
|
+
guard 'jasmine' do
|
20
|
+
watch(%r{src/(.+)\.coffee}) {|m| "spec/#{ m[1] }_spec.coffee" }
|
21
|
+
watch(%r{spec/(.+)_spec\.coffee})
|
27
22
|
end
|
data/lib/luca/rails/version.rb
CHANGED
@@ -24,10 +24,9 @@ Luca.components.CollectionLoaderView = Luca.components.Template.extend
|
|
24
24
|
loaded = @manager.loadedCollectionsCount()
|
25
25
|
total = @manager.totalCollectionsCount()
|
26
26
|
progress = parseInt((loaded / total) * 100)
|
27
|
-
collectionName = _.string.titleize( _.string.humanize( name ) )
|
28
27
|
|
29
28
|
@modalContainer().find('.progress .bar').attr("style", "width: #{progress}%;")
|
30
|
-
@modalContainer().find('.message').html("Loaded #{
|
29
|
+
@modalContainer().find('.message').html("Loaded #{ _(name).chain().humanize().titleize().value() }...")
|
31
30
|
|
32
31
|
@manager.bind "all_collections_loaded", ()=>
|
33
32
|
@modalContainer().find('.message').html("All done!")
|
@@ -93,15 +93,8 @@ 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
|
-
|
102
96
|
render: ()->
|
103
97
|
$( @container ).append( @$el )
|
104
|
-
@
|
105
98
|
|
106
99
|
wrapper: ()->
|
107
100
|
@$el.parents('.luca-ui-form-view-wrapper')
|
@@ -115,9 +108,6 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
115
108
|
toolbar = Luca.util.lazyComponent(toolbar)
|
116
109
|
toolbar.render()
|
117
110
|
|
118
|
-
eachField: (iterator)->
|
119
|
-
_( @getFields() ).map( iterator )
|
120
|
-
|
121
111
|
getField: (name)->
|
122
112
|
_( @getFields('name', name) ).first()
|
123
113
|
|
@@ -200,8 +190,8 @@ Luca.components.FormView = Luca.core.Container.extend
|
|
200
190
|
|
201
191
|
skip = false
|
202
192
|
skip = true if options.skip_buttons and field.ctype is "button_field"
|
203
|
-
skip = true if options.reject_blank is true and _.
|
204
|
-
skip = true if field.input_name is "id" and _.
|
193
|
+
skip = true if options.reject_blank is true and _.isBlank(value)
|
194
|
+
skip = true if field.input_name is "id" and _.isBlank(value)
|
205
195
|
|
206
196
|
memo[ key ] = value unless skip is true
|
207
197
|
|
data/src/core/container.coffee
CHANGED
@@ -182,7 +182,6 @@ 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
|
186
185
|
|
187
186
|
#### Container Activation
|
188
187
|
#
|
data/src/core/view.coffee
CHANGED
@@ -141,7 +141,7 @@ _.extend Luca.View.prototype,
|
|
141
141
|
parts = eventId.split(':')
|
142
142
|
prefix = parts.shift()
|
143
143
|
|
144
|
-
parts = _( parts ).map (p)-> _.
|
144
|
+
parts = _( parts ).map (p)-> _.capitalize(p)
|
145
145
|
fn = prefix + parts.join('')
|
146
146
|
|
147
147
|
@bind eventId, ()=> @[fn].apply @, arguments if @[fn]
|
data/src/framework.coffee
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
+
_.mixin( _.string )
|
2
|
+
|
1
3
|
window.Luca =
|
2
|
-
VERSION: "0.8.
|
4
|
+
VERSION: "0.8.06"
|
3
5
|
core: {}
|
4
6
|
containers: {}
|
5
7
|
components: {}
|
6
8
|
modules: {}
|
7
|
-
util: {}
|
8
9
|
fields: {}
|
9
|
-
|
10
|
-
cid_index: {}
|
11
|
-
name_index: {}
|
10
|
+
util: {}
|
12
11
|
registry:
|
13
12
|
classes: {}
|
14
13
|
namespaces:["Luca.containers","Luca.components"]
|
14
|
+
component_cache:
|
15
|
+
cid_index: {}
|
16
|
+
name_index: {}
|
15
17
|
|
16
18
|
|
17
19
|
# let's use the Twitter 2.0 Bootstrap Framework
|
@@ -56,18 +58,12 @@ Luca.cache = (needle, component)->
|
|
56
58
|
Luca.component_cache.cid_index[ lookup_id ]
|
57
59
|
|
58
60
|
# Takes an string like "deep.nested.value" and an object like window
|
59
|
-
# and returns the value of window.deep.nested.value
|
60
|
-
# references on objects which don't yet exist, as strings, which get
|
61
|
-
# evaluated at runtime when such references will be available
|
61
|
+
# and returns the value of window.deep.nested.value
|
62
62
|
Luca.util.nestedValue = (accessor, source_object)->
|
63
63
|
_( accessor.split(/\./) ).inject (obj,key)->
|
64
64
|
obj = obj?[key]
|
65
65
|
, source_object
|
66
66
|
|
67
|
-
# turns a word like form_view into FormView
|
68
|
-
Luca.util.classify = (string="")->
|
69
|
-
_.string.camelize( _.string.capitalize( string ) )
|
70
|
-
|
71
67
|
# Lookup a component in the Luca component registry
|
72
68
|
# by it's ctype identifier. If it doesn't exist,
|
73
69
|
# check any other registered namespace
|
@@ -76,18 +72,16 @@ Luca.registry.lookup = (ctype)->
|
|
76
72
|
|
77
73
|
return c if c?
|
78
74
|
|
79
|
-
className =
|
75
|
+
className = _.camelize _.capitalize( ctype )
|
80
76
|
|
81
77
|
parents = _( Luca.registry.namespaces ).map (namespace)-> Luca.util.nestedValue(namespace, (window || global))
|
82
78
|
|
83
79
|
_.first _.compact _( parents ).map (parent)-> parent[className]
|
84
80
|
|
85
|
-
#
|
86
|
-
#
|
87
|
-
# a Luca component, we lookup the object's class by converting its ctype / type
|
88
|
-
# property into a class that has been registered in the component registry
|
81
|
+
# creates a new object from a hash with a ctype property
|
82
|
+
# matching something in the Luca registry
|
89
83
|
Luca.util.lazyComponent = (config)->
|
90
|
-
ctype = config.ctype
|
84
|
+
ctype = config.ctype
|
91
85
|
|
92
86
|
componentClass = Luca.registry.lookup( ctype )
|
93
87
|
|
@@ -102,7 +96,7 @@ Luca.register = (component, constructor_class)->
|
|
102
96
|
exists = Luca.registry.classes[component]
|
103
97
|
|
104
98
|
if exists?
|
105
|
-
|
99
|
+
throw "Can not register component with the signature #{ component }. Already exists"
|
106
100
|
else
|
107
101
|
Luca.registry.classes[component] = constructor_class
|
108
102
|
|
@@ -125,7 +125,7 @@ class Luca.CollectionManager
|
|
125
125
|
@get(key) || @create(key,collectionOptions,initialModels,false)
|
126
126
|
|
127
127
|
guessCollectionClass: (key)->
|
128
|
-
classified =
|
128
|
+
classified = _( key ).chain().capitalize().camelize().value()
|
129
129
|
guess = (@collectionNamespace || (window || global) )[ classified ]
|
130
130
|
guess ||= (@collectionNamespace || (window || global) )[ "#{classified}Collection" ]
|
131
131
|
guess
|
@@ -1,20 +1,22 @@
|
|
1
1
|
(function() {
|
2
2
|
|
3
|
+
_.mixin(_.string);
|
4
|
+
|
3
5
|
window.Luca = {
|
4
|
-
VERSION: "0.8.
|
6
|
+
VERSION: "0.8.06",
|
5
7
|
core: {},
|
6
8
|
containers: {},
|
7
9
|
components: {},
|
8
10
|
modules: {},
|
9
|
-
util: {},
|
10
11
|
fields: {},
|
11
|
-
|
12
|
-
cid_index: {},
|
13
|
-
name_index: {}
|
14
|
-
},
|
12
|
+
util: {},
|
15
13
|
registry: {
|
16
14
|
classes: {},
|
17
15
|
namespaces: ["Luca.containers", "Luca.components"]
|
16
|
+
},
|
17
|
+
component_cache: {
|
18
|
+
cid_index: {},
|
19
|
+
name_index: {}
|
18
20
|
}
|
19
21
|
};
|
20
22
|
|
@@ -57,16 +59,11 @@
|
|
57
59
|
}, source_object);
|
58
60
|
};
|
59
61
|
|
60
|
-
Luca.util.classify = function(string) {
|
61
|
-
if (string == null) string = "";
|
62
|
-
return _.string.camelize(_.string.capitalize(string));
|
63
|
-
};
|
64
|
-
|
65
62
|
Luca.registry.lookup = function(ctype) {
|
66
63
|
var c, className, parents;
|
67
64
|
c = Luca.registry.classes[ctype];
|
68
65
|
if (c != null) return c;
|
69
|
-
className =
|
66
|
+
className = _.camelize(_.capitalize(ctype));
|
70
67
|
parents = _(Luca.registry.namespaces).map(function(namespace) {
|
71
68
|
return Luca.util.nestedValue(namespace, window || global);
|
72
69
|
});
|
@@ -77,7 +74,7 @@
|
|
77
74
|
|
78
75
|
Luca.util.lazyComponent = function(config) {
|
79
76
|
var componentClass, constructor, ctype;
|
80
|
-
ctype = config.ctype
|
77
|
+
ctype = config.ctype;
|
81
78
|
componentClass = Luca.registry.lookup(ctype);
|
82
79
|
if (!componentClass) {
|
83
80
|
throw "Invalid Component Type: " + ctype + ". Did you forget to register it?";
|
@@ -90,7 +87,7 @@
|
|
90
87
|
var exists;
|
91
88
|
exists = Luca.registry.classes[component];
|
92
89
|
if (exists != null) {
|
93
|
-
|
90
|
+
throw "Can not register component with the signature " + component + ". Already exists";
|
94
91
|
} else {
|
95
92
|
return Luca.registry.classes[component] = constructor_class;
|
96
93
|
}
|
@@ -269,14 +266,6 @@
|
|
269
266
|
Luca.templates || (Luca.templates = {});
|
270
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('');};
|
271
268
|
}).call(this);
|
272
|
-
(function() {
|
273
|
-
Luca.templates || (Luca.templates = {});
|
274
|
-
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('');};
|
275
|
-
}).call(this);
|
276
|
-
(function() {
|
277
|
-
Luca.templates || (Luca.templates = {});
|
278
|
-
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('');};
|
279
|
-
}).call(this);
|
280
269
|
(function() {
|
281
270
|
Luca.templates || (Luca.templates = {});
|
282
271
|
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('');};
|
@@ -447,7 +436,7 @@
|
|
447
436
|
parts = eventId.split(':');
|
448
437
|
prefix = parts.shift();
|
449
438
|
parts = _(parts).map(function(p) {
|
450
|
-
return _.
|
439
|
+
return _.capitalize(p);
|
451
440
|
});
|
452
441
|
fn = prefix + parts.join('');
|
453
442
|
return _this.bind(eventId, function() {
|
@@ -924,8 +913,7 @@
|
|
924
913
|
} catch (e) {
|
925
914
|
console.log("Error Rendering Component " + (component.name || component.cid), component);
|
926
915
|
console.log(e.message);
|
927
|
-
console.log(e.stack);
|
928
|
-
if ((Luca.silenceRenderErrors != null) !== true) throw e;
|
916
|
+
return console.log(e.stack);
|
929
917
|
}
|
930
918
|
});
|
931
919
|
},
|
@@ -1107,7 +1095,7 @@
|
|
1107
1095
|
|
1108
1096
|
CollectionManager.prototype.guessCollectionClass = function(key) {
|
1109
1097
|
var classified, guess;
|
1110
|
-
classified =
|
1098
|
+
classified = _(key).chain().capitalize().camelize().value();
|
1111
1099
|
guess = (this.collectionNamespace || (window || global))[classified];
|
1112
1100
|
guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
|
1113
1101
|
return guess;
|
@@ -1,20 +1,22 @@
|
|
1
1
|
(function() {
|
2
2
|
|
3
|
+
_.mixin(_.string);
|
4
|
+
|
3
5
|
window.Luca = {
|
4
|
-
VERSION: "0.8.
|
6
|
+
VERSION: "0.8.06",
|
5
7
|
core: {},
|
6
8
|
containers: {},
|
7
9
|
components: {},
|
8
10
|
modules: {},
|
9
|
-
util: {},
|
10
11
|
fields: {},
|
11
|
-
|
12
|
-
cid_index: {},
|
13
|
-
name_index: {}
|
14
|
-
},
|
12
|
+
util: {},
|
15
13
|
registry: {
|
16
14
|
classes: {},
|
17
15
|
namespaces: ["Luca.containers", "Luca.components"]
|
16
|
+
},
|
17
|
+
component_cache: {
|
18
|
+
cid_index: {},
|
19
|
+
name_index: {}
|
18
20
|
}
|
19
21
|
};
|
20
22
|
|
@@ -57,16 +59,11 @@
|
|
57
59
|
}, source_object);
|
58
60
|
};
|
59
61
|
|
60
|
-
Luca.util.classify = function(string) {
|
61
|
-
if (string == null) string = "";
|
62
|
-
return _.string.camelize(_.string.capitalize(string));
|
63
|
-
};
|
64
|
-
|
65
62
|
Luca.registry.lookup = function(ctype) {
|
66
63
|
var c, className, parents;
|
67
64
|
c = Luca.registry.classes[ctype];
|
68
65
|
if (c != null) return c;
|
69
|
-
className =
|
66
|
+
className = _.camelize(_.capitalize(ctype));
|
70
67
|
parents = _(Luca.registry.namespaces).map(function(namespace) {
|
71
68
|
return Luca.util.nestedValue(namespace, window || global);
|
72
69
|
});
|
@@ -77,7 +74,7 @@
|
|
77
74
|
|
78
75
|
Luca.util.lazyComponent = function(config) {
|
79
76
|
var componentClass, constructor, ctype;
|
80
|
-
ctype = config.ctype
|
77
|
+
ctype = config.ctype;
|
81
78
|
componentClass = Luca.registry.lookup(ctype);
|
82
79
|
if (!componentClass) {
|
83
80
|
throw "Invalid Component Type: " + ctype + ". Did you forget to register it?";
|
@@ -90,7 +87,7 @@
|
|
90
87
|
var exists;
|
91
88
|
exists = Luca.registry.classes[component];
|
92
89
|
if (exists != null) {
|
93
|
-
|
90
|
+
throw "Can not register component with the signature " + component + ". Already exists";
|
94
91
|
} else {
|
95
92
|
return Luca.registry.classes[component] = constructor_class;
|
96
93
|
}
|
@@ -269,14 +266,6 @@
|
|
269
266
|
Luca.templates || (Luca.templates = {});
|
270
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('');};
|
271
268
|
}).call(this);
|
272
|
-
(function() {
|
273
|
-
Luca.templates || (Luca.templates = {});
|
274
|
-
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('');};
|
275
|
-
}).call(this);
|
276
|
-
(function() {
|
277
|
-
Luca.templates || (Luca.templates = {});
|
278
|
-
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('');};
|
279
|
-
}).call(this);
|
280
269
|
(function() {
|
281
270
|
Luca.templates || (Luca.templates = {});
|
282
271
|
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('');};
|
@@ -447,7 +436,7 @@
|
|
447
436
|
parts = eventId.split(':');
|
448
437
|
prefix = parts.shift();
|
449
438
|
parts = _(parts).map(function(p) {
|
450
|
-
return _.
|
439
|
+
return _.capitalize(p);
|
451
440
|
});
|
452
441
|
fn = prefix + parts.join('');
|
453
442
|
return _this.bind(eventId, function() {
|
@@ -924,8 +913,7 @@
|
|
924
913
|
} catch (e) {
|
925
914
|
console.log("Error Rendering Component " + (component.name || component.cid), component);
|
926
915
|
console.log(e.message);
|
927
|
-
console.log(e.stack);
|
928
|
-
if ((Luca.silenceRenderErrors != null) !== true) throw e;
|
916
|
+
return console.log(e.stack);
|
929
917
|
}
|
930
918
|
});
|
931
919
|
},
|
@@ -1107,7 +1095,7 @@
|
|
1107
1095
|
|
1108
1096
|
CollectionManager.prototype.guessCollectionClass = function(key) {
|
1109
1097
|
var classified, guess;
|
1110
|
-
classified =
|
1098
|
+
classified = _(key).chain().capitalize().camelize().value();
|
1111
1099
|
guess = (this.collectionNamespace || (window || global))[classified];
|
1112
1100
|
guess || (guess = (this.collectionNamespace || (window || global))["" + classified + "Collection"]);
|
1113
1101
|
return guess;
|
@@ -1775,13 +1763,12 @@
|
|
1775
1763
|
setupBindings: function() {
|
1776
1764
|
var _this = this;
|
1777
1765
|
this.manager.bind("collection_loaded", function(name) {
|
1778
|
-
var
|
1766
|
+
var loaded, progress, total;
|
1779
1767
|
loaded = _this.manager.loadedCollectionsCount();
|
1780
1768
|
total = _this.manager.totalCollectionsCount();
|
1781
1769
|
progress = parseInt((loaded / total) * 100);
|
1782
|
-
collectionName = _.string.titleize(_.string.humanize(name));
|
1783
1770
|
_this.modalContainer().find('.progress .bar').attr("style", "width: " + progress + "%;");
|
1784
|
-
return _this.modalContainer().find('.message').html("Loaded " +
|
1771
|
+
return _this.modalContainer().find('.message').html("Loaded " + (_(name).chain().humanize().titleize().value()) + "...");
|
1785
1772
|
});
|
1786
1773
|
return this.manager.bind("all_collections_loaded", function() {
|
1787
1774
|
_this.modalContainer().find('.message').html("All done!");
|
@@ -1941,89 +1928,6 @@
|
|
1941
1928
|
|
1942
1929
|
Luca.register("button_field", "Luca.fields.ButtonField");
|
1943
1930
|
|
1944
|
-
}).call(this);
|
1945
|
-
(function() {
|
1946
|
-
|
1947
|
-
Luca.fields.CheckboxArray = Luca.core.Field.extend({
|
1948
|
-
template: "fields/checkbox_array",
|
1949
|
-
events: {
|
1950
|
-
"click input": "clickHandler"
|
1951
|
-
},
|
1952
|
-
initialize: function(options) {
|
1953
|
-
this.options = options != null ? options : {};
|
1954
|
-
_.extend(this, this.options);
|
1955
|
-
_.extend(this, Luca.modules.Deferrable);
|
1956
|
-
_.bindAll(this, "populateCheckboxes", "clickHandler", "_updateModel");
|
1957
|
-
Luca.core.Field.prototype.initialize.apply(this, arguments);
|
1958
|
-
this.input_id || (this.input_id = _.uniqueId('field'));
|
1959
|
-
this.input_name || (this.input_name = this.name);
|
1960
|
-
this.label || (this.label = this.name);
|
1961
|
-
this.valueField || (this.valueField = "id");
|
1962
|
-
this.displayField || (this.displayField = "name");
|
1963
|
-
return this.selectedItems = [];
|
1964
|
-
},
|
1965
|
-
afterInitialize: function(options) {
|
1966
|
-
this.options = options != null ? options : {};
|
1967
|
-
try {
|
1968
|
-
this.configure_collection();
|
1969
|
-
} catch (e) {
|
1970
|
-
console.log("Error Configuring Collection", this, e.message);
|
1971
|
-
}
|
1972
|
-
return this.collection.bind("reset", this.populateCheckboxes);
|
1973
|
-
},
|
1974
|
-
afterRender: function() {
|
1975
|
-
var _ref, _ref2;
|
1976
|
-
if (((_ref = this.collection) != null ? (_ref2 = _ref.models) != null ? _ref2.length : void 0 : void 0) > 0) {
|
1977
|
-
return this.populateCheckboxes();
|
1978
|
-
} else {
|
1979
|
-
return this.collection.trigger("reset");
|
1980
|
-
}
|
1981
|
-
},
|
1982
|
-
clickHandler: function(event) {
|
1983
|
-
var checkbox;
|
1984
|
-
checkbox = event.target;
|
1985
|
-
if (checkbox.checked) {
|
1986
|
-
this.selectedItems.push(checkbox.value);
|
1987
|
-
} else {
|
1988
|
-
if (this.selectedItems.indexOf(checkbox.value) !== -1) {
|
1989
|
-
this.selectedItems = _.without(this.selectedItems, [checkbox.value]);
|
1990
|
-
}
|
1991
|
-
}
|
1992
|
-
return this._updateModel();
|
1993
|
-
},
|
1994
|
-
populateCheckboxes: function() {
|
1995
|
-
var controls,
|
1996
|
-
_this = this;
|
1997
|
-
controls = $(this.el).find('.controls');
|
1998
|
-
controls.empty();
|
1999
|
-
this.selectedItems = this.getModel().get(this.name);
|
2000
|
-
this.collection.each(function(model) {
|
2001
|
-
var input_id, label, value;
|
2002
|
-
value = model.get(_this.valueField);
|
2003
|
-
label = model.get(_this.displayField);
|
2004
|
-
input_id = _.uniqueId('field');
|
2005
|
-
controls.append(Luca.templates["fields/checkbox_array_item"]({
|
2006
|
-
label: label,
|
2007
|
-
value: value,
|
2008
|
-
input_id: input_id,
|
2009
|
-
input_name: _this.input_name
|
2010
|
-
}));
|
2011
|
-
if (_this.selectedItems.indexOf(value) !== -1) {
|
2012
|
-
return _this.$("#" + input_id).attr("checked", "checked");
|
2013
|
-
}
|
2014
|
-
});
|
2015
|
-
return $(this.container).append(this.$el);
|
2016
|
-
},
|
2017
|
-
_updateModel: function() {
|
2018
|
-
var attributes;
|
2019
|
-
attributes = {};
|
2020
|
-
attributes[this.name] = this.selectedItems;
|
2021
|
-
return this.getModel().set(attributes);
|
2022
|
-
}
|
2023
|
-
});
|
2024
|
-
|
2025
|
-
Luca.register("checkbox_array", "Luca.fields.CheckboxArray");
|
2026
|
-
|
2027
1931
|
}).call(this);
|
2028
1932
|
(function() {
|
2029
1933
|
|
@@ -2431,24 +2335,8 @@
|
|
2431
2335
|
return component.container = container;
|
2432
2336
|
});
|
2433
2337
|
},
|
2434
|
-
afterComponents: function() {
|
2435
|
-
var _ref,
|
2436
|
-
_this = this;
|
2437
|
-
if ((_ref = Luca.core.Container.prototype.afterComponents) != null) {
|
2438
|
-
_ref.apply(this, arguments);
|
2439
|
-
}
|
2440
|
-
return this.eachField(function(field) {
|
2441
|
-
field.getForm = function() {
|
2442
|
-
return _this;
|
2443
|
-
};
|
2444
|
-
return field.getModel = function() {
|
2445
|
-
return _this.currentModel();
|
2446
|
-
};
|
2447
|
-
});
|
2448
|
-
},
|
2449
2338
|
render: function() {
|
2450
|
-
$(this.container).append(this.$el);
|
2451
|
-
return this;
|
2339
|
+
return $(this.container).append(this.$el);
|
2452
2340
|
},
|
2453
2341
|
wrapper: function() {
|
2454
2342
|
return this.$el.parents('.luca-ui-form-view-wrapper');
|
@@ -2465,9 +2353,6 @@
|
|
2465
2353
|
return toolbar.render();
|
2466
2354
|
});
|
2467
2355
|
},
|
2468
|
-
eachField: function(iterator) {
|
2469
|
-
return _(this.getFields()).map(iterator);
|
2470
|
-
},
|
2471
2356
|
getField: function(name) {
|
2472
2357
|
return _(this.getFields('name', name)).first();
|
2473
2358
|
},
|
@@ -2547,8 +2432,8 @@
|
|
2547
2432
|
key = field.input_name || field.name;
|
2548
2433
|
skip = false;
|
2549
2434
|
if (options.skip_buttons && field.ctype === "button_field") skip = true;
|
2550
|
-
if (options.reject_blank === true && _.
|
2551
|
-
if (field.input_name === "id" && _.
|
2435
|
+
if (options.reject_blank === true && _.isBlank(value)) skip = true;
|
2436
|
+
if (field.input_name === "id" && _.isBlank(value)) skip = true;
|
2552
2437
|
if (skip !== true) memo[key] = value;
|
2553
2438
|
return memo;
|
2554
2439
|
}, {});
|