luca 0.9.6 → 0.9.7

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.
Files changed (76) hide show
  1. data/CHANGELOG +37 -14
  2. data/lib/luca/rails/version.rb +1 -1
  3. data/spec/components/collection_view_spec.coffee +24 -2
  4. data/spec/components/pagination_control_spec.coffee +0 -0
  5. data/spec/concerns/dom_helpers_spec.coffee +16 -0
  6. data/spec/concerns/filterable_spec.coffee +25 -0
  7. data/spec/concerns/model_presenter_spec.coffee +31 -0
  8. data/spec/concerns/paginatable_spec.coffee +0 -0
  9. data/spec/concerns/state_model_spec.coffee +0 -0
  10. data/spec/concerns_spec.coffee +88 -0
  11. data/spec/core/container_spec.coffee +74 -12
  12. data/spec/core/model_spec.coffee +6 -1
  13. data/spec/define_spec.coffee +0 -6
  14. data/spec/util_spec.coffee +24 -0
  15. data/src/components/application.coffee +32 -30
  16. data/src/components/base_toolbar.coffee +6 -4
  17. data/src/components/collection_loader_view.coffee +3 -1
  18. data/src/components/collection_view.coffee +42 -21
  19. data/src/components/controller.coffee +3 -1
  20. data/src/components/fields/button_field.coffee +19 -12
  21. data/src/components/fields/checkbox_array.coffee +8 -2
  22. data/src/components/fields/checkbox_field.coffee +18 -9
  23. data/src/components/fields/file_upload_field.coffee +5 -1
  24. data/src/components/fields/hidden_field.coffee +3 -1
  25. data/src/components/fields/label_field.coffee +4 -3
  26. data/src/components/fields/select_field.coffee +7 -8
  27. data/src/components/fields/text_field.coffee +3 -1
  28. data/src/components/fields/type_ahead_field.coffee +4 -2
  29. data/src/components/form_button_toolbar.coffee +4 -1
  30. data/src/components/form_view.coffee +49 -44
  31. data/src/components/grid_view.coffee +1 -1
  32. data/src/components/multi_collection_view.coffee +49 -22
  33. data/src/components/pagination_control.coffee +17 -13
  34. data/src/{modules → concerns}/application_event_bindings.coffee +1 -1
  35. data/src/{modules → concerns}/collection_event_bindings.coffee +1 -1
  36. data/src/{modules → concerns}/deferrable.coffee +1 -1
  37. data/src/{modules → concerns}/dom_helpers.coffee +11 -2
  38. data/src/{modules → concerns}/enhanced_properties.coffee +1 -1
  39. data/src/concerns/filterable.coffee +82 -0
  40. data/src/{modules → concerns}/grid_layout.coffee +1 -1
  41. data/src/{modules → concerns}/loadmaskable.coffee +1 -1
  42. data/src/{modules → concerns}/local_storage.coffee +0 -0
  43. data/src/{modules → concerns}/modal_view.coffee +1 -1
  44. data/src/concerns/model_presenter.coffee +23 -0
  45. data/src/concerns/paginatable.coffee +87 -0
  46. data/src/{modules → concerns}/state_model.coffee +1 -1
  47. data/src/{modules → concerns}/templating.coffee +1 -1
  48. data/src/concerns.coffee +70 -0
  49. data/src/containers/tab_view.coffee +7 -10
  50. data/src/core/collection.coffee +17 -1
  51. data/src/core/container.coffee +56 -31
  52. data/src/core/field.coffee +39 -38
  53. data/src/core/meta_data.coffee +37 -0
  54. data/src/core/model.coffee +18 -1
  55. data/src/core/view.coffee +25 -29
  56. data/src/define.coffee +54 -66
  57. data/src/framework.coffee +23 -18
  58. data/src/index.coffee +3 -1
  59. data/src/stylesheets/components/checkbox_array.scss +1 -1
  60. data/src/stylesheets/components/form_view.scss +5 -5
  61. data/src/stylesheets/components/viewport.scss +2 -1
  62. data/src/stylesheets/containers/container.scss +0 -5
  63. data/src/stylesheets/containers/tab_view.scss +5 -5
  64. data/src/tools/console.coffee +5 -5
  65. data/src/util.coffee +47 -0
  66. data/vendor/assets/javascripts/luca-ui-development-tools.js +5 -5
  67. data/vendor/assets/javascripts/luca-ui-development-tools.min.js +1 -1
  68. data/vendor/assets/javascripts/luca-ui-full.js +905 -416
  69. data/vendor/assets/javascripts/luca-ui-full.min.js +5 -5
  70. data/vendor/assets/javascripts/luca-ui.js +905 -416
  71. data/vendor/assets/javascripts/luca-ui.min.js +5 -4
  72. data/vendor/assets/stylesheets/luca-ui.css +15 -15
  73. metadata +27 -17
  74. data/spec/mixin_spec.coffee +0 -49
  75. data/src/modules/filterable.coffee +0 -60
  76. data/src/modules/paginatable.coffee +0 -79
