luca 0.9.42 → 0.9.65

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/CHANGELOG +50 -9
  2. data/Gemfile +1 -0
  3. data/Gemfile.lock +2 -0
  4. data/README.md +5 -0
  5. data/assets/javascripts/dependencies/underscore-min.js +5 -31
  6. data/lib/generators/luca/application/application_generator.rb +71 -0
  7. data/lib/generators/luca/application/templates/controller.rb +6 -0
  8. data/lib/generators/luca/application/templates/index.html.erb +7 -0
  9. data/lib/generators/luca/application/templates/index.html.haml +6 -0
  10. data/lib/generators/luca/application/templates/javascripts/application.js +28 -0
  11. data/lib/generators/luca/application/templates/javascripts/application.js.coffee +20 -0
  12. data/lib/generators/luca/application/templates/javascripts/config.js +15 -0
  13. data/lib/generators/luca/application/templates/javascripts/config.js.coffee +9 -0
  14. data/lib/generators/luca/application/templates/javascripts/dependencies.js +5 -0
  15. data/lib/generators/luca/application/templates/javascripts/dependencies.js.coffee +5 -0
  16. data/lib/generators/luca/application/templates/javascripts/index.js +9 -0
  17. data/lib/generators/luca/application/templates/javascripts/index.js.coffee +9 -0
  18. data/lib/generators/luca/application/templates/javascripts/main.js +8 -0
  19. data/lib/generators/luca/application/templates/javascripts/main.js.coffee +3 -0
  20. data/lib/generators/luca/application/templates/javascripts/main.jst.ejs +1 -0
  21. data/lib/generators/luca/application/templates/javascripts/router.js +12 -0
  22. data/lib/generators/luca/application/templates/javascripts/router.js.coffee +7 -0
  23. data/lib/luca/rails/version.rb +1 -1
  24. data/spec/components/collection_view_spec.coffee +59 -0
  25. data/spec/components/multi_collection_view_spec.coffee +5 -0
  26. data/{src/templates/components/form_alert → spec/components/pagination_control_spec.coffee} +0 -0
  27. data/spec/components/table_view_spec.coffee +17 -0
  28. data/spec/core/container_spec.coffee +127 -5
  29. data/spec/core/model_spec.coffee +21 -3
  30. data/spec/define_spec.coffee +19 -0
  31. data/spec/mixin_spec.coffee +49 -0
  32. data/spec/modules/filterable_spec.coffee +25 -0
  33. data/spec/modules/paginatable_spec.coffee +0 -0
  34. data/spec/modules/state_model_spec.coffee +0 -0
  35. data/src/components/application.coffee +52 -38
  36. data/src/components/collection_view.coffee +118 -45
  37. data/src/components/fields/checkbox_field.coffee +2 -2
  38. data/src/components/fields/file_upload_field.coffee +0 -3
  39. data/src/components/fields/hidden_field.coffee +0 -3
  40. data/src/components/fields/label_field.coffee +1 -4
  41. data/src/components/fields/select_field.coffee +6 -6
  42. data/src/components/fields/text_area_field.coffee +1 -0
  43. data/src/components/fields/text_field.coffee +4 -0
  44. data/src/components/fields/type_ahead_field.coffee +5 -9
  45. data/src/components/form_view.coffee +28 -23
  46. data/src/components/multi_collection_view.coffee +121 -0
  47. data/src/components/pagination_control.coffee +106 -0
  48. data/src/components/table_view.coffee +22 -13
  49. data/src/containers/card_view.coffee +44 -11
  50. data/src/containers/panel_toolbar.coffee +88 -82
  51. data/src/containers/tab_view.coffee +3 -3
  52. data/src/core/collection.coffee +11 -4
  53. data/src/core/container.coffee +206 -122
  54. data/src/core/field.coffee +13 -10
  55. data/src/core/model.coffee +23 -27
  56. data/src/core/registry.coffee +42 -29
  57. data/src/core/view.coffee +63 -149
  58. data/src/define.coffee +91 -19
  59. data/src/framework.coffee +11 -9
  60. data/src/managers/collection_manager.coffee +24 -8
  61. data/src/modules/application_event_bindings.coffee +19 -0
  62. data/src/modules/collection_event_bindings.coffee +26 -0
  63. data/src/modules/deferrable.coffee +3 -1
  64. data/src/modules/dom_helpers.coffee +49 -0
  65. data/src/modules/enhanced_properties.coffee +23 -0
  66. data/src/modules/filterable.coffee +82 -0
  67. data/src/modules/grid_layout.coffee +13 -1
  68. data/src/modules/{load_mask.coffee → loadmaskable.coffee} +10 -4
  69. data/src/modules/modal_view.coffee +38 -0
  70. data/src/modules/paginatable.coffee +87 -0
  71. data/src/modules/state_model.coffee +16 -0
  72. data/src/modules/templating.coffee +8 -0
  73. data/src/plugins/events.coffee +30 -2
  74. data/src/templates/components/bootstrap_form_controls.jst.ejs +10 -0
  75. data/src/templates/components/collection_loader_view.jst.ejs +6 -0
  76. data/src/templates/components/form_alert.jst.ejs +4 -0
  77. data/src/templates/components/grid_view.jst.ejs +11 -0
  78. data/src/templates/components/grid_view_empty_text.jst.ejs +3 -0
  79. data/src/templates/components/load_mask.jst.ejs +5 -0
  80. data/src/templates/components/nav_bar.jst.ejs +4 -0
  81. data/src/templates/components/pagination.jst.ejs +10 -0
  82. data/src/templates/containers/basic.jst.ejs +1 -0
  83. data/src/templates/containers/tab_selector_container.jst.ejs +12 -0
  84. data/src/templates/containers/tab_view.jst.ejs +2 -0
  85. data/src/templates/containers/toolbar_wrapper.jst.ejs +1 -0
  86. data/src/templates/fields/button_field.jst.ejs +2 -0
  87. data/src/templates/fields/button_field_link.jst.ejs +6 -0
  88. data/src/templates/fields/checkbox_array.jst.ejs +4 -0
  89. data/src/templates/fields/checkbox_array_item.jst.ejs +3 -0
  90. data/src/templates/fields/checkbox_field.jst.ejs +10 -0
  91. data/src/templates/fields/file_upload_field.jst.ejs +10 -0
  92. data/src/templates/fields/hidden_field.jst.ejs +1 -0
  93. data/src/templates/fields/select_field.jst.ejs +11 -0
  94. data/src/templates/fields/text_area_field.jst.ejs +11 -0
  95. data/src/templates/fields/text_field.jst.ejs +16 -0
  96. data/src/templates/table_view.jst.ejs +4 -0
  97. data/src/tools/console.coffee +51 -21
  98. data/src/util.coffee +17 -4
  99. data/vendor/assets/javascripts/luca-ui-base.js +5304 -0
  100. data/vendor/assets/javascripts/luca-ui-bootstrap.js +9 -0
  101. data/vendor/assets/javascripts/luca-ui-development-tools.js +52 -24
  102. data/vendor/assets/javascripts/luca-ui-development-tools.min.js +1 -1
  103. data/vendor/assets/javascripts/luca-ui-full.js +1700 -595
  104. data/vendor/assets/javascripts/luca-ui-full.min.js +7 -6
  105. data/vendor/assets/javascripts/luca-ui-spec.js +6815 -0
  106. data/vendor/assets/javascripts/luca-ui-templates.js +92 -24
  107. data/vendor/assets/javascripts/luca-ui.js +1695 -564
  108. data/vendor/assets/javascripts/luca-ui.min.js +4 -4
  109. metadata +69 -28
  110. data/src/templates/components/bootstrap_form_controls.luca +0 -7
  111. data/src/templates/components/collection_loader_view.luca +0 -5
  112. data/src/templates/components/form_alert.luca +0 -3
  113. data/src/templates/components/grid_view.luca +0 -7
  114. data/src/templates/components/grid_view_empty_text.luca +0 -3
  115. data/src/templates/components/load_mask.luca +0 -3
  116. data/src/templates/components/nav_bar.luca +0 -2
  117. data/src/templates/containers/basic.luca +0 -1
  118. data/src/templates/containers/tab_selector_container.luca +0 -8
  119. data/src/templates/containers/tab_view.luca +0 -2
  120. data/src/templates/containers/toolbar_wrapper.luca +0 -1
  121. data/src/templates/fields/button_field.luca +0 -2
  122. data/src/templates/fields/button_field_link.luca +0 -5
  123. data/src/templates/fields/checkbox_array.luca +0 -4
  124. data/src/templates/fields/checkbox_array_item.luca +0 -4
  125. data/src/templates/fields/checkbox_field.luca +0 -9
  126. data/src/templates/fields/file_upload_field.luca +0 -8
  127. data/src/templates/fields/hidden_field.luca +0 -1
  128. data/src/templates/fields/select_field.luca +0 -8
  129. data/src/templates/fields/text_area_field.luca +0 -8
  130. data/src/templates/fields/text_field.luca +0 -17
  131. data/src/templates/sample/contents.luca +0 -1
  132. data/src/templates/sample/welcome.luca +0 -1
  133. data/src/templates/table_view.luca +0 -4
