lanes 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (54) hide show
  1. checksums.yaml +4 -4
  2. data/client/lanes/components/ChoicesInput.coffee +1 -1
  3. data/client/lanes/components/grid/Grid.coffee +4 -4
  4. data/client/lanes/components/grid/PopOverEditor.coffee +1 -1
  5. data/client/lanes/components/popover/PopOver.coffee +3 -3
  6. data/client/lanes/components/record_finder/RecordFinder.coffee +4 -4
  7. data/client/lanes/components/select_field/SelectField.coffee +1 -1
  8. data/client/lanes/extension/Base.coffee +1 -1
  9. data/client/lanes/extension/Extensions.coffee +3 -3
  10. data/client/lanes/extension/GlAccounts.coffee +2 -2
  11. data/client/lanes/lib/namespace.coffee +1 -1
  12. data/client/lanes/minimal.js +1 -1
  13. data/client/lanes/{data/Model.coffee → models/Base.coffee} +29 -47
  14. data/client/lanes/models/Bootstrap.coffee +8 -0
  15. data/client/lanes/{data → models}/ChangeSet.coffee +3 -3
  16. data/client/lanes/{data → models}/Collection.coffee +20 -40
  17. data/client/lanes/{data → models}/Config.coffee +2 -2
  18. data/client/lanes/{data → models}/PubSub.coffee +4 -3
  19. data/client/lanes/{data → models}/Query.coffee +7 -7
  20. data/client/lanes/{data → models}/Screens.coffee +12 -12
  21. data/client/lanes/models/Sync.coffee +86 -0
  22. data/client/lanes/{data → models}/User.coffee +8 -8
  23. data/client/lanes/{data → models}/index.js +1 -1
  24. data/client/lanes/{data → models}/mixins/HasCodeField.coffee +2 -2
  25. data/client/lanes/screens/Base.coffee +1 -1
  26. data/client/lanes/screens/ChangeListener.coffee +1 -1
  27. data/client/lanes/screens/Instance.coffee +3 -3
  28. data/client/lanes/screens/screen-definitions.js.erb +2 -2
  29. data/client/lanes/views/Base.coffee +10 -10
  30. data/client/lanes/views/ModelObserver.coffee +1 -1
  31. data/client/lanes/views/PubSub.coffee +4 -4
  32. data/client/lanes/views/Viewport.coffee +1 -1
  33. data/client/lanes/workspace/ActiveScreensSwitcher.coffee +1 -1
  34. data/client/lanes/workspace/Pages.coffee +2 -2
  35. data/client/lanes/workspace/ScreensMenu.coffee +1 -1
  36. data/lanes.gemspec +2 -1
  37. data/lib/lanes/command/generate_model.rb +6 -7
  38. data/lib/lanes/command/named_command.rb +1 -1
  39. data/lib/lanes/command/templates/client/index.js +1 -1
  40. data/lib/lanes/command/templates/client/{data → models}/Model.coffee +3 -7
  41. data/lib/lanes/command/templates/client/views/View.coffee +1 -1
  42. data/lib/lanes/command/templates/spec/client/models/ModelSpec.coffee +5 -0
  43. data/lib/lanes/command/update_model.rb +4 -11
  44. data/lib/lanes/command.rb +4 -3
  45. data/lib/lanes/version.rb +1 -1
  46. data/spec/helpers/lanes-helpers.coffee +5 -4
  47. data/spec/lanes/{data/ModelSpec.coffee → models/BaseSpec.coffee} +23 -11
  48. data/spec/lanes/{data → models}/PubSubSpec.coffee +6 -6
  49. data/views/specs.erb +1 -4
  50. metadata +19 -20
  51. data/client/lanes/data/Bootstrap.coffee +0 -8
  52. data/client/lanes/data/Sync.coffee +0 -63
  53. data/lib/lanes/command/templates/spec/client/data/ModelSpec.coffee +0 -5
  54. data/lib/lanes/spec_asset_expander.rb +0 -43
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4e6cb1567e7230eb1c9320af1e79312501b03f6a
4
- data.tar.gz: 075ddb6c5d12cb8006bb6b0a0f6b52350f9bd736
3
+ metadata.gz: 0b20837325a4feed75930d806fcc0ab5a8e914d3
4
+ data.tar.gz: 42515ab0003321f83e4946766645550b706deea5
5
5
  SHA512:
6
- metadata.gz: 40c369f55a08e182b116d4a6baf22612a1385104ebb961967811c2639cea03ebb0255e222e7e820a53334f50e42f3271a49147e2866f09f15908adc9d206cf76
7
- data.tar.gz: d33486e07c3b727ccf22160d161b87860eb6edccfb39e1b82d4fa23304c3e0c64da50d87995481bf2048c7054a4f1427a1614d82a6bce531e1c23f8a8c11c45b
6
+ metadata.gz: 70dc86cd4d7e8c44aa1536ad7301672ccb75e0b1b0525bb7f5bfc07fade7de185644190ea99358df5e6d01200e1b7605a5cad2c2b324270a7efc498f2c9f2e43
7
+ data.tar.gz: 9fd2a37a119aaadfe4dda3f22fa2cd4882d2f79e19eed6e1a96469f8060ea77a579e3c38fd6dcf5dfc86552a34128bbc901f88a7dc94a3c8e15f01968646b69e
@@ -21,7 +21,7 @@ class Lanes.Component.ChoicesInput extends Lanes.Component.Base
21
21
 
22
22
  initialize: (options={})->
23
23
  if @association
24
- collection = Lanes.Data[@association.model].sharedCollection()
24
+ collection = Lanes.Models[@association.model].sharedCollection()
25
25
  collection.fetch().then (m)=>
26
26
  @selections = m
27
27
  this.on('change:model', this.onModelChange )
