ende 0.2.3 → 0.2.4
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 +2 -1
- data/lib/assets/javascripts/aura/extensions/devise.js.coffee +3 -2
- data/lib/assets/javascripts/aura/extensions/models.js.coffee.erb +1 -2
- data/lib/assets/javascripts/aura/extensions/widget/lifecycleable.js.coffee +37 -16
- data/lib/assets/javascripts/ende.js.coffee +1 -1
- data/lib/assets/javascripts/widgets/dialog/main.js.coffee +100 -0
- data/lib/assets/javascripts/widgets/dialog/presenter.js.coffee +18 -0
- data/lib/assets/javascripts/widgets/dialog/states/default.html +2 -0
- data/lib/assets/javascripts/widgets/dialog/states/index.js.coffee +2 -0
- data/lib/assets/javascripts/widgets/list/main.js.coffee +1 -0
- data/lib/assets/stylesheets/ende.styl +1 -0
- data/lib/ende/version.rb +1 -1
- data/lib/ende.rb +6 -2
- data/vendor/assets/components/build.css +111 -0
- data/vendor/{components/indefinido-indemma/build/release.js → assets/components/build.js} +25468 -17590
- data/vendor/assets/components/ende_build.css +111 -0
- data/vendor/assets/components/ende_build.js +29571 -0
- data/vendor/assets/javascripts/ende/build.js +1962 -0
- data/vendor/components/component-classes/component.json +19 -0
- data/vendor/components/component-classes/index.js +165 -0
- data/vendor/components/component-css/component.json +18 -0
- data/vendor/components/component-css/index.js +34 -0
- data/vendor/components/component-delegate/component.json +2 -2
- data/vendor/components/component-delegate/index.js +4 -4
- data/vendor/components/component-dialog/component.json +23 -0
- data/vendor/components/component-dialog/dialog.css +92 -0
- data/vendor/components/component-dialog/index.js +292 -0
- data/vendor/components/component-dialog/template.js +1 -0
- data/vendor/components/component-dom/component.json +33 -0
- data/vendor/components/component-dom/index.js +725 -0
- data/vendor/components/component-domify/component.json +22 -0
- data/vendor/components/component-domify/index.js +71 -0
- data/vendor/components/component-emitter/component.json +13 -0
- data/vendor/components/component-emitter/index.js +156 -0
- data/vendor/components/component-event/index.js +8 -11
- data/vendor/components/component-indexof/component.json +15 -0
- data/vendor/components/component-indexof/index.js +10 -0
- data/vendor/components/component-overlay/component.json +22 -0
- data/vendor/components/component-overlay/index.js +111 -0
- data/vendor/components/component-overlay/overlay.css +19 -0
- data/vendor/components/component-overlay/template.js +1 -0
- data/vendor/components/component-query/component.json +2 -1
- data/vendor/components/component-sort/component.json +20 -0
- data/vendor/components/component-sort/index.js +43 -0
- data/vendor/components/component-value/component.json +25 -0
- data/vendor/components/component-value/index.js +95 -0
- data/vendor/components/indefinido-indemma/component.json +2 -3
- data/vendor/components/indefinido-indemma/lib/record/resource.js +2 -4
- data/vendor/components/mikeric-rivets/component.json +1 -1
- data/vendor/components/mikeric-rivets/dist/rivets.js +64 -44
- data/vendor/components/paulmillr-es6-shim/component.json +1 -1
- data/vendor/components/paulmillr-es6-shim/es6-shim.js +22 -11
- data/vendor/components/pluma-assimilate/component.json +1 -1
- data/vendor/components/pluma-assimilate/dist/assimilate.js +103 -63
- metadata +35 -246
- data/lib/tasks/component.thor +0 -63
- data/vendor/assets/components/KapIT-observe-utils/component.json +0 -16
- data/vendor/assets/components/KapIT-observe-utils/lib/observe-utils.js +0 -780
- data/vendor/assets/components/chaijs-assertion-error/component.json +0 -18
- data/vendor/assets/components/chaijs-assertion-error/index.js +0 -110
- data/vendor/assets/components/chaijs-chai/component.json +0 -47
- data/vendor/assets/components/chaijs-chai/index.js +0 -1
- data/vendor/assets/components/chaijs-chai/lib/chai/assertion.js +0 -130
- data/vendor/assets/components/chaijs-chai/lib/chai/core/assertions.js +0 -1270
- data/vendor/assets/components/chaijs-chai/lib/chai/interface/assert.js +0 -1080
- data/vendor/assets/components/chaijs-chai/lib/chai/interface/expect.js +0 -12
- data/vendor/assets/components/chaijs-chai/lib/chai/interface/should.js +0 -76
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +0 -94
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/addMethod.js +0 -37
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/addProperty.js +0 -40
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/flag.js +0 -32
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getActual.js +0 -19
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +0 -25
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getMessage.js +0 -49
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getName.js +0 -20
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getPathValue.js +0 -102
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/getProperties.js +0 -35
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/index.js +0 -108
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/inspect.js +0 -320
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/objDisplay.js +0 -48
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +0 -51
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +0 -54
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/test.js +0 -26
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/transferFlags.js +0 -44
- data/vendor/assets/components/chaijs-chai/lib/chai/utils/type.js +0 -45
- data/vendor/assets/components/chaijs-chai/lib/chai.js +0 -80
- data/vendor/assets/components/chaijs-deep-eql/component.json +0 -18
- data/vendor/assets/components/chaijs-deep-eql/lib/eql.js +0 -257
- data/vendor/assets/components/chaijs-type-detect/component.json +0 -16
- data/vendor/assets/components/chaijs-type-detect/lib/type.js +0 -142
- data/vendor/assets/components/component-bind/component.json +0 -14
- data/vendor/assets/components/component-bind/index.js +0 -24
- data/vendor/assets/components/component-delegate/component.json +0 -19
- data/vendor/assets/components/component-delegate/index.js +0 -42
- data/vendor/assets/components/component-event/component.json +0 -13
- data/vendor/assets/components/component-event/index.js +0 -40
- data/vendor/assets/components/component-jquery/component.json +0 -14
- data/vendor/assets/components/component-jquery/index.js +0 -9601
- data/vendor/assets/components/component-link-delegate/component.json +0 -23
- data/vendor/assets/components/component-link-delegate/index.js +0 -60
- data/vendor/assets/components/component-matches-selector/component.json +0 -20
- data/vendor/assets/components/component-matches-selector/index.js +0 -45
- data/vendor/assets/components/component-query/component.json +0 -21
- data/vendor/assets/components/component-query/index.js +0 -21
- data/vendor/assets/components/component-type/component.json +0 -18
- data/vendor/assets/components/component-type/index.js +0 -32
- data/vendor/assets/components/component-url/component.json +0 -17
- data/vendor/assets/components/component-url/index.js +0 -63
- data/vendor/assets/components/discore-closest/component.json +0 -14
- data/vendor/assets/components/discore-closest/index.js +0 -18
- data/vendor/assets/components/indefinido-advisable/component.json +0 -21
- data/vendor/assets/components/indefinido-advisable/index.js +0 -1
- data/vendor/assets/components/indefinido-advisable/lib/advisable.js +0 -60
- data/vendor/assets/components/indefinido-indemma/component.json +0 -40
- data/vendor/assets/components/indefinido-indemma/index.js +0 -1
- data/vendor/assets/components/indefinido-indemma/lib/extensions/rivets.js +0 -23
- data/vendor/assets/components/indefinido-indemma/lib/record/associable.js +0 -217
- data/vendor/assets/components/indefinido-indemma/lib/record/maid.js +0 -24
- data/vendor/assets/components/indefinido-indemma/lib/record/resource.js +0 -104
- data/vendor/assets/components/indefinido-indemma/lib/record/rest.js +0 -36
- data/vendor/assets/components/indefinido-indemma/lib/record/restfulable.js +0 -326
- data/vendor/assets/components/indefinido-indemma/lib/record/scopable.js +0 -279
- data/vendor/assets/components/indefinido-indemma/lib/record/translationable.js +0 -19
- data/vendor/assets/components/indefinido-indemma/lib/record/validatable.js +0 -216
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/associated.js +0 -30
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/confirmation.js +0 -19
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/cpf.js +0 -60
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/presence.js +0 -19
- data/vendor/assets/components/indefinido-indemma/lib/record/validations/remote.js +0 -71
- data/vendor/assets/components/indefinido-indemma/lib/record.js +0 -167
- data/vendor/assets/components/indefinido-indemma/vendor/sinon.js +0 -4290
- data/vendor/assets/components/indefinido-indemma/vendor/stampit.js +0 -392
- data/vendor/assets/components/indefinido-observable/component.json +0 -25
- data/vendor/assets/components/indefinido-observable/components/cjohansen-sinon/sinon.js +0 -4290
- data/vendor/assets/components/indefinido-observable/index.js +0 -1
- data/vendor/assets/components/indefinido-observable/lib/adapters/rivets.js +0 -26
- data/vendor/assets/components/indefinido-observable/lib/observable.js +0 -320
- data/vendor/assets/components/indefinido-observable/vendor/shims/accessors-legacy.js +0 -92
- data/vendor/assets/components/indefinido-observable/vendor/shims/accessors.js +0 -173
- data/vendor/assets/components/indefinido-observable/vendor/shims/array.indexOf.js +0 -8
- data/vendor/assets/components/indefinido-observable/vendor/shims/object.create.js +0 -77
- data/vendor/assets/components/mikeric-rivets/component.json +0 -15
- data/vendor/assets/components/mikeric-rivets/dist/rivets.js +0 -1020
- data/vendor/assets/components/paulmillr-es6-shim/component.json +0 -17
- data/vendor/assets/components/paulmillr-es6-shim/es6-shim.js +0 -985
- data/vendor/assets/components/pluma-assimilate/component.json +0 -25
- data/vendor/assets/components/pluma-assimilate/dist/assimilate.js +0 -87
- data/vendor/assets/components/segmentio-extend/component.json +0 -13
- data/vendor/assets/components/segmentio-extend/index.js +0 -15
- data/vendor/components/chaijs-assertion-error/component.json +0 -18
- data/vendor/components/chaijs-assertion-error/index.js +0 -110
- data/vendor/components/chaijs-chai/component.json +0 -47
- data/vendor/components/chaijs-chai/index.js +0 -1
- data/vendor/components/chaijs-chai/lib/chai/assertion.js +0 -130
- data/vendor/components/chaijs-chai/lib/chai/core/assertions.js +0 -1270
- data/vendor/components/chaijs-chai/lib/chai/interface/assert.js +0 -1080
- data/vendor/components/chaijs-chai/lib/chai/interface/expect.js +0 -12
- data/vendor/components/chaijs-chai/lib/chai/interface/should.js +0 -76
- data/vendor/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +0 -94
- data/vendor/components/chaijs-chai/lib/chai/utils/addMethod.js +0 -37
- data/vendor/components/chaijs-chai/lib/chai/utils/addProperty.js +0 -40
- data/vendor/components/chaijs-chai/lib/chai/utils/flag.js +0 -32
- data/vendor/components/chaijs-chai/lib/chai/utils/getActual.js +0 -19
- data/vendor/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +0 -25
- data/vendor/components/chaijs-chai/lib/chai/utils/getMessage.js +0 -49
- data/vendor/components/chaijs-chai/lib/chai/utils/getName.js +0 -20
- data/vendor/components/chaijs-chai/lib/chai/utils/getPathValue.js +0 -102
- data/vendor/components/chaijs-chai/lib/chai/utils/getProperties.js +0 -35
- data/vendor/components/chaijs-chai/lib/chai/utils/index.js +0 -108
- data/vendor/components/chaijs-chai/lib/chai/utils/inspect.js +0 -320
- data/vendor/components/chaijs-chai/lib/chai/utils/objDisplay.js +0 -48
- data/vendor/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +0 -51
- data/vendor/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +0 -54
- data/vendor/components/chaijs-chai/lib/chai/utils/test.js +0 -26
- data/vendor/components/chaijs-chai/lib/chai/utils/transferFlags.js +0 -44
- data/vendor/components/chaijs-chai/lib/chai/utils/type.js +0 -45
- data/vendor/components/chaijs-chai/lib/chai.js +0 -80
- data/vendor/components/chaijs-deep-eql/component.json +0 -18
- data/vendor/components/chaijs-deep-eql/lib/eql.js +0 -257
- data/vendor/components/chaijs-type-detect/component.json +0 -16
- data/vendor/components/chaijs-type-detect/lib/type.js +0 -142
- data/vendor/components/component-link-delegate/component.json +0 -23
- data/vendor/components/component-link-delegate/index.js +0 -60
- data/vendor/components/component-url/component.json +0 -17
- data/vendor/components/component-url/index.js +0 -63
- data/vendor/components/discore-closest/component.json +0 -14
- data/vendor/components/discore-closest/index.js +0 -18
- data/vendor/components/indefinido-indemma/.gitignore +0 -14
- data/vendor/components/indefinido-indemma/.ruby-gemset +0 -1
- data/vendor/components/indefinido-indemma/.ruby-version +0 -1
- data/vendor/components/indefinido-indemma/Gemfile +0 -13
- data/vendor/components/indefinido-indemma/Guardfile +0 -39
- data/vendor/components/indefinido-indemma/History.md +0 -0
- data/vendor/components/indefinido-indemma/Readme.md +0 -443
- data/vendor/components/indefinido-indemma/build/development.js +0 -331
- data/vendor/components/indefinido-indemma/build/test.js +0 -331
- data/vendor/components/indefinido-indemma/components/chaijs-assertion-error/component.json +0 -18
- data/vendor/components/indefinido-indemma/components/chaijs-assertion-error/index.js +0 -110
- data/vendor/components/indefinido-indemma/components/chaijs-chai/component.json +0 -47
- data/vendor/components/indefinido-indemma/components/chaijs-chai/index.js +0 -1
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/assertion.js +0 -130
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/core/assertions.js +0 -1270
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/interface/assert.js +0 -1080
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/interface/expect.js +0 -12
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/interface/should.js +0 -76
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +0 -94
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js +0 -37
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addProperty.js +0 -40
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/eql.js +0 -129
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/flag.js +0 -32
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getActual.js +0 -19
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +0 -25
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js +0 -49
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getName.js +0 -20
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getPathValue.js +0 -102
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getProperties.js +0 -35
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/index.js +0 -108
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/inspect.js +0 -320
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js +0 -48
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +0 -51
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +0 -54
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/test.js +0 -26
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/transferFlags.js +0 -44
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/type.js +0 -45
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai.js +0 -80
- data/vendor/components/indefinido-indemma/components/component-bind/component.json +0 -14
- data/vendor/components/indefinido-indemma/components/component-bind/index.js +0 -24
- data/vendor/components/indefinido-indemma/components/component-jquery/component.json +0 -14
- data/vendor/components/indefinido-indemma/components/component-jquery/index.js +0 -9601
- data/vendor/components/indefinido-indemma/components/component-type/component.json +0 -18
- data/vendor/components/indefinido-indemma/components/component-type/index.js +0 -32
- data/vendor/components/indefinido-indemma/components/indefinido-advisable/component.json +0 -21
- data/vendor/components/indefinido-indemma/components/indefinido-advisable/index.js +0 -1
- data/vendor/components/indefinido-indemma/components/indefinido-advisable/lib/advisable.js +0 -60
- data/vendor/components/indefinido-indemma/components/indefinido-observable/component.json +0 -25
- data/vendor/components/indefinido-indemma/components/indefinido-observable/components/cjohansen-sinon/sinon.js +0 -4290
- data/vendor/components/indefinido-indemma/components/indefinido-observable/index.js +0 -1
- data/vendor/components/indefinido-indemma/components/indefinido-observable/lib/adapters/rivets.js +0 -26
- data/vendor/components/indefinido-indemma/components/indefinido-observable/lib/observable.js +0 -323
- data/vendor/components/indefinido-indemma/components/indefinido-observable/vendor/shims/accessors-legacy.js +0 -92
- data/vendor/components/indefinido-indemma/components/indefinido-observable/vendor/shims/accessors.js +0 -173
- data/vendor/components/indefinido-indemma/components/indefinido-observable/vendor/shims/array.indexOf.js +0 -8
- data/vendor/components/indefinido-indemma/components/indefinido-observable/vendor/shims/object.create.js +0 -77
- data/vendor/components/indefinido-indemma/components/kapit-observe-utils/component.json +0 -13
- data/vendor/components/indefinido-indemma/components/pluma-assimilate/component.json +0 -25
- data/vendor/components/indefinido-indemma/components/pluma-assimilate/dist/assimilate.js +0 -87
- data/vendor/components/indefinido-indemma/karma.conf.js +0 -86
- data/vendor/components/indefinido-indemma/lib/record/errors.js +0 -1
- data/vendor/components/indefinido-indemma/spec/record/associable_spec.js +0 -76
- data/vendor/components/indefinido-indemma/spec/record/resource_spec.js +0 -90
- data/vendor/components/indefinido-indemma/spec/record/rest_spec.js +0 -32
- data/vendor/components/indefinido-indemma/spec/record/restfulable_spec.js +0 -232
- data/vendor/components/indefinido-indemma/spec/record/scopable_spec.js +0 -201
- data/vendor/components/indefinido-indemma/spec/record/translationable.js +0 -28
- data/vendor/components/indefinido-indemma/spec/record/validatable_spec.js +0 -111
- data/vendor/components/indefinido-indemma/spec/record/validations/associated_spec.js +0 -43
- data/vendor/components/indefinido-indemma/spec/record/validations/confirmation_spec.js +0 -36
- data/vendor/components/indefinido-indemma/spec/record/validations/cpf_spec.js +0 -35
- data/vendor/components/indefinido-indemma/spec/record/validations/presence_spec.js +0 -28
- data/vendor/components/indefinido-indemma/spec/record/validations/remote_spec.js +0 -86
- data/vendor/components/indefinido-indemma/spec/record/validations/type_spec.js +0 -48
- data/vendor/components/indefinido-indemma/spec/record_spec.js +0 -37
- data/vendor/components/indefinido-indemma/spec/spec_helper.js +0 -11
- data/vendor/components/indefinido-indemma/spec/support/value_objects/phone.js +0 -45
- data/vendor/components/indefinido-indemma/src/lib/extensions/rivets.coffee +0 -17
- data/vendor/components/indefinido-indemma/src/lib/record/associable.coffee +0 -173
- data/vendor/components/indefinido-indemma/src/lib/record/errors.coffee +0 -20
- data/vendor/components/indefinido-indemma/src/lib/record/maid.coffee +0 -16
- data/vendor/components/indefinido-indemma/src/lib/record/resource.coffee +0 -103
- data/vendor/components/indefinido-indemma/src/lib/record/rest.coffee +0 -28
- data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +0 -314
- data/vendor/components/indefinido-indemma/src/lib/record/scopable.coffee +0 -266
- data/vendor/components/indefinido-indemma/src/lib/record/translationable.coffee +0 -18
- data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +0 -209
- data/vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee +0 -32
- data/vendor/components/indefinido-indemma/src/lib/record/validations/confirmation.coffee +0 -19
- data/vendor/components/indefinido-indemma/src/lib/record/validations/cpf.coffee +0 -58
- data/vendor/components/indefinido-indemma/src/lib/record/validations/presence.coffee +0 -19
- data/vendor/components/indefinido-indemma/src/lib/record/validations/remote.coffee +0 -65
- data/vendor/components/indefinido-indemma/src/lib/record/validations/type.coffee +0 -32
- data/vendor/components/indefinido-indemma/src/lib/record.coffee +0 -123
- data/vendor/components/indefinido-indemma/src/spec/record/associable_spec.coffee +0 -63
- data/vendor/components/indefinido-indemma/src/spec/record/resource_spec.coffee +0 -64
- data/vendor/components/indefinido-indemma/src/spec/record/rest_spec.coffee +0 -22
- data/vendor/components/indefinido-indemma/src/spec/record/restfulable_spec.coffee +0 -164
- data/vendor/components/indefinido-indemma/src/spec/record/scopable_spec.coffee +0 -181
- data/vendor/components/indefinido-indemma/src/spec/record/translationable.coffee +0 -19
- data/vendor/components/indefinido-indemma/src/spec/record/validatable_spec.coffee +0 -100
- data/vendor/components/indefinido-indemma/src/spec/record/validations/associated_spec.coffee +0 -35
- data/vendor/components/indefinido-indemma/src/spec/record/validations/confirmation_spec.coffee +0 -25
- data/vendor/components/indefinido-indemma/src/spec/record/validations/cpf_spec.coffee +0 -28
- data/vendor/components/indefinido-indemma/src/spec/record/validations/presence_spec.coffee +0 -24
- data/vendor/components/indefinido-indemma/src/spec/record/validations/remote_spec.coffee +0 -72
- data/vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee +0 -33
- data/vendor/components/indefinido-indemma/src/spec/record_spec.coffee +0 -23
- data/vendor/components/indefinido-indemma/src/spec/spec_helper.coffee +0 -9
- data/vendor/components/indefinido-indemma/src/spec/support/value_objects/phone.coffee +0 -30
- data/vendor/components/indefinido-indemma/vendor/owl/pluralize.js +0 -190
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
require './translationable'
|
|
2
|
-
|
|
3
|
-
root = exports ? window
|
|
4
|
-
stampit = require '../../vendor/stampit'
|
|
5
|
-
observable = require('observable').mixin
|
|
6
|
-
type = require 'type'
|
|
7
|
-
|
|
8
|
-
# TODO better model require
|
|
9
|
-
# model = require ...
|
|
10
|
-
|
|
11
|
-
# TODO Add base settings to validation
|
|
12
|
-
# TODO implement method
|
|
13
|
-
# model[resource].validators_on 'field' # Get all validators related to this field
|
|
14
|
-
|
|
15
|
-
messages =
|
|
16
|
-
blank: (attribute_name) ->
|
|
17
|
-
attribute_name = @human_attribute_name attribute_name
|
|
18
|
-
"O campo #{attribute_name} não pode ficar em branco."
|
|
19
|
-
|
|
20
|
-
cpf: (attribute_name) ->
|
|
21
|
-
attribute_name = @human_attribute_name attribute_name
|
|
22
|
-
"O campo #{attribute_name} não está válido."
|
|
23
|
-
|
|
24
|
-
confirmation: (attribute_name) ->
|
|
25
|
-
confirmation_attribute_name = @human_attribute_name attribute_name
|
|
26
|
-
attribute_name = @human_attribute_name attribute_name.replace '_confirmation', ''
|
|
27
|
-
"O campo #{attribute_name} não está de acordo com o campo #{confirmation_attribute_name}."
|
|
28
|
-
|
|
29
|
-
associated: (attribute_name) ->
|
|
30
|
-
attribute_name = @human_attribute_name attribute_name
|
|
31
|
-
"O registro associado #{attribute_name} não é válido."
|
|
32
|
-
|
|
33
|
-
server: (attribute_name, options) ->
|
|
34
|
-
attribute_name = @human_attribute_name attribute_name
|
|
35
|
-
"#{attribute_name} #{options.server_message}."
|
|
36
|
-
|
|
37
|
-
type: (attribute_name, options) ->
|
|
38
|
-
attribute_name = @human_attribute_name attribute_name
|
|
39
|
-
"O campo #{attribute_name} não está válido."
|
|
40
|
-
|
|
41
|
-
# TODO move to errorsable.coffee
|
|
42
|
-
errorsable = stampit
|
|
43
|
-
add: (attribute_name, message_key, options) ->
|
|
44
|
-
|
|
45
|
-
@push [attribute_name, message_key, options]
|
|
46
|
-
# TODO Also push to attribute named
|
|
47
|
-
# @[attribute_name].push message_key, message, options
|
|
48
|
-
|
|
49
|
-
@messages[attribute_name] = ''
|
|
50
|
-
|
|
51
|
-
translator = messages[message_key]
|
|
52
|
-
|
|
53
|
-
if translator?
|
|
54
|
-
@messages[attribute_name] += translator.call @model, attribute_name, options
|
|
55
|
-
else
|
|
56
|
-
@messages[attribute_name] += message_key
|
|
57
|
-
|
|
58
|
-
clear: ->
|
|
59
|
-
if @length
|
|
60
|
-
@length = 0
|
|
61
|
-
@messages[attribute_name] = null for attribute_name of @messages
|
|
62
|
-
|
|
63
|
-
push: Array.prototype.push
|
|
64
|
-
splice: Array.prototype.splice
|
|
65
|
-
,
|
|
66
|
-
model: null
|
|
67
|
-
messages: null
|
|
68
|
-
length: 0
|
|
69
|
-
, ->
|
|
70
|
-
@messages = {}
|
|
71
|
-
@
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
initializers =
|
|
75
|
-
define_triggers: ->
|
|
76
|
-
|
|
77
|
-
# TODO remove the extra inheritance level of model[@resource]
|
|
78
|
-
@errors = errorsable model: model[@resource]
|
|
79
|
-
|
|
80
|
-
# TODO only add after save when resourceable is included
|
|
81
|
-
# TODO @after_initialize validate_field_types
|
|
82
|
-
# TODO only execute save operation if record is valid
|
|
83
|
-
@before 'save', -> @validate() if @save
|
|
84
|
-
|
|
85
|
-
# TODO move this functionality control to validatorable
|
|
86
|
-
@validated = false
|
|
87
|
-
@subscribe 'dirty', -> @validated = false
|
|
88
|
-
|
|
89
|
-
Object.defineProperty @, 'valid',
|
|
90
|
-
get: ->
|
|
91
|
-
|
|
92
|
-
@validate()
|
|
93
|
-
|
|
94
|
-
if @validation.state() == 'resolved'
|
|
95
|
-
!@errors.length
|
|
96
|
-
else
|
|
97
|
-
null
|
|
98
|
-
|
|
99
|
-
set: -> throw new TypeError "You can't set the value for the valid property."
|
|
100
|
-
enumerable: false
|
|
101
|
-
|
|
102
|
-
create_validators: (definitions) ->
|
|
103
|
-
|
|
104
|
-
@validators = []
|
|
105
|
-
|
|
106
|
-
for name, validator of manager.validators
|
|
107
|
-
definition = definitions[validator.definition_key]
|
|
108
|
-
|
|
109
|
-
if definition
|
|
110
|
-
definition = [definition] unless type(definition) == 'array'
|
|
111
|
-
|
|
112
|
-
for validator_options in definition
|
|
113
|
-
|
|
114
|
-
# Parse validation definition
|
|
115
|
-
validator_options = attribute_name: validator_options unless type(validator_options) == 'object'
|
|
116
|
-
validator_options.model = @
|
|
117
|
-
|
|
118
|
-
# Instantiate validator
|
|
119
|
-
@validators.push validator validator_options
|
|
120
|
-
|
|
121
|
-
# Clear out definition to prevent validators from becoming
|
|
122
|
-
# attributes
|
|
123
|
-
delete definitions[validator.definition_key]
|
|
124
|
-
|
|
125
|
-
# Model and Record extensions
|
|
126
|
-
# TODO Use stampit!
|
|
127
|
-
extensions =
|
|
128
|
-
model:
|
|
129
|
-
validators: null
|
|
130
|
-
|
|
131
|
-
record:
|
|
132
|
-
|
|
133
|
-
validate_attribute: (attribute, doned, failed) ->
|
|
134
|
-
# TODO better clearing of single attribute error message
|
|
135
|
-
@errors.messages[attribute] = null
|
|
136
|
-
|
|
137
|
-
results = [@, attribute]
|
|
138
|
-
|
|
139
|
-
# TODO copy validators reference from model object to record object
|
|
140
|
-
# TODO update json serializer
|
|
141
|
-
# TODO filter validators for attribute
|
|
142
|
-
for validator in model[@resource.toString()].validators
|
|
143
|
-
if validator.attribute_name is attribute
|
|
144
|
-
results.push validator.validate_each @, validator.attribute_name, @[validator.attribute_name]
|
|
145
|
-
|
|
146
|
-
validation = jQuery.when.apply jQuery, results
|
|
147
|
-
validation.done doned
|
|
148
|
-
validation.fail failed
|
|
149
|
-
|
|
150
|
-
validation
|
|
151
|
-
|
|
152
|
-
validate: (doned, failed) ->
|
|
153
|
-
return @validation if @validated
|
|
154
|
-
|
|
155
|
-
@errors.clear()
|
|
156
|
-
results = [@]
|
|
157
|
-
|
|
158
|
-
# TODO copy validators reference from model object to record object
|
|
159
|
-
# TODO update json serializer
|
|
160
|
-
for validator in model[@resource.toString()].validators
|
|
161
|
-
results.push validator.validate_each @, validator.attribute_name, @[validator.attribute_name]
|
|
162
|
-
|
|
163
|
-
@validation = jQuery.when results...
|
|
164
|
-
@validation.done doned
|
|
165
|
-
@validation.fail failed
|
|
166
|
-
|
|
167
|
-
# TODO store this callback
|
|
168
|
-
@validation.then (record) -> record.validated = true
|
|
169
|
-
|
|
170
|
-
@validation
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
# Validators management
|
|
174
|
-
manager =
|
|
175
|
-
|
|
176
|
-
validators: {}
|
|
177
|
-
|
|
178
|
-
# TODO async validator loading
|
|
179
|
-
# for: (name) ->
|
|
180
|
-
# builder = @validators[name] ||= require "validations/#{name}"
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
validatable = stampit
|
|
184
|
-
validate: -> throw new Error 'Composed factory must override the validate method'
|
|
185
|
-
validate_each: -> throw new Error 'Composed factory must override the validate each method'
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
# TODO better stampit integration
|
|
189
|
-
model.mix (modelable) ->
|
|
190
|
-
jQuery.extend modelable, extensions.model
|
|
191
|
-
|
|
192
|
-
jQuery.extend modelable.record, extensions.record
|
|
193
|
-
|
|
194
|
-
modelable.after_mix.unshift initializers.create_validators
|
|
195
|
-
modelable.record.after_initialize.push initializers.define_triggers
|
|
196
|
-
|
|
197
|
-
model.validators = manager.validators
|
|
198
|
-
|
|
199
|
-
# Globalize definitions
|
|
200
|
-
root.validatable = validatable
|
|
201
|
-
root.manager = manager
|
|
202
|
-
|
|
203
|
-
# TODO async validator loading
|
|
204
|
-
require './validations/confirmation'
|
|
205
|
-
require './validations/associated'
|
|
206
|
-
require './validations/presence'
|
|
207
|
-
require './validations/remote'
|
|
208
|
-
require './validations/type'
|
|
209
|
-
require './validations/cpf'
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# TODO Add base settings to validation
|
|
2
|
-
# model = window.model
|
|
3
|
-
|
|
4
|
-
# TODO implement method
|
|
5
|
-
# model[resource].validators_on 'field' # Get all validators related to this field
|
|
6
|
-
|
|
7
|
-
validations = require '../validatable'
|
|
8
|
-
stampit = require '../../../vendor/stampit'
|
|
9
|
-
|
|
10
|
-
associationable = stampit
|
|
11
|
-
validate_each: (record, attribute, value) ->
|
|
12
|
-
# TODO figure out why this method is being called twice
|
|
13
|
-
if record[attribute]
|
|
14
|
-
|
|
15
|
-
# TODO detect association type, and then validate
|
|
16
|
-
# current we only support has_one associations
|
|
17
|
-
unless model[record.resource].has_one.indexOf(attribute) != -1
|
|
18
|
-
throw new Error 'Only has_one associations are supported to validates_associated'
|
|
19
|
-
|
|
20
|
-
associated_validation = record[attribute].validate()
|
|
21
|
-
|
|
22
|
-
associated_validation.done ->
|
|
23
|
-
if record[attribute].errors.length
|
|
24
|
-
record.errors.add attribute, 'associated', @options
|
|
25
|
-
|
|
26
|
-
associated_validation
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
composed = stampit.compose(validations.validatable, associationable)
|
|
30
|
-
composed.definition_key = 'validates_associated'
|
|
31
|
-
|
|
32
|
-
validations.manager.validators.association = composed
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# TODO Add base settings to validation
|
|
2
|
-
# model = window.model
|
|
3
|
-
|
|
4
|
-
# TODO implement method
|
|
5
|
-
# model[resource].validators_on 'field' # Get all validators related to this field
|
|
6
|
-
|
|
7
|
-
validations = require '../validatable'
|
|
8
|
-
stampit = require '../../../vendor/stampit'
|
|
9
|
-
|
|
10
|
-
confirmationable = stampit
|
|
11
|
-
validate_each: (record, attribute, value) ->
|
|
12
|
-
if record[attribute] != record["#{attribute}_confirmation"]
|
|
13
|
-
record.errors.add "#{attribute}_confirmation", 'confirmation', @options
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
composed = stampit.compose(validations.validatable, confirmationable)
|
|
17
|
-
composed.definition_key = 'validates_confirmation_of'
|
|
18
|
-
|
|
19
|
-
validations.manager.validators.confirmation = composed
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
# TODO Add base settings to validation
|
|
2
|
-
# model = window.model
|
|
3
|
-
|
|
4
|
-
# TODO implement method
|
|
5
|
-
# model[resource].validators_on 'field' # Get all validators related to this field
|
|
6
|
-
|
|
7
|
-
validations = require '../validatable'
|
|
8
|
-
stampit = require '../../../vendor/stampit'
|
|
9
|
-
|
|
10
|
-
cpfable = stampit
|
|
11
|
-
validate_format: (value) ->
|
|
12
|
-
value = value.replace /[\.\-]/g, ""
|
|
13
|
-
|
|
14
|
-
# Wrong cpf size
|
|
15
|
-
return false if value.length < 11
|
|
16
|
-
|
|
17
|
-
# Dummy but valid values (000.000.000-00, 111.111.111-11, ...)
|
|
18
|
-
return false if value.match /^(0+|1+|2+|3+|4+|5+|6+|7+|8+|9+)$/
|
|
19
|
-
|
|
20
|
-
# Mod 11 validation
|
|
21
|
-
c = value.substr 0, 9
|
|
22
|
-
dv = value.substr 9, 2
|
|
23
|
-
d1 = 0
|
|
24
|
-
v = false
|
|
25
|
-
i = 0
|
|
26
|
-
|
|
27
|
-
for i in [1..9]
|
|
28
|
-
d1 += c.charAt(i) * (10 - i)
|
|
29
|
-
|
|
30
|
-
return false if d1 == 0
|
|
31
|
-
|
|
32
|
-
d1 = 11 - (d1 % 11)
|
|
33
|
-
d1 = 0 if (d1 > 9 )
|
|
34
|
-
|
|
35
|
-
return false if +dv.charAt 0 != d1
|
|
36
|
-
|
|
37
|
-
d1 *= 2
|
|
38
|
-
for i in [1..9]
|
|
39
|
-
d1 += c.charAt(i) * (11 - i)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
d1 = 11 - (d1 % 11)
|
|
43
|
-
d1 = 0 if (d1 > 9 )
|
|
44
|
-
|
|
45
|
-
return false if +dv.charAt(1) != d1
|
|
46
|
-
|
|
47
|
-
true
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
validate_each: (record, attribute, value) ->
|
|
51
|
-
record.errors.add attribute, 'cpf', @options if value and not @validate_format value
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
composed = stampit.compose validations.validatable, cpfable
|
|
57
|
-
composed.definition_key = 'validates_cpf_format'
|
|
58
|
-
validations.manager.validators.cpf = composed
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# TODO Add base settings to validation
|
|
2
|
-
# model = window.model
|
|
3
|
-
|
|
4
|
-
# TODO implement method
|
|
5
|
-
# model[resource].validators_on 'field' # Get all validators related to this field
|
|
6
|
-
|
|
7
|
-
validations = require '../validatable'
|
|
8
|
-
stampit = require '../../../vendor/stampit'
|
|
9
|
-
|
|
10
|
-
presenceable = stampit
|
|
11
|
-
validate_each: (record, attribute, value) ->
|
|
12
|
-
if value == null or value == '' or value == undefined
|
|
13
|
-
record.errors.add attribute, 'blank', @options
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
composed = stampit.compose(validations.validatable, presenceable)
|
|
17
|
-
composed.definition_key = 'validates_presence_of'
|
|
18
|
-
|
|
19
|
-
validations.manager.validators.presence = composed
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
# TODO Add base settings to validation
|
|
2
|
-
# model = window.model
|
|
3
|
-
|
|
4
|
-
# TODO implement method
|
|
5
|
-
# model[resource].validators_on 'field' # Get all validators related to this field
|
|
6
|
-
|
|
7
|
-
root = exports ? window
|
|
8
|
-
|
|
9
|
-
validations = require '../validatable'
|
|
10
|
-
rest = require '../rest'
|
|
11
|
-
stampit = require '../../../vendor/stampit'
|
|
12
|
-
|
|
13
|
-
remoteable = stampit
|
|
14
|
-
validate_each: (record, attribute, value) ->
|
|
15
|
-
data = @json record
|
|
16
|
-
|
|
17
|
-
# TODO best partial application
|
|
18
|
-
# @post(data).done(_.partial @succeeded, record)
|
|
19
|
-
@post(data).done((json) => @succeeded(json, record))
|
|
20
|
-
|
|
21
|
-
json: (record) ->
|
|
22
|
-
param = @resource.param_name || @resource.toString()
|
|
23
|
-
|
|
24
|
-
data = {}
|
|
25
|
-
data[param] = record.json()
|
|
26
|
-
|
|
27
|
-
# TODO stop renaming id field, lol
|
|
28
|
-
data[param].id ||= data[param]._id
|
|
29
|
-
delete data[param]._id
|
|
30
|
-
|
|
31
|
-
data
|
|
32
|
-
|
|
33
|
-
# TODO Use rest.post
|
|
34
|
-
post: (data) ->
|
|
35
|
-
|
|
36
|
-
jQuery.ajax
|
|
37
|
-
url : @route
|
|
38
|
-
data : data
|
|
39
|
-
type : 'post'
|
|
40
|
-
dataType: 'json'
|
|
41
|
-
context : @
|
|
42
|
-
|
|
43
|
-
succeeded: (json, record) ->
|
|
44
|
-
error_messages = json[@attribute_name]
|
|
45
|
-
|
|
46
|
-
return unless error_messages
|
|
47
|
-
|
|
48
|
-
for error_message in error_messages
|
|
49
|
-
record.errors.add @attribute_name, 'server', server_message: error_message
|
|
50
|
-
,
|
|
51
|
-
message: "Remote validation failed"
|
|
52
|
-
route: null
|
|
53
|
-
, ->
|
|
54
|
-
# TODO discover why @model.route is coming null!
|
|
55
|
-
# Desglobalize model constant
|
|
56
|
-
pluralized_resource = model.pluralize @model.resource.toString()
|
|
57
|
-
@resource = @model.resource
|
|
58
|
-
@route ||= "/#{pluralized_resource}/validate"
|
|
59
|
-
@
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
composed = stampit.compose(validations.validatable, remoteable)
|
|
63
|
-
composed.definition_key = 'validates_remotely'
|
|
64
|
-
|
|
65
|
-
validations.manager.validators.remote = composed
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# TODO Add base settings to validation
|
|
2
|
-
# model = window.model
|
|
3
|
-
|
|
4
|
-
# TODO implement method
|
|
5
|
-
# model[resource].validators_on 'field' # Get all validators related to this field
|
|
6
|
-
|
|
7
|
-
validations = require '../validatable'
|
|
8
|
-
stampit = require '../../../vendor/stampit'
|
|
9
|
-
|
|
10
|
-
typeable = stampit
|
|
11
|
-
validate_each: (record, attribute, value) ->
|
|
12
|
-
# TODO store type on validator instantiation
|
|
13
|
-
@type ||= model[record.resource.toString()][attribute]
|
|
14
|
-
|
|
15
|
-
if value
|
|
16
|
-
|
|
17
|
-
if value instanceof @type
|
|
18
|
-
|
|
19
|
-
# TODO store type_name on costructor
|
|
20
|
-
@type_name ||= @type.name
|
|
21
|
-
|
|
22
|
-
unless value.valid # Will trigger validation
|
|
23
|
-
record.errors.add attribute, 'type', type_name: @type_name?
|
|
24
|
-
|
|
25
|
-
else
|
|
26
|
-
throw new Error "Invalid attribute value type! Found #{typeof value} expected #{@type.name}"
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
composed = stampit.compose(validations.validatable, typeable)
|
|
30
|
-
composed.definition_key = 'validates_type_of'
|
|
31
|
-
|
|
32
|
-
validations.manager.validators.type = composed
|
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
$ = require 'jquery'
|
|
2
|
-
type = require 'type'
|
|
3
|
-
bind = require 'bind'
|
|
4
|
-
observable = require('observable').mixin
|
|
5
|
-
advisable = require('advisable' ).mixin
|
|
6
|
-
extend = require 'assimilate'
|
|
7
|
-
merge = require('assimilate').withStrategy 'deep'
|
|
8
|
-
|
|
9
|
-
# TODO support other type of associations
|
|
10
|
-
@model = do -> # mixin
|
|
11
|
-
modelable =
|
|
12
|
-
after_mix: []
|
|
13
|
-
record:
|
|
14
|
-
# TODO usar deferred
|
|
15
|
-
after_initialize: []
|
|
16
|
-
all: ->
|
|
17
|
-
# TODO transform model in a array like object and store cache in root
|
|
18
|
-
@cache
|
|
19
|
-
# TODO better find support
|
|
20
|
-
create: (params...) ->
|
|
21
|
-
# Implementat non restful model creation
|
|
22
|
-
throw 'model.create not implemented yet, try using the restful.model.create method'
|
|
23
|
-
find: (id) ->
|
|
24
|
-
@where id: id, true
|
|
25
|
-
where: (conditions, first = false) ->
|
|
26
|
-
results = []
|
|
27
|
-
conditions.id = [conditions.id] if type(conditions.id) != 'array'
|
|
28
|
-
# TODO transform model in a array like object and store cache in root
|
|
29
|
-
for record in @cache when conditions.id.indexOf(record._id) isnt -1
|
|
30
|
-
if first
|
|
31
|
-
return record
|
|
32
|
-
else
|
|
33
|
-
results.push record
|
|
34
|
-
|
|
35
|
-
if first then null else results
|
|
36
|
-
|
|
37
|
-
initialize_record = (data = {resource: @resource, parent_resource: @parent_resource}) ->
|
|
38
|
-
data.resource ||= @resource
|
|
39
|
-
data.parent_resource ||= @resource.parent || @parent_resource
|
|
40
|
-
data.route ||= @route
|
|
41
|
-
data.nested_attributes = @nested_attributes || []
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
# instance = record.call extend data, @record # TODO remove @record from outside scop
|
|
45
|
-
after_initialize = (data.after_initialize || []).concat(@record.after_initialize)
|
|
46
|
-
instance = record.call extend Object.create(data), @record, after_initialize: after_initialize # TODO remove @record from outside scope
|
|
47
|
-
|
|
48
|
-
# Call and remove used callbacks
|
|
49
|
-
callback.call instance, instance for callback in instance.after_initialize
|
|
50
|
-
delete instance.after_initialize
|
|
51
|
-
|
|
52
|
-
instance
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
# Create model
|
|
56
|
-
mixer = (options) ->
|
|
57
|
-
throw 'Model mixin called incorrectly call with model.call {} instead of model({})' if @ == window
|
|
58
|
-
mixer.stale = true unless mixer.stale # Prevent model changes
|
|
59
|
-
|
|
60
|
-
# TODO Use stampit and solve this mess!!
|
|
61
|
-
if @record and @record.after_initialize
|
|
62
|
-
after_initialize = @record.after_initialize.splice 0
|
|
63
|
-
else
|
|
64
|
-
after_initialize = []
|
|
65
|
-
|
|
66
|
-
instance = bind @, initialize_record
|
|
67
|
-
|
|
68
|
-
extend instance, merge @, modelable
|
|
69
|
-
|
|
70
|
-
@record = instance.record = merge {}, instance.record, modelable.record
|
|
71
|
-
@record.after_initialize = instance.record.after_initialize = instance.record.after_initialize.concat after_initialize
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
callback.call instance, instance for callback in modelable.after_mix
|
|
75
|
-
|
|
76
|
-
# Store model for later use
|
|
77
|
-
|
|
78
|
-
# TODO implement correctly stampit usage, and remove the need for
|
|
79
|
-
# direct storage
|
|
80
|
-
mixer[@resource.name || @resource.toString()] = instance
|
|
81
|
-
|
|
82
|
-
mixer.mix = (blender) ->
|
|
83
|
-
throw "Trying to change model mixin with #{object} but model already used.\nCheck your configuration order" if @stale
|
|
84
|
-
|
|
85
|
-
blender modelable
|
|
86
|
-
|
|
87
|
-
# window.model
|
|
88
|
-
mixer
|
|
89
|
-
|
|
90
|
-
@record = do -> # mixin
|
|
91
|
-
|
|
92
|
-
callbacks =
|
|
93
|
-
# TODO search for a existing word and rename method, 'smudge' perhaps?
|
|
94
|
-
dirtify: ->
|
|
95
|
-
# TODO add suport to subscribe to any property
|
|
96
|
-
# @subscribe (prop, value, old) ->
|
|
97
|
-
# if prop isnt 'dirty' and not @dirty and value isnt old
|
|
98
|
-
# console.groupCollapsed "◉ Property '#{prop}' dirtied a #{@resource}"
|
|
99
|
-
# console.log old, "→", value
|
|
100
|
-
# console.log @
|
|
101
|
-
# console.groupEnd()
|
|
102
|
-
# @dirty = true
|
|
103
|
-
|
|
104
|
-
recordable =
|
|
105
|
-
# TODO usar deferred
|
|
106
|
-
dirty: false
|
|
107
|
-
after_initialize: [ callbacks.dirtify ]
|
|
108
|
-
|
|
109
|
-
that = (data) ->
|
|
110
|
-
throw "Mixin called incorrectly, call mixin with call method: record.call(object, data)" if @ == window
|
|
111
|
-
|
|
112
|
-
data ||= {}
|
|
113
|
-
after_initialize = (@after_initialize || []).concat(data.after_initialize || []).concat(recordable.after_initialize)
|
|
114
|
-
advisable observable(extend(@, recordable, data, after_initialize: after_initialize))
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
that.mix = (blender) ->
|
|
118
|
-
blender recordable
|
|
119
|
-
|
|
120
|
-
that
|
|
121
|
-
|
|
122
|
-
exports.record = @record
|
|
123
|
-
exports.model = @model
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
root = exports ? window
|
|
2
|
-
|
|
3
|
-
require 'indemma/lib/record/associable'
|
|
4
|
-
|
|
5
|
-
describe 'record', ->
|
|
6
|
-
record = root.record
|
|
7
|
-
|
|
8
|
-
it 'should create a record'
|
|
9
|
-
|
|
10
|
-
describe 'model', ->
|
|
11
|
-
model = root.model
|
|
12
|
-
person = corporation = null
|
|
13
|
-
|
|
14
|
-
beforeEach ->
|
|
15
|
-
corporation = model.call
|
|
16
|
-
resource: 'corporation'
|
|
17
|
-
|
|
18
|
-
# TODO implement support for self referential associations
|
|
19
|
-
friend = model.call
|
|
20
|
-
resource: 'friends'
|
|
21
|
-
|
|
22
|
-
person = model.call
|
|
23
|
-
resource : 'person'
|
|
24
|
-
has_many : 'friends'
|
|
25
|
-
belongs_to: 'corporation'
|
|
26
|
-
|
|
27
|
-
describe 'belongs_to', ->
|
|
28
|
-
|
|
29
|
-
it 'should add builded object to association named attribute', ->
|
|
30
|
-
arthur = person
|
|
31
|
-
name: 'Arthur Dent'
|
|
32
|
-
|
|
33
|
-
corporation = arthur.build_corporation()
|
|
34
|
-
arthur.should.have.property 'corporation'
|
|
35
|
-
expect(corporation).to.be.ok
|
|
36
|
-
|
|
37
|
-
describe 'has_many', ->
|
|
38
|
-
|
|
39
|
-
it 'should return a record factory with associations stored', ->
|
|
40
|
-
person.has_many.should.be.array
|
|
41
|
-
|
|
42
|
-
has_many = Array.prototype.splice.call person.has_many, 0
|
|
43
|
-
|
|
44
|
-
has_many.should.contain 'friends'
|
|
45
|
-
|
|
46
|
-
describe '#()', ->
|
|
47
|
-
|
|
48
|
-
it 'should return a record with an association object', ->
|
|
49
|
-
person().should.have.property 'friends'
|
|
50
|
-
|
|
51
|
-
describe '{generated_association}', ->
|
|
52
|
-
association = null
|
|
53
|
-
|
|
54
|
-
beforeEach -> association = person().friends
|
|
55
|
-
|
|
56
|
-
it 'should have query methods', ->
|
|
57
|
-
association.should.have.property 'all'
|
|
58
|
-
association.should.have.property 'each'
|
|
59
|
-
association.should.have.property 'reload'
|
|
60
|
-
|
|
61
|
-
describe '#all', ->
|
|
62
|
-
|
|
63
|
-
it 'should auto observe nested associations attributes'
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
require 'indemma/lib/record/restfulable'
|
|
2
|
-
require 'indemma/lib/record/resource'
|
|
3
|
-
|
|
4
|
-
root = exports ? window
|
|
5
|
-
|
|
6
|
-
model = root.model # TODO model = require 'indemma/model'
|
|
7
|
-
record = root.record # TODO model = require 'indemma/record'
|
|
8
|
-
jQuery = require 'component-jquery'
|
|
9
|
-
|
|
10
|
-
describe 'resource', ->
|
|
11
|
-
|
|
12
|
-
describe 'with scope option', ->
|
|
13
|
-
person = towel = null
|
|
14
|
-
|
|
15
|
-
beforeEach ->
|
|
16
|
-
person = model.call
|
|
17
|
-
resource: 'person'
|
|
18
|
-
|
|
19
|
-
towel = model.call
|
|
20
|
-
resource:
|
|
21
|
-
name: 'towel'
|
|
22
|
-
scope: 'users'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
it 'should be prefixed with scope', ->
|
|
26
|
-
towel. route.should.be.eq '/users/towels'
|
|
27
|
-
towel( { } ).route.should.be.eq '/users/towels'
|
|
28
|
-
towel(id: 1).route.should.be.eq '/users/towels'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
describe 'with singular resource', ->
|
|
32
|
-
towel = null
|
|
33
|
-
|
|
34
|
-
beforeEach ->
|
|
35
|
-
towel = model.call
|
|
36
|
-
resource:
|
|
37
|
-
name: 'towel'
|
|
38
|
-
singular: true
|
|
39
|
-
|
|
40
|
-
deferred = jQuery.Deferred()
|
|
41
|
-
deferred.resolveWith towel(name: 'Arthur'), [_id: 1]
|
|
42
|
-
sinon.stub(jQuery, "ajax").returns(deferred)
|
|
43
|
-
promises = towel.create {name: 'Arthur'}, {name: 'Ford'}
|
|
44
|
-
|
|
45
|
-
afterEach -> jQuery.ajax.restore()
|
|
46
|
-
|
|
47
|
-
it 'the route should be in singular form', ->
|
|
48
|
-
towel. route.should.be.eq '/towel'
|
|
49
|
-
towel( { } ).route.should.be.eq '/towel'
|
|
50
|
-
towel(id: 1).route.should.be.eq '/towel'
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
describe 'when included', ->
|
|
54
|
-
xit 'sets the resource loaded flag on model', ->
|
|
55
|
-
# model.resource.should.be.true
|
|
56
|
-
|
|
57
|
-
describe 'model' , ->
|
|
58
|
-
it 'add methods to model object'
|
|
59
|
-
|
|
60
|
-
describe '#pluralize', ->
|
|
61
|
-
xit 'transforms word into plural form'
|
|
62
|
-
|
|
63
|
-
describe '#singularize', ->
|
|
64
|
-
xit 'transforms word into singular form'
|