@@ -1,25 +1,25 @@
1
- codeMirrorOptions =
2
- readOnly: true
3
- autoFocus: false
4
- theme: "monokai"
5
- mode: "javascript"
1
+ developmentConsole = Luca.register "Luca.tools.DevelopmentConsole"
6
2
 
7
- Luca.define("Luca.tools.DevelopmentConsole").extends("Luca.core.Container").with
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
- "code_input key:keyup" : "historyUp"
15
- "code_input key:keydown" : "historyDown"
16
- "code_input key:enter" : "runCommand"
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
- ctype: "code_mirror_field"
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
- ctype: "text_field"
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
- @$container.css
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 = Luca("code_input").getValue()
82
- Luca("code_input").setValue( @history[ @historyIndex ] || currentValue )
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 = Luca("code_input").getValue()
92
+ currentValue = @getInput().getValue()
89
93
 
90
- Luca("code_input").setValue( @history[ @historyIndex ] || currentValue)
94
+ @getInput().setValue( @history[ @historyIndex ] || currentValue)
91
95
 
92
96
  append: (code, result, skipFormatting=false)->
93
- output = Luca("code_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
- dump = JSON.stringify(result, null, "\t")
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 = Luca("code_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 = Luca("code_input").getValue()
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
- source_object ||= (window || global)
7
- _( accessor.split(/\./) ).inject (obj,key)->
8
- obj = obj?[key]
9
- , source_object
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
+