@@ -1,9 +1,12 @@
1
- # Luca.Application
1
+ application = Luca.register "Luca.Application"
2
+ application.extends "Luca.containers.Viewport"
3
+
4
+ # Luca.Application
2
5
  #
3
6
  # The Application class is the global state tracking mechanism
4
7
  # for your single page application, as well as the entry point.
5
8
  #
6
- # By default it contains a main controller which is a Luca.components.Controller instance.
9
+ # By default it contains a main controller which is a Luca.components.Controller instance.
7
10
  #
8
11
  # In a typical Luca application, the router will use the applications @navigate_to() method to switch
9
12
  # from page to page on the main controller, or any other controllers nested inside of it.
@@ -12,11 +15,8 @@
12
15
  #
13
16
  # Decoupling application control flow from the URL Fragment from Backbone.History and preventing
14
17
  # your components from directly caring about the URL Fragment, allows you to build applications as
15
- # isolated components which can run separately or nested inside of other applications.
16
-
17
- startHistory = ()-> Backbone.history.start()
18
-
19
- _.def('Luca.Application').extends('Luca.containers.Viewport').with
18
+ # isolated components which can run separately or nested inside of other applications.
19
+ application.defines
20
20
  name: "MyApp"
21
21
 
22
22
  # The Application uses a Backbone.Model as a state machine, which
@@ -26,18 +26,18 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
26
26
  # the @defaultState property will be the default attributes
27
27
  defaultState: {}
28
28
 
29
- # if autoBoot is set to true, the application will
29
+ # if autoBoot is set to true, the application will
30
30
  # attempt to boot on document ready.
31
31
  autoBoot: false
32
32
 
33
- # automatically starts the @router if it exists,
34
- # once the components for the application have
33
+ # automatically starts the @router if it exists,
34
+ # once the components for the application have
35
35
  # been created. Pass the event name you want to
36
36
  # listen for on this component before you start history
37
37
  autoStartHistory: "before:render"
38
38
 
39
39
  # we will create a collection manager singleton
40
- # by default unless otherwise specified.
40
+ # by default unless otherwise specified.
41
41
  useCollectionManager: true
42
42
 
43
43
  # to pass options to the collection manager, set the @collectionManager
@@ -46,7 +46,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
46
46
 
47
47
  # by default we will use the standard collection manager which ships with
48
48
  # Luca. If you would like to use your own extension of the collection manager
49
- # just pass a reference to the class you would like to use.
49
+ # just pass a reference to the class you would like to use.
50
50
  collectionManagerClass: "Luca.CollectionManager"
51
51
 
52
52
  # Luca plugin apps are apps which mount onto existing
@@ -61,7 +61,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
61
61
  useController: true
62
62
 
63
63
  # Key Handler
64
- #
64
+ #
65
65
  # One responsibility of the application, since it is a viewport which monopolizes the entire screen
66
66
  # is to relay keypress events from the document, to whatever views are interested in responding to them.
67
67
  #
@@ -70,7 +70,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
70
70
 
71
71
  # You can configure key events by specifying them by their name, as it exists in Luca.keyMap. For example:
72
72
  #
73
- keyEvents: {}
73
+ keyEvents: {}
74
74
 
75
75
  # keyEvents
76
76
  # keyup: keyUpHandler
@@ -103,7 +103,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
103
103
 
104
104
  Luca.Application.instances ||= {}
105
105
  Luca.Application.instances[ appName ] = app
106
-
106
+
107
107
  Luca.containers.Viewport::initialize.apply @, arguments
108
108
 
109
109
  @state = new Luca.Model( @defaultState )
