ende 0.4.17 → 0.4.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/component.json +0 -1
  3. data/lib/assets/javascripts/aura/extensions/domain.js.coffee +8 -6
  4. data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +2 -2
  5. data/lib/assets/javascripts/aura/extensions/states.js.coffee +27 -26
  6. data/lib/assets/javascripts/aura/extensions/widget/composable.js.coffee +12 -13
  7. data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +1 -5
  8. data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +3 -2
  9. data/lib/assets/javascripts/config/load_components.js.coffee +2 -0
  10. data/lib/ende/version.rb +1 -1
  11. data/vendor/assets/components/ende_build.js +684 -5384
  12. data/vendor/components/indefinido-indemma/build/development.js +44 -21901
  13. data/vendor/components/indefinido-indemma/build/release.js +228 -256
  14. data/vendor/components/indefinido-indemma/build/test.js +44 -21901
  15. data/vendor/components/indefinido-indemma/lib/record/rest.js +7 -2
  16. data/vendor/components/indefinido-indemma/lib/record/restfulable.js +17 -7
  17. data/vendor/components/indefinido-indemma/lib/record/scopable.js +1 -41
  18. data/vendor/components/indefinido-indemma/lib/record/validatable.js +206 -191
  19. data/vendor/components/indefinido-indemma/src/lib/record/rest.coffee +7 -1
  20. data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +12 -5
  21. data/vendor/components/indefinido-indemma/src/lib/record/scopable.coffee +14 -23
  22. data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +12 -1
  23. metadata +3 -3
  24. /data/{vendor/assets/javascripts/stampit → lib/assets/javascripts/aura/extensions/stamps}/stampit.js +0 -0
@@ -1,4 +1,4 @@
1
- var $, request;
1
+ var $, data_for, request;
2
2
 
3
3
  $ = require('jquery');
4
4
 
@@ -17,7 +17,7 @@ module.exports = {
17
17
  }
18
18
  };
19
19
 
