ende 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- 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,28 +0,0 @@
|
|
1
|
-
var root;
|
2
|
-
|
3
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
4
|
-
|
5
|
-
require('indemma/lib/record/validatable');
|
6
|
-
|
7
|
-
describe('model #() validates presence of', function() {
|
8
|
-
return describe('basic usage', function() {
|
9
|
-
var model, person;
|
10
|
-
|
11
|
-
model = root.model;
|
12
|
-
person = null;
|
13
|
-
beforeEach(function() {
|
14
|
-
return person = model.call({
|
15
|
-
resource: 'person',
|
16
|
-
name: String,
|
17
|
-
belongs_to: 'corporation',
|
18
|
-
validates_presence_of: 'name'
|
19
|
-
});
|
20
|
-
});
|
21
|
-
afterEach(function() {
|
22
|
-
return person.validators.length = 0;
|
23
|
-
});
|
24
|
-
return describe('#validate', function() {
|
25
|
-
return it('should add error to record when required field is empty (null, undefined or \'\')');
|
26
|
-
});
|
27
|
-
});
|
28
|
-
});
|
@@ -1,86 +0,0 @@
|
|
1
|
-
var root;
|
2
|
-
|
3
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
4
|
-
|
5
|
-
require('indemma/lib/record/validatable');
|
6
|
-
|
7
|
-
describe('model #() validates_remotely', function() {
|
8
|
-
var arthur, model, person, request;
|
9
|
-
|
10
|
-
model = root.model;
|
11
|
-
request = arthur = person = null;
|
12
|
-
describe('basic usage', function() {
|
13
|
-
beforeEach(function() {
|
14
|
-
person = model.call({
|
15
|
-
resource: 'person',
|
16
|
-
name: String,
|
17
|
-
validates_remotely: 'name'
|
18
|
-
});
|
19
|
-
return arthur = person({
|
20
|
-
name: "Arthur Dent"
|
21
|
-
});
|
22
|
-
});
|
23
|
-
afterEach(function() {
|
24
|
-
return person != null ? person.validators.length = 0 : void 0;
|
25
|
-
});
|
26
|
-
return describe('#validate', function() {
|
27
|
-
beforeEach(function() {
|
28
|
-
request = jQuery.Deferred();
|
29
|
-
return sinon.stub(jQuery, "ajax").returns(request);
|
30
|
-
});
|
31
|
-
afterEach(function() {
|
32
|
-
return jQuery.ajax.restore();
|
33
|
-
});
|
34
|
-
it('should send paramenters accordingly', function() {
|
35
|
-
arthur.validate();
|
36
|
-
jQuery.ajax.called.should.be["true"];
|
37
|
-
return jQuery.ajax.calledWithMatch({
|
38
|
-
url: '/persons/validate',
|
39
|
-
data: {
|
40
|
-
person: {
|
41
|
-
name: 'Arthur Dent'
|
42
|
-
}
|
43
|
-
}
|
44
|
-
}).should.be["true"];
|
45
|
-
});
|
46
|
-
return it('should add errors to record when request responds with errors', function() {
|
47
|
-
arthur.validate();
|
48
|
-
request.resolveWith(arthur, [
|
49
|
-
{
|
50
|
-
name: ['The name should be Marvin!', 'The name should be in lowercase!']
|
51
|
-
}
|
52
|
-
]);
|
53
|
-
arthur.errors.length.should.be.eq(2);
|
54
|
-
return arthur.errors.messages.name.should.exist;
|
55
|
-
});
|
56
|
-
});
|
57
|
-
});
|
58
|
-
return describe('with options usage', function() {
|
59
|
-
beforeEach(function() {
|
60
|
-
if (person != null) {
|
61
|
-
person.validators.length = 0;
|
62
|
-
}
|
63
|
-
person = model.call({
|
64
|
-
resource: 'person',
|
65
|
-
name: String,
|
66
|
-
validates_remotely: 'name'
|
67
|
-
});
|
68
|
-
return arthur = person({
|
69
|
-
name: "Arthur Dent"
|
70
|
-
});
|
71
|
-
});
|
72
|
-
return describe('#validate', function() {
|
73
|
-
beforeEach(function() {
|
74
|
-
request = jQuery.Deferred();
|
75
|
-
return sinon.stub(jQuery, "ajax").returns(request);
|
76
|
-
});
|
77
|
-
afterEach(function() {
|
78
|
-
return jQuery.ajax.restore();
|
79
|
-
});
|
80
|
-
return it('should make ajax call', function() {
|
81
|
-
arthur.validate();
|
82
|
-
return jQuery.ajax.called.should.be["true"];
|
83
|
-
});
|
84
|
-
});
|
85
|
-
});
|
86
|
-
});
|
@@ -1,48 +0,0 @@
|
|
1
|
-
var root;
|
2
|
-
|
3
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
4
|
-
|
5
|
-
require('indemma/lib/record/validatable');
|
6
|
-
|
7
|
-
describe('model #() validates type of', function() {
|
8
|
-
return describe('basic usage', function() {
|
9
|
-
var model, person;
|
10
|
-
|
11
|
-
model = root.model;
|
12
|
-
person = null;
|
13
|
-
beforeEach(function() {
|
14
|
-
return person = model.call({
|
15
|
-
resource: 'person',
|
16
|
-
name: String,
|
17
|
-
phone: Phone,
|
18
|
-
validates_type_of: ['name', 'phone']
|
19
|
-
});
|
20
|
-
});
|
21
|
-
afterEach(function() {
|
22
|
-
return person.validators.length = 0;
|
23
|
-
});
|
24
|
-
return describe('#validate', function() {
|
25
|
-
it('should use Phone#validate to find out if attribute is valid');
|
26
|
-
it('should add error to record when phone typed attribute has an non valid phone value', function() {
|
27
|
-
var arthur;
|
28
|
-
|
29
|
-
arthur = person({
|
30
|
-
phone: new Phone('batata')
|
31
|
-
});
|
32
|
-
arthur.valid.should.be["false"];
|
33
|
-
arthur.errors.messages.should.have.property('phone');
|
34
|
-
return expect(arthur.errors.messages.phone).to.match(/não está válido/);
|
35
|
-
});
|
36
|
-
return it('should throw error to when phone typed attribute has an non phone value', function() {
|
37
|
-
var arthur;
|
38
|
-
|
39
|
-
arthur = person({
|
40
|
-
phone: 'batata'
|
41
|
-
});
|
42
|
-
return expect(function() {
|
43
|
-
return arthur.valid;
|
44
|
-
}).to["throw"](/invalid attribute value type/i);
|
45
|
-
});
|
46
|
-
});
|
47
|
-
});
|
48
|
-
});
|
@@ -1,37 +0,0 @@
|
|
1
|
-
var root;
|
2
|
-
|
3
|
-
root = typeof exports !== "undefined" && exports !== null ? exports : window;
|
4
|
-
|
5
|
-
describe('record', function() {
|
6
|
-
var record;
|
7
|
-
|
8
|
-
record = root.record;
|
9
|
-
return it('should create a record', function() {
|
10
|
-
var arthur;
|
11
|
-
|
12
|
-
arthur = record.call({
|
13
|
-
resource: 'person'
|
14
|
-
});
|
15
|
-
return arthur.should.be.object;
|
16
|
-
});
|
17
|
-
});
|
18
|
-
|
19
|
-
describe('model', function() {
|
20
|
-
var model;
|
21
|
-
|
22
|
-
model = root.model;
|
23
|
-
return describe('#()', function() {
|
24
|
-
xit('should throw exception if no resource is passed');
|
25
|
-
return it('should create a record factory', function() {
|
26
|
-
var john, person;
|
27
|
-
|
28
|
-
person = model.call({
|
29
|
-
resource: 'person'
|
30
|
-
});
|
31
|
-
person.should.be.object;
|
32
|
-
john = person();
|
33
|
-
john.should.be.object;
|
34
|
-
return john.resource.should.have.property('name', 'person');
|
35
|
-
});
|
36
|
-
});
|
37
|
-
});
|
@@ -1,45 +0,0 @@
|
|
1
|
-
this.Phone = (function() {
|
2
|
-
function Phone(area_code, number) {
|
3
|
-
var _ref;
|
4
|
-
|
5
|
-
this.area_code = area_code;
|
6
|
-
this.number = number;
|
7
|
-
if (typeof this.area_code === 'object') {
|
8
|
-
_ref = this.area_code, this.area_code = _ref.area_code, this.number = _ref.number;
|
9
|
-
}
|
10
|
-
if (!this.number) {
|
11
|
-
this.number = this.area_code;
|
12
|
-
this.area_code = null;
|
13
|
-
}
|
14
|
-
Object.defineProperty(this, 'valid', {
|
15
|
-
get: this.validate
|
16
|
-
});
|
17
|
-
}
|
18
|
-
|
19
|
-
Phone.prototype.validate = function() {
|
20
|
-
return (this.area_code != null) && (this.number != null);
|
21
|
-
};
|
22
|
-
|
23
|
-
Phone.prototype.toString = function() {
|
24
|
-
var formatted_number;
|
25
|
-
|
26
|
-
if (this.number != null) {
|
27
|
-
formatted_number = this.number.substr(0, 4) + '-' + this.number.substr(4);
|
28
|
-
}
|
29
|
-
if (this.area_code != null) {
|
30
|
-
return "(" + this.area_code + ") " + formatted_number;
|
31
|
-
} else {
|
32
|
-
return formatted_number;
|
33
|
-
}
|
34
|
-
};
|
35
|
-
|
36
|
-
Phone.prototype.toJSON = function() {
|
37
|
-
return {
|
38
|
-
area_code: this.area_code,
|
39
|
-
number: this.number
|
40
|
-
};
|
41
|
-
};
|
42
|
-
|
43
|
-
return Phone;
|
44
|
-
|
45
|
-
})();
|
@@ -1,17 +0,0 @@
|
|
1
|
-
root = exports ? this
|
2
|
-
|
3
|
-
model.rivets = ->
|
4
|
-
|
5
|
-
model_extensions =
|
6
|
-
record:
|
7
|
-
tie: (element) ->
|
8
|
-
lasso = {}
|
9
|
-
lasso[@resource] = @
|
10
|
-
rivets.bind element, lasso
|
11
|
-
|
12
|
-
# Always preload data into the template
|
13
|
-
preloadData: true
|
14
|
-
|
15
|
-
model.mix (modelable) ->
|
16
|
-
# TODO remove jquery dependency
|
17
|
-
$.extend true, modelable, model_extensions
|
@@ -1,173 +0,0 @@
|
|
1
|
-
|
2
|
-
root = window
|
3
|
-
$ = require 'jquery'
|
4
|
-
|
5
|
-
require './resource'
|
6
|
-
|
7
|
-
# Store association methods
|
8
|
-
# TODO Implement setter for route
|
9
|
-
plural = # has_many ## TODO embeds_many
|
10
|
-
add : (params...) -> @push @build attributes for attributes in params
|
11
|
-
create: (params...) ->
|
12
|
-
for attributes in params
|
13
|
-
record = @build attributes
|
14
|
-
@push record
|
15
|
-
record.save()
|
16
|
-
build: (data = {}) ->
|
17
|
-
data.parent_resource = @parent_resource
|
18
|
-
|
19
|
-
|
20
|
-
# TODO Setup a before save callback to generate route when there is no id
|
21
|
-
data.route ||= "#{@parent.route}/#{@parent._id}/#{model.pluralize @resource.toString()}" if @parent?
|
22
|
-
throw "associable.has_many: cannot redefine route of association #{@parent_resource}.#{@resource} from #{@route} to #{data.route}" if @route isnt data.route and @route
|
23
|
-
# Adds parent record to children side of association, if not set
|
24
|
-
# TODO check if this reference is unmade on instance elimination
|
25
|
-
data[@parent_resource] ||= @parent
|
26
|
-
|
27
|
-
# TODO store a singular copy of the resource for better performace
|
28
|
-
model[model.singularize @resource] data
|
29
|
-
push : Array.prototype.push
|
30
|
-
|
31
|
-
length : 0
|
32
|
-
json : (methods, omissions) -> record.json(methods, omissions) for record in @
|
33
|
-
|
34
|
-
|
35
|
-
singular = # belongs_to, has_one ## TODO embeds_one, embedded_in
|
36
|
-
create: (data) -> model[@resource].create $.extend {}, @, data
|
37
|
-
build : (data) ->
|
38
|
-
# Adds child record of association to parent, and returns new
|
39
|
-
# record
|
40
|
-
@[@parent_resource][@resource] = model[@resource] $.extend {}, @, data
|
41
|
-
|
42
|
-
# TODO Better association segregation
|
43
|
-
associable =
|
44
|
-
# @ = model
|
45
|
-
model: (options) ->
|
46
|
-
console.error 'resource must be defined in order to associate' unless @resource?
|
47
|
-
|
48
|
-
callbacks =
|
49
|
-
# Forward association nested attributes
|
50
|
-
has_many:
|
51
|
-
nest_attributes: ->
|
52
|
-
# TODO only nest specified nested attributes on model definition
|
53
|
-
association_names = model[@resource].has_many
|
54
|
-
if association_names
|
55
|
-
for association_name in association_names
|
56
|
-
associations_attributes = @["#{association_name}_attributes"]
|
57
|
-
if associations_attributes and associations_attributes.length
|
58
|
-
association = @[model.pluralize association_name]
|
59
|
-
|
60
|
-
unless association
|
61
|
-
message = "has_many.nest_attributes: Association not found for #{association_name}. \n"
|
62
|
-
message += "did you set it on model declaration? \n has_many: #{association_name} "
|
63
|
-
throw message
|
64
|
-
|
65
|
-
# TODO store a singular copy of the resource for better performace
|
66
|
-
association.resource = model.singularize association.resource
|
67
|
-
association.add.apply association, associations_attributes
|
68
|
-
association.resource = model.pluralize association.resource
|
69
|
-
|
70
|
-
# TODO Update route after setting the id
|
71
|
-
# TODO Update route association only once for each associated record
|
72
|
-
update_association: (data) ->
|
73
|
-
id = @_id || data && (data._id || data.id)
|
74
|
-
|
75
|
-
# Keep trying until we have a id
|
76
|
-
return unless id
|
77
|
-
|
78
|
-
for association_name in model[@resource.toString()].has_many
|
79
|
-
pluralized_association = model.pluralize association_name
|
80
|
-
association = @[pluralized_association]
|
81
|
-
|
82
|
-
# TODO setter of association.route
|
83
|
-
# to automatically update associated records
|
84
|
-
unless association.route
|
85
|
-
association.route = "/#{model.pluralize @resource.toString()}/#{id}/#{model.pluralize association.resource}"
|
86
|
-
|
87
|
-
for associated in association
|
88
|
-
if not associated.route and associated.parent?
|
89
|
-
associated.route = "/#{model.pluralize @resource.toString()}/#{id}/#{model.pluralize association.resource}"
|
90
|
-
|
91
|
-
true
|
92
|
-
autosave: ->
|
93
|
-
@save()
|
94
|
-
|
95
|
-
# TODO autosave
|
96
|
-
# @after_save.push ->
|
97
|
-
# model[@resource] =
|
98
|
-
#
|
99
|
-
@has_many = [@has_many ] if @has_many and $.type(@has_many) != 'array'
|
100
|
-
@has_one = [@has_one ] if @has_one and $.type(@has_one) != 'array'
|
101
|
-
@belongs_to = [@belongs_to] if @belongs_to and $.type(@belongs_to) != 'array'
|
102
|
-
|
103
|
-
@has_many ||= []
|
104
|
-
@has_one ||= []
|
105
|
-
@belongs_to ||= []
|
106
|
-
|
107
|
-
# TODO better organisation of this code
|
108
|
-
# inside this function: @ = record (running on after_initialize)
|
109
|
-
@create_associations = ->
|
110
|
-
# Create association methods
|
111
|
-
# Setup one to many association in model
|
112
|
-
if options.has_many
|
113
|
-
|
114
|
-
# TODO accept more options on has_many association creation
|
115
|
-
for resource in options.has_many
|
116
|
-
# unless model[resource]
|
117
|
-
# throw "Model not found for association with resource '#{resource}', on association 'has_many' "
|
118
|
-
|
119
|
-
# TODO instantiate default resources in has_many association
|
120
|
-
# @resource = model[resource].resource
|
121
|
-
|
122
|
-
# TODO Remember to clear association proxy when object is destroyed
|
123
|
-
association_proxy = resource: resource, parent_resource: @resource, parent: @
|
124
|
-
association_name = model.pluralize resource
|
125
|
-
@[association_name] = $.extend association_proxy, plural
|
126
|
-
|
127
|
-
# Update association attribute
|
128
|
-
@after 'saved', callbacks.has_many.update_association
|
129
|
-
|
130
|
-
# Forward nested attributes
|
131
|
-
callbacks.has_many.nest_attributes.call @
|
132
|
-
|
133
|
-
if options.has_one
|
134
|
-
for resource in options.has_one
|
135
|
-
# unless model[resource]
|
136
|
-
# throw "Model not found for association with resource '#{resource}', on association 'has_one' "
|
137
|
-
|
138
|
-
association_proxy = resource: resource, parent_resource: @resource
|
139
|
-
association_proxy[@resource] = @
|
140
|
-
|
141
|
-
@["build_#{resource}" ] = $.proxy singular.build , association_proxy
|
142
|
-
@["create_#{resource}"] = $.proxy singular.create, association_proxy
|
143
|
-
|
144
|
-
if options.belongs_to
|
145
|
-
|
146
|
-
for resource in options.belongs_to
|
147
|
-
# unless model[resource]
|
148
|
-
# throw "Model not found for association with resource '#{resource}', on association 'belongs_to' "
|
149
|
-
|
150
|
-
association_proxy = resource: resource, parent_resource: @resource
|
151
|
-
|
152
|
-
# TODO override default setter to set resource_id from parent resource FTW!
|
153
|
-
association_proxy[@resource] = @
|
154
|
-
|
155
|
-
@["build_#{resource}" ] = $.proxy singular.build , association_proxy
|
156
|
-
@["create_#{resource}"] = $.proxy singular.create, association_proxy
|
157
|
-
|
158
|
-
# @ = record
|
159
|
-
record: (options) ->
|
160
|
-
console.error 'resource must be defined in order to associate' unless @resource?
|
161
|
-
model[@resource.name || @resource.toString()].create_associations.call @
|
162
|
-
|
163
|
-
|
164
|
-
# Extend indemma
|
165
|
-
model = root.model # TODO better way to get parent
|
166
|
-
model.mix (modelable) ->
|
167
|
-
modelable.after_mix.push associable.model
|
168
|
-
modelable.record.after_initialize.push associable.record
|
169
|
-
|
170
|
-
# This allows to extendind the associable mixin
|
171
|
-
model.associable =
|
172
|
-
mix : (blender) ->
|
173
|
-
blender singular, plural
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# TODO externalize errorsable from validatable
|
2
|
-
# errorsable = stampit
|
3
|
-
# add: (attribute, message_key, options) ->
|
4
|
-
#
|
5
|
-
# @push [attribute, message_key, options]
|
6
|
-
# @messages[attribute_name] messages[message_key](attribute_name)
|
7
|
-
#
|
8
|
-
# clear: ->
|
9
|
-
# if @length
|
10
|
-
# @length = 0
|
11
|
-
# @messages = {}
|
12
|
-
#
|
13
|
-
# push: Array.prototype.push
|
14
|
-
# splice: Array.prototype.splice
|
15
|
-
# ,
|
16
|
-
# messages: {}
|
17
|
-
# length: 0
|
18
|
-
# , ->
|
19
|
-
# @messages = []
|
20
|
-
# @
|
@@ -1,16 +0,0 @@
|
|
1
|
-
maid =
|
2
|
-
|
3
|
-
model : ->
|
4
|
-
@record.after_initialize.push maid.record if @washing?
|
5
|
-
|
6
|
-
record: ->
|
7
|
-
|
8
|
-
@subscribe 'dirty', (dirty) ->
|
9
|
-
dirty && setTimeout =>
|
10
|
-
@save()
|
11
|
-
, 500
|
12
|
-
|
13
|
-
# Extend indemma
|
14
|
-
model = window.model
|
15
|
-
model.mix (modelable) ->
|
16
|
-
modelable.after_mix.unshift maid.model
|
@@ -1,103 +0,0 @@
|
|
1
|
-
stampit = require '../../vendor/stampit'
|
2
|
-
require '../../vendor/owl/pluralize'
|
3
|
-
|
4
|
-
# TODO Think of a better name
|
5
|
-
resource = stampit
|
6
|
-
toString: -> @name
|
7
|
-
# TODO move resourceable.route() to here
|
8
|
-
,
|
9
|
-
name : 'unknown'
|
10
|
-
scope : null
|
11
|
-
singular: false
|
12
|
-
, ->
|
13
|
-
|
14
|
-
# TODO better integration with record.coffee, and stop storing
|
15
|
-
# original reference
|
16
|
-
if @original_reference
|
17
|
-
stampit.mixIn @original_reference, @
|
18
|
-
@original_reference.toString = @toString
|
19
|
-
@original_reference.param_name ||= @name
|
20
|
-
|
21
|
-
return @original_reference
|
22
|
-
|
23
|
-
@param_name ||= @name
|
24
|
-
|
25
|
-
@
|
26
|
-
|
27
|
-
resourceable =
|
28
|
-
pluralize: (word, count, plural) ->
|
29
|
-
throw new TypeError "Invalid string passed to pluralize '#{word}'" unless word and word.length
|
30
|
-
|
31
|
-
unless word.indexOf('s') == word.length - 1
|
32
|
-
owl.pluralize word, count, plural
|
33
|
-
else
|
34
|
-
word
|
35
|
-
|
36
|
-
singularize: (word) ->
|
37
|
-
throw new TypeError "Invalid string passed to singularize '#{word}'" unless word and word.length
|
38
|
-
|
39
|
-
if word.lastIndexOf('s') == word.length - 1
|
40
|
-
word.substring 0, word.length - 1
|
41
|
-
else
|
42
|
-
word
|
43
|
-
|
44
|
-
# TODO move to resourceable method
|
45
|
-
route:
|
46
|
-
get: ->
|
47
|
-
return @initial_route if @initial_route?
|
48
|
-
|
49
|
-
# TODO use resource object on associations!
|
50
|
-
@resource = name: @resource if typeof @resource == 'string'
|
51
|
-
|
52
|
-
route = '/'
|
53
|
-
route += "#{@parent.route}/#{@parent._id}/" if @parent?
|
54
|
-
route += @resource.scope + '/' if @resource.scope?
|
55
|
-
|
56
|
-
route += if @resource.singular then @resource.name else model.pluralize @resource.name
|
57
|
-
@initial_route = route
|
58
|
-
|
59
|
-
route
|
60
|
-
|
61
|
-
set: (value) -> @initial_route = value
|
62
|
-
|
63
|
-
parent_id:
|
64
|
-
get: -> @[@parent_resource]._id
|
65
|
-
set: -> console.error 'Warning changing associations throught parent_id not allowed for security and style guide purposes' # TODO
|
66
|
-
|
67
|
-
initialize: ->
|
68
|
-
# Set parent attribute and default nested route
|
69
|
-
if @parent_resource
|
70
|
-
Object.defineProperty @, "#{@parent_resource}_id", resourceable.parent_id
|
71
|
-
|
72
|
-
# Setup resource
|
73
|
-
resource_definition = {}
|
74
|
-
resource_definition = name: @resource if typeof @resource == 'string'
|
75
|
-
if typeof @resource == 'object'
|
76
|
-
# TODO deeper resource integration with record.coffee, and remove original reference
|
77
|
-
# To prevent reference lost and allow dinamic modification of resources
|
78
|
-
# we need to preserve the original reference
|
79
|
-
@resource.original_reference = @resource
|
80
|
-
|
81
|
-
resource_definition = @resource
|
82
|
-
|
83
|
-
# TODO remove mentions of @parent_resource and use only resource: {parent: ...}
|
84
|
-
resource_definition.parent = @parent_resource
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
@resource = resource resource_definition
|
90
|
-
|
91
|
-
# TODO Support route parsing, and change route to /parents/:id/childrens
|
92
|
-
@route ? Object.defineProperty @, 'route', resourceable.route
|
93
|
-
|
94
|
-
|
95
|
-
# Extend indemma
|
96
|
-
model = window.model # TODO better way to get parent
|
97
|
-
|
98
|
-
model.mix (modelable) ->
|
99
|
-
modelable.record.after_initialize.unshift resourceable.initialize
|
100
|
-
modelable.after_mix.unshift resourceable.initialize
|
101
|
-
|
102
|
-
model.singularize = resourceable.singularize
|
103
|
-
model.pluralize = resourceable.pluralize
|
@@ -1,28 +0,0 @@
|
|
1
|
-
$ = require 'jquery'
|
2
|
-
|
3
|
-
module.exports =
|
4
|
-
# TODO render route in the object itself with getter, and normalize this methods
|
5
|
-
get : (data) -> request.call @, 'get' , (if @_id then "#{@route}/#{@_id}" else @route), data
|
6
|
-
put : (data) -> request.call @, 'put' , (if @_id then "#{@route}/#{@_id}" else @route), data # TODO change from put to patch
|
7
|
-
post : (data) -> request.call @, 'post' , @route, data
|
8
|
-
delete: (data) -> request.call @, 'delete', @route, data
|
9
|
-
|
10
|
-
request = (method, url, data) ->
|
11
|
-
param_name = @resource.param_name || @resource.toString()
|
12
|
-
|
13
|
-
# TODO optmize this serialization lookup
|
14
|
-
if not data and @json
|
15
|
-
data = {}
|
16
|
-
data[param_name] = @json()
|
17
|
-
|
18
|
-
if data and data[param_name]
|
19
|
-
delete data[param_name]['id']
|
20
|
-
delete data[param_name]['_id']
|
21
|
-
|
22
|
-
|
23
|
-
$.ajax
|
24
|
-
url : url
|
25
|
-
data : data
|
26
|
-
type : method
|
27
|
-
dataType: 'json'
|
28
|
-
context : @
|