@@ -115,7 +115,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
115
115
  # with the state machine of the application
116
116
  @setupMainController() if @useController is true
117
117
 
118
- # The Collection Manager is responsible
118
+ # The Collection Manager is responsible
119
119
  @setupCollectionManager()
120
120
 
121
121
  # we will render when all of the various components
@@ -137,23 +137,23 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
137
137
  # forwardslash: "altSlashHandler"
138
138
  if @useKeyRouter is true
139
139
  console.log "The useKeyRouter property is being deprecated. switch to useKeyHandler instead"
140
-
140
+
141
141
  @setupKeyHandler() if (@useKeyHandler is true or @useKeyRouter is true) and @keyEvents?
142
142
 
143
143
  # if the application is a plugin designed to modify the behavior
144
144
  # of another app, then don't claim ownership. otherwise the most common
145
145
  # use-case is that there will be one application instance
146
146
  unless @plugin is true or alreadyRunning
147
- Luca.getApplication = (name)=>
147
+ Luca.getApplication = (name)=>
148
148
  return app unless name?
149
- Luca.Application.instances[ name ]
149
+ Luca.Application.instances[ name ]
150
150
 
151
151
  if @autoBoot
152
152
  if Luca.util.resolve(@name)
153
153
  throw "Attempting to override window.#{ @name } when it already exists"
154
154
 
155
155
  $ ->
156
- window[ appName ] = app
156
+ window[ appName ] = app
157
157
  app.boot()
158
158
 
159
159
  # @activeView() returns a reference to the instance of the view
@@ -161,14 +161,14 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
161
161
  #
162
162
  # this will be whicever component is active on the controllers
163
163
  # nested within the main controller, if there are any, or the view
164
- # itself which is active on the main controller.
164
+ # itself which is active on the main controller.
165
165
  activeView: ()->
166
166
  if active = @activeSubSection()
167
167
  @view( active )
168
168
  else
169
169
  @view( @activeSection() )
170
170
 
171
- # Returns the name of the active component on the main controller
171
+ # Returns the name of the active component on the main controller
172
172
  activeSection: ()->
173
173
  @get("active_section")
174
174
 
@@ -216,7 +216,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
216
216
  return @components[0] if @useController is true
217
217
  Luca.cache('main_controller')
218
218
 
219
- #
219
+ #
220
220
  keyHandler: (e)->
221
221
  return unless e and @keyEvents
222
222
 
@@ -256,7 +256,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
256
256
  type = component.type || component.type
257
257
  if type.match(/controller$/)
258
258
  component.bind "after:card:switch", (previous,current)=>
259
- @state.set(active_sub_section:current.name)
259
+ @state.set(active_sub_section:current.name)
260
260
  app.trigger "sub:page:change"
261
261
 
262
262
  setupMainController: ()->
@@ -275,9 +275,9 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
275
275
  return unless @useCollectionManager is true
276
276
 
277
277
  return if @collectionManager? and @collectionManager?.get?
278
-
278
+
279
279
  if _.isString( @collectionManagerClass )
280
- @collectionManagerClass = Luca.util.resolve( @collectionManagerClass )
280
+ @collectionManagerClass = Luca.util.resolve( @collectionManagerClass )
281
281
 
282
282
  collectionManagerOptions = @collectionManagerOptions || {}
283
283
 
@@ -291,9 +291,9 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
291
291
 
292
292
  # if the collection manager property is a string, then it is a
293
293
  # reference to a name of a collection manager to use. so let's
294
- # stash it
294
+ # stash it
295
295
  if _.isString(@collectionManager)
296
- collectionManagerOptions =
296
+ collectionManagerOptions =
297
297
  name: @collectionManager
298
298
 
299
299
  # let's try and get the collection manager by name if we can
@@ -301,7 +301,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
301
301
 
302
302
  # if we can't, then we will have to create one ourselves
303
303
  unless _.isFunction(@collectionManager?.get)
304
- @collectionManager = new @collectionManagerClass( collectionManagerOptions )
304
+ @collectionManager = new @collectionManagerClass( collectionManagerOptions )
305
305
 
306
306
  setupRouter: ()->
307
307
  app = @
@@ -315,7 +315,7 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
315
315
  # you can control which by setting the @startHistoryOn property
316
316
  if @router and @autoStartHistory
