ende 0.4.12 → 0.4.13
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/build/build.css +111 -0
- data/lib/assets/javascripts/aura/extensions/routes.js.coffee +9 -4
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/ende_build.js +236 -215
- data/vendor/components/indefinido-indemma/build/development.js +21901 -44
- data/vendor/components/indefinido-indemma/build/release.js +208 -210
- data/vendor/components/indefinido-indemma/build/test.js +21901 -44
- data/vendor/components/indefinido-indemma/lib/record/rest.js +2 -7
- data/vendor/components/indefinido-indemma/lib/record/validatable.js +191 -206
- data/vendor/components/indefinido-indemma/src/lib/record/rest.coffee +1 -7
- data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +1 -12
- metadata +4 -3
@@ -1,4 +1,4 @@
|
|
1
|
-
var $,
|
1
|
+
var $, request;
|
2
2
|
|
3
3
|
$ = require('jquery');
|
4
4
|
|
@@ -17,7 +17,7 @@ module.exports = {
|
|
17
17
|
}
|
18
18
|
};
|
19
19
|
|
20
|
-
|
20
|
+
request = function(method, url, data) {
|
21
21
|
var param_name;
|
22
22
|
|
23
23
|
param_name = this.resource.param_name || this.resource.toString();
|
@@ -29,11 +29,6 @@ data_for = function(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);
|
37
32
|
return $.ajax({
|
38
33
|
url: url,
|
39
34
|
data: data,
|
@@ -1,224 +1,209 @@
|
|
1
|
-
|
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 {
|
37
|
-
attribute_name = this.human_attribute_name(attribute_name);
|
38
|
-
return "" + attribute_name + " " + options.server_message + ".";
|
39
|
-
}
|
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;
|
1
|
+
(function() {
|
2
|
+
var errorsable, extensions, initializers, manager, messages, observable, root, stampit, type;
|
62
3
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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 + ".";
|
68
39
|
}
|
69
|
-
|
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.";
|
70
44
|
}
|
71
|
-
}
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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.");
|
109
|
-
},
|
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));
|
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);
|
143
55
|
} else {
|
144
|
-
|
56
|
+
return this.messages[attribute_name] += message_key;
|
145
57
|
}
|
146
|
-
}
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
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
|
-
}
|
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;
|
167
68
|
}
|
168
|
-
validation = jQuery.when.apply(jQuery, results);
|
169
|
-
validation.done(doned);
|
170
|
-
validation.fail(failed);
|
171
|
-
return validation;
|
172
69
|
},
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
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;
|
113
|
+
_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
|
+
}
|
178
138
|
}
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
139
|
+
return _results;
|
140
|
+
}
|
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;
|
163
|
+
},
|
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
|
+
});
|
185
180
|
}
|
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
181
|
}
|
199
|
-
}
|
200
|
-
|
182
|
+
};
|
183
|
+
|
184
|
+
manager = {
|
185
|
+
validators: {}
|
186
|
+
};
|
201
187
|
|
202
|
-
|
203
|
-
|
204
|
-
|
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
|
+
});
|
205
195
|
|
206
|
-
|
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
|
-
});
|
196
|
+
manager.validators.confirmation = require('./validations/confirmation');
|
213
197
|
|
214
|
-
manager.validators.
|
198
|
+
manager.validators.associated = require('./validations/associated');
|
215
199
|
|
216
|
-
manager.validators.
|
200
|
+
manager.validators.presence = require('./validations/presence');
|
217
201
|
|
218
|
-
manager.validators.
|
202
|
+
manager.validators.remote = require('./validations/remote');
|
219
203
|
|
220
|
-
manager.validators.
|
204
|
+
manager.validators.type = require('./validations/type');
|
221
205
|
|
222
|
-
manager.validators.
|
206
|
+
manager.validators.cpf = require('./validations/cpf');
|
223
207
|
|
224
|
-
|
208
|
+
}).call(this);
|
209
|
+
;
|
@@ -7,9 +7,7 @@ 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
|
-
|
11
|
-
# TODO move to serialization module
|
12
|
-
data_for = (data) ->
|
10
|
+
request = (method, url, data) ->
|
13
11
|
param_name = @resource.param_name || @resource.toString()
|
14
12
|
|
15
13
|
# TODO optmize this serialization lookup
|
@@ -21,10 +19,6 @@ data_for = (data) ->
|
|
21
19
|
delete data[param_name]['id']
|
22
20
|
delete data[param_name]['_id']
|
23
21
|
|
24
|
-
data
|
25
|
-
|
26
|
-
request = (method, url, data) ->
|
27
|
-
data = data_for.call @, data
|
28
22
|
|
29
23
|
$.ajax
|
30
24
|
url : url
|
@@ -173,18 +173,7 @@ extensions =
|
|
173
173
|
@validation.fail failed
|
174
174
|
|
175
175
|
# TODO store this callback
|
176
|
-
@validation.done (record) ->
|
177
|
-
# Disable dirty checking to prevent validation believe that
|
178
|
-
# the model values has changed
|
179
|
-
old_dirty = record.dirty
|
180
|
-
record.dirty = null
|
181
|
-
|
182
|
-
record.validated ||= true
|
183
|
-
|
184
|
-
# Restore dirty state
|
185
|
-
record.dirty = old_dirty
|
186
|
-
|
187
|
-
record
|
176
|
+
@validation.done (record) -> record.validated ||= true
|
188
177
|
|
189
178
|
|
190
179
|
# Validators management
|
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.13
|
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-03-
|
11
|
+
date: 2014-03-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -67,6 +67,7 @@ files:
|
|
67
67
|
- README.md
|
68
68
|
- Rakefile
|
69
69
|
- WTFP-LICENSE
|
70
|
+
- build/build.css
|
70
71
|
- component.json
|
71
72
|
- ende.gemspec
|
72
73
|
- lib/assets/.gitkeep
|
@@ -446,7 +447,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
446
447
|
version: '0'
|
447
448
|
requirements: []
|
448
449
|
rubyforge_project:
|
449
|
-
rubygems_version: 2.
|
450
|
+
rubygems_version: 2.1.11
|
450
451
|
signing_key:
|
451
452
|
specification_version: 4
|
452
453
|
summary: Endë (core, middle) a web application engine for rails with aurajs.
|