@@ -1,4 +1,4 @@
1
- # DataTables class modifications
1
+ # ModelsTables class modifications
2
2
  _.extend( Lanes.$.fn.dataTableExt.oStdClasses,{
3
3
  sTable: "table table-striped"
4
4
  sWrapper: "dataTables_wrapper form-inline"
@@ -18,7 +18,7 @@ class Lanes.Components.Grid extends Lanes.Components.Base
18
18
  'order.dt table': 'onSort'
19
19
 
20
20
  template: 'grid/template'
21
- templateData: ->
21
+ templateModels: ->
22
22
  data = { grid: this, buttons: ['refresh'] }
23
23
  data['buttons'].push('create') if @add_records
24
24
  data['buttons'].push('delete') if @delete_records
@@ -161,7 +161,7 @@ class Lanes.Components.Grid extends Lanes.Components.Base
161
161
  # columnDefs: @column_definitions
162
162
  ajax:
163
163
  url: @record_query.url + ".json"
164
- data: (d)=>@buildData(d)
164
+ data: (d)=>@buildModels(d)
165
165
  dataSrc: (d)->
166
166
  d.recordsFiltered = d.recordsTotal = d.total
167
167
  row.DT_RowId = row.shift() for row in d.data
@@ -176,7 +176,7 @@ class Lanes.Components.Grid extends Lanes.Components.Base
176
176
  this.delayedGridConfiguration()
177
177
  this
178
178
 
179
- buildData: (d)->
179
+ buildModels: (d)->
180
180
  params = { o: {}, s: d.start, l: d.length||100, df:'array', f: ['id'].concat(_.pluck(@column_definitions, 'field')) }
181
181
  if ! _.isEmpty( query = @record_query.asParams() )
182
182
  params['q']=query
@@ -1,7 +1,7 @@
1
1
  class Lanes.Components.Grid.PopOverEditor extends Lanes.Components.Grid.Editor
2
2
 
3
3
  template: 'grid/popover-editor'
4
- templateData: ->
4
+ templateModels: ->
5
5
  { columns: this.grid.column_definitions }
6
6
 
7
7
  session:
@@ -8,20 +8,20 @@ class Lanes.Components.PopOver extends Lanes.Components.Base
8
8
  title: 'string'
9
9
  content: 'any'
10
10
  template: 'string'
11
- templateData: 'object'
11
+ templateModels: 'object'
12
12
  placement: { type: 'string', default: "right" }
13
13
  destroyAfterHide: [ 'boolean', true, false ]
14
14
 
15
15
  derived:
16
16
  options:
17
- deps: ['title','content','template','templateData'], fn:->
17
+ deps: ['title','content','template','templateModels'], fn:->
18
18
  content = if this.template then this.renderTemplate() else this.content
19
19
  { title: @title, content: content, html: true, placement: "auto #{@placement}" }
20
20
 
21
21
  renderTemplate: ->
22
22
  template = Lanes.Templates.find(this.template)
23
23
  if template
24
- template(this.templateData)
24
+ template(this.templateModels)
25
25
  else
26
26
  Lanes.warn "PopOver Template #{this.template} was not found"
27
27
 
@@ -103,7 +103,7 @@ Lanes.Component.ModalDialog.extend(FinderDialog)
103
103
  class RecordFinder
104
104
  constructor: -> super
105
105
  template: 'record-finder/field'
106
- templateData: -> { field_name: @record_query.initial_field }
106
+ templateModels: -> { field_name: @record_query.initial_field }
107
107
 
108
108
  events:
109
109
  "keyup .record-finder-query-string": "onKey"
@@ -115,7 +115,7 @@ class RecordFinder
115
115
  query_field: [ 'string', false, 'code' ]
116
116
 
117
117
  initialize:(options)->
118
- @record_query = new Lanes.Data.Query(fields: options.fields, collection_class: options.query_using)
118
+ @record_query = new Lanes.Models.Query(fields: options.fields, collection_class: options.query_using)
119
119
 
120
120
  displayFinder: ->
121
121
  finder = new FinderDialog( title: @title, record_query: @record_query )
@@ -132,8 +132,8 @@ class RecordFinder
132
132
  qf=this.$('.record-finder-query-string')
133
133
  if 13 == ev.keyCode
134
134
  this.runQuery(ev)
135
- else if qf.val().match( Lanes.Data.mixins.Lanes.sCodeField.INVALID )
136
- qf.val( qf.val().replace( Lanes.Data.mixins.Lanes.sCodeField.INVALID, '' ) )
135
+ else if qf.val().match( Lanes.Models.mixins.Lanes.sCodeField.INVALID )
136
+ qf.val( qf.val().replace( Lanes.Models.mixins.Lanes.sCodeField.INVALID, '' ) )
137
137
 
138
138
  runQuery: (ev)->
139
139
  code = this.$(ev.target).val()
@@ -44,7 +44,7 @@ class Lanes.Components.SelectField extends Lanes.Components.Base
44
44
 
45
45
  initialize: (options={})->
46
46
  if @association
47
- collection = Lanes.Data[@association.model].sharedCollection()
47
+ collection = Lanes.Models[@association.model].sharedCollection()
48
48
  collection.fetch().then (m)=>
49
49
  @selections = m
50
50
  this.on('change:model', this.onModelChange )
@@ -1,6 +1,6 @@
1
1
  class BaseExtension
2
2
 
3
- setBootstrapData: (data)->
3
+ setBootstrapModels: (data)->
4
4
 
5
5
  @extended:(klass)->
6
6
  Lanes.Extensions.register(klass)
@@ -10,12 +10,12 @@ Lanes.Extensions = {
10
10
  fireOnAvailable: (application)->
11
11
  instance.onAvailable?(application) for identifier, instance of @instances
12
12
 
13
- setBootstrapData: (bootstrap_data)->
13
+ setBootstrapModels: (bootstrap_data)->
14
14
  for identifier,data of bootstrap_data
15
- instance?.setBootstrapData?(data)
15
+ instance?.setBootstrapModels?(data)
16
16
 
17
17
  makeNamespace: (identifier)->
18
- for ns in ['Data','Views','Controllers','Screens']
18
+ for ns in ['Models','Views','Controllers','Screens']
19
19
  Lanes.namespace("#{identifier}.#{ns}")
20
20
 
21
21
 
@@ -2,8 +2,8 @@ class GlAccounts
2
2
 
3
3
  identifier: 'gl_accounts'
4
4
 
5
- setBootstrapData: (data)->
6
- Lanes.Data.GlAccount.sharedCollection().reset(data)
5
+ setBootstrapModels: (data)->
6
+ Lanes.Models.GlAccount.sharedCollection().reset(data)
7
7
 
8
8
 
9
9
  Lanes.Extension.Base.extend(GlAccounts)
@@ -8,5 +8,5 @@ Lanes.namespace = (target, name, block) ->
8
8
  target = target[item] or= {} for item in name.split '.'
9
9
  block( target, top ) if typeof block == 'function'
10
10
 
11
- for ns in ['Components', 'Data.Mixins', 'Views.Mixins', 'Screens', 'Vendor', 'Templates', 'Extensions','lib']
11
+ for ns in ['Components', 'Models.Mixins', 'Views.Mixins', 'Screens', 'Vendor', 'Templates', 'Extensions','lib']
12
12
  Lanes.namespace(ns)
@@ -2,7 +2,7 @@
2
2
  //= require ./vendor/modern-stack
3
3
  //= require ./lib
4
4
  //= require ./extension
5
- //= require ./data
5
+ //= require ./models
6
6
  //= require ./plugins
7
7
  //= require ./views
8
8
  //= require ./screens
@@ -38,8 +38,8 @@ class AssocationMap
38
38
  constructor: (@klass)->
39
39
  @klass::derived ||= {}
40
40
  @definitions = @klass::associations
41
- @definitions['created_by'] ||= { model: 'Lanes.Data.User', readOnly: true }
42
- @definitions['updated_by'] ||= { model: 'Lanes.Data.User', readOnly: true }
41
+ @definitions['created_by'] ||= { model: 'Lanes.Models.User', readOnly: true }
42
+ @definitions['updated_by'] ||= { model: 'Lanes.Models.User', readOnly: true }
43
43
  for name, options of @definitions
44
44
  @klass::derived[name] = this.derivedDefinition(name,options)
45
45
 
@@ -47,7 +47,7 @@ class AssocationMap
47
47
  derivedDefinition: (name,definition)->
48
48
  findAssocationClass = ->
49
49
  object = definition.model || definition.collection
50
- if _.isObject(object) then object else Lanes.getPath( object, "Lanes.Data")
50
+ if _.isObject(object) then object else Lanes.getPath( object, "Lanes.Models")
51
51
  target_klass = findAssocationClass()
52
52
  # will be called in the scope of the model
53
53
  createAssocation = ->
@@ -82,36 +82,9 @@ class AssocationMap
82
82
  list.push(name)
83
83
  list
84
84
 
85
- urlError = ->
86
- throw new Error('A "url" property or function must be specified for Model or Collection')
87
-
88
- copyServerResp = (record,resp)->
89
- record.errors = resp?.errors
90
- record.lastServerMessage = resp?.message
91
- { record: record, response: resp }
92
-
93
- # Wraps a sync request's error and success functions
94
- # Copies any errors onto the model and sets it's data on success
95
- wrapRequest = (record, options)->
96
- error = options.error
97
- success = options.success
98
- options.promise = new _.Promise( (resolve,reject)->
99
- options.resolvePromise = resolve
100
- options.rejectPromise = reject
101
- )
102
- options.error = (reply, resp, req)->
103
- options.rejectPromise( copyServerResp(record,resp.responseJSON || {error: resp.responseText}) )
104
- error?.apply(options.scope, arguments)
105
-
106
- options.success = (reply,resp,req)->
107
- record.setFromResponse( resp.data ) if resp?.data?
108
- options.resolvePromise( copyServerResp(record,resp) )
109
- success?.apply(options.scope, arguments)
110
- options
111
-
112
85
 
113
86
  # Da Model. Handles all things dataish
114
- class DataModel
87
+ class BaseModel
115
88
  isModel: true
116
89
  session:
117
90
  errors: 'object'
@@ -168,17 +141,17 @@ class DataModel
168
141
 
169
142
  # used by PubSub to record a remote change to the model
170
143
  addChangeSet: (change)->
171
- this.changes ||= new Lanes.Data.ChangeSetCollection( parent: this )
144
+ this.changes ||= new Lanes.Models.ChangeSetCollection( parent: this )
172
145
  change.record = this
173
146
  change = this.changes.add(change)
174
147
  this.set( change.value() )
175
148
 
176
149
  urlRoot: ->
177
- Lanes.Data.Config.api_path + '/' + _.result(this,'api_path')
150
+ Lanes.Models.Config.api_path + '/' + _.result(this,'api_path')
178
151
 
179
152
  # Default URL for the model's representation on the server
180
153
  url: ->
181
- base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || urlError();
154
+ base = _.result(this, 'urlRoot') || _.result(this.collection, 'url') || Lanes.Models.Sync.urlError();
182
155
  if this.isNew() then return base;
183
156
  if base.charAt(base.length - 1) != '/'
184
157
  base += "/"
@@ -213,7 +186,7 @@ class DataModel
213
186
  # When not found, it will create a new record and return it.
214
187
  # The newly created record will not be stored, in PubSub map, only records bound to a view are stored
215
188
  @findOrCreate: (attrs, options={})->
216
- if attrs.id && ( record = Lanes.Data.PubSub.instanceFor(this, attrs.id) )
189
+ if attrs.id && ( record = Lanes.Models.PubSub.instanceFor(this, attrs.id) )
217
190
  record.set(attrs)
218
191
  else
219
192
  new this(attrs,options)
@@ -231,9 +204,13 @@ class DataModel
231
204
  this.associations.set(this,attrs) if this.associations
232
205
  this
233
206
 
207
+ where: (query,options)->
208
+ collection = new @constructor.Collection
209
+ collection.fetch( _.extend({query: query}, options) )
210
+ collection
211
+
234
212
  # Sets the attribute data from a server respose
235
- setFromResponse: (data)->
236
- return unless data
213
+ setFromServer: (data,options)->
237
214
  this.set( if _.isArray(data) then data[0] else data )
238
215
  this.changeMonitor.reset()
239
216
 
@@ -244,7 +221,7 @@ class DataModel
244
221
  options = _.clone(options)
245
222
 
246
223
  options.saving=true
247
- handlers = wrapRequest(this,options)
224
+ handlers = Lanes.Models.Sync.wrapRequest(this,options)
248
225
 
249
226
  method = if this.isNew()
250
227
  'create'
@@ -260,7 +237,7 @@ class DataModel
260
237
  # triggering a `"change"` event.
261
238
  fetch: (options={}) ->
262
239
  options = _.clone(options)
263
- handlers = wrapRequest(this,options)
240
+ handlers = Lanes.Models.Sync.wrapRequest(this,options)
264
241
  _.extend(options,{limit:1,ignoreUnsaved:true})
265
242
 
266
243
  this.sync('read', this, options)
@@ -269,7 +246,7 @@ class DataModel
269
246
  # Removes the model's record from the server (if it is persistent)
270
247
  # and then fires the "destroy" event
271
248
  destroy: (options={})->
272
- handlers = wrapRequest(this,options)
249
+ handlers = Lanes.Models.Sync.wrapRequest(this,options)
273
250
  model = this
274
251
  success = options.success
275
252
  options.success = (reply, msg, options)->
@@ -283,7 +260,7 @@ class DataModel
283
260
  handlers.promise
284
261
 
285
262
  # returns any attributes that have been set and not saved
286
- unsavedData: ->
263
+ unsavedModels: ->
287
264
  attrs = if this.isNew() then {} else { id: this.getId() }
288
265
  _.extend(attrs, _.pick( this.getAttributes(props:true, true),
289
266
  @changeMonitor.changedAttributes() ) )
@@ -295,7 +272,7 @@ class DataModel
295
272
  if options.saveAll
296
273
  data = this.getAttributes(props:true, true)
297
274
  else
298
- data = this.unsavedData()
275
+ data = this.unsavedModels()
299
276
  _.extend(data, this.associations.dataForSave(this, options)) if this.associations
300
277
  data
301
278
 
@@ -318,7 +295,7 @@ class DataModel
318
295
  else
319
296
  ''
320
297
  # Use Sync directly
321
- sync: Lanes.Data.Sync
298
+ sync: Lanes.Models.Sync.perform
322
299
 
323
300
  # When the model is extended it auto-creates the created_at and updated_at
324
301
  # and sets up the AssociationMap
@@ -332,23 +309,28 @@ class DataModel
332
309
  if klass::associations
333
310
  klass::associations = new AssocationMap(klass)
334
311
 
312
+ unless klass.Collection
313
+ class DefaultCollection
314
+ constructor: -> super
315
+ model: klass
316
+ klass.Collection = Lanes.Models.Collection.extend(DefaultCollection)
335
317
 
336
- Lanes.Data.Model = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.State, DataModel )
318
+ Lanes.Models.Base = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.State, BaseModel )
337
319
 
338
320
 
339
321
 
340
322
  # ------------------------------------------------------------------ #
341
323
  # The BasicModel is just a very thin layer over State #
342
324
  # ------------------------------------------------------------------ #
343
- class BasicModel #
325
+ class BasicModel
344
326
  constructor: -> super
345
327
  isPersistent: -> false
346
328
  isModel: true
347
329
 
348
- Lanes.Data.BasicModel = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.State, BasicModel )
330
+ Lanes.Models.BasicModel = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.State, BasicModel )
349
331
 