317
317
  @autoStartHistory = "before:render" if @autoStartHistory is true
318
- @defer(startHistory, false).until(@, @autoStartHistory)
318
+ @defer( Luca.util.startHistory, false).until(@, @autoStartHistory)
319
319
 
320
320
  setupKeyHandler: ()->
321
321
  return unless @keyEvents
@@ -330,3 +330,5 @@ _.def('Luca.Application').extends('Luca.containers.Viewport').with
330
330
  for keyEvent in (@keypressEvents || ["keydown"])
331
331
  $( document ).on( keyEvent, handler )
332
332
 
333
+ Luca.util.startHistory = ()->
334
+ Backbone.history.start()
@@ -1,15 +1,17 @@
1
1
  _.def('Luca.components.Toolbar').extends('Luca.core.Container').with
2
2
 
3
+ toolbar = Luca.register "Luca.components.Toolbar"
4
+ toolbar.extends "Luca.core.Container"
5
+
6
+ toolbar.defines
3
7
  className: 'luca-ui-toolbar toolbar'
4
8
 
5
9
  position: 'bottom'
6
10
 
7
- initialize: (@options={})->
8
- Luca.core.Container::initialize.apply @, arguments
9
-
10
11
  prepareComponents: ()->
11
12
  _( @components ).each (component)=>
12
13
  component.container = @$el
13
14
 
14
15
  render: ()->
15
- $(@container).append(@el)
16
+ $(@container).append(@el)
17
+ @
@@ -3,8 +3,10 @@
3
3
  # if you want to. Default implementation uses twitter bootstrap modal and
4
4
  # progress bar (http://twitter.github.com/bootstrap/). You template
5
5
  # should contain `progress`, `bar` and `message` classes
6
- _.def('Luca.components.CollectionLoaderView').extends('Luca.components.Template').with
6
+ loaderView = Luca.register "Luca.components.CollectionLoaderView"
7
+ loaderView.extends "Luca.View"
7
8
 
9
+ loaderView.defines
8
10
  className: 'luca-ui-collection-loader-view'
9
11
 
10
12
  template: "components/collection_loader_view"
@@ -1,4 +1,4 @@
1
- collectionView = Luca.define "Luca.components.CollectionView"
1
+ collectionView = Luca.register "Luca.components.CollectionView"
2
2
  # The CollectionView facilitates the rendering of a Collection
3
3
  # of models into a group of many rendered templates
4
4
  #
@@ -16,17 +16,16 @@ collectionView = Luca.define "Luca.components.CollectionView"
16
16
  #
17
17
  collectionView.extends "Luca.components.Panel"
18
18
 
19
- collectionView.behavesAs "LoadMaskable",
20
- "Filterable",
21
- "Paginatable"
19
+ collectionView.mixesIn "LoadMaskable",
20
+ "Filterable",
21
+ "Paginatable"
22
22
 
23
- collectionView.triggers "before:refresh",
24
- "after:refresh",
25
- "refresh",
26
- "empty:results"
27
-
28
- collectionView.defaults
23
+ collectionView.triggers "before:refresh",
24
+ "after:refresh",
25
+ "refresh",
26
+ "empty:results"
29
27
 
28
+ collectionView.defines
30
29
  tagName: "ol"
31
30
 
32
31
  className: "luca-ui-collection-view"
@@ -43,11 +42,13 @@ collectionView.defaults
43
42
 
44
43
  itemClassName: 'collection-item'
45
44
 
45
+
46
46
  initialize: (@options={})->
47
47
  _.extend(@, @options)
48
48
 
49
49
  _.bindAll @, "refresh"
50
50
 
51
+
51
52
  unless @collection? or @options.collection
52
53
  console.log "Error on initialize of collection view", @
53
54
  throw "Collection Views must specify a collection"
@@ -55,12 +56,14 @@ collectionView.defaults
55
56
  unless @itemTemplate? || @itemRenderer? || @itemProperty?
56
57
  throw "Collection Views must specify an item template or item renderer function"
57
58
 
58
- Luca.components.Panel::initialize.apply(@, arguments)
59
-
60
- if _.isString(@collection) and Luca.CollectionManager.get()
61
- @collection = Luca.CollectionManager.get().getOrCreate(@collection)
59
+ if _.isString(@collection)
60
+ if Luca.CollectionManager.get()
61
+ @collection = Luca.CollectionManager.get().getOrCreate(@collection)
62
+ else
63
+ console.log "String Collection but no collection manager"
62
64
 
