lanes 0.0.8 → 0.1.0
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.
- checksums.yaml +4 -4
- data/client/lanes/components/ChoicesInput.coffee +1 -1
- data/client/lanes/components/grid/Grid.coffee +4 -4
- data/client/lanes/components/grid/PopOverEditor.coffee +1 -1
- data/client/lanes/components/popover/PopOver.coffee +3 -3
- data/client/lanes/components/record_finder/RecordFinder.coffee +4 -4
- data/client/lanes/components/select_field/SelectField.coffee +1 -1
- data/client/lanes/extension/Base.coffee +1 -1
- data/client/lanes/extension/Extensions.coffee +3 -3
- data/client/lanes/extension/GlAccounts.coffee +2 -2
- data/client/lanes/lib/namespace.coffee +1 -1
- data/client/lanes/minimal.js +1 -1
- data/client/lanes/{data/Model.coffee → models/Base.coffee} +29 -47
- data/client/lanes/models/Bootstrap.coffee +8 -0
- data/client/lanes/{data → models}/ChangeSet.coffee +3 -3
- data/client/lanes/{data → models}/Collection.coffee +20 -40
- data/client/lanes/{data → models}/Config.coffee +2 -2
- data/client/lanes/{data → models}/PubSub.coffee +4 -3
- data/client/lanes/{data → models}/Query.coffee +7 -7
- data/client/lanes/{data → models}/Screens.coffee +12 -12
- data/client/lanes/models/Sync.coffee +86 -0
- data/client/lanes/{data → models}/User.coffee +8 -8
- data/client/lanes/{data → models}/index.js +1 -1
- data/client/lanes/{data → models}/mixins/HasCodeField.coffee +2 -2
- data/client/lanes/screens/Base.coffee +1 -1
- data/client/lanes/screens/ChangeListener.coffee +1 -1
- data/client/lanes/screens/Instance.coffee +3 -3
- data/client/lanes/screens/screen-definitions.js.erb +2 -2
- data/client/lanes/views/Base.coffee +10 -10
- data/client/lanes/views/ModelObserver.coffee +1 -1
- data/client/lanes/views/PubSub.coffee +4 -4
- data/client/lanes/views/Viewport.coffee +1 -1
- data/client/lanes/workspace/ActiveScreensSwitcher.coffee +1 -1
- data/client/lanes/workspace/Pages.coffee +2 -2
- data/client/lanes/workspace/ScreensMenu.coffee +1 -1
- data/lanes.gemspec +2 -1
- data/lib/lanes/command/generate_model.rb +6 -7
- data/lib/lanes/command/named_command.rb +1 -1
- data/lib/lanes/command/templates/client/index.js +1 -1
- data/lib/lanes/command/templates/client/{data → models}/Model.coffee +3 -7
- data/lib/lanes/command/templates/client/views/View.coffee +1 -1
- data/lib/lanes/command/templates/spec/client/models/ModelSpec.coffee +5 -0
- data/lib/lanes/command/update_model.rb +4 -11
- data/lib/lanes/command.rb +4 -3
- data/lib/lanes/version.rb +1 -1
- data/spec/helpers/lanes-helpers.coffee +5 -4
- data/spec/lanes/{data/ModelSpec.coffee → models/BaseSpec.coffee} +23 -11
- data/spec/lanes/{data → models}/PubSubSpec.coffee +6 -6
- data/views/specs.erb +1 -4
- metadata +19 -20
- data/client/lanes/data/Bootstrap.coffee +0 -8
- data/client/lanes/data/Sync.coffee +0 -63
- data/lib/lanes/command/templates/spec/client/data/ModelSpec.coffee +0 -5
- data/lib/lanes/spec_asset_expander.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b20837325a4feed75930d806fcc0ab5a8e914d3
|
4
|
+
data.tar.gz: 42515ab0003321f83e4946766645550b706deea5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
#
|
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
|
-
|
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)=>@
|
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
|
-
|
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
|
@@ -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
|
-
|
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','
|
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.
|
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
|
-
|
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.
|
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.
|
136
|
-
qf.val( qf.val().replace( Lanes.
|
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.
|
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 )
|
@@ -10,12 +10,12 @@ Lanes.Extensions = {
|
|
10
10
|
fireOnAvailable: (application)->
|
11
11
|
instance.onAvailable?(application) for identifier, instance of @instances
|
12
12
|
|
13
|
-
|
13
|
+
setBootstrapModels: (bootstrap_data)->
|
14
14
|
for identifier,data of bootstrap_data
|
15
|
-
instance?.
|
15
|
+
instance?.setBootstrapModels?(data)
|
16
16
|
|
17
17
|
makeNamespace: (identifier)->
|
18
|
-
for ns in ['
|
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
|
-
|
6
|
-
Lanes.
|
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', '
|
11
|
+
for ns in ['Components', 'Models.Mixins', 'Views.Mixins', 'Screens', 'Vendor', 'Templates', 'Extensions','lib']
|
12
12
|
Lanes.namespace(ns)
|
data/client/lanes/minimal.js
CHANGED
@@ -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.
|
42
|
-
@definitions['updated_by'] ||= { model: 'Lanes.
|
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.
|
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
|
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.
|
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.
|
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.
|
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
|
-
|
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
|
-
|
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.
|
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.
|
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.
|
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.
|
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.
|
336
|
+
Lanes.Models.State = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.State, State )
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Lanes.
|
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.
|
35
|
+
class Lanes.Models.ChangeSetCollection extends Lanes.Models.BasicCollection
|
36
36
|
|
37
|
-
model: Lanes.
|
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.
|
23
|
+
Lanes.Models.Sync.perform('delete', this, options)
|
24
24
|
|
25
25
|
}
|
26
26
|
|
27
|
-
class
|
27
|
+
class ModelsCollection
|
28
28
|
|
29
29
|
constructor: ->
|
30
|
-
@
|
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
|
-
@
|
41
|
-
wrapRequest(this,options)
|
42
|
-
|
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
|
-
@
|
51
|
+
@_isLoaded
|
46
52
|
|
47
53
|
ensureLoaded: ( callback )->
|
48
|
-
if ! @
|
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.
|
75
|
+
sync: Lanes.Models.Sync.perform
|
70
76
|
|
71
77
|
save: (options)->
|
72
|
-
Lanes.
|
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.
|
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.
|
118
|
+
Lanes.Models.SubCollection = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.SubCollection, SubCollection )
|
139
119
|
|
140
120
|
|
141
|
-
Lanes.
|
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.
|
126
|
+
Lanes.Models.Collection = Lanes.lib.MakeBaseClass( Lanes.Vendor.Ampersand.RestCollection, ModelsCollection )
|
@@ -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
|
-
|
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.
|
39
|
+
Lanes.Models.PubSub = {
|
39
40
|
|
40
41
|
types: new ModelTypesCollection
|
41
42
|
|
@@ -1,4 +1,4 @@
|
|
1
|
-
class Field extends Lanes.
|
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.
|
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.
|
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.
|
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.
|
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.
|
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.
|
137
|
+
class Lanes.Models.Query extends Lanes.Models.Base
|
138
138
|
|
139
139
|
session:
|
140
140
|
fields: 'collection'
|