350
332
 
351
333
  class State
352
334
  constructor: -> super
353
335
 
354
- Lanes.Data.State = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.State, State )
336
+ Lanes.Models.State = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.State, State )
@@ -0,0 +1,8 @@
1
+ Lanes.Models.Bootstrap = {
2
+
3
+ initialize: (options)->
4
+ Lanes.Models.Config.csrf_token = options.csrf
5
+ Lanes.Models.Config.api_path = options.api_path
6
+ Lanes.Extensions.setBootstrapModels(options);
7
+
8
+ }
@@ -1,4 +1,4 @@
1
- class Lanes.Data.ChangeSet extends Lanes.Data.Model
1
+ class Lanes.Models.ChangeSet extends Lanes.Models.Base
2
2
 
3
3
  constructor: ->
4
4
  super
@@ -32,9 +32,9 @@ class Lanes.Data.ChangeSet extends Lanes.Data.Model
32
32
  @time_ago = Lanes.Vendor.Moment( @created_at ).fromNow()
33
33
 
34
34
 
35
- class Lanes.Data.ChangeSetCollection extends Lanes.Data.BasicCollection
35
+ class Lanes.Models.ChangeSetCollection extends Lanes.Models.BasicCollection
36
36
 
37
- model: Lanes.Data.ChangeSet
37
+ model: Lanes.Models.ChangeSet
38
38
 
