luca 0.9.42 → 0.9.65
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +50 -9
- data/Gemfile +1 -0
- data/Gemfile.lock +2 -0
- data/README.md +5 -0
- data/assets/javascripts/dependencies/underscore-min.js +5 -31
- data/lib/generators/luca/application/application_generator.rb +71 -0
- data/lib/generators/luca/application/templates/controller.rb +6 -0
- data/lib/generators/luca/application/templates/index.html.erb +7 -0
- data/lib/generators/luca/application/templates/index.html.haml +6 -0
- data/lib/generators/luca/application/templates/javascripts/application.js +28 -0
- data/lib/generators/luca/application/templates/javascripts/application.js.coffee +20 -0
- data/lib/generators/luca/application/templates/javascripts/config.js +15 -0
- data/lib/generators/luca/application/templates/javascripts/config.js.coffee +9 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.js +5 -0
- data/lib/generators/luca/application/templates/javascripts/dependencies.js.coffee +5 -0
- data/lib/generators/luca/application/templates/javascripts/index.js +9 -0
- data/lib/generators/luca/application/templates/javascripts/index.js.coffee +9 -0
- data/lib/generators/luca/application/templates/javascripts/main.js +8 -0
- data/lib/generators/luca/application/templates/javascripts/main.js.coffee +3 -0
- data/lib/generators/luca/application/templates/javascripts/main.jst.ejs +1 -0
- data/lib/generators/luca/application/templates/javascripts/router.js +12 -0
- data/lib/generators/luca/application/templates/javascripts/router.js.coffee +7 -0
- data/lib/luca/rails/version.rb +1 -1
- data/spec/components/collection_view_spec.coffee +59 -0
- data/spec/components/multi_collection_view_spec.coffee +5 -0
- data/{src/templates/components/form_alert → spec/components/pagination_control_spec.coffee} +0 -0
- data/spec/components/table_view_spec.coffee +17 -0
- data/spec/core/container_spec.coffee +127 -5
- data/spec/core/model_spec.coffee +21 -3
- data/spec/define_spec.coffee +19 -0
- data/spec/mixin_spec.coffee +49 -0
- data/spec/modules/filterable_spec.coffee +25 -0
- data/spec/modules/paginatable_spec.coffee +0 -0
- data/spec/modules/state_model_spec.coffee +0 -0
- data/src/components/application.coffee +52 -38
- data/src/components/collection_view.coffee +118 -45
- data/src/components/fields/checkbox_field.coffee +2 -2
- data/src/components/fields/file_upload_field.coffee +0 -3
- data/src/components/fields/hidden_field.coffee +0 -3
- data/src/components/fields/label_field.coffee +1 -4
- data/src/components/fields/select_field.coffee +6 -6
- data/src/components/fields/text_area_field.coffee +1 -0
- data/src/components/fields/text_field.coffee +4 -0
- data/src/components/fields/type_ahead_field.coffee +5 -9
- data/src/components/form_view.coffee +28 -23
- data/src/components/multi_collection_view.coffee +121 -0
- data/src/components/pagination_control.coffee +106 -0
- data/src/components/table_view.coffee +22 -13
- data/src/containers/card_view.coffee +44 -11
- data/src/containers/panel_toolbar.coffee +88 -82
- data/src/containers/tab_view.coffee +3 -3
- data/src/core/collection.coffee +11 -4
- data/src/core/container.coffee +206 -122
- data/src/core/field.coffee +13 -10
- data/src/core/model.coffee +23 -27
- data/src/core/registry.coffee +42 -29
- data/src/core/view.coffee +63 -149
- data/src/define.coffee +91 -19
- data/src/framework.coffee +11 -9
- data/src/managers/collection_manager.coffee +24 -8
- data/src/modules/application_event_bindings.coffee +19 -0
- data/src/modules/collection_event_bindings.coffee +26 -0
- data/src/modules/deferrable.coffee +3 -1
- data/src/modules/dom_helpers.coffee +49 -0
- data/src/modules/enhanced_properties.coffee +23 -0
- data/src/modules/filterable.coffee +82 -0
- data/src/modules/grid_layout.coffee +13 -1
- data/src/modules/{load_mask.coffee → loadmaskable.coffee} +10 -4
- data/src/modules/modal_view.coffee +38 -0
- data/src/modules/paginatable.coffee +87 -0
- data/src/modules/state_model.coffee +16 -0
- data/src/modules/templating.coffee +8 -0
- data/src/plugins/events.coffee +30 -2
- data/src/templates/components/bootstrap_form_controls.jst.ejs +10 -0
- data/src/templates/components/collection_loader_view.jst.ejs +6 -0
- data/src/templates/components/form_alert.jst.ejs +4 -0
- data/src/templates/components/grid_view.jst.ejs +11 -0
- data/src/templates/components/grid_view_empty_text.jst.ejs +3 -0
- data/src/templates/components/load_mask.jst.ejs +5 -0
- data/src/templates/components/nav_bar.jst.ejs +4 -0
- data/src/templates/components/pagination.jst.ejs +10 -0
- data/src/templates/containers/basic.jst.ejs +1 -0
- data/src/templates/containers/tab_selector_container.jst.ejs +12 -0
- data/src/templates/containers/tab_view.jst.ejs +2 -0
- data/src/templates/containers/toolbar_wrapper.jst.ejs +1 -0
- data/src/templates/fields/button_field.jst.ejs +2 -0
- data/src/templates/fields/button_field_link.jst.ejs +6 -0
- data/src/templates/fields/checkbox_array.jst.ejs +4 -0
- data/src/templates/fields/checkbox_array_item.jst.ejs +3 -0
- data/src/templates/fields/checkbox_field.jst.ejs +10 -0
- data/src/templates/fields/file_upload_field.jst.ejs +10 -0
- data/src/templates/fields/hidden_field.jst.ejs +1 -0
- data/src/templates/fields/select_field.jst.ejs +11 -0
- data/src/templates/fields/text_area_field.jst.ejs +11 -0
- data/src/templates/fields/text_field.jst.ejs +16 -0
- data/src/templates/table_view.jst.ejs +4 -0
- data/src/tools/console.coffee +51 -21
- data/src/util.coffee +17 -4
- data/vendor/assets/javascripts/luca-ui-base.js +5304 -0
- data/vendor/assets/javascripts/luca-ui-bootstrap.js +9 -0
- data/vendor/assets/javascripts/luca-ui-development-tools.js +52 -24
- data/vendor/assets/javascripts/luca-ui-development-tools.min.js +1 -1
- data/vendor/assets/javascripts/luca-ui-full.js +1700 -595
- data/vendor/assets/javascripts/luca-ui-full.min.js +7 -6
- data/vendor/assets/javascripts/luca-ui-spec.js +6815 -0
- data/vendor/assets/javascripts/luca-ui-templates.js +92 -24
- data/vendor/assets/javascripts/luca-ui.js +1695 -564
- data/vendor/assets/javascripts/luca-ui.min.js +4 -4
- metadata +69 -28
- data/src/templates/components/bootstrap_form_controls.luca +0 -7
- data/src/templates/components/collection_loader_view.luca +0 -5
- data/src/templates/components/form_alert.luca +0 -3
- data/src/templates/components/grid_view.luca +0 -7
- data/src/templates/components/grid_view_empty_text.luca +0 -3
- data/src/templates/components/load_mask.luca +0 -3
- data/src/templates/components/nav_bar.luca +0 -2
- data/src/templates/containers/basic.luca +0 -1
- data/src/templates/containers/tab_selector_container.luca +0 -8
- data/src/templates/containers/tab_view.luca +0 -2
- data/src/templates/containers/toolbar_wrapper.luca +0 -1
- data/src/templates/fields/button_field.luca +0 -2
- data/src/templates/fields/button_field_link.luca +0 -5
- data/src/templates/fields/checkbox_array.luca +0 -4
- data/src/templates/fields/checkbox_array_item.luca +0 -4
- data/src/templates/fields/checkbox_field.luca +0 -9
- data/src/templates/fields/file_upload_field.luca +0 -8
- data/src/templates/fields/hidden_field.luca +0 -1
- data/src/templates/fields/select_field.luca +0 -8
- data/src/templates/fields/text_area_field.luca +0 -8
- data/src/templates/fields/text_field.luca +0 -17
- data/src/templates/sample/contents.luca +0 -1
- data/src/templates/sample/welcome.luca +0 -1
- data/src/templates/table_view.luca +0 -4
data/src/tools/console.coffee
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
|
2
|
-
readOnly: true
|
3
|
-
autoFocus: false
|
4
|
-
theme: "monokai"
|
5
|
-
mode: "javascript"
|
1
|
+
developmentConsole = Luca.register "Luca.tools.DevelopmentConsole"
|
6
2
|
|
7
|
-
|
3
|
+
developmentConsole.extends "Luca.core.Container"
|
4
|
+
|
5
|
+
developmentConsole.defines
|
8
6
|
className: "luca-ui-console"
|
9
7
|
name: "console"
|
10
8
|
history: []
|
11
9
|
historyIndex: 0
|
10
|
+
width: 1000
|
12
11
|
|
13
12
|
componentEvents:
|
14
|
-
"
|
15
|
-
"
|
16
|
-
"
|
13
|
+
"input key:keyup" : "historyUp"
|
14
|
+
"input key:keydown" : "historyDown"
|
15
|
+
"input key:enter" : "runCommand"
|
17
16
|
|
18
17
|
compileOptions:
|
19
18
|
bare: true
|
20
19
|
|
21
20
|
components:[
|
22
|
-
|
21
|
+
type: "code_mirror_field"
|
22
|
+
role: "code_mirror"
|
23
23
|
additionalClassNames: "clearfix"
|
24
24
|
name: "code_output"
|
25
25
|
readOnly: true
|
@@ -28,8 +28,9 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
28
28
|
lineWrapping: true
|
29
29
|
gutter: false
|
30
30
|
,
|
31
|
-
|
31
|
+
type: "text_field"
|
32
32
|
name: "code_input"
|
33
|
+
role: "input"
|
33
34
|
lineNumbers: false
|
34
35
|
height: '30px'
|
35
36
|
maxHeight: '30px'
|
@@ -57,7 +58,10 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
57
58
|
|
58
59
|
afterRender: ()->
|
59
60
|
@$container().modal(backdrop: false)
|
60
|
-
|
61
|
+
|
62
|
+
if @width?
|
63
|
+
marginLeft = parseInt(@width) * 0.5 * -1
|
64
|
+
@$container().css("width", @width).css('margin-left', parseInt(marginLeft) )
|
61
65
|
|
62
66
|
show: (options={})->
|
63
67
|
@$container().modal('show')
|
@@ -78,19 +82,19 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
78
82
|
@historyIndex -= 1
|
79
83
|
@historyIndex = 0 if @historyIndex < 0
|
80
84
|
|
81
|
-
currentValue =
|
82
|
-
|
85
|
+
currentValue = @getInput().getValue()
|
86
|
+
@getInput().setValue( @history[ @historyIndex ] || currentValue )
|
83
87
|
|
84
88
|
historyDown: ()->
|
85
89
|
@historyIndex += 1
|
86
90
|
@historyIndex = @history.length - 1 if @historyIndex > @history.length - 1
|
87
91
|
|
88
|
-
currentValue =
|
92
|
+
currentValue = @getInput().getValue()
|
89
93
|
|
90
|
-
|
94
|
+
@getInput().setValue( @history[ @historyIndex ] || currentValue)
|
91
95
|
|
92
96
|
append: (code, result, skipFormatting=false)->
|
93
|
-
output =
|
97
|
+
output = @getCodeMirror()
|
94
98
|
current = output.getValue()
|
95
99
|
|
96
100
|
source = "// #{ code }" if code?
|
@@ -105,7 +109,12 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
105
109
|
|
106
110
|
onSuccess: (result, js, coffee)->
|
107
111
|
@saveHistory(coffee)
|
108
|
-
|
112
|
+
|
113
|
+
dump = ""
|
114
|
+
|
115
|
+
if _.isArray( result ) or _.isObject( result ) or _.isString( result ) or _.isNumber(result)
|
116
|
+
dump = JSON.stringify(result, null, "\t")
|
117
|
+
|
109
118
|
dump ||= result.toString?()
|
110
119
|
|
111
120
|
@append(js, dump || "undefined")
|
@@ -117,7 +126,7 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
117
126
|
return unless code?.length > 0
|
118
127
|
|
119
128
|
raw = _.string.strip(raw)
|
120
|
-
output =
|
129
|
+
output = @getCodeMirror()
|
121
130
|
dev = @
|
122
131
|
|
123
132
|
evaluator = ()->
|
@@ -142,6 +151,13 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
142
151
|
|
143
152
|
try
|
144
153
|
result = evaluator.call( @getContext() )
|
154
|
+
|
155
|
+
# capture luca objects for special inspection
|
156
|
+
if Luca.isComponent( result )
|
157
|
+
result = Luca.util.inspectComponent( result )
|
158
|
+
else if Luca.isComponentPrototype( result )
|
159
|
+
result = Luca.util.inspectComponentPrototype( result )
|
160
|
+
|
145
161
|
@onSuccess(result, code, raw) unless raw.match(/^console\.log/)
|
146
162
|
catch error
|
147
163
|
@onError(error, code, raw)
|
@@ -149,20 +165,34 @@ Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
|
|
149
165
|
runCommand: ()->
|
150
166
|
dev = @
|
151
167
|
compile = _.bind(Luca.tools.CoffeeEditor::compile, @)
|
152
|
-
raw =
|
168
|
+
raw = @getInput().getValue()
|
153
169
|
compiled = compile raw, (compiled)->
|
154
170
|
dev.evaluateCode(compiled, raw)
|
155
171
|
|
156
172
|
Luca.util.launchers ||= {}
|
157
173
|
|
174
|
+
Luca.util.inspectComponentPrototype = (componentPrototype)->
|
175
|
+
liveInstances = Luca.registry.findInstancesByClass( componentPrototype )
|
176
|
+
|
177
|
+
Luca.util.inspectComponent = (component)->
|
178
|
+
component = Luca(component) if _.isString(component)
|
179
|
+
|
180
|
+
{
|
181
|
+
name: component.name
|
182
|
+
instanceOf: component.displayName
|
183
|
+
subclassOf: component._superClass()::displayName
|
184
|
+
inheritsFrom: Luca.parentClasses( component )
|
185
|
+
}
|
186
|
+
|
158
187
|
Luca.util.launchers.developmentConsole = (name="luca-development-console")->
|
159
188
|
@_lucaDevConsole = Luca name, ()=>
|
160
|
-
@$el.append Backbone.View::make("div", id: "#{ name }-wrapper", class: "modal fade")
|
189
|
+
@$el.append Backbone.View::make("div", id: "#{ name }-wrapper", class: "modal fade large")
|
161
190
|
|
162
191
|
console = new Luca.tools.DevelopmentConsole
|
163
192
|
name: name
|
164
193
|
container: "##{ name }-wrapper"
|
165
194
|
|
166
195
|
console.render()
|
196
|
+
console.getCodeMirror().setHeight(602)
|
167
197
|
|
168
198
|
@_lucaDevConsole.show()
|
data/src/util.coffee
CHANGED
@@ -3,14 +3,26 @@
|
|
3
3
|
# references on objects which don't yet exist, as strings, which get
|
4
4
|
# evaluated at runtime when such references will be available
|
5
5
|
Luca.util.resolve = (accessor, source_object)->
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
try
|
7
|
+
source_object ||= (window || global)
|
8
|
+
resolved = _( accessor.split(/\./) ).inject (obj,key)->
|
9
|
+
obj = obj?[key]
|
10
|
+
, source_object
|
11
|
+
catch e
|
12
|
+
console.log "Error resolving", accessor, source_object
|
13
|
+
throw e
|
14
|
+
|
15
|
+
resolved
|
10
16
|
|
11
17
|
# A better name for Luca.util.nestedValue
|
12
18
|
Luca.util.nestedValue = Luca.util.resolve
|
13
19
|
|
20
|
+
Luca.util.argumentsLogger = (prompt)->
|
21
|
+
()-> console.log prompt, arguments
|
22
|
+
|
23
|
+
Luca.util.read = (property, args...)->
|
24
|
+
if _.isFunction(property) then property.apply(@, args) else property
|
25
|
+
|
14
26
|
# turns a word like form_view into FormView
|
15
27
|
Luca.util.classify = (string="")->
|
16
28
|
_.string.camelize( _.string.capitalize( string ) )
|
@@ -105,3 +117,4 @@ Luca.util.badge = (contents="", type, baseClass="badge")->
|
|
105
117
|
cssClass = baseClass
|
106
118
|
cssClass += " #{ baseClass }-#{ type }" if type?
|
107
119
|
Luca.util.make("span",{class:cssClass},contents)
|
120
|
+
|