63
65
  unless Luca.isBackboneCollection(@collection)
66
+ console.log "Missing Collection on #{ @name || @cid }", @, @collection
64
67
  throw "Collection Views must have a valid backbone collection"
65
68
 
66
69
  @collection.on "before:fetch", ()=>
@@ -79,12 +82,14 @@ collectionView.defaults
79
82
  if @observeChanges is true
80
83
  @collection.on "change", @refreshModel, @
81
84
 
85
+ Luca.components.Panel::initialize.apply(@, arguments)
86
+
82
87
  unless @autoRefreshOnModelsPresent is false
83
88
  @defer ()=>
84
89
  @refresh() if @collection.length > 0
85
90
  .until("after:render")
86
91
 
87
- @on "collection:change", @refresh, @
92
+ @on "refresh", @refresh, @
88
93
 
89
94
  attributesForItem: (item, model)->
90
95
  _.extend {}, class: @itemClassName, "data-index": item.index, "data-model-id": item.model.get('id')
@@ -116,15 +121,32 @@ collectionView.defaults
116
121
  getCollection: ()->
117
122
  @collection
118
123
 
124
+ loadModels: (models=[], options={})->
125
+ @getCollection()?.reset(models, options)
126
+
127
+ applyQuery: (query={},queryOptions={})->
128
+ @query = query
129
+ @queryOptions = queryOptions
130
+ @refresh()
131
+ @
132
+
119
133
  # Private: returns the query that is applied to the underlying collection.
120
134
  # accepts the same options as Luca.Collection.query's initial query option.
121
135
  getQuery: ()->
122
- @query ||= {}
136
+ query = @query ||= {}
137
+ for querySource in _( @querySources || [] ).compact()
138
+ query = _.extend(query, (querySource()||{}) )
139
+ query
123
140
 
124
141
  # Private: returns the query that is applied to the underlying collection.
125
142
  # accepts the same options as Luca.Collection.query's initial query option.
126
143
  getQueryOptions: ()->
127
- @queryOptions ||= {}
144
+ options = @queryOptions ||= {}
145
+
146
+ for optionSource in _( @optionsSources || [] ).compact()
147
+ options = _.extend(options, (optionSource()||{}) )
148
+
149
+ options
128
150
 
129
151
  # Private: returns the models to be rendered. If the underlying collection
130
152
  # responds to @query() then it will use that interface.
@@ -145,12 +167,12 @@ collectionView.defaults
145
167
  @locateItemElement(model.get('id')).empty().append( @contentForItem({model,index}, model) )
146
168
  @trigger("model:refreshed", index, model)
147
169
 
148
- refresh: (query,options)->
149
- query ||= @getQuery()
170
+ refresh: (query,options,models)->
171
+ query ||= @getQuery()
150
172
  options ||= @getQueryOptions()
173
+ models ||= @getModels(query, options)
151
174
 
152
175
  @$bodyEl().empty()
153
- models = @getModels(query, options)
154
176
 
155
177
  @trigger("before:refresh", models, query, options)
156
178
 
@@ -158,7 +180,6 @@ collectionView.defaults
158
180
  @trigger("empty:results")
159
181
 
160
182
  index = 0
161
-
162
183
  for model in models
163
184
  @$append @makeItem(model, index++)
164
185
 
@@ -1,5 +1,7 @@
1
- _.def('Luca.components.Controller').extends('Luca.containers.CardView').with
1
+ controller = Luca.register "Luca.components.Controller"
2
+ controller.extends "Luca.containers.CardView"
2
3
 
4
+ controller.defines
3
5
  additionalClassNames:['luca-ui-controller']
4
6
 
5
7
  activeAttribute: "active-section"
@@ -1,18 +1,23 @@
1
- _.def('Luca.fields.ButtonField').extends('Luca.core.Field').with
1
+ buttonField = Luca.register "Luca.fields.ButtonField"
2
2
 
3
- readOnly: true
3
+ buttonField.extends "Luca.core.Field"
4
4
 
5
- events:
6
- "click input" : "click_handler"
7
-
8
- hooks:[
9
- "button:click"
10
- ]
5
+ buttonField.triggers "button:click"
11
6
 