39
39
  constructor: (options)->
40
40
  super([],options)
@@ -20,14 +20,14 @@ CommonMethods = {
20
20
  model.trigger('destroy', model, model.collection, options)
21
21
  success.apply(@,arguments) if success
22
22
  })
23
- Lanes.Data.Sync('delete', this, options)
23
+ Lanes.Models.Sync.perform('delete', this, options)
24
24
 
25
25
  }
26
26
 
27
- class DataCollection
27
+ class ModelsCollection
28
28
 
29
29
  constructor: ->
30
- @isLoaded=false
30
+ @_isLoaded=false
31
31
  @errors=[]
32
32
  Lanes.Vendor.Ampersand.Collection.apply(this, arguments)
33
33
 
@@ -37,15 +37,21 @@ class DataCollection
37
37
  collection
38
38
 
39
39
  fetch: (options={})->
40
- @isLoaded = true
41
- wrapRequest(this,options)
42
- super(options).then => @
40
+ @_isLoaded = true
41
+ Lanes.Models.Sync.wrapRequest(this,options)
42
+ return this.sync('read', this, options)
43
+
44
+ # Sets the attribute data from a server respose
45
+ setFromServer: (data, options)->
46
+ method = if options.reset then 'reset' else 'set'
47
+ this[method](data, options)
48
+ this.trigger('sync', this, data, options)
43
49
 
