Core libraries and tools part for pro architecture. It's a submodule - use from this perspective http://git.maniak.pro/madmaniak/pro
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

32 lines
978 B

module.exports =
add: (name, object, relations) ->
object['id'] = L.uniqueId("tmp")
object['type'] = name
Dispatcher.once Requests.perform(L.ns(__dirname, 'add'),
object: L.assign {}, object
relations: L.map(relations, L.reference)
), (data) ->
change = data.change
# find object with tmp_id
object = Store.get(change.collection, change.tmp_id)[0]
old_id = object.id
object.id = change.id
# store object with real id
Store.collections[change.collection][change.id] = object
delete Store.collections[change.collection][change.tmp_id]
Dispatcher.trigger "#{change.tmp_id}_to_id"
arguments
update: (object, transition, params) ->
Requests.perform L.ns(__dirname, 'update'), {
params
transition
ref: L.reference(object)
v: object.v
}
arguments
delete: (object) ->
Requests.perform L.ns(__dirname, 'delete'), ref: L.reference(object)
arguments