12
- className: 'luca-ui-field luca-ui-button-field'
7
+ buttonField.publicConfiguration
8
+ readOnly: true
9
+ input_value: undefined
10
+ input_type: "button"
11
+ icon_class: undefined
12
+ input_name: undefined
13
+ white: undefined
13
14
 
14
- template: 'fields/button_field'
15
+ buttonField.privateConfiguration
16
+ template: "fields/button_field"
17
+ events:
18
+ "click input" : "click_handler"
15
19
 
20
+ buttonField.privateInterface
16
21
  click_handler: (e)->
17
22
  me = my = $( e.currentTarget )
18
23
  @trigger "button:click"
@@ -29,10 +34,12 @@ _.def('Luca.fields.ButtonField').extends('Luca.core.Field').with
29
34
  @input_id ||= _.uniqueId('button')
30
35
  @input_name ||= @name ||= @input_id
31
36
  @input_value ||= @label ||= @text
32
- @input_type ||= "button"
33
37
  @input_class ||= @class
34
38
  @icon_class ||= ""
35
39
  @icon_class = "icon-#{ @icon_class }" if @icon_class.length and !@icon_class.match(/^icon-/)
36
40
  @icon_class += " icon-white" if @white
37
41
 
38
- setValue: ()-> true
42
+ setValue: ()-> true
43
+
44
+ buttonField.defines
45
+ version: 1
@@ -1,6 +1,9 @@
1
1
  make = Luca.View::make
2
2
 
3
- _.def('Luca.fields.CheckboxArray').extends('Luca.core.Field').with
3
+ checkboxArray = Luca.register "Luca.fields.CheckboxArray"
4
+ checkboxArray.extends "Luca.core.Field"
5
+
6
+ checkboxArray.defines
4
7
  version: 2
5
8
 
6
9
  template: "fields/checkbox_array"
@@ -14,7 +17,7 @@ _.def('Luca.fields.CheckboxArray').extends('Luca.core.Field').with
14
17
 
15
18
  initialize: (@options={})->
16
19
  _.extend @, @options
17
- _.extend @, Luca.modules.Deferrable
20
+ _.extend @, Luca.concerns.Deferrable
18
21
  _.bindAll @, "renderCheckboxes", "clickHandler", "checkSelected"
19
22
 
20
23
  Luca.core.Field::initialize.apply @, arguments
@@ -33,6 +36,9 @@ _.def('Luca.fields.CheckboxArray').extends('Luca.core.Field').with
33
36
 
34
37
  cbArray = @
35
38
 
39
+ unless Luca.isBackboneCollection(@collection)
40
+ throw "Checkbox Array Fields must specify a @collection property"
41
+
36
42
  if @collection.length > 0
37
43
  @renderCheckboxes()
38
44
  else
@@ -1,13 +1,20 @@
1
- _.def('Luca.fields.CheckboxField').extends('Luca.core.Field').with
1
+ checkboxField = Luca.register "Luca.fields.CheckboxField"
2
2
 
3
- events:
4
- "change input" : "change_handler"
3
+ checkboxField.extends "Luca.core.Field"
5
4
 
6
- className: 'luca-ui-checkbox-field luca-ui-field'
7
- template: 'fields/checkbox_field'
8
- hooks: ["checked","unchecked"]
5
+ checkboxField.triggers "checked",
6
+ "unchecked"
7
+
8
+ checkboxField.publicConfiguration
9
9
  send_blanks: true
10
+ input_value: 1
10
11
 
12
+ checkboxField.privateConfiguration
13
+ template: 'fields/checkbox_field'
14
+ events:
15
+ "change input" : "change_handler"
16
+
17
+ checkboxField.privateInterface
11
18
  change_handler: (e)->
12
19
  me = my = $(e.target)
13
20
 
@@ -24,14 +31,16 @@ _.def('Luca.fields.CheckboxField').extends('Luca.core.Field').with
24
31
 
25
32
  Luca.core.Field::initialize.apply @, arguments
26
33
 
27
- afterInitialize: ()->
28
34
  @input_id ||= _.uniqueId('field')
29
35
  @input_name ||= @name
30
- @input_value ||= 1
31
36
  @label ||= @name
32
37
 
38
+ checkboxField.publicInterface
33
39
  setValue: (checked)->
34
40
  @getInputElement().attr('checked', checked)
35
41
 