44
50
  isLoaded:->
45
- @isLoaded
51
+ @_isLoaded
46
52
 
47
53
  ensureLoaded: ( callback )->
48
- if ! @isLoaded && ! this.length
54
+ if ! @_isLoaded && ! this.length
49
55
  this.fetch({ success: callback })
50
56
  else if callback
51
57
  callback()
@@ -66,15 +72,15 @@ class DataCollection
66
72
  url: ->
67
73
  @model::urlRoot()
68
74
 
69
- sync: Lanes.Data.Sync
75
+ sync: Lanes.Models.Sync.perform
70
76
 
71
77
  save: (options)->
72
- Lanes.Data.Sync('update', this, options)
78
+ Lanes.Models.Sync.perform('update', this, options)
73
79
 
74
80
  dataForSave: (options)->
75
81
  unsaved = []
76
82
  for model in @models
77
- unsaved.push( model.unsavedData() ) if model.isDirty()
83
+ unsaved.push( model.unsavedModels() ) if model.isDirty()
78
84
  unsaved
79
85
 
80
86
  _prepareModel: (attrs, options={})->
@@ -88,32 +94,6 @@ class DataCollection
88
94
  CommonMethods
89
95
  ]
90
96
 
91
- @afterExtended: (klass)->
92
- if klass::model
93
- klass::model::Collection = klass
94
-
95
- copyServerMessages=(collection,msg)->
96
- return unless msg
97
- collection.errors = msg.errors || []
98
- collection.lastServerMessage = msg.message
99
-
100
- wrapRequest = (collection, options)->
101
- error = options.error
102
- success = options.success
103
-
104
- options.error = (collection,resp)->
105
- copyServerMessages(collection,resp.responseJSON)
106
- error?.apply(options.scope, arguments)
107
- Lanes.warn("request fail",resp)
108
- options.complete?.apply(options.scope, arguments)
109
- options.success = (collection,resp)->
110
- copyServerMessages(collection,resp)
111
- if resp.success
112
- success?.apply(options.scope, arguments)
113
- else
114
- error?.apply(options.scope, arguments)
115
- options.complete?.apply(options.scope, arguments)
116
-
117
97
  class BasicCollection