20
- request = function(method, url, data) {
20
+ data_for = function(data) {
21
21
  var param_name;
22
22
 
23
23
  param_name = this.resource.param_name || this.resource.toString();
@@ -29,6 +29,11 @@ request = function(method, url, data) {
29
29
  delete data[param_name]['id'];
30
30
  delete data[param_name]['_id'];
31
31
  }
32
+ return data;
33
+ };
34
+
35
+ request = function(method, url, data) {
36
+ data = data_for.call(this, data);
32
37
  return $.ajax({
33
38
  url: url,
34
39
  data: data,
@@ -339,11 +339,11 @@ restful = {
339
339
  return JSON.stringify(serialized);
340
340
  }
341
341
  },
342
- json: function(methods) {
343
- var definition, json, name, nature, nested, value;
342
+ json: function(options) {
343
+ var definition, json, method, name, nature, nested, value, _ref, _ref1;
344
344
 
345
- if (methods == null) {
346
- methods = {};
345
+ if (options == null) {
346
+ options = {};
347
347
  }
348
348
  json = {};
349
349
  definition = model[this.resource.toString()];
@@ -369,15 +369,15 @@ restful = {
369
369
  console.warn("json: Tryied to serialize nested attribute '" + name + "' without serialization method!");
370
370
  continue;
371
371
  }
372
- json["" + name + "_attributes"] = value.json(methods[name]);
372
+ json["" + name + "_attributes"] = value.json(options[name]);
373
373
  } else if ((value.toJSON != null) || (value.json != null)) {
374
374
  if (value.resource) {
375
375
  continue;
376
376
  }
377
377
  if (value.json != null) {
378
- json[name] = value.json(methods[name]);
378
+ json[name] = value.json(options[name]);
379
379
  } else {
380
- json[name] = value.toJSON(methods[name]);
380
+ json[name] = value.toJSON(options[name]);
381
381
  }
382
382
  } else {
383
383
  continue;
@@ -387,6 +387,16 @@ restful = {
387
387
  }
388
388
  }
389
389
  json = observable.unobserve(json);
390
+ _ref1 = (_ref = options.methods) != null ? _ref : {};
391
+ for (name in _ref1) {
392
+ value = _ref1[name];
393
+ method = this[name];
394
+ if (typeof method === 'function') {
395
+ json[name] = method();
396
+ } else {
397
+ json[name] = method;
398
+ }
399
+ }
390
400
  delete json.dirty;
391
401
  delete json.resource;
392
402
  delete json.route;
@@ -124,7 +124,7 @@ scopable = {
124
124
  return this.scope.fetch.call(this, data, done, fail);
125
125
  },
126
126
  forward_scopes_to_associations: function() {
127
- var associated_factory, associated_resource, association, association_name, factory, forwarder, generate_forwarder, scope, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _m, _ref, _ref1, _ref2, _ref3, _ref4;
127
+ var associated_factory, associated_resource, association, association_name, factory, scope, _i, _j, _len, _len1, _ref, _ref1;
128
128
 
129
129
  factory = model[this.resource.name];
130
130
  _ref = factory.has_many;
@@ -144,46 +144,6 @@ scopable = {
144
144
  association.scope(scope, associated_factory["$" + scope]);
145
145
  }
146
146
  }
147
- _ref2 = factory.has_one;
148
- for (_k = 0, _len2 = _ref2.length; _k < _len2; _k++) {
149
- associated_resource = _ref2[_k];
150
- if (!model[associated_resource]) {
151
- console.warn("Associated factory not found for associated resource: " + associated_resource);
152
- continue;
153
- }
154
- _ref3 = model[associated_resource].scope.declared;
155
- for (_l = 0, _len3 = _ref3.length; _l < _len3; _l++) {
156
- scope = _ref3[_l];
157
- this[associated_resource][scope] = factory[scope];
158
- }
159
- }
160
- if (factory.belongs_to.length) {
161
- generate_forwarder = function(associated_resource) {
162
- var declared_scopes;
163
-
164
- associated_factory = model[associated_resource];
165
- if (!associated_factory) {
166
- return console.warn("Associated factory not found for associated resource: " + associated_resource);
167
- }
168
- declared_scopes = associated_factory.scope.declared;
169
- return function() {
170
- var _len4, _m, _results;
171
-
172
- _results = [];
173
- for (_m = 0, _len4 = declared_scopes.length; _m < _len4; _m++) {
174
- scope = declared_scopes[_m];
175
- _results.push(this[associated_resource][scope] = associated_factory[scope]);
176
- }
177
- return _results;
178
- };
179
- };
180
- _ref4 = factory.belongs_to;
181
- for (_m = 0, _len4 = _ref4.length; _m < _len4; _m++) {
182
- associated_resource = _ref4[_m];
183
- forwarder = generate_forwarder(associated_resource);
184
- this.after("build_" + associated_resource, forwarder);
185
- }
186
- }
187
147
  return true;
188
148
  }
189
149
  },
@@ -1,209 +1,224 @@
1
- (function() {
2
- var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
3
-
4
- require('./translationable');
5
-
6
- root = typeof exports !== "undefined" && exports !== null ? exports : this;
7
-
8
- stampit = require('../../vendor/stampit');
9
-
10
- observable = require('observable').mixin;
11
-
12
- type = require('type');
13
-
14
- messages = {
15
- blank: function(attribute_name) {
16
- attribute_name = this.human_attribute_name(attribute_name);
17
- return "O campo " + attribute_name + " não pode ficar em branco.";
18
- },
19
- cpf: function(attribute_name) {
20
- attribute_name = this.human_attribute_name(attribute_name);
21
- return "O campo " + attribute_name + " não está válido.";
22
- },
23
- confirmation: function(attribute_name) {
24
- var confirmation_attribute_name;
25
- confirmation_attribute_name = this.human_attribute_name(attribute_name);
26
- attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
27
- return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
28
- },
29
- associated: function(attribute_name) {
30
- attribute_name = this.human_attribute_name(attribute_name);
31
- return "O registro associado " + attribute_name + " não é válido.";
32
- },
33
- server: function(attribute_name, options) {
34
- if (attribute_name === 'base') {
35
- return options.server_message;
36
- } else {
37
- attribute_name = this.human_attribute_name(attribute_name);
38
- return "" + attribute_name + " " + options.server_message + ".";
39
- }
40
- },
41
- type: function(attribute_name, options) {
1
+ var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
2
+
3
+ require('./translationable');
4
+
5
+ root = typeof exports !== "undefined" && exports !== null ? exports : this;
6
+
7
+ stampit = require('../../vendor/stampit');
8
+
9
+ observable = require('observable').mixin;
10
+
11
+ type = require('type');
12
+
13
+ messages = {
14
+ blank: function(attribute_name) {
15
+ attribute_name = this.human_attribute_name(attribute_name);
16
+ return "O campo " + attribute_name + " não pode ficar em branco.";
17
+ },
18
+ cpf: function(attribute_name) {
19
+ attribute_name = this.human_attribute_name(attribute_name);
20
+ return "O campo " + attribute_name + " não está válido.";
21
+ },
22
+ confirmation: function(attribute_name) {
23
+ var confirmation_attribute_name;
24
+
25
+ confirmation_attribute_name = this.human_attribute_name(attribute_name);
26
+ attribute_name = this.human_attribute_name(attribute_name.replace('_confirmation', ''));
27
+ return "O campo " + attribute_name + " não está de acordo com o campo " + confirmation_attribute_name + ".";
28
+ },
29
+ associated: function(attribute_name) {
30
+ attribute_name = this.human_attribute_name(attribute_name);
31
+ return "O registro associado " + attribute_name + " não é válido.";
32
+ },
33
+ server: function(attribute_name, options) {
34
+ if (attribute_name === 'base') {
35
+ return options.server_message;
36
+ } else {
42
37
  attribute_name = this.human_attribute_name(attribute_name);
43
- return "O campo " + attribute_name + " não está válido.";
38
+ return "" + attribute_name + " " + options.server_message + ".";
44
39
  }
45
- };
46
-
47
- errorsable = stampit({
48
- add: function(attribute_name, message_key, options) {
49
- var translator;
50
- this.push([attribute_name, message_key, options]);
51
- this.messages[attribute_name] = '';
52
- translator = messages[message_key];
53
- if (translator != null) {
54
- return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
55
- } else {
56
- return this.messages[attribute_name] += message_key;
57
- }
58
- },
59
- clear: function() {
60
- var attribute_name, _results;
61
- if (this.length) {
62
- this.length = 0;
63
- _results = [];
64
- for (attribute_name in this.messages) {
65
- _results.push(this.messages[attribute_name] = null);
66
- }
67
- return _results;
68
- }
69
- },
70
- push: Array.prototype.push,
71
- splice: Array.prototype.splice,
72
- indexOf: Array.prototype.indexOf
73
- }, {
74
- model: null,
75
- messages: null,
76
- length: 0
77
- }, function() {
78
- this.messages = {};
79
- return this;
80
- });
81
-
82
- initializers = {
83
- define_triggers: function() {
84
- this.errors = errorsable({
85
- model: model[this.resource]
86
- });
87
- this.before('save', function() {
88
- if (this.save) return this.validate();
89
- });
90
- this.validated = false;
91
- this.subscribe('dirty', function(value) {
92
- return value && (this.validated = false);
93
- });
94
- return Object.defineProperty(this, 'valid', {
95
- get: function() {
96
- this.validate();
97
- if (this.validation.state() === 'resolved') {
98
- return !this.errors.length;
99
- } else {
100
- return null;
101
- }
102
- },
103
- set: function() {
104
- throw new TypeError("You can't set the value for the valid property.");
105
- },
106
- enumerable: false
107
- });
108
- },
109
- create_validators: function(definitions) {
110
- var definition, name, validator, validator_options, _ref, _results;
111
- this.validators = [];
112
- _ref = manager.validators;
40
+ },
41
+ type: function(attribute_name, options) {
42
+ attribute_name = this.human_attribute_name(attribute_name);
43
+ return "O campo " + attribute_name + " não está válido.";
44
+ }
45
+ };
46
+
47
+ errorsable = stampit({
48
+ add: function(attribute_name, message_key, options) {
49
+ var translator;
50
+
51
+ this.push([attribute_name, message_key, options]);
52
+ this.messages[attribute_name] = '';
53
+ translator = messages[message_key];
54
+ if (translator != null) {
55
+ return this.messages[attribute_name] += translator.call(this.model, attribute_name, options);
56
+ } else {
57
+ return this.messages[attribute_name] += message_key;
58
+ }
59
+ },
60
+ clear: function() {
61
+ var attribute_name, _results;
62
+
63
+ if (this.length) {
64
+ this.length = 0;
113
65
  _results = [];
114
- for (name in _ref) {
115
- validator = _ref[name];
116
- definition = definitions[validator.definition_key];
117
- if (definition) {
118
- if (type(definition) !== 'array') definition = [definition];
119
- _results.push((function() {
120
- var _i, _len, _results2;
121
- _results2 = [];
122
- for (_i = 0, _len = definition.length; _i < _len; _i++) {
123
- validator_options = definition[_i];
124
- if (type(validator_options) !== 'object') {
125
- validator_options = {
126
- attribute_name: validator_options
127
- };
128
- }
129
- validator_options.model = this;
130
- this.validators.push(validator(validator_options));
131
- _results2.push(delete definitions[validator.definition_key]);
132
- }
133
- return _results2;
134
- }).call(this));
135
- } else {
136
- _results.push(void 0);
137
- }
66
+ for (attribute_name in this.messages) {
67
+ _results.push(this.messages[attribute_name] = null);
138
68
  }
139
69
  return _results;
140
70
  }
141
- };
142
-
143
- extensions = {
144
- model: {
145
- validators: null
146
- },
147
- record: {
148
- validate_attribute: function(attribute, doned, failed) {
149
- var results, validation, validator, _i, _len, _ref;
150
- this.errors.messages[attribute] = null;
151
- results = [this, attribute];
152
- _ref = model[this.resource.toString()].validators;
153
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
154
- validator = _ref[_i];
155
- if (validator.attribute_name === attribute) {
156
- results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
157
- }
158
- }
159
- validation = jQuery.when.apply(jQuery, results);
160
- validation.done(doned);
161
- validation.fail(failed);
162
- return validation;
71
+ },
72
+ push: Array.prototype.push,
73
+ splice: Array.prototype.splice,
74
+ indexOf: Array.prototype.indexOf
75
+ }, {
76
+ model: null,
77
+ messages: null,
78
+ length: 0
79
+ }, function() {
80
+ this.messages = {};
81
+ return this;
82
+ });
83
+
84
+ initializers = {
85
+ define_triggers: function() {
86
+ this.errors = errorsable({
87
+ model: model[this.resource]
88
+ });
89
+ this.before('save', function() {
90
+ if (this.save) {
91
+ return this.validate();
92
+ }
93
+ });
94
+ this.validated = false;
95
+ this.subscribe('dirty', function(value) {
96
+ return value && (this.validated = false);
97
+ });
98
+ return Object.defineProperty(this, 'valid', {
99
+ get: function() {
100
+ this.validate();
101
+ if (this.validation.state() === 'resolved') {
102
+ return !this.errors.length;
103
+ } else {
104
+ return null;
105
+ }
106
+ },
107
+ set: function() {
108
+ throw new TypeError("You can't set the value for the valid property.");
163
109
  },
164
- validate: function(doned, failed) {
165
- var results, validator, _i, _len, _ref;
166
- if (this.validated && !this.dirty) return this.validation;
167
- this.errors.clear();
168
- results = [this];
169
- _ref = model[this.resource.toString()].validators;
170
- for (_i = 0, _len = _ref.length; _i < _len; _i++) {
171
- validator = _ref[_i];
172
- results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
173
- }
174
- this.validation = jQuery.when.apply(jQuery, results);
175
- this.validation.done(doned);
176
- this.validation.fail(failed);
177
- return this.validation.done(function(record) {
178
- return record.validated || (record.validated = true);
179
- });
110
+ enumerable: false
111
+ });
112
+ },
113
+ create_validators: function(definitions) {
114
+ var definition, name, validator, validator_options, _ref, _results;
115
+
116
+ this.validators = [];
117
+ _ref = manager.validators;
118
+ _results = [];
119
+ for (name in _ref) {
120
+ validator = _ref[name];
121
+ definition = definitions[validator.definition_key];
122
+ if (definition) {
123
+ if (type(definition) !== 'array') {
124
+ definition = [definition];
125
+ }
126
+ _results.push((function() {
127
+ var _i, _len, _results1;
128
+
129
+ _results1 = [];
130
+ for (_i = 0, _len = definition.length; _i < _len; _i++) {
131
+ validator_options = definition[_i];
132
+ if (type(validator_options) !== 'object') {
133
+ validator_options = {
134
+ attribute_name: validator_options
135
+ };
136
+ }
137
+ validator_options.model = this;
138
+ this.validators.push(validator(validator_options));
139
+ _results1.push(delete definitions[validator.definition_key]);
140
+ }
141
+ return _results1;
142
+ }).call(this));
143
+ } else {
144
+ _results.push(void 0);
180
145
  }
181
146
  }
182
- };
147
+ return _results;
148
+ }
149
+ };
150
+
151
+ extensions = {
152
+ model: {
153
+ validators: null
154
+ },
155
+ record: {
156
+ validate_attribute: function(attribute, doned, failed) {
157
+ var results, validation, validator, _i, _len, _ref;
158
+
159
+ this.errors.messages[attribute] = null;
160
+ results = [this, attribute];
161
+ _ref = model[this.resource.toString()].validators;
162
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
163
+ validator = _ref[_i];
164
+ if (validator.attribute_name === attribute) {
165
+ results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
166
+ }
167
+ }
168
+ validation = jQuery.when.apply(jQuery, results);
169
+ validation.done(doned);
170
+ validation.fail(failed);
171
+ return validation;
172
+ },
173
+ validate: function(doned, failed) {
174
+ var results, validator, _i, _len, _ref;
183
175
 
184
- manager = {
185
- validators: {}
186
- };
176
+ if (this.validated && !this.dirty) {
177
+ return this.validation;
178
+ }
179
+ this.errors.clear();
180
+ results = [this];
181
+ _ref = model[this.resource.toString()].validators;
182
+ for (_i = 0, _len = _ref.length; _i < _len; _i++) {
183
+ validator = _ref[_i];
184
+ results.push(validator.validate_each(this, validator.attribute_name, this[validator.attribute_name]));
185
+ }
186
+ this.validation = jQuery.when.apply(jQuery, results);
187
+ this.validation.done(doned);
188
+ this.validation.fail(failed);
189
+ return this.validation.done(function(record) {
190
+ var old_dirty;
191
+
192
+ old_dirty = record.dirty;
193
+ record.dirty = null;
194
+ record.validated || (record.validated = true);
195
+ record.dirty = old_dirty;
196
+ return record;
197
+ });
198
+ }
199
+ }
200
+ };
187
201
 
188
- model.mix(function(modelable) {
189
- jQuery.extend(modelable, extensions.model);
190
- jQuery.extend(modelable.record, extensions.record);
191
- modelable.after_mix.unshift(initializers.create_validators);
192
- modelable.record.after_initialize.push(initializers.define_triggers);
193
- return model.validators = manager.validators;
194
- });
202
+ manager = {
203
+ validators: {}
204
+ };
195
205
 
196
- manager.validators.confirmation = require('./validations/confirmation');
206
+ model.mix(function(modelable) {
207
+ jQuery.extend(modelable, extensions.model);
208
+ jQuery.extend(modelable.record, extensions.record);
209
+ modelable.after_mix.unshift(initializers.create_validators);
210
+ modelable.record.after_initialize.push(initializers.define_triggers);
211
+ return model.validators = manager.validators;
212
+ });
197
213
 
198
- manager.validators.associated = require('./validations/associated');
214
+ manager.validators.confirmation = require('./validations/confirmation');
199
215
 
200
- manager.validators.presence = require('./validations/presence');
216
+ manager.validators.associated = require('./validations/associated');
201
217
 
202
- manager.validators.remote = require('./validations/remote');
218
+ manager.validators.presence = require('./validations/presence');
203
219
 
204
- manager.validators.type = require('./validations/type');
220
+ manager.validators.remote = require('./validations/remote');
205
221
 
206
- manager.validators.cpf = require('./validations/cpf');
222
+ manager.validators.type = require('./validations/type');
207
223
 
208
- }).call(this);
209
- ;
224
+ manager.validators.cpf = require('./validations/cpf');
@@ -7,7 +7,9 @@ module.exports =
7
7
  post : (data) -> request.call @, 'post' , @route, data
8
8
  delete: (data) -> request.call @, 'delete', (if @_id then "#{@route}/#{@_id}" else @route), data
9
9
 
10
- request = (method, url, data) ->
10
+
11
+ # TODO move to serialization module
12
+ data_for = (data) ->
11
13
  param_name = @resource.param_name || @resource.toString()
12
14
 
13
15
  # TODO optmize this serialization lookup
@@ -19,6 +21,10 @@ request = (method, url, data) ->
19
21
  delete data[param_name]['id']
20
22
  delete data[param_name]['_id']
21
23
 
24
+ data
25
+
26
+ request = (method, url, data) ->
27
+ data = data_for.call @, data
22
28
 
23
29
  $.ajax
24
30
  url : url
@@ -323,7 +323,7 @@ restful =
323
323
  # TODO move this to serializable module
324
324
  # TODO figure out why sometimes is rendering a circular referenced json
325
325
  # TODO rename to toJSON
326
- json: (methods = {}) ->
326
+ json: (options = {}) ->
327
327
  json = {}
328
328
 
329
329
  definition = model[@resource.toString()]
@@ -356,7 +356,7 @@ restful =
356
356
 
357
357
  # TODO move nested attributes to model definition and
358
358
  # implement toJSON there
359
- json["#{name}_attributes"] = value.json methods[name]
359
+ json["#{name}_attributes"] = value.json options[name]
360
360
 
361
361
  # Serialize complex type values
362
362
  else if value.toJSON? || value.json?
@@ -366,9 +366,9 @@ restful =
366
366
 
367
367
  # TODO rename json to toJSON
368
368
  if value.json?
369
- json[name] = value.json methods[name]
369
+ json[name] = value.json options[name]
370
370
  else
371
- json[name] = value.toJSON methods[name]
371
+ json[name] = value.toJSON options[name]
372
372
 
373
373
  # It is a complex type value without serializtion support so
374
374
  # we just ignore it
@@ -381,9 +381,16 @@ restful =
381
381
  # Serialize primitive type values
382
382
  json[name] = value
383
383
 
384
- # Remove observable methods and dom node properties
384
+ # Remove observable options and dom node properties
385
385
  json = observable.unobserve json
386
386
 
387
+ for name, value of options.methods ? {}
388
+ method = @[name]
389
+ if typeof method == 'function'
390
+ json[name] = method()
391
+ else
392
+ json[name] = method
393
+
387
394
  # TODO Store reserved words in a array
388
395
  # TODO Use _.omit function
389
396
  # TODO Use object.defineProperty to not need to delete this properties