36
42
  getValue:()->
37
- @getInputElement().is(":checked")
43
+ @getInputElement().is(":checked")
44
+
45
+ checkboxField.defines
46
+ version: 1
@@ -1,4 +1,8 @@
1
- _.def('Luca.fields.FileUploadField').extends('Luca.core.Field').with
1
+ fileUpload = Luca.register "Luca.fields.FileUploadField"
2
+ fileUpload.extends "Luca.core.Field"
3
+
4
+ fileUpload.defines
5
+ version: 1
2
6
 
3
7
  template: 'fields/file_upload_field'
4
8
 
@@ -1,5 +1,7 @@
1
- _.def('Luca.fields.HiddenField').extends('Luca.core.Field').with
1
+ hiddenField = Luca.register "Luca.fields.HiddenField"
2
+ hiddenField.extends "Luca.core.Field"
2
3
 
4
+ hiddenField.defines
3
5
  template: 'fields/hidden_field'
4
6
 
5
7
  afterInitialize: ()->
@@ -1,6 +1,7 @@
1
- _.def("Luca.components.LabelField").extends("Luca.core.Field").with
2
- className: "luca-ui-field luca-ui-label-field"
3
-
1
+ labelField = Luca.register "Luca.components.LabelField"
2
+ labelField.extends "Luca.core.Field"
3
+
4
+ labelField.defines
4
5
  formatter: (value)->
5
6
  value ||= @getValue()
6
7
  _.str.titleize( value )
@@ -1,13 +1,12 @@
1
- _.def('Luca.fields.SelectField').extends('Luca.core.Field').with
1
+ selectField = Luca.register "Luca.fields.SelectField"
2
2
 
3
- events:
4
- "change select" : "change_handler"
3
+ selectField.extends "Luca.core.Field"
5
4
 
6
- hooks:[
7
- "after:select"
8
- ]
5
+ selectField.triggers "after:select"
9
6
 
10
- className: 'luca-ui-select-field luca-ui-field'
7
+ selectField.defines
8
+ events:
9
+ "change select" : "change_handler"
11
10
 
12
11
  template: "fields/select_field"
13
12
 
@@ -19,7 +18,7 @@ _.def('Luca.fields.SelectField').extends('Luca.core.Field').with
19
18
 
20
19
  initialize: (@options={})->
21
20
  _.extend @, @options
22
- _.extend @, Luca.modules.Deferrable
21
+ _.extend @, Luca.concerns.Deferrable
23
22
  _.bindAll @, "change_handler", "populateOptions", "beforeFetch"
24
23
 
25
24
  Luca.core.Field::initialize.apply @, arguments
@@ -1,5 +1,7 @@
1
+ textField = Luca.register 'Luca.fields.TextField'
2
+ textField.extends 'Luca.core.Field'
1
3
 
2
- _.def('Luca.fields.TextField').extends('Luca.core.Field').with
4
+ textField.defines
3
5
  events:
4
6
  "blur input" : "blur_handler"
5
7
  "focus input" : "focus_handler"
@@ -1,6 +1,8 @@
1
- _.def('Luca.fields.TypeAheadField').extends('Luca.fields.TextField').with
2
- className: 'luca-ui-field'
1
+ typeAheadField = Luca.register "Luca.fields.TypeAheadField"
2
+ typeAheadField.extends "Luca.fields.TextField"
3
3
 
4
+
5
+ typeAheadField.defines
4
6
  getSource: ()->
5
7
  Luca.util.read(@source) || []
6
8
 
@@ -1,5 +1,7 @@
1
- _.def('Luca.components.FormButtonToolbar').extends('Luca.components.Toolbar').with
1
+ toolbar = Luca.register "Luca.components.FormButtonToolbar"
2
+ toolbar.extends "Luca.components.Toolbar"
2
3
 
4
+ toolbar.defines
3
5
  className: 'luca-ui-form-toolbar form-actions'
4
6
 
5
7
  position: 'bottom'
@@ -8,6 +10,7 @@ _.def('Luca.components.FormButtonToolbar').extends('Luca.components.Toolbar').wi
8
10
 
9
11
  render: ()->
10
12
  $(@container).append(@el)
13
+ @
11
14
 
12
15
  initialize: (@options={})->
13
16
  Luca.components.Toolbar.prototype.initialize.apply @, arguments