118
98
  constructor: -> super
119
99
  isLoaded: -> true
@@ -135,12 +115,12 @@ class SubCollection
135
115
  filter: ->
136
116
  this._runFilters()
137
117
 
138
- Lanes.Data.SubCollection = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.SubCollection, SubCollection )
118
+ Lanes.Models.SubCollection = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.SubCollection, SubCollection )
139
119
 
140
120
 
141
- Lanes.Data.BasicCollection = Lanes.lib.MakeBaseClass(
121
+ Lanes.Models.BasicCollection = Lanes.lib.MakeBaseClass(
142
122
  Lanes.Vendor.Ampersand.Collection.extend(Lanes.Vendor.Ampersand.USCollection), BasicCollection
143
123
  )
144
124
 
145
125
 
146
- Lanes.Data.Collection = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.RestCollection, DataCollection )
126
+ Lanes.Models.Collection = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.RestCollection, ModelsCollection )
@@ -5,6 +5,6 @@ class Config
5
5
  csrf_token: { type: 'string', setOnce: false }
6
6
  api_path: { type: 'string', setOnce: false }
7
7
 
8
- Lanes.Data.State.extend(Config)
8
+ Lanes.Models.State.extend(Config)
9
9
 
10
- Lanes.Data.Config = new Config
10
+ Lanes.Models.Config = new Config
@@ -1,5 +1,5 @@
1
- class ModelType extends Lanes.Data.State
2
1
 
