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
@@ -3,11 +3,12 @@ type = require 'type'
|
|
3
3
|
observable = require('observable').mixin
|
4
4
|
$ = require 'jquery' # TODO remove jquery dependency and use simple promises implementation
|
5
5
|
rest = require './rest.js'
|
6
|
+
root = exports ? @
|
6
7
|
|
7
8
|
util =
|
8
9
|
model:
|
9
|
-
map: (
|
10
|
-
@
|
10
|
+
map: (records) ->
|
11
|
+
@ record for record in records
|
11
12
|
|
12
13
|
|
13
14
|
restful =
|
@@ -32,9 +33,9 @@ restful =
|
|
32
33
|
|
33
34
|
# returns a promise
|
34
35
|
# TODO move to scopable
|
35
|
-
all: (conditions = {},
|
36
|
+
all: (conditions = {}, doned, failed) ->
|
36
37
|
if typeof conditions == 'function'
|
37
|
-
|
38
|
+
doned = conditions
|
38
39
|
conditions = {}
|
39
40
|
|
40
41
|
# TODO Consider parent resources
|
@@ -44,7 +45,8 @@ restful =
|
|
44
45
|
|
45
46
|
$.when(rest.get.call @, conditions)
|
46
47
|
.then(util.model.map )
|
47
|
-
.done
|
48
|
+
.done(doned )
|
49
|
+
.fail failed
|
48
50
|
|
49
51
|
first: (conditions = {}, callback) ->
|
50
52
|
if typeof conditions == 'function'
|
@@ -61,9 +63,15 @@ restful =
|
|
61
63
|
# TODO better treating of arguments
|
62
64
|
get: (action, data = {}) ->
|
63
65
|
# TODO better way to override route
|
64
|
-
old_route
|
65
|
-
|
66
|
-
@route
|
66
|
+
old_route = @route
|
67
|
+
default_route = "/#{model.pluralize @resource.name}"
|
68
|
+
@route = default_route unless default_route == @route
|
69
|
+
|
70
|
+
if action
|
71
|
+
# TODO Get own property descriptor, or better way do override route
|
72
|
+
Object.defineProperty @, 'route',
|
73
|
+
value: "#{default_route}/#{action}"
|
74
|
+
configurable: true
|
67
75
|
|
68
76
|
# TODO not allow resource overriding
|
69
77
|
resource = data.resource
|
@@ -76,7 +84,10 @@ restful =
|
|
76
84
|
|
77
85
|
promise = rest.get.call @, data
|
78
86
|
|
79
|
-
route
|
87
|
+
# TODO Get own property descriptor, or better way do override route
|
88
|
+
Object.defineProperty @, 'route',
|
89
|
+
value: old_route
|
90
|
+
configurable: true
|
80
91
|
|
81
92
|
promise
|
82
93
|
|
@@ -84,6 +95,7 @@ restful =
|
|
84
95
|
delete: rest.delete
|
85
96
|
|
86
97
|
record:
|
98
|
+
ready: (callback) -> callback.call @
|
87
99
|
reload: (params...) ->
|
88
100
|
|
89
101
|
# TODO better signature implementation
|
@@ -94,6 +106,12 @@ restful =
|
|
94
106
|
promise.done @assign_attributes
|
95
107
|
promise.fail @failed
|
96
108
|
|
109
|
+
@reloading = promise
|
110
|
+
# Assign ready callback before, to allow promise override
|
111
|
+
@ready = ->
|
112
|
+
console.warn "resource.ready was deprecated, please use resource.reloading.done"
|
113
|
+
promise.done arguments...
|
114
|
+
|
97
115
|
# Bind one time save callbacks
|
98
116
|
promise.done param for param in params
|
99
117
|
|
@@ -163,8 +181,14 @@ restful =
|
|
163
181
|
|
164
182
|
# Assign remaining attributes
|
165
183
|
# TODO see if it is a best practice not overriding unchanged attributes
|
166
|
-
|
167
|
-
|
184
|
+
# TODO rename attributes for properties
|
185
|
+
for name, attribute of attributes when attribute isnt @[name]
|
186
|
+
# TODO faster object property assignment, get from model definition, instead of checking every attribute
|
187
|
+
# TODO implement custom comparator for each object when es7 is out
|
188
|
+
if type(attribute) == 'object'
|
189
|
+
@[name] = attributes[name] if JSON.stringify(attribute) != JSON.stringify @[name]
|
190
|
+
else
|
191
|
+
@[name] = attributes[name]
|
168
192
|
|
169
193
|
destroy: (doned, failed, data) ->
|
170
194
|
throw new Error 'Can\'t delete record without id!' unless @id? or @_id?
|
@@ -182,18 +206,28 @@ restful =
|
|
182
206
|
saving: false
|
183
207
|
salvation: null
|
184
208
|
save: (doned, failed, data) ->
|
185
|
-
|
209
|
+
lock = JSON.stringify @json()
|
210
|
+
|
211
|
+
# When saving and receive save command again check if the model
|
212
|
+
# has changed, then abort the salvation operation and send a new
|
213
|
+
# save request
|
214
|
+
# TODO check dirty property instead of lock!
|
215
|
+
if @saving
|
216
|
+
if @lock == lock
|
217
|
+
return @salvation
|
218
|
+
else
|
219
|
+
@salvation.abort()
|
186
220
|
|
187
221
|
# TODO better lock generation
|
188
|
-
@lock =
|
222
|
+
@lock = lock
|
189
223
|
|
190
224
|
# TODO remove jquery dependency
|
191
225
|
# TODO think with wich value makes more sense to resolve the
|
192
226
|
# absence of need to save the model
|
193
227
|
salvation = $.Deferred().resolveWith @, null unless @dirty
|
228
|
+
@saving = true
|
194
229
|
salvation ||= rest[if @_id then 'put' else 'post'].call @, data
|
195
230
|
@salvation = salvation
|
196
|
-
@saving = true
|
197
231
|
|
198
232
|
salvation.done @saved
|
199
233
|
salvation.fail @failed
|
@@ -211,9 +245,6 @@ restful =
|
|
211
245
|
if @lock == JSON.stringify(@json())
|
212
246
|
@dirty = false
|
213
247
|
delete @lock
|
214
|
-
# Delayed optimistic lock
|
215
|
-
else
|
216
|
-
return @save()
|
217
248
|
|
218
249
|
@assign_attributes data if data?
|
219
250
|
|
@@ -225,13 +256,22 @@ restful =
|
|
225
256
|
try payload ||= JSON.parse(xhr.responseText) catch e
|
226
257
|
payload ||= xhr.responseText
|
227
258
|
|
228
|
-
|
229
259
|
# When client fail
|
230
260
|
switch xhr.status
|
231
261
|
# TODO move to validatable
|
262
|
+
when 0
|
263
|
+
message = status or xhr.statusText
|
264
|
+
switch message
|
265
|
+
when 'abort'
|
266
|
+
console.info "salvation probably aborted"
|
267
|
+
when 'error'
|
268
|
+
console.info "server probably unreachable"
|
269
|
+
else
|
270
|
+
throw new Error 'Unhandled status code for xhr'
|
271
|
+
|
232
272
|
when 422
|
233
273
|
|
234
|
-
definition = model[@resource]
|
274
|
+
definition = model[@resource.toString()]
|
235
275
|
|
236
276
|
for attribute_name, messages of payload.errors
|
237
277
|
|
@@ -258,8 +298,9 @@ restful =
|
|
258
298
|
else
|
259
299
|
message = "Fail in #{@resource}.save:\n"
|
260
300
|
message += "Record: #{@}\n"
|
261
|
-
message += "Status: #{status} (#{payload
|
301
|
+
message += "Status: #{status} (#{(payload || xhr).status})\n"
|
262
302
|
message += "Error : #{payload.error || payload.message || payload}"
|
303
|
+
console.log message
|
263
304
|
|
264
305
|
# Finish saving
|
265
306
|
@saving = false
|
@@ -272,8 +313,17 @@ restful =
|
|
272
313
|
json: (methods = {}) ->
|
273
314
|
json = {}
|
274
315
|
|
275
|
-
|
276
|
-
|
316
|
+
definition = model[@resource.toString()]
|
317
|
+
|
318
|
+
for name of @ when type(value)
|
319
|
+
# TODO treat other associations to!
|
320
|
+
# TODO create association reflection for god sake!
|
321
|
+
continue if definition.belongs_to.indexOf(name) != -1 and @nested_attributes.indexOf(name) == -1
|
322
|
+
|
323
|
+
# TODO Bypass only undefined values so we can erase data on server
|
324
|
+
value = @[name]
|
325
|
+
continue unless value?
|
326
|
+
continue if type(value) == 'function'
|
277
327
|
|
278
328
|
if type(value) == 'object'
|
279
329
|
|
@@ -302,16 +352,23 @@ restful =
|
|
302
352
|
delete json.resource
|
303
353
|
delete json.route
|
304
354
|
delete json.initial_route # TODO implement better initial_route and remove attribute from here
|
355
|
+
|
305
356
|
delete json.after_initialize
|
306
357
|
delete json.before_initialize
|
307
358
|
delete json.parent_resource
|
308
359
|
delete json.nested_attributes
|
360
|
+
|
361
|
+
delete json.reloading
|
362
|
+
delete json.ready
|
363
|
+
|
309
364
|
delete json.saving
|
310
365
|
delete json.salvation
|
311
366
|
delete json.sustained
|
367
|
+
|
312
368
|
delete json.element
|
313
369
|
delete json.default
|
314
370
|
delete json.lock
|
371
|
+
|
315
372
|
delete json.validated
|
316
373
|
delete json.validation
|
317
374
|
|
@@ -1,13 +1,20 @@
|
|
1
1
|
require './restfulable'
|
2
2
|
require './resource'
|
3
3
|
|
4
|
-
stampit
|
5
|
-
extend
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
stampit = require '../../vendor/stampit'
|
5
|
+
extend = require 'assimilate'
|
6
|
+
observable = require('observable').mixin
|
7
|
+
merge = extend.withStrategy 'deep'
|
8
|
+
$ = require 'jquery'
|
9
|
+
rest = require './rest'
|
10
|
+
|
11
|
+
# TODO merge all with fetch and remove this util object
|
12
|
+
util =
|
13
|
+
model:
|
14
|
+
map: (records) ->
|
15
|
+
(@build or @).call @, record for record, index in records
|
10
16
|
|
17
|
+
# TODO better responsibilty division for this code
|
11
18
|
scopable =
|
12
19
|
builder: stampit().enclose ->
|
13
20
|
|
@@ -35,7 +42,13 @@ scopable =
|
|
35
42
|
fail: []
|
36
43
|
declared: []
|
37
44
|
fetch: (data, done, fail) ->
|
45
|
+
|
46
|
+
if typeof data == 'function'
|
47
|
+
done = data
|
48
|
+
data = {}
|
49
|
+
|
38
50
|
scope = extend {}, @scope.data
|
51
|
+
observable.unobserve scope
|
39
52
|
|
40
53
|
if scope.noned?
|
41
54
|
deferred = $.Deferred()
|
@@ -44,8 +57,9 @@ scopable =
|
|
44
57
|
deferred = rest.get.call(@, extend scope, data)
|
45
58
|
|
46
59
|
deferred
|
47
|
-
.
|
48
|
-
.
|
60
|
+
.then(util.model.map)
|
61
|
+
.done(@scope.then.concat [done])
|
62
|
+
.fail(@scope.fail.concat [fail])
|
49
63
|
|
50
64
|
@scope.clear()
|
51
65
|
|
@@ -85,7 +99,12 @@ scopable =
|
|
85
99
|
@scope.data.noned = true
|
86
100
|
@
|
87
101
|
|
102
|
+
# TODO merge with all object
|
88
103
|
fetch: (data, done, fail) ->
|
104
|
+
if typeof data == 'function'
|
105
|
+
done = data
|
106
|
+
data = null
|
107
|
+
|
89
108
|
@scope.fetch.call @, data, done, fail
|
90
109
|
|
91
110
|
# TODO optmize this iterations or add support for stampit on associable and merge factories
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require './translationable'
|
2
2
|
|
3
|
-
root = exports ?
|
3
|
+
root = exports ? @
|
4
4
|
stampit = require '../../vendor/stampit'
|
5
5
|
observable = require('observable').mixin
|
6
6
|
type = require 'type'
|
@@ -90,9 +90,9 @@ initializers =
|
|
90
90
|
# TODO only execute save operation if record is valid
|
91
91
|
@before 'save', -> @validate() if @save
|
92
92
|
|
93
|
-
# TODO move this functionality control to
|
93
|
+
# TODO move this functionality control to validatable
|
94
94
|
@validated = false
|
95
|
-
@subscribe 'dirty', (value) -> @validated = false
|
95
|
+
@subscribe 'dirty', (value) -> value and @validated = false
|
96
96
|
|
97
97
|
Object.defineProperty @, 'valid',
|
98
98
|
get: ->
|
@@ -173,7 +173,16 @@ extensions =
|
|
173
173
|
@validation.fail failed
|
174
174
|
|
175
175
|
# TODO store this callback
|
176
|
-
@validation.then (record) ->
|
176
|
+
@validation.then (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
|
177
186
|
|
178
187
|
@validation
|
179
188
|
|
@@ -188,11 +197,6 @@ manager =
|
|
188
197
|
# builder = @validators[name] ||= require "validations/#{name}"
|
189
198
|
|
190
199
|
|
191
|
-
validatable = stampit
|
192
|
-
validate: -> throw new Error 'Composed factory must override the validate method'
|
193
|
-
validate_each: -> throw new Error 'Composed factory must override the validate each method'
|
194
|
-
|
195
|
-
|
196
200
|
# TODO better stampit integration
|
197
201
|
model.mix (modelable) ->
|
198
202
|
jQuery.extend modelable, extensions.model
|
@@ -204,14 +208,11 @@ model.mix (modelable) ->
|
|
204
208
|
|
205
209
|
model.validators = manager.validators
|
206
210
|
|
207
|
-
# Globalize definitions
|
208
|
-
root.validatable = validatable
|
209
|
-
root.manager = manager
|
210
|
-
|
211
211
|
# TODO async validator loading
|
212
|
-
require './validations/confirmation'
|
213
|
-
require './validations/associated'
|
214
|
-
require './validations/presence'
|
215
|
-
require './validations/remote'
|
216
|
-
require './validations/type'
|
217
|
-
require './validations/cpf'
|
212
|
+
manager.validators.confirmation = require './validations/confirmation'
|
213
|
+
manager.validators.associated = require './validations/associated'
|
214
|
+
manager.validators.presence = require './validations/presence'
|
215
|
+
manager.validators.remote = require './validations/remote'
|
216
|
+
manager.validators.type = require './validations/type'
|
217
|
+
manager.validators.cpf = require './validations/cpf'
|
218
|
+
|
@@ -1,10 +1,9 @@
|
|
1
1
|
# TODO Add base settings to validation
|
2
2
|
# model = window.model
|
3
|
-
|
4
3
|
# TODO implement method
|
4
|
+
|
5
5
|
# model[resource].validators_on 'field' # Get all validators related to this field
|
6
6
|
|
7
|
-
validations = require '../validatable'
|
8
7
|
stampit = require '../../../vendor/stampit'
|
9
8
|
|
10
9
|
associationable = stampit
|
@@ -26,7 +25,6 @@ associationable = stampit
|
|
26
25
|
associated_validation
|
27
26
|
|
28
27
|
|
29
|
-
composed = stampit.compose(
|
28
|
+
composed = stampit.compose(require('./validatorable'), associationable)
|
30
29
|
composed.definition_key = 'validates_associated'
|
31
|
-
|
32
|
-
validations.manager.validators.association = composed
|
30
|
+
module.exports = composed
|
@@ -4,7 +4,6 @@
|
|
4
4
|
# TODO implement method
|
5
5
|
# model[resource].validators_on 'field' # Get all validators related to this field
|
6
6
|
|
7
|
-
validations = require '../validatable'
|
8
7
|
stampit = require '../../../vendor/stampit'
|
9
8
|
|
10
9
|
confirmationable = stampit
|
@@ -13,7 +12,6 @@ confirmationable = stampit
|
|
13
12
|
record.errors.add "#{attribute}_confirmation", 'confirmation', @options
|
14
13
|
|
15
14
|
|
16
|
-
composed = stampit.compose(
|
15
|
+
composed = stampit.compose require('./validatorable'), confirmationable
|
17
16
|
composed.definition_key = 'validates_confirmation_of'
|
18
|
-
|
19
|
-
validations.manager.validators.confirmation = composed
|
17
|
+
module.exports = composed
|
@@ -4,7 +4,6 @@
|
|
4
4
|
# TODO implement method
|
5
5
|
# model[resource].validators_on 'field' # Get all validators related to this field
|
6
6
|
|
7
|
-
validations = require '../validatable'
|
8
7
|
stampit = require '../../../vendor/stampit'
|
9
8
|
|
10
9
|
cpfable = stampit
|
@@ -24,7 +23,7 @@ cpfable = stampit
|
|
24
23
|
v = false
|
25
24
|
i = 0
|
26
25
|
|
27
|
-
for i in [
|
26
|
+
for i in [0..9]
|
28
27
|
d1 += c.charAt(i) * (10 - i)
|
29
28
|
|
30
29
|
return false if d1 == 0
|
@@ -35,7 +34,7 @@ cpfable = stampit
|
|
35
34
|
return false if +dv.charAt(0) != d1
|
36
35
|
|
37
36
|
d1 *= 2
|
38
|
-
for i in [
|
37
|
+
for i in [0..9]
|
39
38
|
d1 += c.charAt(i) * (11 - i)
|
40
39
|
|
41
40
|
|
@@ -53,6 +52,6 @@ cpfable = stampit
|
|
53
52
|
|
54
53
|
|
55
54
|
|
56
|
-
composed = stampit.compose
|
55
|
+
composed = stampit.compose require('./validatorable'), cpfable
|
57
56
|
composed.definition_key = 'validates_cpf_format'
|
58
|
-
|
57
|
+
module.exports = composed
|
@@ -4,7 +4,6 @@
|
|
4
4
|
# TODO implement method
|
5
5
|
# model[resource].validators_on 'field' # Get all validators related to this field
|
6
6
|
|
7
|
-
validations = require '../validatable'
|
8
7
|
stampit = require '../../../vendor/stampit'
|
9
8
|
|
10
9
|
presenceable = stampit
|
@@ -12,8 +11,6 @@ presenceable = stampit
|
|
12
11
|
if value == null or value == '' or value == undefined
|
13
12
|
record.errors.add attribute, 'blank', @options
|
14
13
|
|
15
|
-
|
16
|
-
composed = stampit.compose(validations.validatable, presenceable)
|
14
|
+
composed = stampit.compose require('./validatorable'), presenceable
|
17
15
|
composed.definition_key = 'validates_presence_of'
|
18
|
-
|
19
|
-
validations.manager.validators.presence = composed
|
16
|
+
module.exports = composed
|
@@ -1,12 +1,9 @@
|
|
1
1
|
# TODO Add base settings to validation
|
2
2
|
# model = window.model
|
3
3
|
|
4
|
-
|
4
|
+
# TODO implement method
|
5
5
|
# model[resource].validators_on 'field' # Get all validators related to this field
|
6
6
|
|
7
|
-
root = exports ? window
|
8
|
-
|
9
|
-
validations = require '../validatable'
|
10
7
|
rest = require '../rest'
|
11
8
|
stampit = require '../../../vendor/stampit'
|
12
9
|
|
@@ -59,7 +56,6 @@ remoteable = stampit
|
|
59
56
|
@
|
60
57
|
|
61
58
|
|
62
|
-
composed = stampit.compose(
|
59
|
+
composed = stampit.compose require('./validatorable'), remoteable
|
63
60
|
composed.definition_key = 'validates_remotely'
|
64
|
-
|
65
|
-
validations.manager.validators.remote = composed
|
61
|
+
module.exports = composed
|
@@ -26,7 +26,6 @@ typeable = stampit
|
|
26
26
|
throw new Error "Invalid attribute value type! Found #{typeof value} expected #{@type.name}"
|
27
27
|
|
28
28
|
|
29
|
-
composed = stampit.compose(
|
29
|
+
composed = stampit.compose require('./validatorable'), typeable
|
30
30
|
composed.definition_key = 'validates_type_of'
|
31
|
-
|
32
|
-
validations.manager.validators.type = composed
|
31
|
+
module.exports = composed
|
@@ -105,6 +105,14 @@ describe 'restfulable', ->
|
|
105
105
|
belongs_to: 'person'
|
106
106
|
|
107
107
|
# TODO implement setter on has many association and move this code to there
|
108
|
+
it 'should not assign attribute with the same value twice', ->
|
109
|
+
object = {}
|
110
|
+
|
111
|
+
arthur = person name: object
|
112
|
+
arthur.assign_attributes name: {}
|
113
|
+
|
114
|
+
arthur.name.should.not.be.eq object
|
115
|
+
|
108
116
|
it 'assigns associations properly', ->
|
109
117
|
arthur = person name: 'Arthur Dent'
|
110
118
|
ford = friend name: 'Ford Perfect'
|
@@ -13,11 +13,11 @@ describe 'model', ->
|
|
13
13
|
person.should.have.property 'validators'
|
14
14
|
person.validators.should.be.an 'array'
|
15
15
|
|
16
|
-
describe '
|
16
|
+
describe '(validates_... : ...)', ->
|
17
17
|
|
18
18
|
describe 'validators instatiation', ->
|
19
19
|
|
20
|
-
it 'should
|
20
|
+
it 'should have validators', ->
|
21
21
|
person = model.call
|
22
22
|
resource : 'person'
|
23
23
|
name : String
|
@@ -27,7 +27,7 @@ describe 'model', ->
|
|
27
27
|
validator = person.validators[0]
|
28
28
|
validator.should.have.property 'attribute_name', 'name'
|
29
29
|
|
30
|
-
it 'should
|
30
|
+
it 'should have validators with in the key validates'
|
31
31
|
#person = model.call
|
32
32
|
# resource : 'person'
|
33
33
|
# name : String
|
@@ -35,7 +35,7 @@ describe 'model', ->
|
|
35
35
|
|
36
36
|
#person.validators.should.have.key 'name'
|
37
37
|
|
38
|
-
describe '
|
38
|
+
describe '.validate_attribute()', ->
|
39
39
|
|
40
40
|
beforeEach ->
|
41
41
|
# TODO implement better model redefinition pattern
|
data/vendor/components/indefinido-indemma/src/spec/record/validations/associated_spec.coffee
CHANGED
@@ -2,7 +2,7 @@ root = exports ? window
|
|
2
2
|
|
3
3
|
require 'indemma/lib/record/validatable'
|
4
4
|
|
5
|
-
describe 'model
|
5
|
+
describe 'model ( validates_associated: ... )', ->
|
6
6
|
|
7
7
|
describe 'basic usage', ->
|
8
8
|
model = root.model
|
@@ -23,7 +23,7 @@ describe 'model #() validates_associated', ->
|
|
23
23
|
person.validators.length = 0
|
24
24
|
address.validators.length = 0
|
25
25
|
|
26
|
-
describe '
|
26
|
+
describe '.validate()', ->
|
27
27
|
|
28
28
|
it 'should add error to record when fields does not match', ->
|
29
29
|
arthur = person {}
|
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
|
+
version: 0.4.0
|
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-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -79,7 +79,6 @@ files:
|
|
79
79
|
- lib/assets/javascripts/aura/extensions/rivets.js.coffee
|
80
80
|
- lib/assets/javascripts/aura/extensions/rivets/accounting.js.coffee
|
81
81
|
- lib/assets/javascripts/aura/extensions/rivets/formatters.js.coffee
|
82
|
-
- lib/assets/javascripts/aura/extensions/rivets/formatters.js.coffee~
|
83
82
|
- lib/assets/javascripts/aura/extensions/routes.js.coffee
|
84
83
|
- lib/assets/javascripts/aura/extensions/states.js.coffee
|
85
84
|
- lib/assets/javascripts/aura/extensions/widget/eventable.js.coffee
|
@@ -87,6 +86,7 @@ files:
|
|
87
86
|
- lib/assets/javascripts/aura/extensions/widget/napable.js.coffee
|
88
87
|
- lib/assets/javascripts/aura/extensions/widget/presentable.js.coffee
|
89
88
|
- lib/assets/javascripts/aura/presentable.js.coffee
|
89
|
+
- lib/assets/javascripts/config/initializers.js.coffee
|
90
90
|
- lib/assets/javascripts/config/initializers/jquery.js.coffee
|
91
91
|
- lib/assets/javascripts/config/initializers/requirejs.js.coffee
|
92
92
|
- lib/assets/javascripts/config/load_components.js.coffee
|
@@ -140,8 +140,10 @@ files:
|
|
140
140
|
- lib/ende/version.rb
|
141
141
|
- lib/tasks/.gitkeep
|
142
142
|
- vendor/assets/components/build.css
|
143
|
+
- vendor/assets/components/build.js
|
143
144
|
- vendor/assets/components/ende_build.css
|
144
145
|
- vendor/assets/components/ende_build.js
|
146
|
+
- vendor/assets/components/indemma_with_none.js
|
145
147
|
- vendor/assets/javascripts/accounting/accounting.js
|
146
148
|
- vendor/assets/javascripts/ende/build.js
|
147
149
|
- vendor/assets/javascripts/jquery/inputmask.extensions.js
|
@@ -150,6 +152,7 @@ files:
|
|
150
152
|
- vendor/assets/javascripts/jquery/inview.js
|
151
153
|
- vendor/assets/javascripts/lennon/lennon.js
|
152
154
|
- vendor/assets/javascripts/shims/es6-map-shim.js
|
155
|
+
- vendor/assets/javascripts/spin/spin.js
|
153
156
|
- vendor/assets/javascripts/stampit/stampit.js
|
154
157
|
- vendor/components/KapIT-observe-utils/component.json
|
155
158
|
- vendor/components/KapIT-observe-utils/lib/observe-utils.js
|
@@ -286,6 +289,8 @@ files:
|
|
286
289
|
- vendor/components/indefinido-indemma/lib/record/validations/presence.js
|
287
290
|
- vendor/components/indefinido-indemma/lib/record/validations/remote.js
|
288
291
|
- vendor/components/indefinido-indemma/lib/record/validations/type.js
|
292
|
+
- vendor/components/indefinido-indemma/lib/record/validations/validatorable.js
|
293
|
+
- vendor/components/indefinido-indemma/package.json
|
289
294
|
- vendor/components/indefinido-indemma/spec/record/associable_spec.js
|
290
295
|
- vendor/components/indefinido-indemma/spec/record/persistable_spec.js
|
291
296
|
- vendor/components/indefinido-indemma/spec/record/queryable_spec.js
|
@@ -325,6 +330,7 @@ files:
|
|
325
330
|
- vendor/components/indefinido-indemma/src/lib/record/validations/presence.coffee
|
326
331
|
- vendor/components/indefinido-indemma/src/lib/record/validations/remote.coffee
|
327
332
|
- vendor/components/indefinido-indemma/src/lib/record/validations/type.coffee
|
333
|
+
- vendor/components/indefinido-indemma/src/lib/record/validations/validatorable.coffee
|
328
334
|
- vendor/components/indefinido-indemma/src/spec/record/associable_spec.coffee
|
329
335
|
- vendor/components/indefinido-indemma/src/spec/record/persistable_spec.coffee
|
330
336
|
- vendor/components/indefinido-indemma/src/spec/record/queryable_spec.coffee
|
File without changes
|