ende 0.4.19 → 0.4.20
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/README.md +1 -1
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +8 -19
- data/lib/assets/javascripts/aura/extensions/stamps.js.coffee +35 -0
- data/lib/assets/javascripts/aura/extensions/widget/napable.js.coffee +6 -7
- data/lib/assets/javascripts/widgets/dialog/main.js.coffee +2 -1
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +1 -0
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/ende_build.js +2 -2
- data/vendor/components/indefinido-indemma/build/development.js +1 -1
- data/vendor/components/indefinido-indemma/build/release.js +2 -2
- data/vendor/components/indefinido-indemma/build/test.js +2 -2
- data/vendor/components/indefinido-indemma/component.json +1 -0
- data/vendor/components/indefinido-indemma/lib/record/restfulable.js +2 -2
- data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 132a354f8488b0d4365d5af7d316b3233509dacf
|
|
4
|
+
data.tar.gz: 2ee8c242cf523e31d55da0d664305e590c9d476c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5967e853633eeacd0e3ae3a8cae10ebd48cb105098db100646519212bd50f3ee62306dd7caa71b7507db14c39bdfd925e608c7d021e632495370a26a3bb6f95a
|
|
7
|
+
data.tar.gz: 00c3ee46d953cb469bfe64ed38ea9a937367a3a7d3f8a7905de02cfd4762c90101615a5779fea51315eae2c9c7a6126b93f51b5e8e32140d3a1584954ba40d4f
|
data/README.md
CHANGED
|
@@ -5,7 +5,7 @@ endë
|
|
|
5
5
|
Summary
|
|
6
6
|
-------
|
|
7
7
|
|
|
8
|
-
Endë (core, middle)
|
|
8
|
+
Endë (core, middle) [](http://badge.fury.io/rb/ende)
|
|
9
9
|
|
|
10
10
|
A modular web application rails gem. Using aurajs for architecture and indemma for resource management by default.
|
|
11
11
|
|
|
@@ -185,15 +185,12 @@ define 'aura/extensions/rivets', ['aura/extensions/rivets/formatters'], (formatt
|
|
|
185
185
|
rivets.binders.spell ||=
|
|
186
186
|
publishes: true
|
|
187
187
|
bind: (el) ->
|
|
188
|
-
|
|
189
|
-
@options.publisher ||= (event) =>
|
|
188
|
+
@options.publisher ||= (event) =>
|
|
190
189
|
value = Rivets.Util.getInputValue @el
|
|
191
190
|
|
|
192
191
|
# TODO more controllable enter handling
|
|
193
192
|
return if event.which == 13
|
|
194
193
|
|
|
195
|
-
value += String.fromCharCode event.which || event.keyCode || event.charCode
|
|
196
|
-
|
|
197
194
|
for formatter in @formatters.slice(0).reverse()
|
|
198
195
|
args = formatter.split /\s+/
|
|
199
196
|
id = args.shift()
|
|
@@ -204,26 +201,18 @@ define 'aura/extensions/rivets', ['aura/extensions/rivets/formatters'], (formatt
|
|
|
204
201
|
@view.config.adapter.publish @model, @keypath, value
|
|
205
202
|
event.preventDefault()
|
|
206
203
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
else
|
|
212
|
-
Rivets.Util.bindEvent el, 'keypress', @options.publisher
|
|
213
|
-
Rivets.Util.bindEvent el, 'change' , @publish
|
|
204
|
+
# TODO Rivets.Util.bindEvent el, 'keypress change', @options.publisher
|
|
205
|
+
Rivets.Util.bindEvent el, 'keyup' , @options.publisher
|
|
206
|
+
Rivets.Util.bindEvent el, 'change' , @publish
|
|
207
|
+
|
|
214
208
|
|
|
215
209
|
unbind: (el) ->
|
|
216
210
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
Rivets.Util.unbindEvent el, 'keypress', @options.publisher
|
|
220
|
-
Rivets.Util.unbindEvent el, 'change', @publish
|
|
221
|
-
else
|
|
222
|
-
# TODO Rivets.Util.unbindEvent el, 'change' , @options.publisher
|
|
223
|
-
Rivets.Util.unbindEvent el, 'keypress', @options.publisher
|
|
224
|
-
Rivets.Util.unbindEvent el, 'change', @publish
|
|
211
|
+
Rivets.Util.unbindEvent el, 'keyup' , @options.publisher
|
|
212
|
+
Rivets.Util.unbindEvent el, 'change', @publish
|
|
225
213
|
|
|
226
214
|
routine: (el, value) ->
|
|
215
|
+
|
|
227
216
|
if window.jQuery?
|
|
228
217
|
el = jQuery el
|
|
229
218
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
define 'aura/extensions/stamps', ->
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
name: 'stamps'
|
|
7
|
+
|
|
8
|
+
version: '0.1.0'
|
|
9
|
+
|
|
10
|
+
require:
|
|
11
|
+
paths:
|
|
12
|
+
stampit: 'aura/extensions/stamps/stampit'
|
|
13
|
+
|
|
14
|
+
initialize: (application) ->
|
|
15
|
+
{sandbox, core} = application
|
|
16
|
+
stampit = require 'stampit'
|
|
17
|
+
|
|
18
|
+
core.stamps = {}
|
|
19
|
+
|
|
20
|
+
# TODO store stamps on a sandbox basis too
|
|
21
|
+
sandbox.stamp = core.stamp = stampit.mixIn (name, params...) ->
|
|
22
|
+
unless typeof name == 'string'
|
|
23
|
+
params.unshift name
|
|
24
|
+
name = null
|
|
25
|
+
|
|
26
|
+
stamp = stampit.apply stampit, params
|
|
27
|
+
|
|
28
|
+
if name then core.stamps[name] = stamp else stamp
|
|
29
|
+
|
|
30
|
+
, stampit
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
@@ -4,9 +4,10 @@ define 'aura/extensions/widget/napable', ['stampit/stampit'], (stampit) ->
|
|
|
4
4
|
|
|
5
5
|
# TODO think about adding rivets bindings to the element
|
|
6
6
|
napable = stampit
|
|
7
|
-
|
|
8
|
-
@sandbox.on "#{@name}.#{@identifier}.sleep",
|
|
9
|
-
@sandbox.on "#{@name}.#{@identifier}.wake" ,
|
|
7
|
+
tired: ->
|
|
8
|
+
@sandbox.on "#{@name}.#{@identifier}.sleep", @sleep, @
|
|
9
|
+
@sandbox.on "#{@name}.#{@identifier}.wake" , @wake , @
|
|
10
|
+
@
|
|
10
11
|
sleep: ->
|
|
11
12
|
@$el.addClass 'asleep'
|
|
12
13
|
@$el.removeClass 'awake'
|
|
@@ -15,15 +16,13 @@ define 'aura/extensions/widget/napable', ['stampit/stampit'], (stampit) ->
|
|
|
15
16
|
@$el.removeClass 'asleep'
|
|
16
17
|
,
|
|
17
18
|
naping: false
|
|
18
|
-
, ->
|
|
19
|
-
napable_extensions["super"].constructor.apply @, arguments
|
|
20
|
-
napable.bind.call @
|
|
19
|
+
, -> @tired()
|
|
21
20
|
|
|
22
21
|
# The purpose of this extension is allow parent widget to save
|
|
23
22
|
# memory by sending a sleep command to the child widgets
|
|
24
23
|
(application) ->
|
|
25
24
|
|
|
26
|
-
version: '0.1.
|
|
25
|
+
version: '0.1.2'
|
|
27
26
|
|
|
28
27
|
initialize: (application) ->
|
|
29
28
|
{core} = application
|
|
@@ -165,7 +165,8 @@ define ->
|
|
|
165
165
|
extract_options: ->
|
|
166
166
|
options = _.omit @options, 'el', 'ref', '_ref', 'name', 'require', 'baseUrl', 'theme', 'resource'
|
|
167
167
|
|
|
168
|
-
|
|
168
|
+
# TODO merge default options in prototype
|
|
169
|
+
dynamic_options = _.omit options, Object.keys(@__proto__.options)
|
|
169
170
|
|
|
170
171
|
keys = Object.keys dynamic_options
|
|
171
172
|
throw new TypeError "Too many keys on options object! #{keys.join(', ')}" unless keys.length == 1
|
data/lib/ende/version.rb
CHANGED
|
@@ -19358,7 +19358,7 @@ restful = {
|
|
|
19358
19358
|
return promise;
|
|
19359
19359
|
},
|
|
19360
19360
|
assign_attributes: function(attributes) {
|
|
19361
|
-
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource,
|
|
19361
|
+
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
|
|
19362
19362
|
|
|
19363
19363
|
_ref = model[this.resource.toString()].has_many;
|
|
19364
19364
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
@@ -19405,7 +19405,7 @@ restful = {
|
|
|
19405
19405
|
_ref3 = model[this.resource.toString()].belongs_to;
|
|
19406
19406
|
for (_m = 0, _len4 = _ref3.length; _m < _len4; _m++) {
|
|
19407
19407
|
association_name = _ref3[_m];
|
|
19408
|
-
association_attributes = (_ref4 =
|
|
19408
|
+
association_attributes = (_ref4 = (_ref5 = attributes[association_name]) != null ? typeof _ref5.json === "function" ? _ref5.json() : void 0 : void 0) != null ? _ref4 : attributes[association_name];
|
|
19409
19409
|
delete attributes[association_name];
|
|
19410
19410
|
delete attributes[association_name + "_attributes"];
|
|
19411
19411
|
if (association_attributes) {
|
|
@@ -272,7 +272,7 @@ require.register("indemma/lib/record/rest.js", Function("exports, require, modul
|
|
|
272
272
|
"var $, data_for, request;\n\n$ = require('jquery');\n\nmodule.exports = {\n get: function(data) {\n return request.call(this, 'get', (this._id ? \"\" + this.route + \"/\" + this._id : this.route), data);\n },\n put: function(data) {\n return request.call(this, 'put', (this._id ? \"\" + this.route + \"/\" + this._id : this.route), data);\n },\n post: function(data) {\n return request.call(this, 'post', this.route, data);\n },\n \"delete\": function(data) {\n return request.call(this, 'delete', (this._id ? \"\" + this.route + \"/\" + this._id : this.route), data);\n }\n};\n\ndata_for = function(data) {\n var param_name;\n\n param_name = this.resource.param_name || this.resource.toString();\n if (!data && this.json) {\n data = {};\n data[param_name] = this.json();\n }\n if (data && data[param_name]) {\n delete data[param_name]['id'];\n delete data[param_name]['_id'];\n }\n return data;\n};\n\nrequest = function(method, url, data) {\n data = data_for.call(this, data);\n return $.ajax({\n url: url,\n data: data,\n type: method,\n dataType: 'json',\n context: this\n });\n};\n//@ sourceURL=indemma/lib/record/rest.js"
|
|
273
273
|
));
|
|
274
274
|
require.register("indemma/lib/record/restfulable.js", Function("exports, require, module",
|
|
275
|
-
"var $, merge, model, observable, record, rest, restful, root, type, util,\n __slice = [].slice;\n\nmerge = require('assimilate').withStrategy('deep');\n\ntype = require('type');\n\nobservable = require('observable').mixin;\n\n$ = require('jquery');\n\nrest = require('./rest.js');\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nutil = {\n model: {\n map: function(records) {\n var record, _i, _len, _results;\n\n _results = [];\n for (_i = 0, _len = records.length; _i < _len; _i++) {\n record = records[_i];\n _results.push(this(record));\n }\n return _results;\n }\n }\n};\n\nrestful = {\n model: {\n create: function() {\n var attributes, callback, params, record, savings, _i, _j, _len;\n\n params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), callback = arguments[_i++];\n if (!arguments.length) {\n throw new TypeError(\"No arguments provided for \" + this.resource + \".create\");\n }\n if (typeof callback !== 'function') {\n params.push(callback);\n callback = void 0;\n }\n if (!params.length) {\n params.unshift({});\n }\n savings = [];\n for (_j = 0, _len = params.length; _j < _len; _j++) {\n attributes = params[_j];\n record = this(attributes);\n record.dirty = true;\n savings.push(record.save(callback));\n }\n return $.when.apply($, savings);\n },\n every: function(conditions, doned, failed) {\n if (conditions == null) {\n conditions = {};\n }\n if (typeof conditions === 'function') {\n doned = conditions;\n conditions = {};\n }\n return $.when(rest.get.call(this, conditions)).then(util.model.map).done(doned).fail(failed);\n },\n first: function(conditions, callback) {\n var namespaced;\n\n if (conditions == null) {\n conditions = {};\n }\n if (typeof conditions === 'function') {\n callback = conditions;\n conditions = {};\n }\n namespaced = conditions[this.resource] || {};\n namespaced.limit = 1;\n namespaced.order = 'desc';\n return this.every(conditions, callback);\n },\n get: function(action, data) {\n var default_route, old_route, payload, promise, resource;\n\n if (data == null) {\n data = {};\n }\n old_route = this.route;\n default_route = \"/\" + (model.pluralize(this.resource.name));\n if (default_route !== this.route) {\n this.route = default_route;\n }\n if (action) {\n Object.defineProperty(this, 'route', {\n value: \"\" + default_route + \"/\" + action,\n configurable: true\n });\n }\n resource = data.resource;\n if (data && data.json) {\n data = data.json();\n }\n if (resource != null) {\n payload = data;\n data = {};\n data[resource] = payload;\n }\n promise = rest.get.call(this, data);\n Object.defineProperty(this, 'route', {\n value: old_route,\n configurable: true\n });\n return promise;\n },\n put: rest.put,\n \"delete\": rest[\"delete\"]\n },\n record: {\n ready: function(callback) {\n return callback.call(this);\n },\n reload: function() {\n var data, param, params, promise, _i, _len;\n\n params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];\n data = params.pop();\n if (type(data) !== 'object') {\n params.push(data);\n }\n promise = rest.get.call(this, data || {});\n promise.done(this.assign_attributes);\n promise.fail(this.failed);\n this.reloading = promise;\n this.ready = function() {\n console.warn(\"resource.ready was deprecated, please use resource.reloading.done\");\n return promise.done.apply(promise, arguments);\n };\n for (_i = 0, _len = params.length; _i < _len; _i++) {\n param = params[_i];\n promise.done(param);\n }\n return promise;\n },\n assign_attributes: function(attributes) {\n var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _base, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _results;\n\n _ref = model[this.resource.toString()].has_many;\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n association_name = _ref[_i];\n associations_attributes = attributes[association_name];\n delete attributes[association_name];\n association = this[association_name];\n if (association == null) {\n message = \"Association '\" + association_name + \"' not found. \\n\";\n message += \"For record with resource \" + this.resource + \". \\n\";\n message += \"Probably defined on server side but not on client side.\\n\";\n message += \"Skipping association assignment!\";\n console.warn(message);\n continue;\n }\n if (association.length) {\n Array.prototype.splice.call(association, 0);\n }\n if (!((associations_attributes != null) && associations_attributes.length)) {\n continue;\n }\n singular_resource = model.singularize(association_name);\n for (_j = 0, _len1 = associations_attributes.length; _j < _len1; _j++) {\n association_attributes = associations_attributes[_j];\n _ref1 = model[singular_resource].has_many;\n for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {\n association_name = _ref1[_k];\n association_attributes[\"\" + association_name + \"_attributes\"] = association_attributes[association_name];\n delete association_attributes[association_name];\n }\n }\n association.add.apply(association, associations_attributes);\n }\n _ref2 = model[this.resource.toString()].has_one;\n for (_l = 0, _len3 = _ref2.length; _l < _len3; _l++) {\n association_name = _ref2[_l];\n association_attributes = attributes[association_name];\n delete attributes[association_name];\n delete attributes[association_name + \"_attributes\"];\n if (association_attributes) {\n this[association_name] = this[\"build_\" + association_name](association_attributes);\n }\n }\n _ref3 = model[this.resource.toString()].belongs_to;\n for (_m = 0, _len4 = _ref3.length; _m < _len4; _m++) {\n association_name = _ref3[_m];\n association_attributes = (_ref4 = typeof (_base = attributes[association_name]).json === \"function\" ? _base.json() : void 0) != null ? _ref4 : attributes[association_name];\n delete attributes[association_name];\n delete attributes[association_name + \"_attributes\"];\n if (association_attributes) {\n this[association_name] = this[\"build_\" + association_name](association_attributes);\n }\n }\n _results = [];\n for (name in attributes) {\n attribute = attributes[name];\n if (attribute !== this[name]) {\n if (type(attribute) === 'object') {\n if (JSON.stringify(attribute) !== JSON.stringify(this[name])) {\n _results.push(this[name] = attributes[name]);\n } else {\n _results.push(void 0);\n }\n } else {\n _results.push(this[name] = attributes[name]);\n }\n }\n }\n return _results;\n },\n destroy: function(doned, failed, data) {\n var promise;\n\n if (!((this.id != null) || (this._id != null))) {\n throw new Error('Can\\'t delete record without id!');\n }\n promise = rest[\"delete\"].call(this, data);\n promise.done(this.destroyed);\n promise.fail(this.failed);\n promise.done(doned);\n promise.fail(failed);\n return promise;\n },\n saving: false,\n salvation: null,\n save: function(doned, failed, data) {\n var lock, salvation;\n\n lock = JSON.stringify(this.json());\n if (this.saving) {\n if (this.lock === lock) {\n return this.salvation;\n } else {\n this.salvation.abort();\n }\n }\n this.lock = lock;\n if (!this.dirty) {\n salvation = $.Deferred().resolveWith(this, null);\n }\n this.saving = true;\n salvation || (salvation = rest[this._id ? 'put' : 'post'].call(this, data));\n this.salvation = salvation;\n salvation.done(this.saved);\n salvation.fail(this.failed);\n salvation.always(function() {\n return this.saving = false;\n });\n salvation.done(doned);\n salvation.fail(failed);\n return salvation;\n },\n saved: function(data) {\n var callback, _i, _len, _ref, _results;\n\n if (this.lock === JSON.stringify(this.json())) {\n this.dirty = false;\n delete this.lock;\n }\n if (data != null) {\n this.assign_attributes(data);\n }\n if (this.after_save) {\n _ref = this.after_save;\n _results = [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n callback = _ref[_i];\n throw \"Not supported after_save callback: \" + callback;\n }\n return _results;\n }\n },\n failed: function(xhr, error, status) {\n var attribute_name, definition, e, message, messages, payload, _i, _len, _ref;\n\n payload = xhr.responseJSON;\n try {\n payload || (payload = JSON.parse(xhr.responseText));\n } catch (_error) {\n e = _error;\n }\n payload || (payload = xhr.responseText);\n switch (xhr.status) {\n case 0:\n message = status || xhr.statusText;\n switch (message) {\n case 'abort':\n console.info(\"salvation probably aborted\");\n break;\n case 'error':\n console.info(\"server probably unreachable\");\n break;\n default:\n throw new Error('Unhandled status code for xhr');\n }\n break;\n case 422:\n definition = model[this.resource.toString()];\n _ref = payload.errors;\n for (attribute_name in _ref) {\n messages = _ref[attribute_name];\n if (!definition.associations) {\n definition.associations = definition.has_one.concat(definition.has_many.concat(definition.belongs_to));\n }\n if (!(this.hasOwnProperty(attribute_name) || definition.hasOwnProperty(attribute_name) || definition.associations.indexOf(attribute_name) !== -1 || attribute_name === 'base')) {\n message = \"Server returned an validation error message for a attribute that is not defined in your model.\\n\";\n message += \"The attribute was '\" + attribute_name + \"', the model resource was '\" + this.resource + \"'.\\n\";\n message += \"The model definition keys were '\" + (JSON.stringify(Object.keys(definition))) + \"'.\\n\";\n message += \"Please remove server validation, or update your model definition.\";\n throw new TypeError(message);\n }\n for (_i = 0, _len = messages.length; _i < _len; _i++) {\n message = messages[_i];\n this.errors.add(attribute_name, 'server', {\n server_message: message\n });\n }\n }\n break;\n default:\n message = \"Fail in \" + this.resource + \".save:\\n\";\n message += \"Record: \" + this + \"\\n\";\n message += \"Status: \" + status + \" (\" + (payload || xhr).status + \")\\n\";\n message += \"Error : \" + (payload.error || payload.message || payload);\n console.log(message);\n }\n return this.saving = false;\n },\n toString: function() {\n var e, name, property, serialized;\n\n serialized = {};\n serialized[this.resource] = this.json();\n try {\n return JSON.stringify(serialized);\n } catch (_error) {\n e = _error;\n console.warn(\"restfulable.toString: Failed to stringify record: \" + e.message + \". retrying...\");\n for (name in serialized) {\n property = serialized[name];\n if (typeof property === 'object') {\n delete serialized[name];\n }\n }\n return JSON.stringify(serialized);\n }\n },\n json: function(options) {\n var definition, json, method, name, nature, nested, value, _ref, _ref1;\n\n if (options == null) {\n options = {};\n }\n json = {};\n definition = model[this.resource.toString()];\n for (name in this) {\n if (observable.ignores.indexOf(name) !== -1) {\n continue;\n }\n nested = this.nested_attributes.indexOf(name) !== -1;\n if (!nested && (definition.belongs_to.indexOf(name) !== -1 || definition.has_one.indexOf(name) !== -1 || definition.has_many.indexOf(name) !== -1)) {\n continue;\n }\n value = this[name];\n if (value == null) {\n continue;\n }\n nature = type(value);\n if (nature === 'function') {\n continue;\n }\n if (nature === 'object' || nature === 'element') {\n if (nested) {\n if (!value.json) {\n console.warn(\"json: Tryied to serialize nested attribute '\" + name + \"' without serialization method!\");\n continue;\n }\n json[\"\" + name + \"_attributes\"] = value.json(options[name]);\n } else if ((value.toJSON != null) || (value.json != null)) {\n if (value.resource) {\n continue;\n }\n if (value.json != null) {\n json[name] = value.json(options[name]);\n } else {\n json[name] = value.toJSON(options[name]);\n }\n } else {\n continue;\n }\n } else {\n json[name] = value;\n }\n }\n json = observable.unobserve(json);\n _ref1 = (_ref = options.methods) != null ? _ref : {};\n for (name in _ref1) {\n value = _ref1[name];\n method = this[name];\n if (typeof method === 'function') {\n json[name] = method();\n } else {\n json[name] = method;\n }\n }\n delete json.dirty;\n delete json.resource;\n delete json.route;\n delete json.initial_route;\n delete json.after_initialize;\n delete json.before_initialize;\n delete json.parent_resource;\n delete json.nested_attributes;\n delete json.reloading;\n delete json.ready;\n delete json.saving;\n delete json.salvation;\n delete json.sustained;\n delete json.element;\n delete json[\"default\"];\n delete json.lock;\n delete json.validated;\n delete json.validation;\n delete json.errors;\n return json;\n }\n }\n};\n\nrestful.toJSON = restful.json;\n\nmodel = window.model;\n\nrecord = window.record;\n\nmodel.restfulable = true;\n\nrecord.mix(function(recordable) {\n return merge(recordable, restful.record);\n});\n\nmodel.mix(function(modelable) {\n return merge(modelable, restful.model);\n});\n\nmodel.associable && model.associable.mix(function(singular_association, plural_association) {\n plural_association.get = function() {\n if (this.parent != null) {\n this.route || (this.route = \"\" + this.parent.route + \"/\" + this.parent._id + \"/\" + (model.pluralize(this.resource.name)));\n }\n return rest.get.apply(this, arguments);\n };\n return plural_association.post = function() {\n if (this.parent != null) {\n this.route || (this.route = \"\" + this.parent.route + \"/\" + this.parent._id + \"/\" + (model.pluralize(this.resource.name)));\n }\n return rest.post.apply(this, arguments);\n };\n});\n//@ sourceURL=indemma/lib/record/restfulable.js"
|
|
275
|
+
"var $, merge, model, observable, record, rest, restful, root, type, util,\n __slice = [].slice;\n\nmerge = require('assimilate').withStrategy('deep');\n\ntype = require('type');\n\nobservable = require('observable').mixin;\n\n$ = require('jquery');\n\nrest = require('./rest.js');\n\nroot = typeof exports !== \"undefined\" && exports !== null ? exports : this;\n\nutil = {\n model: {\n map: function(records) {\n var record, _i, _len, _results;\n\n _results = [];\n for (_i = 0, _len = records.length; _i < _len; _i++) {\n record = records[_i];\n _results.push(this(record));\n }\n return _results;\n }\n }\n};\n\nrestful = {\n model: {\n create: function() {\n var attributes, callback, params, record, savings, _i, _j, _len;\n\n params = 2 <= arguments.length ? __slice.call(arguments, 0, _i = arguments.length - 1) : (_i = 0, []), callback = arguments[_i++];\n if (!arguments.length) {\n throw new TypeError(\"No arguments provided for \" + this.resource + \".create\");\n }\n if (typeof callback !== 'function') {\n params.push(callback);\n callback = void 0;\n }\n if (!params.length) {\n params.unshift({});\n }\n savings = [];\n for (_j = 0, _len = params.length; _j < _len; _j++) {\n attributes = params[_j];\n record = this(attributes);\n record.dirty = true;\n savings.push(record.save(callback));\n }\n return $.when.apply($, savings);\n },\n every: function(conditions, doned, failed) {\n if (conditions == null) {\n conditions = {};\n }\n if (typeof conditions === 'function') {\n doned = conditions;\n conditions = {};\n }\n return $.when(rest.get.call(this, conditions)).then(util.model.map).done(doned).fail(failed);\n },\n first: function(conditions, callback) {\n var namespaced;\n\n if (conditions == null) {\n conditions = {};\n }\n if (typeof conditions === 'function') {\n callback = conditions;\n conditions = {};\n }\n namespaced = conditions[this.resource] || {};\n namespaced.limit = 1;\n namespaced.order = 'desc';\n return this.every(conditions, callback);\n },\n get: function(action, data) {\n var default_route, old_route, payload, promise, resource;\n\n if (data == null) {\n data = {};\n }\n old_route = this.route;\n default_route = \"/\" + (model.pluralize(this.resource.name));\n if (default_route !== this.route) {\n this.route = default_route;\n }\n if (action) {\n Object.defineProperty(this, 'route', {\n value: \"\" + default_route + \"/\" + action,\n configurable: true\n });\n }\n resource = data.resource;\n if (data && data.json) {\n data = data.json();\n }\n if (resource != null) {\n payload = data;\n data = {};\n data[resource] = payload;\n }\n promise = rest.get.call(this, data);\n Object.defineProperty(this, 'route', {\n value: old_route,\n configurable: true\n });\n return promise;\n },\n put: rest.put,\n \"delete\": rest[\"delete\"]\n },\n record: {\n ready: function(callback) {\n return callback.call(this);\n },\n reload: function() {\n var data, param, params, promise, _i, _len;\n\n params = 1 <= arguments.length ? __slice.call(arguments, 0) : [];\n data = params.pop();\n if (type(data) !== 'object') {\n params.push(data);\n }\n promise = rest.get.call(this, data || {});\n promise.done(this.assign_attributes);\n promise.fail(this.failed);\n this.reloading = promise;\n this.ready = function() {\n console.warn(\"resource.ready was deprecated, please use resource.reloading.done\");\n return promise.done.apply(promise, arguments);\n };\n for (_i = 0, _len = params.length; _i < _len; _i++) {\n param = params[_i];\n promise.done(param);\n }\n return promise;\n },\n assign_attributes: function(attributes) {\n var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;\n\n _ref = model[this.resource.toString()].has_many;\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n association_name = _ref[_i];\n associations_attributes = attributes[association_name];\n delete attributes[association_name];\n association = this[association_name];\n if (association == null) {\n message = \"Association '\" + association_name + \"' not found. \\n\";\n message += \"For record with resource \" + this.resource + \". \\n\";\n message += \"Probably defined on server side but not on client side.\\n\";\n message += \"Skipping association assignment!\";\n console.warn(message);\n continue;\n }\n if (association.length) {\n Array.prototype.splice.call(association, 0);\n }\n if (!((associations_attributes != null) && associations_attributes.length)) {\n continue;\n }\n singular_resource = model.singularize(association_name);\n for (_j = 0, _len1 = associations_attributes.length; _j < _len1; _j++) {\n association_attributes = associations_attributes[_j];\n _ref1 = model[singular_resource].has_many;\n for (_k = 0, _len2 = _ref1.length; _k < _len2; _k++) {\n association_name = _ref1[_k];\n association_attributes[\"\" + association_name + \"_attributes\"] = association_attributes[association_name];\n delete association_attributes[association_name];\n }\n }\n association.add.apply(association, associations_attributes);\n }\n _ref2 = model[this.resource.toString()].has_one;\n for (_l = 0, _len3 = _ref2.length; _l < _len3; _l++) {\n association_name = _ref2[_l];\n association_attributes = attributes[association_name];\n delete attributes[association_name];\n delete attributes[association_name + \"_attributes\"];\n if (association_attributes) {\n this[association_name] = this[\"build_\" + association_name](association_attributes);\n }\n }\n _ref3 = model[this.resource.toString()].belongs_to;\n for (_m = 0, _len4 = _ref3.length; _m < _len4; _m++) {\n association_name = _ref3[_m];\n association_attributes = (_ref4 = (_ref5 = attributes[association_name]) != null ? typeof _ref5.json === \"function\" ? _ref5.json() : void 0 : void 0) != null ? _ref4 : attributes[association_name];\n delete attributes[association_name];\n delete attributes[association_name + \"_attributes\"];\n if (association_attributes) {\n this[association_name] = this[\"build_\" + association_name](association_attributes);\n }\n }\n _results = [];\n for (name in attributes) {\n attribute = attributes[name];\n if (attribute !== this[name]) {\n if (type(attribute) === 'object') {\n if (JSON.stringify(attribute) !== JSON.stringify(this[name])) {\n _results.push(this[name] = attributes[name]);\n } else {\n _results.push(void 0);\n }\n } else {\n _results.push(this[name] = attributes[name]);\n }\n }\n }\n return _results;\n },\n destroy: function(doned, failed, data) {\n var promise;\n\n if (!((this.id != null) || (this._id != null))) {\n throw new Error('Can\\'t delete record without id!');\n }\n promise = rest[\"delete\"].call(this, data);\n promise.done(this.destroyed);\n promise.fail(this.failed);\n promise.done(doned);\n promise.fail(failed);\n return promise;\n },\n saving: false,\n salvation: null,\n save: function(doned, failed, data) {\n var lock, salvation;\n\n lock = JSON.stringify(this.json());\n if (this.saving) {\n if (this.lock === lock) {\n return this.salvation;\n } else {\n this.salvation.abort();\n }\n }\n this.lock = lock;\n if (!this.dirty) {\n salvation = $.Deferred().resolveWith(this, null);\n }\n this.saving = true;\n salvation || (salvation = rest[this._id ? 'put' : 'post'].call(this, data));\n this.salvation = salvation;\n salvation.done(this.saved);\n salvation.fail(this.failed);\n salvation.always(function() {\n return this.saving = false;\n });\n salvation.done(doned);\n salvation.fail(failed);\n return salvation;\n },\n saved: function(data) {\n var callback, _i, _len, _ref, _results;\n\n if (this.lock === JSON.stringify(this.json())) {\n this.dirty = false;\n delete this.lock;\n }\n if (data != null) {\n this.assign_attributes(data);\n }\n if (this.after_save) {\n _ref = this.after_save;\n _results = [];\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n callback = _ref[_i];\n throw \"Not supported after_save callback: \" + callback;\n }\n return _results;\n }\n },\n failed: function(xhr, error, status) {\n var attribute_name, definition, e, message, messages, payload, _i, _len, _ref;\n\n payload = xhr.responseJSON;\n try {\n payload || (payload = JSON.parse(xhr.responseText));\n } catch (_error) {\n e = _error;\n }\n payload || (payload = xhr.responseText);\n switch (xhr.status) {\n case 0:\n message = status || xhr.statusText;\n switch (message) {\n case 'abort':\n console.info(\"salvation probably aborted\");\n break;\n case 'error':\n console.info(\"server probably unreachable\");\n break;\n default:\n throw new Error('Unhandled status code for xhr');\n }\n break;\n case 422:\n definition = model[this.resource.toString()];\n _ref = payload.errors;\n for (attribute_name in _ref) {\n messages = _ref[attribute_name];\n if (!definition.associations) {\n definition.associations = definition.has_one.concat(definition.has_many.concat(definition.belongs_to));\n }\n if (!(this.hasOwnProperty(attribute_name) || definition.hasOwnProperty(attribute_name) || definition.associations.indexOf(attribute_name) !== -1 || attribute_name === 'base')) {\n message = \"Server returned an validation error message for a attribute that is not defined in your model.\\n\";\n message += \"The attribute was '\" + attribute_name + \"', the model resource was '\" + this.resource + \"'.\\n\";\n message += \"The model definition keys were '\" + (JSON.stringify(Object.keys(definition))) + \"'.\\n\";\n message += \"Please remove server validation, or update your model definition.\";\n throw new TypeError(message);\n }\n for (_i = 0, _len = messages.length; _i < _len; _i++) {\n message = messages[_i];\n this.errors.add(attribute_name, 'server', {\n server_message: message\n });\n }\n }\n break;\n default:\n message = \"Fail in \" + this.resource + \".save:\\n\";\n message += \"Record: \" + this + \"\\n\";\n message += \"Status: \" + status + \" (\" + (payload || xhr).status + \")\\n\";\n message += \"Error : \" + (payload.error || payload.message || payload);\n console.log(message);\n }\n return this.saving = false;\n },\n toString: function() {\n var e, name, property, serialized;\n\n serialized = {};\n serialized[this.resource] = this.json();\n try {\n return JSON.stringify(serialized);\n } catch (_error) {\n e = _error;\n console.warn(\"restfulable.toString: Failed to stringify record: \" + e.message + \". retrying...\");\n for (name in serialized) {\n property = serialized[name];\n if (typeof property === 'object') {\n delete serialized[name];\n }\n }\n return JSON.stringify(serialized);\n }\n },\n json: function(options) {\n var definition, json, method, name, nature, nested, value, _ref, _ref1;\n\n if (options == null) {\n options = {};\n }\n json = {};\n definition = model[this.resource.toString()];\n for (name in this) {\n if (observable.ignores.indexOf(name) !== -1) {\n continue;\n }\n nested = this.nested_attributes.indexOf(name) !== -1;\n if (!nested && (definition.belongs_to.indexOf(name) !== -1 || definition.has_one.indexOf(name) !== -1 || definition.has_many.indexOf(name) !== -1)) {\n continue;\n }\n value = this[name];\n if (value == null) {\n continue;\n }\n nature = type(value);\n if (nature === 'function') {\n continue;\n }\n if (nature === 'object' || nature === 'element') {\n if (nested) {\n if (!value.json) {\n console.warn(\"json: Tryied to serialize nested attribute '\" + name + \"' without serialization method!\");\n continue;\n }\n json[\"\" + name + \"_attributes\"] = value.json(options[name]);\n } else if ((value.toJSON != null) || (value.json != null)) {\n if (value.resource) {\n continue;\n }\n if (value.json != null) {\n json[name] = value.json(options[name]);\n } else {\n json[name] = value.toJSON(options[name]);\n }\n } else {\n continue;\n }\n } else {\n json[name] = value;\n }\n }\n json = observable.unobserve(json);\n _ref1 = (_ref = options.methods) != null ? _ref : {};\n for (name in _ref1) {\n value = _ref1[name];\n method = this[name];\n if (typeof method === 'function') {\n json[name] = method();\n } else {\n json[name] = method;\n }\n }\n delete json.dirty;\n delete json.resource;\n delete json.route;\n delete json.initial_route;\n delete json.after_initialize;\n delete json.before_initialize;\n delete json.parent_resource;\n delete json.nested_attributes;\n delete json.reloading;\n delete json.ready;\n delete json.saving;\n delete json.salvation;\n delete json.sustained;\n delete json.element;\n delete json[\"default\"];\n delete json.lock;\n delete json.validated;\n delete json.validation;\n delete json.errors;\n return json;\n }\n }\n};\n\nrestful.toJSON = restful.json;\n\nmodel = window.model;\n\nrecord = window.record;\n\nmodel.restfulable = true;\n\nrecord.mix(function(recordable) {\n return merge(recordable, restful.record);\n});\n\nmodel.mix(function(modelable) {\n return merge(modelable, restful.model);\n});\n\nmodel.associable && model.associable.mix(function(singular_association, plural_association) {\n plural_association.get = function() {\n if (this.parent != null) {\n this.route || (this.route = \"\" + this.parent.route + \"/\" + this.parent._id + \"/\" + (model.pluralize(this.resource.name)));\n }\n return rest.get.apply(this, arguments);\n };\n return plural_association.post = function() {\n if (this.parent != null) {\n this.route || (this.route = \"\" + this.parent.route + \"/\" + this.parent._id + \"/\" + (model.pluralize(this.resource.name)));\n }\n return rest.post.apply(this, arguments);\n };\n});\n//@ sourceURL=indemma/lib/record/restfulable.js"
|
|
276
276
|
));
|
|
277
277
|
require.register("indemma/lib/record/scopable.js", Function("exports, require, module",
|
|
278
278
|
"var $, builders, defaults, extend, merge, model, observable, record, rest, scopable, stampit, util,\n __slice = [].slice;\n\nrequire('./restfulable');\n\nrequire('./resource');\n\nstampit = require('../../vendor/stampit');\n\nextend = require('assimilate');\n\nobservable = require('observable').mixin;\n\nmerge = extend.withStrategy('deep');\n\n$ = require('jquery');\n\nrest = require('./rest');\n\nutil = {\n model: {\n map: function(records) {\n var index, record, _i, _len, _results;\n\n _results = [];\n for (index = _i = 0, _len = records.length; _i < _len; index = ++_i) {\n record = records[index];\n _results.push((this.build || this).call(this, record));\n }\n return _results;\n }\n }\n};\n\nscopable = {\n builder: stampit().enclose(function() {\n return stampit.mixIn(function(name, type) {\n var builder;\n\n if ($.type(type) === 'function') {\n this[\"$\" + name] = type() || new type;\n type = $.type(this[\"$\" + name]);\n } else {\n this[\"$\" + name] = defaults[type] || type;\n }\n if ($.type(type) !== 'string') {\n type = $.type(type);\n }\n builder = builders[type];\n if (builder == null) {\n throw \"Unknown scope type: '\" + type + \"', For model with resource: '\" + this.resource + \"'\";\n }\n this.scope.declared.push(name);\n return this[name] = builder({\n name: name\n });\n }, {\n data: {},\n then: [],\n fail: [],\n declared: [],\n fetch: function(data, done, fail) {\n var deferred, scope;\n\n if (typeof data === 'function') {\n done = data;\n data = {};\n }\n scope = extend({}, this.scope.data);\n observable.unobserve(scope);\n if (scope.noned != null) {\n deferred = $.Deferred();\n deferred.resolveWith(this, [[]]);\n } else {\n deferred = rest.get.call(this, extend(scope, data));\n }\n deferred.then(util.model.map).done(this.scope.then.concat([done])).fail(this.scope.fail.concat([fail]));\n this.scope.clear();\n return deferred;\n },\n clear: function() {\n this.data = {};\n return this.callbacks = [];\n }\n });\n }),\n base: stampit().state({\n name: 'unamed_scope'\n }),\n record: {\n failed: function(xhr, error, status) {\n var e, message, payload;\n\n payload = xhr.responseJSON;\n try {\n payload || (payload = JSON.parse(xhr.responseText));\n } catch (_error) {\n e = _error;\n }\n payload || (payload = xhr.responseText);\n switch (xhr.status) {\n case 422:\n this.valid = false;\n return this.errors = payload.errors;\n default:\n message = \"Fail in \" + this.resource + \".save:\\n\";\n message += \"Record: \" + this + \"\\n\";\n message += \"Status: \" + status + \" (\" + (payload.status || xhr.status) + \")\\n\";\n message += \"Error : \" + (payload.error || payload.message || payload);\n }\n return console.error(message);\n }\n },\n model: {\n none: function() {\n this.scope.data.noned = true;\n return this;\n },\n fetch: function(data, done, fail) {\n if (typeof data === 'function') {\n done = data;\n data = null;\n }\n return this.scope.fetch.call(this, data, done, fail);\n },\n forward_scopes_to_associations: function() {\n var associated_factory, associated_resource, association, association_name, factory, scope, _i, _j, _len, _len1, _ref, _ref1;\n\n factory = model[this.resource.name];\n _ref = factory.has_many;\n for (_i = 0, _len = _ref.length; _i < _len; _i++) {\n association_name = _ref[_i];\n associated_resource = model.singularize(association_name);\n associated_factory = model[associated_resource];\n if (!model[associated_resource]) {\n console.warn(\"Associated factory not found for associated resource: \" + associated_resource);\n continue;\n }\n association = this[association_name];\n association.scope = scopable.builder(association);\n _ref1 = associated_factory.scope.declared;\n for (_j = 0, _len1 = _ref1.length; _j < _len1; _j++) {\n scope = _ref1[_j];\n association.scope(scope, associated_factory[\"$\" + scope]);\n }\n }\n return true;\n }\n },\n after_mix: function() {\n var name, property, type, _results;\n\n this.scope = scopable.builder(this);\n _results = [];\n for (property in this) {\n type = this[property];\n if (property.charAt(0) === '$') {\n name = property.substring(1);\n _results.push(this.scope(name, type));\n } else {\n _results.push(void 0);\n }\n }\n return _results;\n }\n};\n\nbuilders = {\n string: stampit().enclose(function() {\n var base;\n\n base = scopable.base(this);\n return stampit.mixIn(function() {\n var callbacks, value, _base, _name;\n\n value = arguments[0], callbacks = 2 <= arguments.length ? __slice.call(arguments, 1) : [];\n callbacks.length && (this.scope.then = this.scope.then.concat(callbacks));\n (_base = this.scope.data)[_name = base.name] || (_base[_name] = value != null ? value : this[\"$\" + base.name]);\n return this;\n });\n }),\n boolean: stampit().enclose(function() {\n var base;\n\n base = scopable.base(this);\n return stampit.mixIn(function() {\n var callbacks, value, _base, _name;\n\n value = arguments[0], callbacks = 2 <= arguments.length ? __slice.call(arguments, 1) : [];\n callbacks.length && (this.scope.then = this.scope.then.concat(callbacks));\n (_base = this.scope.data)[_name = base.name] || (_base[_name] = value != null ? value : this[\"$\" + base.name]);\n return this;\n });\n }),\n array: stampit().enclose(function() {\n var base;\n\n base = scopable.base(this);\n return stampit.mixIn(function() {\n var values, _base, _name;\n\n values = 1 <= arguments.length ? __slice.call(arguments, 0) : [];\n (_base = this.scope.data)[_name = base.name] || (_base[_name] = values != null ? values : this[\"$\" + base.name]);\n return this;\n });\n })\n};\n\ndefaults = {\n boolean: true,\n array: []\n};\n\nmodel = window.model;\n\nrecord = window.record;\n\nmodel.scopable = true;\n\nmodel.mix(function(modelable) {\n merge(modelable, scopable.model);\n return modelable.after_mix.push(scopable.after_mix);\n});\n\nif (model.associable) {\n model.mix(function(modelable) {\n return modelable.record.after_initialize.push(function() {\n return scopable.model.forward_scopes_to_associations.call(this);\n });\n });\n model.associable.mix(function(singular_association, plural_association) {\n plural_association.every = plural_association.reload = function(data, done, fail) {\n var promises, reload;\n\n if (this.parent != null) {\n this.route || (this.route = \"\" + this.parent.route + \"/\" + this.parent._id + \"/\" + (model.pluralize(this.resource)));\n }\n promises = [];\n if (typeof data === 'function') {\n done = data;\n data = void 0;\n }\n promises.push(this.scope.fetch.call(this, data, null, scopable.record.failed));\n reload = $.when.apply(jQuery, promises);\n reload.done(function(records, status) {\n var association_name, create, index, singular_resource, target, _i, _j, _k, _len, _len1, _len2, _ref;\n\n if (!records.length) {\n if (this.length) {\n Array.prototype.splice.call(this, 0);\n }\n return true;\n }\n singular_resource = model.singularize(this.resource);\n for (_i = 0, _len = records.length; _i < _len; _i++) {\n record = records[_i];\n _ref = model[singular_resource].has_many;\n for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {\n association_name = _ref[_j];\n record[\"\" + association_name + \"_attributes\"] = record[association_name];\n delete record[association_name];\n }\n }\n create = [];\n for (index = _k = 0, _len2 = records.length; _k < _len2; index = ++_k) {\n record = records[index];\n if (target = this.find(record._id)) {\n target.assign_attributes(record);\n } else {\n create.push(record);\n }\n }\n this.add.apply(this, create);\n records.splice(0);\n return records.push.apply(records, this);\n });\n reload.done(done);\n reload.fail(fail);\n return reload;\n };\n return plural_association.each = function(callback) {\n var _this = this;\n\n if (this.parent != null) {\n this.route || (this.route = \"\" + this.parent.route + \"/\" + this.parent._id + \"/\" + (model.pluralize(this.resource)));\n }\n return this.get().done(function(records) {\n var _i, _len, _results;\n\n _results = [];\n for (_i = 0, _len = _this.length; _i < _len; _i++) {\n record = _this[_i];\n _results.push(callback(record));\n }\n return _results;\n });\n };\n });\n}\n//@ sourceURL=indemma/lib/record/scopable.js"
|
|
@@ -20935,7 +20935,7 @@ restful = {
|
|
|
20935
20935
|
return promise;
|
|
20936
20936
|
},
|
|
20937
20937
|
assign_attributes: function(attributes) {
|
|
20938
|
-
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource,
|
|
20938
|
+
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
|
|
20939
20939
|
|
|
20940
20940
|
_ref = model[this.resource.toString()].has_many;
|
|
20941
20941
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
@@ -20982,7 +20982,7 @@ restful = {
|
|
|
20982
20982
|
_ref3 = model[this.resource.toString()].belongs_to;
|
|
20983
20983
|
for (_m = 0, _len4 = _ref3.length; _m < _len4; _m++) {
|
|
20984
20984
|
association_name = _ref3[_m];
|
|
20985
|
-
association_attributes = (_ref4 =
|
|
20985
|
+
association_attributes = (_ref4 = (_ref5 = attributes[association_name]) != null ? typeof _ref5.json === "function" ? _ref5.json() : void 0 : void 0) != null ? _ref4 : attributes[association_name];
|
|
20986
20986
|
delete attributes[association_name];
|
|
20987
20987
|
delete attributes[association_name + "_attributes"];
|
|
20988
20988
|
if (association_attributes) {
|
|
@@ -20935,7 +20935,7 @@ restful = {
|
|
|
20935
20935
|
return promise;
|
|
20936
20936
|
},
|
|
20937
20937
|
assign_attributes: function(attributes) {
|
|
20938
|
-
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource,
|
|
20938
|
+
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
|
|
20939
20939
|
|
|
20940
20940
|
_ref = model[this.resource.toString()].has_many;
|
|
20941
20941
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
@@ -20982,7 +20982,7 @@ restful = {
|
|
|
20982
20982
|
_ref3 = model[this.resource.toString()].belongs_to;
|
|
20983
20983
|
for (_m = 0, _len4 = _ref3.length; _m < _len4; _m++) {
|
|
20984
20984
|
association_name = _ref3[_m];
|
|
20985
|
-
association_attributes = (_ref4 =
|
|
20985
|
+
association_attributes = (_ref4 = (_ref5 = attributes[association_name]) != null ? typeof _ref5.json === "function" ? _ref5.json() : void 0 : void 0) != null ? _ref4 : attributes[association_name];
|
|
20986
20986
|
delete attributes[association_name];
|
|
20987
20987
|
delete attributes[association_name + "_attributes"];
|
|
20988
20988
|
if (association_attributes) {
|
|
@@ -141,7 +141,7 @@ restful = {
|
|
|
141
141
|
return promise;
|
|
142
142
|
},
|
|
143
143
|
assign_attributes: function(attributes) {
|
|
144
|
-
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource,
|
|
144
|
+
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4, _ref5, _results;
|
|
145
145
|
|
|
146
146
|
_ref = model[this.resource.toString()].has_many;
|
|
147
147
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
|
@@ -188,7 +188,7 @@ restful = {
|
|
|
188
188
|
_ref3 = model[this.resource.toString()].belongs_to;
|
|
189
189
|
for (_m = 0, _len4 = _ref3.length; _m < _len4; _m++) {
|
|
190
190
|
association_name = _ref3[_m];
|
|
191
|
-
association_attributes = (_ref4 =
|
|
191
|
+
association_attributes = (_ref4 = (_ref5 = attributes[association_name]) != null ? typeof _ref5.json === "function" ? _ref5.json() : void 0 : void 0) != null ? _ref4 : attributes[association_name];
|
|
192
192
|
delete attributes[association_name];
|
|
193
193
|
delete attributes[association_name + "_attributes"];
|
|
194
194
|
if (association_attributes) {
|
|
@@ -182,7 +182,7 @@ restful =
|
|
|
182
182
|
# TODO implement setter on belongs_to association and move this
|
|
183
183
|
# code there
|
|
184
184
|
for association_name in model[@resource.toString()].belongs_to
|
|
185
|
-
association_attributes = attributes[association_name]
|
|
185
|
+
association_attributes = attributes[association_name]?.json?() ? attributes[association_name]
|
|
186
186
|
|
|
187
187
|
# TODO copy attributes object and don't change it inside the
|
|
188
188
|
# assignment method
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ende
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.20
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Heitor Salazar
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2014-
|
|
11
|
+
date: 2014-05-08 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -82,6 +82,7 @@ files:
|
|
|
82
82
|
- lib/assets/javascripts/aura/extensions/rivets/formatters.js.coffee
|
|
83
83
|
- lib/assets/javascripts/aura/extensions/routes.js.coffee
|
|
84
84
|
- lib/assets/javascripts/aura/extensions/screening.js.coffee
|
|
85
|
+
- lib/assets/javascripts/aura/extensions/stamps.js.coffee
|
|
85
86
|
- lib/assets/javascripts/aura/extensions/stamps/stampit.js
|
|
86
87
|
- lib/assets/javascripts/aura/extensions/states.js.coffee
|
|
87
88
|
- lib/assets/javascripts/aura/extensions/widget/composable.js.coffee
|