ende 0.3.13 → 0.4.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/component.json +7 -0
- data/lib/assets/javascripts/aura/extensions/devise.js.coffee +2 -2
- data/lib/assets/javascripts/aura/extensions/loader.js.coffee +13 -11
- data/lib/assets/javascripts/aura/extensions/mask.js.coffee +54 -40
- data/lib/assets/javascripts/aura/extensions/mediator.js +5 -3
- data/lib/assets/javascripts/aura/extensions/models.js.coffee.erb +2 -2
- data/lib/assets/javascripts/aura/extensions/rivets/accounting.js.coffee +7 -1
- data/lib/assets/javascripts/aura/extensions/rivets/formatters.js.coffee +5 -1
- data/lib/assets/javascripts/aura/extensions/rivets.js.coffee +47 -29
- data/lib/assets/javascripts/aura/extensions/routes.js.coffee +10 -5
- data/lib/assets/javascripts/aura/extensions/states.js.coffee +2 -2
- data/lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee +18 -19
- data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +15 -10
- data/lib/assets/javascripts/config/initializers/jquery.js.coffee +2 -1
- data/lib/assets/javascripts/config/initializers/requirejs.js.coffee +3 -4
- data/lib/assets/javascripts/config/initializers.js.coffee +3 -0
- data/lib/assets/javascripts/config/load_components.js.coffee +106 -83
- data/lib/assets/javascripts/ende.js.coffee +13 -4
- data/lib/assets/javascripts/widgets/authenticator/presenter.js.coffee +3 -2
- data/lib/assets/javascripts/widgets/dialog/main.js.coffee +7 -3
- data/lib/assets/javascripts/widgets/support/main.js.coffee +3 -4
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +35 -103
- data/lib/assets/javascripts/widgets/viewer/presenters/default.js.coffee +2 -4
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/build.js +30877 -0
- data/vendor/assets/components/ende_build.js +2487 -148
- data/vendor/assets/components/indemma_with_none.js +30553 -0
- data/vendor/assets/javascripts/spin/spin.js +349 -0
- data/vendor/components/indefinido-indemma/.gitignore +3 -0
- data/vendor/components/indefinido-indemma/.ruby-gemset +1 -1
- data/vendor/components/indefinido-indemma/.ruby-version +1 -1
- data/vendor/components/indefinido-indemma/build/development.js +17 -14
- data/vendor/components/indefinido-indemma/build/release.js +213 -148
- data/vendor/components/indefinido-indemma/build/test.js +213 -148
- data/vendor/components/indefinido-indemma/component.json +3 -1
- data/vendor/components/indefinido-indemma/karma.conf.js +50 -60
- data/vendor/components/indefinido-indemma/lib/record/associable.js +17 -17
- data/vendor/components/indefinido-indemma/lib/record/persistable.js +8 -1
- data/vendor/components/indefinido-indemma/lib/record/queryable.js +3 -0
- data/vendor/components/indefinido-indemma/lib/record/resource.js +25 -45
- data/vendor/components/indefinido-indemma/lib/record/restfulable.js +82 -28
- data/vendor/components/indefinido-indemma/lib/record/scopable.js +28 -2
- data/vendor/components/indefinido-indemma/lib/record/storable.js +1 -1
- data/vendor/components/indefinido-indemma/lib/record/validatable.js +15 -23
- data/vendor/components/indefinido-indemma/lib/record/validations/associated.js +3 -5
- data/vendor/components/indefinido-indemma/lib/record/validations/confirmation.js +3 -5
- data/vendor/components/indefinido-indemma/lib/record/validations/cpf.js +5 -7
- data/vendor/components/indefinido-indemma/lib/record/validations/presence.js +3 -5
- data/vendor/components/indefinido-indemma/lib/record/validations/remote.js +3 -7
- data/vendor/components/indefinido-indemma/lib/record/validations/type.js +2 -2
- data/vendor/components/indefinido-indemma/lib/record/validations/validatorable.js +12 -0
- data/vendor/components/indefinido-indemma/package.json +9 -0
- data/vendor/components/indefinido-indemma/spec/record/restfulable_spec.js +12 -0
- data/vendor/components/indefinido-indemma/spec/record/validatable_spec.js +4 -4
- data/vendor/components/indefinido-indemma/spec/record/validations/associated_spec.js +2 -2
- data/vendor/components/indefinido-indemma/src/lib/record/associable.coffee +44 -20
- data/vendor/components/indefinido-indemma/src/lib/record/persistable.coffee +7 -2
- data/vendor/components/indefinido-indemma/src/lib/record/queryable.coffee +1 -0
- data/vendor/components/indefinido-indemma/src/lib/record/resource.coffee +32 -32
- data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +79 -22
- data/vendor/components/indefinido-indemma/src/lib/record/scopable.coffee +27 -8
- data/vendor/components/indefinido-indemma/src/lib/record/storable.coffee +1 -1
- data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +20 -19
- data/vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee +3 -5
- data/vendor/components/indefinido-indemma/src/lib/record/validations/confirmation.coffee +2 -4
- data/vendor/components/indefinido-indemma/src/lib/record/validations/cpf.coffee +4 -5
- data/vendor/components/indefinido-indemma/src/lib/record/validations/presence.coffee +2 -5
- data/vendor/components/indefinido-indemma/src/lib/record/validations/remote.coffee +3 -7
- data/vendor/components/indefinido-indemma/src/lib/record/validations/type.coffee +2 -3
- data/vendor/components/indefinido-indemma/src/lib/record/validations/validatorable.coffee +5 -0
- data/vendor/components/indefinido-indemma/src/spec/record/restfulable_spec.coffee +8 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validatable_spec.coffee +4 -4
- data/vendor/components/indefinido-indemma/src/spec/record/validations/associated_spec.coffee +2 -2
- metadata +9 -3
- data/lib/assets/javascripts/aura/extensions/rivets/formatters.js.coffee~ +0 -0
@@ -20202,26 +20202,22 @@ singular = {
|
|
20202
20202
|
subscribers = {
|
20203
20203
|
belongs_to: {
|
20204
20204
|
foreign_key: function(resource_id) {
|
20205
|
-
var
|
20205
|
+
var association_name, current_resource_id, resource, _ref;
|
20206
20206
|
|
20207
20207
|
association_name = this.resource.toString();
|
20208
|
-
if (resource_id
|
20208
|
+
if (!resource_id) {
|
20209
20209
|
this.dirty = true;
|
20210
20210
|
this.owner[association_name] = resource_id;
|
20211
20211
|
return resource_id;
|
20212
20212
|
}
|
20213
|
-
current_resource_id = (_ref = this.owner[association_name]) != null ? _ref._id : void 0;
|
20213
|
+
current_resource_id = (_ref = this.owner.observed[association_name]) != null ? _ref._id : void 0;
|
20214
20214
|
if (resource_id !== current_resource_id) {
|
20215
20215
|
resource = model[association_name];
|
20216
20216
|
if (!resource) {
|
20217
20217
|
console.warn("subscribers.belongs_to.foreign_key: associated factory not found for model: " + association_name);
|
20218
20218
|
return resource_id;
|
20219
20219
|
}
|
20220
|
-
|
20221
|
-
associated || (associated = resource({
|
20222
|
-
_id: resource_id
|
20223
|
-
}));
|
20224
|
-
this.owner.observed[association_name] = associated;
|
20220
|
+
this.owner.observed[association_name] = null;
|
20225
20221
|
}
|
20226
20222
|
return resource_id;
|
20227
20223
|
},
|
@@ -20259,10 +20255,12 @@ modifiers = {
|
|
20259
20255
|
return associated;
|
20260
20256
|
}
|
20261
20257
|
associated = resource.find(associated_id || associated._id);
|
20258
|
+
if (associated) {
|
20259
|
+
return _this.owner.observed[association_name] = associated;
|
20260
|
+
}
|
20262
20261
|
associated || (associated = resource({
|
20263
20262
|
_id: associated_id
|
20264
20263
|
}));
|
20265
|
-
resource.storage.store(associated._id, associated);
|
20266
20264
|
associated.reload();
|
20267
20265
|
return _this.owner.observed[association_name] = associated;
|
20268
20266
|
},
|
@@ -20284,8 +20282,8 @@ callbacks = {
|
|
20284
20282
|
for (_i = 0, _len = association_names.length; _i < _len; _i++) {
|
20285
20283
|
association_name = association_names[_i];
|
20286
20284
|
associations_attributes = this["" + association_name + "_attributes"];
|
20285
|
+
association = this[model.pluralize(association_name)];
|
20287
20286
|
if (associations_attributes && associations_attributes.length) {
|
20288
|
-
association = this[model.pluralize(association_name)];
|
20289
20287
|
if (!association) {
|
20290
20288
|
message = "has_many.nest_attributes: Association not found for " + association_name + ". \n";
|
20291
20289
|
message += "did you set it on model declaration? \n has_many: " + association_name + " ";
|
@@ -20375,7 +20373,7 @@ associable = {
|
|
20375
20373
|
return true;
|
20376
20374
|
},
|
20377
20375
|
create_after_hooks: function(definition) {
|
20378
|
-
var association_name, association_proxy, old_resource_id, options, resource, _i, _j, _k, _len, _len1, _len2, _ref, _ref1, _ref2, _results;
|
20376
|
+
var association_attributes, association_name, association_proxy, old_dirty, old_resource_id, options, resource, _i, _j, _k, _len, _len1, _len2, _name, _ref, _ref1, _ref2, _results;
|
20379
20377
|
|
20380
20378
|
options = model[this.resource.name || this.resource.toString()];
|
20381
20379
|
if (options.has_many) {
|
@@ -20388,6 +20386,11 @@ associable = {
|
|
20388
20386
|
parent: this
|
20389
20387
|
};
|
20390
20388
|
association_name = model.pluralize(resource);
|
20389
|
+
association_attributes = this[association_name] || [];
|
20390
|
+
this[_name = "" + association_name + "_attributes"] || (this[_name] = []);
|
20391
|
+
if (association_attributes.length) {
|
20392
|
+
this["" + association_name + "_attributes"] = this["" + association_name + "_attributes"].concat(association_attributes);
|
20393
|
+
}
|
20391
20394
|
this[association_name] = $.extend(association_proxy, plural);
|
20392
20395
|
}
|
20393
20396
|
this.after('saved', callbacks.has_many.update_association);
|
@@ -20423,15 +20426,12 @@ associable = {
|
|
20423
20426
|
this["build_" + resource] = $.proxy(singular.build, association_proxy);
|
20424
20427
|
this["create_" + resource] = $.proxy(singular.create, association_proxy);
|
20425
20428
|
old_resource_id = this["" + resource + "_id"];
|
20429
|
+
old_dirty = this.dirty;
|
20426
20430
|
this["" + resource + "_id"] = null;
|
20427
20431
|
this.subscribe("" + resource + "_id", $.proxy(subscribers.belongs_to.foreign_key, association_proxy));
|
20428
20432
|
this.subscribe(resource.toString(), $.proxy(subscribers.belongs_to.associated_changed, association_proxy));
|
20429
|
-
this
|
20430
|
-
|
20431
|
-
_results.push(this.publish("" + resource + "_id", this["" + resource + "_id"]));
|
20432
|
-
} else {
|
20433
|
-
_results.push(void 0);
|
20434
|
-
}
|
20433
|
+
this["" + resource + "_id"] = old_resource_id;
|
20434
|
+
_results.push(this.dirty = old_dirty);
|
20435
20435
|
}
|
20436
20436
|
return _results;
|
20437
20437
|
}
|
@@ -20506,7 +20506,14 @@ handlers = {
|
|
20506
20506
|
persistable = {
|
20507
20507
|
record: {
|
20508
20508
|
after_initialize: function() {
|
20509
|
-
|
20509
|
+
var storage;
|
20510
|
+
|
20511
|
+
if (this._id) {
|
20512
|
+
storage = model[this.resource.toString()].storage;
|
20513
|
+
return storage.store(this._id, this);
|
20514
|
+
} else {
|
20515
|
+
return this.after('saved', handlers.store_after_saved);
|
20516
|
+
}
|
20510
20517
|
}
|
20511
20518
|
}
|
20512
20519
|
};
|
@@ -20548,7 +20555,7 @@ storable = stampit({
|
|
20548
20555
|
return collection[key];
|
20549
20556
|
} else {
|
20550
20557
|
this.writes++;
|
20551
|
-
value.sustained = true;
|
20558
|
+
value.sustained || (value.sustained = true);
|
20552
20559
|
return collection[key] = value;
|
20553
20560
|
}
|
20554
20561
|
},
|
@@ -20585,6 +20592,9 @@ stampit = require('../../vendor/stampit');
|
|
20585
20592
|
queryable = {
|
20586
20593
|
storage: storable(),
|
20587
20594
|
find: function(key) {
|
20595
|
+
if (!key) {
|
20596
|
+
throw new TypeError("InvalidFind: resource.find was called with a falsey value");
|
20597
|
+
}
|
20588
20598
|
return this.storage.store(key);
|
20589
20599
|
},
|
20590
20600
|
all: function() {
|
@@ -20609,7 +20619,7 @@ model.mix(function(modelable) {
|
|
20609
20619
|
|
20610
20620
|
});
|
20611
20621
|
require.register("indemma/lib/record/resource.js", function(exports, require, module){
|
20612
|
-
var model, resource, resourceable, stampit;
|
20622
|
+
var descriptors, model, resource, resourceable, stampit;
|
20613
20623
|
|
20614
20624
|
stampit = require('../../vendor/stampit');
|
20615
20625
|
|
@@ -20636,34 +20646,11 @@ resource = stampit({
|
|
20636
20646
|
return this;
|
20637
20647
|
});
|
20638
20648
|
|
20639
|
-
|
20640
|
-
pluralize: function(word, count, plural) {
|
20641
|
-
if (!(word && word.length)) {
|
20642
|
-
throw new TypeError("Invalid string passed to pluralize '" + word + "'");
|
20643
|
-
}
|
20644
|
-
if (word.indexOf('s') !== word.length - 1) {
|
20645
|
-
return owl.pluralize(word, count, plural);
|
20646
|
-
} else {
|
20647
|
-
return word;
|
20648
|
-
}
|
20649
|
-
},
|
20650
|
-
singularize: function(word) {
|
20651
|
-
if (!(word && word.length)) {
|
20652
|
-
throw new TypeError("Invalid string passed to singularize '" + word + "'");
|
20653
|
-
}
|
20654
|
-
if (word.lastIndexOf('s') === word.length - 1) {
|
20655
|
-
return word.substring(0, word.length - 1);
|
20656
|
-
} else {
|
20657
|
-
return word;
|
20658
|
-
}
|
20659
|
-
},
|
20649
|
+
descriptors = {
|
20660
20650
|
route: {
|
20661
20651
|
get: function() {
|
20662
20652
|
var route;
|
20663
20653
|
|
20664
|
-
if (this.initial_route != null) {
|
20665
|
-
return this.initial_route;
|
20666
|
-
}
|
20667
20654
|
if (typeof this.resource === 'string') {
|
20668
20655
|
this.resource = {
|
20669
20656
|
name: this.resource
|
@@ -20677,33 +20664,36 @@ resourceable = {
|
|
20677
20664
|
route += this.resource.scope + '/';
|
20678
20665
|
}
|
20679
20666
|
route += this.resource.singular ? this.resource.name : model.pluralize(this.resource.name);
|
20680
|
-
this.
|
20681
|
-
return route;
|
20667
|
+
return this.route = route;
|
20682
20668
|
},
|
20683
|
-
|
20684
|
-
|
20669
|
+
configurable: true
|
20670
|
+
}
|
20671
|
+
};
|
20672
|
+
|
20673
|
+
resourceable = {
|
20674
|
+
pluralize: function(word, count, plural) {
|
20675
|
+
if (!(word && word.length)) {
|
20676
|
+
throw new TypeError("Invalid string passed to pluralize '" + word + "'");
|
20677
|
+
}
|
20678
|
+
if (word.indexOf('s') !== word.length - 1) {
|
20679
|
+
return owl.pluralize(word, count, plural);
|
20680
|
+
} else {
|
20681
|
+
return word;
|
20685
20682
|
}
|
20686
20683
|
},
|
20687
|
-
|
20688
|
-
|
20689
|
-
|
20690
|
-
|
20691
|
-
|
20692
|
-
|
20693
|
-
|
20694
|
-
return
|
20684
|
+
singularize: function(word) {
|
20685
|
+
if (!(word && word.length)) {
|
20686
|
+
throw new TypeError("Invalid string passed to singularize '" + word + "'");
|
20687
|
+
}
|
20688
|
+
if (word.lastIndexOf('s') === word.length - 1) {
|
20689
|
+
return word.substring(0, word.length - 1);
|
20690
|
+
} else {
|
20691
|
+
return word;
|
20695
20692
|
}
|
20696
20693
|
},
|
20697
20694
|
initialize: function() {
|
20698
20695
|
var resource_definition, _ref;
|
20699
20696
|
|
20700
|
-
if (this.parent_resource) {
|
20701
|
-
Object.defineProperty(this, "" + this.parent_resource + "_id", {
|
20702
|
-
value: resourceable.parent_id,
|
20703
|
-
configurable: true,
|
20704
|
-
enumerable: true
|
20705
|
-
});
|
20706
|
-
}
|
20707
20697
|
resource_definition = {};
|
20708
20698
|
if (typeof this.resource === 'string') {
|
20709
20699
|
resource_definition = {
|
@@ -20716,7 +20706,7 @@ resourceable = {
|
|
20716
20706
|
}
|
20717
20707
|
resource_definition.parent = this.parent_resource;
|
20718
20708
|
this.resource = resource(resource_definition);
|
20719
|
-
return (_ref = this.route) != null ? _ref : Object.defineProperty(this, 'route',
|
20709
|
+
return (_ref = this.route) != null ? _ref : Object.defineProperty(this, 'route', descriptors.route);
|
20720
20710
|
}
|
20721
20711
|
};
|
20722
20712
|
|
@@ -20775,7 +20765,7 @@ request = function(method, url, data) {
|
|
20775
20765
|
|
20776
20766
|
});
|
20777
20767
|
require.register("indemma/lib/record/restfulable.js", function(exports, require, module){
|
20778
|
-
var $, merge, model, observable, record, rest, restful, type, util,
|
20768
|
+
var $, merge, model, observable, record, rest, restful, root, type, util,
|
20779
20769
|
__slice = [].slice;
|
20780
20770
|
|
20781
20771
|
merge = require('assimilate').withStrategy('deep');
|
@@ -20788,15 +20778,17 @@ $ = require('jquery');
|
|
20788
20778
|
|
20789
20779
|
rest = require('./rest.js');
|
20790
20780
|
|
20781
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
20782
|
+
|
20791
20783
|
util = {
|
20792
20784
|
model: {
|
20793
|
-
map: function(
|
20794
|
-
var
|
20785
|
+
map: function(records) {
|
20786
|
+
var record, _i, _len, _results;
|
20795
20787
|
|
20796
20788
|
_results = [];
|
20797
|
-
for (_i = 0, _len =
|
20798
|
-
|
20799
|
-
_results.push(this(
|
20789
|
+
for (_i = 0, _len = records.length; _i < _len; _i++) {
|
20790
|
+
record = records[_i];
|
20791
|
+
_results.push(this(record));
|
20800
20792
|
}
|
20801
20793
|
return _results;
|
20802
20794
|
}
|
@@ -20828,15 +20820,15 @@ restful = {
|
|
20828
20820
|
}
|
20829
20821
|
return $.when.apply($, savings);
|
20830
20822
|
},
|
20831
|
-
all: function(conditions,
|
20823
|
+
all: function(conditions, doned, failed) {
|
20832
20824
|
if (conditions == null) {
|
20833
20825
|
conditions = {};
|
20834
20826
|
}
|
20835
20827
|
if (typeof conditions === 'function') {
|
20836
|
-
|
20828
|
+
doned = conditions;
|
20837
20829
|
conditions = {};
|
20838
20830
|
}
|
20839
|
-
return $.when(rest.get.call(this, conditions)).then(util.model.map).done(
|
20831
|
+
return $.when(rest.get.call(this, conditions)).then(util.model.map).done(doned).fail(failed);
|
20840
20832
|
},
|
20841
20833
|
first: function(conditions, callback) {
|
20842
20834
|
var namespaced;
|
@@ -20854,15 +20846,21 @@ restful = {
|
|
20854
20846
|
return this.all(conditions, callback);
|
20855
20847
|
},
|
20856
20848
|
get: function(action, data) {
|
20857
|
-
var old_route, payload, promise, resource
|
20849
|
+
var default_route, old_route, payload, promise, resource;
|
20858
20850
|
|
20859
20851
|
if (data == null) {
|
20860
20852
|
data = {};
|
20861
20853
|
}
|
20862
20854
|
old_route = this.route;
|
20863
|
-
|
20855
|
+
default_route = "/" + (model.pluralize(this.resource.name));
|
20856
|
+
if (default_route !== this.route) {
|
20857
|
+
this.route = default_route;
|
20858
|
+
}
|
20864
20859
|
if (action) {
|
20865
|
-
this
|
20860
|
+
Object.defineProperty(this, 'route', {
|
20861
|
+
value: "" + default_route + "/" + action,
|
20862
|
+
configurable: true
|
20863
|
+
});
|
20866
20864
|
}
|
20867
20865
|
resource = data.resource;
|
20868
20866
|
if (data && data.json) {
|
@@ -20874,13 +20872,19 @@ restful = {
|
|
20874
20872
|
data[resource] = payload;
|
20875
20873
|
}
|
20876
20874
|
promise = rest.get.call(this, data);
|
20877
|
-
route
|
20875
|
+
Object.defineProperty(this, 'route', {
|
20876
|
+
value: old_route,
|
20877
|
+
configurable: true
|
20878
|
+
});
|
20878
20879
|
return promise;
|
20879
20880
|
},
|
20880
20881
|
put: rest.put,
|
20881
20882
|
"delete": rest["delete"]
|
20882
20883
|
},
|
20883
20884
|
record: {
|
20885
|
+
ready: function(callback) {
|
20886
|
+
return callback.call(this);
|
20887
|
+
},
|
20884
20888
|
reload: function() {
|
20885
20889
|
var data, param, params, promise, _i, _len;
|
20886
20890
|
|
@@ -20892,6 +20896,11 @@ restful = {
|
|
20892
20896
|
promise = rest.get.call(this, data || {});
|
20893
20897
|
promise.done(this.assign_attributes);
|
20894
20898
|
promise.fail(this.failed);
|
20899
|
+
this.reloading = promise;
|
20900
|
+
this.ready = function() {
|
20901
|
+
console.warn("resource.ready was deprecated, please use resource.reloading.done");
|
20902
|
+
return promise.done.apply(promise, arguments);
|
20903
|
+
};
|
20895
20904
|
for (_i = 0, _len = params.length; _i < _len; _i++) {
|
20896
20905
|
param = params[_i];
|
20897
20906
|
promise.done(param);
|
@@ -20899,7 +20908,7 @@ restful = {
|
|
20899
20908
|
return promise;
|
20900
20909
|
},
|
20901
20910
|
assign_attributes: function(attributes) {
|
20902
|
-
var association, association_attributes, association_name, associations_attributes, attribute, message, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _results;
|
20911
|
+
var association, association_attributes, association_name, associations_attributes, attribute, message, name, singular_resource, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref, _ref1, _ref2, _results;
|
20903
20912
|
|
20904
20913
|
_ref = model[this.resource.toString()].has_many;
|
20905
20914
|
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
@@ -20944,9 +20953,18 @@ restful = {
|
|
20944
20953
|
}
|
20945
20954
|
}
|
20946
20955
|
_results = [];
|
20947
|
-
for (
|
20948
|
-
|
20949
|
-
|
20956
|
+
for (name in attributes) {
|
20957
|
+
attribute = attributes[name];
|
20958
|
+
if (attribute !== this[name]) {
|
20959
|
+
if (type(attribute) === 'object') {
|
20960
|
+
if (JSON.stringify(attribute) !== JSON.stringify(this[name])) {
|
20961
|
+
_results.push(this[name] = attributes[name]);
|
20962
|
+
} else {
|
20963
|
+
_results.push(void 0);
|
20964
|
+
}
|
20965
|
+
} else {
|
20966
|
+
_results.push(this[name] = attributes[name]);
|
20967
|
+
}
|
20950
20968
|
}
|
20951
20969
|
}
|
20952
20970
|
return _results;
|
@@ -20967,18 +20985,23 @@ restful = {
|
|
20967
20985
|
saving: false,
|
20968
20986
|
salvation: null,
|
20969
20987
|
save: function(doned, failed, data) {
|
20970
|
-
var salvation;
|
20988
|
+
var lock, salvation;
|
20971
20989
|
|
20990
|
+
lock = JSON.stringify(this.json());
|
20972
20991
|
if (this.saving) {
|
20973
|
-
|
20992
|
+
if (this.lock === lock) {
|
20993
|
+
return this.salvation;
|
20994
|
+
} else {
|
20995
|
+
this.salvation.abort();
|
20996
|
+
}
|
20974
20997
|
}
|
20975
|
-
this.lock =
|
20998
|
+
this.lock = lock;
|
20976
20999
|
if (!this.dirty) {
|
20977
21000
|
salvation = $.Deferred().resolveWith(this, null);
|
20978
21001
|
}
|
21002
|
+
this.saving = true;
|
20979
21003
|
salvation || (salvation = rest[this._id ? 'put' : 'post'].call(this, data));
|
20980
21004
|
this.salvation = salvation;
|
20981
|
-
this.saving = true;
|
20982
21005
|
salvation.done(this.saved);
|
20983
21006
|
salvation.fail(this.failed);
|
20984
21007
|
salvation.always(function() {
|
@@ -20994,8 +21017,6 @@ restful = {
|
|
20994
21017
|
if (this.lock === JSON.stringify(this.json())) {
|
20995
21018
|
this.dirty = false;
|
20996
21019
|
delete this.lock;
|
20997
|
-
} else {
|
20998
|
-
return this.save();
|
20999
21020
|
}
|
21000
21021
|
if (data != null) {
|
21001
21022
|
this.assign_attributes(data);
|
@@ -21021,8 +21042,21 @@ restful = {
|
|
21021
21042
|
}
|
21022
21043
|
payload || (payload = xhr.responseText);
|
21023
21044
|
switch (xhr.status) {
|
21045
|
+
case 0:
|
21046
|
+
message = status || xhr.statusText;
|
21047
|
+
switch (message) {
|
21048
|
+
case 'abort':
|
21049
|
+
console.info("salvation probably aborted");
|
21050
|
+
break;
|
21051
|
+
case 'error':
|
21052
|
+
console.info("server probably unreachable");
|
21053
|
+
break;
|
21054
|
+
default:
|
21055
|
+
throw new Error('Unhandled status code for xhr');
|
21056
|
+
}
|
21057
|
+
break;
|
21024
21058
|
case 422:
|
21025
|
-
definition = model[this.resource];
|
21059
|
+
definition = model[this.resource.toString()];
|
21026
21060
|
_ref = payload.errors;
|
21027
21061
|
for (attribute_name in _ref) {
|
21028
21062
|
messages = _ref[attribute_name];
|
@@ -21047,8 +21081,9 @@ restful = {
|
|
21047
21081
|
default:
|
21048
21082
|
message = "Fail in " + this.resource + ".save:\n";
|
21049
21083
|
message += "Record: " + this + "\n";
|
21050
|
-
message += "Status: " + status + " (" + (payload
|
21084
|
+
message += "Status: " + status + " (" + (payload || xhr).status + ")\n";
|
21051
21085
|
message += "Error : " + (payload.error || payload.message || payload);
|
21086
|
+
console.log(message);
|
21052
21087
|
}
|
21053
21088
|
return this.saving = false;
|
21054
21089
|
},
|
@@ -21060,20 +21095,27 @@ restful = {
|
|
21060
21095
|
return JSON.stringify(serialized);
|
21061
21096
|
},
|
21062
21097
|
json: function(methods) {
|
21063
|
-
var attribute, json, name, value, _i, _len, _ref;
|
21098
|
+
var attribute, definition, json, name, value, _i, _len, _ref;
|
21064
21099
|
|
21065
21100
|
if (methods == null) {
|
21066
21101
|
methods = {};
|
21067
21102
|
}
|
21068
21103
|
json = {};
|
21104
|
+
definition = model[this.resource.toString()];
|
21069
21105
|
for (name in this) {
|
21070
|
-
value
|
21071
|
-
|
21106
|
+
if (!(type(value))) {
|
21107
|
+
continue;
|
21108
|
+
}
|
21109
|
+
if (definition.belongs_to.indexOf(name) !== -1 && this.nested_attributes.indexOf(name) === -1) {
|
21072
21110
|
continue;
|
21073
21111
|
}
|
21112
|
+
value = this[name];
|
21074
21113
|
if (value == null) {
|
21075
21114
|
continue;
|
21076
21115
|
}
|
21116
|
+
if (type(value) === 'function') {
|
21117
|
+
continue;
|
21118
|
+
}
|
21077
21119
|
if (type(value) === 'object') {
|
21078
21120
|
if (value.toJSON != null) {
|
21079
21121
|
json[name] = value.toJSON(methods[name]);
|
@@ -21099,6 +21141,8 @@ restful = {
|
|
21099
21141
|
delete json.before_initialize;
|
21100
21142
|
delete json.parent_resource;
|
21101
21143
|
delete json.nested_attributes;
|
21144
|
+
delete json.reloading;
|
21145
|
+
delete json.ready;
|
21102
21146
|
delete json.saving;
|
21103
21147
|
delete json.salvation;
|
21104
21148
|
delete json.sustained;
|
@@ -21145,7 +21189,7 @@ model.associable && model.associable.mix(function(singular_association, plural_a
|
|
21145
21189
|
|
21146
21190
|
});
|
21147
21191
|
require.register("indemma/lib/record/scopable.js", function(exports, require, module){
|
21148
|
-
var $, builders, defaults, extend, merge, model, record, rest, scopable, stampit,
|
21192
|
+
var $, builders, defaults, extend, merge, model, observable, record, rest, scopable, stampit, util,
|
21149
21193
|
__slice = [].slice;
|
21150
21194
|
|
21151
21195
|
require('./restfulable');
|
@@ -21156,12 +21200,29 @@ stampit = require('../../vendor/stampit');
|
|
21156
21200
|
|
21157
21201
|
extend = require('assimilate');
|
21158
21202
|
|
21203
|
+
observable = require('observable').mixin;
|
21204
|
+
|
21159
21205
|
merge = extend.withStrategy('deep');
|
21160
21206
|
|
21161
21207
|
$ = require('jquery');
|
21162
21208
|
|
21163
21209
|
rest = require('./rest');
|
21164
21210
|
|
21211
|
+
util = {
|
21212
|
+
model: {
|
21213
|
+
map: function(records) {
|
21214
|
+
var index, record, _i, _len, _results;
|
21215
|
+
|
21216
|
+
_results = [];
|
21217
|
+
for (index = _i = 0, _len = records.length; _i < _len; index = ++_i) {
|
21218
|
+
record = records[index];
|
21219
|
+
_results.push((this.build || this).call(this, record));
|
21220
|
+
}
|
21221
|
+
return _results;
|
21222
|
+
}
|
21223
|
+
}
|
21224
|
+
};
|
21225
|
+
|
21165
21226
|
scopable = {
|
21166
21227
|
builder: stampit().enclose(function() {
|
21167
21228
|
return stampit.mixIn(function(name, type) {
|
@@ -21192,14 +21253,19 @@ scopable = {
|
|
21192
21253
|
fetch: function(data, done, fail) {
|
21193
21254
|
var deferred, scope;
|
21194
21255
|
|
21256
|
+
if (typeof data === 'function') {
|
21257
|
+
done = data;
|
21258
|
+
data = {};
|
21259
|
+
}
|
21195
21260
|
scope = extend({}, this.scope.data);
|
21261
|
+
observable.unobserve(scope);
|
21196
21262
|
if (scope.noned != null) {
|
21197
21263
|
deferred = $.Deferred();
|
21198
21264
|
deferred.resolveWith(this, [[]]);
|
21199
21265
|
} else {
|
21200
21266
|
deferred = rest.get.call(this, extend(scope, data));
|
21201
21267
|
}
|
21202
|
-
deferred.done(this.scope.then.concat(done)).fail(
|
21268
|
+
deferred.then(util.model.map).done(this.scope.then.concat([done])).fail(this.scope.fail.concat([fail]));
|
21203
21269
|
this.scope.clear();
|
21204
21270
|
return deferred;
|
21205
21271
|
},
|
@@ -21242,6 +21308,10 @@ scopable = {
|
|
21242
21308
|
return this;
|
21243
21309
|
},
|
21244
21310
|
fetch: function(data, done, fail) {
|
21311
|
+
if (typeof data === 'function') {
|
21312
|
+
done = data;
|
21313
|
+
data = null;
|
21314
|
+
}
|
21245
21315
|
return this.scope.fetch.call(this, data, done, fail);
|
21246
21316
|
},
|
21247
21317
|
forward_scopes_to_associations: function() {
|
@@ -21498,10 +21568,23 @@ model.mix(function(modelable) {
|
|
21498
21568
|
});
|
21499
21569
|
|
21500
21570
|
});
|
21501
|
-
require.register("indemma/lib/record/validations/
|
21502
|
-
var
|
21571
|
+
require.register("indemma/lib/record/validations/validatorable.js", function(exports, require, module){
|
21572
|
+
var stampit;
|
21503
21573
|
|
21504
|
-
|
21574
|
+
stampit = require('../../../vendor/stampit');
|
21575
|
+
|
21576
|
+
module.exports = stampit({
|
21577
|
+
validate: function() {
|
21578
|
+
throw new Error('Composed factory must override the validate method');
|
21579
|
+
},
|
21580
|
+
validate_each: function() {
|
21581
|
+
throw new Error('Composed factory must override the validate each method');
|
21582
|
+
}
|
21583
|
+
});
|
21584
|
+
|
21585
|
+
});
|
21586
|
+
require.register("indemma/lib/record/validations/confirmation.js", function(exports, require, module){
|
21587
|
+
var composed, confirmationable, stampit;
|
21505
21588
|
|
21506
21589
|
stampit = require('../../../vendor/stampit');
|
21507
21590
|
|
@@ -21513,17 +21596,15 @@ confirmationable = stampit({
|
|
21513
21596
|
}
|
21514
21597
|
});
|
21515
21598
|
|
21516
|
-
composed = stampit.compose(
|
21599
|
+
composed = stampit.compose(require('./validatorable'), confirmationable);
|
21517
21600
|
|
21518
21601
|
composed.definition_key = 'validates_confirmation_of';
|
21519
21602
|
|
21520
|
-
|
21603
|
+
module.exports = composed;
|
21521
21604
|
|
21522
21605
|
});
|
21523
21606
|
require.register("indemma/lib/record/validations/associated.js", function(exports, require, module){
|
21524
|
-
var associationable, composed, stampit
|
21525
|
-
|
21526
|
-
validations = require('../validatable');
|
21607
|
+
var associationable, composed, stampit;
|
21527
21608
|
|
21528
21609
|
stampit = require('../../../vendor/stampit');
|
21529
21610
|
|
@@ -21546,17 +21627,15 @@ associationable = stampit({
|
|
21546
21627
|
}
|
21547
21628
|
});
|
21548
21629
|
|
21549
|
-
composed = stampit.compose(
|
21630
|
+
composed = stampit.compose(require('./validatorable'), associationable);
|
21550
21631
|
|
21551
21632
|
composed.definition_key = 'validates_associated';
|
21552
21633
|
|
21553
|
-
|
21634
|
+
module.exports = composed;
|
21554
21635
|
|
21555
21636
|
});
|
21556
21637
|
require.register("indemma/lib/record/validations/presence.js", function(exports, require, module){
|
21557
|
-
var composed, presenceable, stampit
|
21558
|
-
|
21559
|
-
validations = require('../validatable');
|
21638
|
+
var composed, presenceable, stampit;
|
21560
21639
|
|
21561
21640
|
stampit = require('../../../vendor/stampit');
|
21562
21641
|
|
@@ -21568,19 +21647,15 @@ presenceable = stampit({
|
|
21568
21647
|
}
|
21569
21648
|
});
|
21570
21649
|
|
21571
|
-
composed = stampit.compose(
|
21650
|
+
composed = stampit.compose(require('./validatorable'), presenceable);
|
21572
21651
|
|
21573
21652
|
composed.definition_key = 'validates_presence_of';
|
21574
21653
|
|
21575
|
-
|
21654
|
+
module.exports = composed;
|
21576
21655
|
|
21577
21656
|
});
|
21578
21657
|
require.register("indemma/lib/record/validations/remote.js", function(exports, require, module){
|
21579
|
-
var composed, remoteable, rest,
|
21580
|
-
|
21581
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
21582
|
-
|
21583
|
-
validations = require('../validatable');
|
21658
|
+
var composed, remoteable, rest, stampit;
|
21584
21659
|
|
21585
21660
|
rest = require('../rest');
|
21586
21661
|
|
@@ -21643,11 +21718,11 @@ remoteable = stampit({
|
|
21643
21718
|
return this;
|
21644
21719
|
});
|
21645
21720
|
|
21646
|
-
composed = stampit.compose(
|
21721
|
+
composed = stampit.compose(require('./validatorable'), remoteable);
|
21647
21722
|
|
21648
21723
|
composed.definition_key = 'validates_remotely';
|
21649
21724
|
|
21650
|
-
|
21725
|
+
module.exports = composed;
|
21651
21726
|
|
21652
21727
|
});
|
21653
21728
|
require.register("indemma/lib/record/validations/type.js", function(exports, require, module){
|
@@ -21675,17 +21750,15 @@ typeable = stampit({
|
|
21675
21750
|
}
|
21676
21751
|
});
|
21677
21752
|
|
21678
|
-
composed = stampit.compose(
|
21753
|
+
composed = stampit.compose(require('./validatorable'), typeable);
|
21679
21754
|
|
21680
21755
|
composed.definition_key = 'validates_type_of';
|
21681
21756
|
|
21682
|
-
|
21757
|
+
module.exports = composed;
|
21683
21758
|
|
21684
21759
|
});
|
21685
21760
|
require.register("indemma/lib/record/validations/cpf.js", function(exports, require, module){
|
21686
|
-
var composed, cpfable, stampit
|
21687
|
-
|
21688
|
-
validations = require('../validatable');
|
21761
|
+
var composed, cpfable, stampit;
|
21689
21762
|
|
21690
21763
|
stampit = require('../../../vendor/stampit');
|
21691
21764
|
|
@@ -21705,7 +21778,7 @@ cpfable = stampit({
|
|
21705
21778
|
d1 = 0;
|
21706
21779
|
v = false;
|
21707
21780
|
i = 0;
|
21708
|
-
for (i = _i =
|
21781
|
+
for (i = _i = 0; _i <= 9; i = ++_i) {
|
21709
21782
|
d1 += c.charAt(i) * (10 - i);
|
21710
21783
|
}
|
21711
21784
|
if (d1 === 0) {
|
@@ -21719,7 +21792,7 @@ cpfable = stampit({
|
|
21719
21792
|
return false;
|
21720
21793
|
}
|
21721
21794
|
d1 *= 2;
|
21722
|
-
for (i = _j =
|
21795
|
+
for (i = _j = 0; _j <= 9; i = ++_j) {
|
21723
21796
|
d1 += c.charAt(i) * (11 - i);
|
21724
21797
|
}
|
21725
21798
|
d1 = 11 - (d1 % 11);
|
@@ -21738,19 +21811,19 @@ cpfable = stampit({
|
|
21738
21811
|
}
|
21739
21812
|
});
|
21740
21813
|
|
21741
|
-
composed = stampit.compose(
|
21814
|
+
composed = stampit.compose(require('./validatorable'), cpfable);
|
21742
21815
|
|
21743
21816
|
composed.definition_key = 'validates_cpf_format';
|
21744
21817
|
|
21745
|
-
|
21818
|
+
module.exports = composed;
|
21746
21819
|
|
21747
21820
|
});
|
21748
21821
|
require.register("indemma/lib/record/validatable.js", function(exports, require, module){
|
21749
|
-
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type
|
21822
|
+
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
|
21750
21823
|
|
21751
21824
|
require('./translationable');
|
21752
21825
|
|
21753
|
-
root = typeof exports !== "undefined" && exports !== null ? exports :
|
21826
|
+
root = typeof exports !== "undefined" && exports !== null ? exports : this;
|
21754
21827
|
|
21755
21828
|
stampit = require('../../vendor/stampit');
|
21756
21829
|
|
@@ -21841,7 +21914,7 @@ initializers = {
|
|
21841
21914
|
});
|
21842
21915
|
this.validated = false;
|
21843
21916
|
this.subscribe('dirty', function(value) {
|
21844
|
-
return this.validated = false;
|
21917
|
+
return value && (this.validated = false);
|
21845
21918
|
});
|
21846
21919
|
return Object.defineProperty(this, 'valid', {
|
21847
21920
|
get: function() {
|
@@ -21935,7 +22008,12 @@ extensions = {
|
|
21935
22008
|
this.validation.done(doned);
|
21936
22009
|
this.validation.fail(failed);
|
21937
22010
|
this.validation.then(function(record) {
|
21938
|
-
|
22011
|
+
var old_dirty;
|
22012
|
+
|
22013
|
+
old_dirty = record.dirty;
|
22014
|
+
record.dirty = null;
|
22015
|
+
record.validated || (record.validated = true);
|
22016
|
+
return record.dirty = old_dirty;
|
21939
22017
|
});
|
21940
22018
|
return this.validation;
|
21941
22019
|
}
|
@@ -21946,15 +22024,6 @@ manager = {
|
|
21946
22024
|
validators: {}
|
21947
22025
|
};
|
21948
22026
|
|
21949
|
-
validatable = stampit({
|
21950
|
-
validate: function() {
|
21951
|
-
throw new Error('Composed factory must override the validate method');
|
21952
|
-
},
|
21953
|
-
validate_each: function() {
|
21954
|
-
throw new Error('Composed factory must override the validate each method');
|
21955
|
-
}
|
21956
|
-
});
|
21957
|
-
|
21958
22027
|
model.mix(function(modelable) {
|
21959
22028
|
jQuery.extend(modelable, extensions.model);
|
21960
22029
|
jQuery.extend(modelable.record, extensions.record);
|
@@ -21963,21 +22032,17 @@ model.mix(function(modelable) {
|
|
21963
22032
|
return model.validators = manager.validators;
|
21964
22033
|
});
|
21965
22034
|
|
21966
|
-
|
21967
|
-
|
21968
|
-
root.manager = manager;
|
21969
|
-
|
21970
|
-
require('./validations/confirmation');
|
22035
|
+
manager.validators.confirmation = require('./validations/confirmation');
|
21971
22036
|
|
21972
|
-
require('./validations/associated');
|
22037
|
+
manager.validators.associated = require('./validations/associated');
|
21973
22038
|
|
21974
|
-
require('./validations/presence');
|
22039
|
+
manager.validators.presence = require('./validations/presence');
|
21975
22040
|
|
21976
|
-
require('./validations/remote');
|
22041
|
+
manager.validators.remote = require('./validations/remote');
|
21977
22042
|
|
21978
|
-
require('./validations/type');
|
22043
|
+
manager.validators.type = require('./validations/type');
|
21979
22044
|
|
21980
|
-
require('./validations/cpf');
|
22045
|
+
manager.validators.cpf = require('./validations/cpf');
|
21981
22046
|
|
21982
22047
|
});
|
21983
22048
|
require.register("indemma/lib/extensions/rivets.js", function(exports, require, module){
|