2
+ class ModelType extends Lanes.Models.State
3
3
  constructor: ->
4
4
  super
5
5
  @records = {}
@@ -27,7 +27,8 @@ class ModelType extends Lanes.Data.State
27
27
  delete @records[model.id]
28
28
 
29
29
 
30
- class ModelTypesCollection extends Lanes.Data.BasicCollection
30
+
31
+ class ModelTypesCollection extends Lanes.Models.BasicCollection
31
32
  constructor: -> super
32
33
  model: ModelType
33
34
 
@@ -35,7 +36,7 @@ class ModelTypesCollection extends Lanes.Data.BasicCollection
35
36
  models = this.get(model.api_path) || this.add(id: model.api_path)
36
37
 
37
38
 
38
- Lanes.Data.PubSub = {
39
+ Lanes.Models.PubSub = {
39
40
 
40
41
  types: new ModelTypesCollection
41
42
 
@@ -1,4 +1,4 @@
1
- class Field extends Lanes.Data.Model
1
+ class Field extends Lanes.Models.Base
2
2
 
3
3
  constructor: (attributes)->
4
4
  super( _.defaults( attributes, {
@@ -25,7 +25,7 @@ class Field extends Lanes.Data.Model
25
25
  value
26
26
 
27
27
 
28
- class AvailableFields extends Lanes.Data.Collection
28
+ class AvailableFields extends Lanes.Models.Collection
29
29
 
30
30
  constructor: (models,options)->
31
31
  @query = options.query
@@ -34,7 +34,7 @@ class AvailableFields extends Lanes.Data.Collection
34
34
 
35
35
 
36
36
 
37
- class Operator extends Lanes.Data.Model
37
+ class Operator extends Lanes.Models.Base
38
38
 
39
39
  addStandardProperties: Lanes.emptyFn
40
40
 
@@ -52,7 +52,7 @@ class Operator extends Lanes.Data.Model
52
52
  !this.types || ( this.field && _.contains(this.types, this.field.type) )
53
53
 
54
54
 
55
- class Operators extends Lanes.Data.Collection
55
+ class Operators extends Lanes.Models.Collection
56
56
  model: Operator
57
57
 
58
58
  constructor: ->
@@ -72,7 +72,7 @@ class Operators extends Lanes.Data.Collection
72
72
  this.findWhere(valid:true).selected = true
73
73
 
74
74
 
75
- class Clause extends Lanes.Data.Model
75
+ class Clause extends Lanes.Models.Base
76
76
 
77
77
  session:
78
78
  value : { type: 'string', default: '' }
@@ -124,7 +124,7 @@ class Clause extends Lanes.Data.Model
124
124
  param
125
125
 
126
126
 
127
- class Clauses extends Lanes.Data.Collection
127
+ class Clauses extends Lanes.Models.Collection
128
128
 
129
129
  model: Clause
130
130
 
@@ -134,7 +134,7 @@ class Clauses extends Lanes.Data.Collection
134
134
  @fields = options.query.fields
135
135
 
136
136
 
137
- class Lanes.Data.Query extends Lanes.Data.Model
137
+ class Lanes.Models.Query extends Lanes.Models.Base
138
138
 
139
139
  session:
140
140
  fields: 'collection'