carnival 0.0.55 → 0.0.56
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/carnival/admin.js +3 -3
- data/app/assets/javascripts/carnival/data_tables_functions.js +18 -2
- data/app/assets/javascripts/carnival/external/{jquery.noty.js → noty/jquery.noty.js} +45 -117
- data/app/assets/javascripts/carnival/external/{jquery.noty.layout.bottom.js → noty/layouts/bottom.js} +1 -1
- data/app/assets/javascripts/carnival/external/noty/layouts/bottomCenter.js +41 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/bottomLeft.js +43 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/bottomRight.js +43 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/center.js +56 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/centerLeft.js +61 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/centerRight.js +61 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/inline.js +31 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/top.js +34 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/topCenter.js +41 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/topLeft.js +43 -0
- data/app/assets/javascripts/carnival/external/noty/layouts/topRight.js +43 -0
- data/app/assets/javascripts/carnival/external/noty/packaged/jquery.noty.packaged.js +1180 -0
- data/app/assets/javascripts/carnival/external/noty/packaged/jquery.noty.packaged.min.js +1 -0
- data/app/assets/javascripts/carnival/external/noty/promise.js +432 -0
- data/app/assets/javascripts/carnival/external/{jquery.noty.theme.default.js → noty/themes/default.js} +3 -3
- data/app/assets/javascripts/carnival/vizir_admin.js +0 -30
- data/app/assets/stylesheets/carnival/admin.css +0 -1
- data/app/assets/stylesheets/carnival/jquery.noty.css +17 -104
- data/app/assets/stylesheets/carnival/main.css +31 -3
- data/app/controllers/carnival/base_admin_controller.rb +15 -4
- data/app/datatable/carnival/generic_datatable.rb +23 -11
- data/app/helpers/carnival/base_admin_helper.rb +20 -3
- data/app/inputs/admin_enum_input.rb +5 -3
- data/app/inputs/admin_relationship_select_input.rb +17 -5
- data/app/models/carnival/admin_user.rb +2 -1
- data/app/models/carnival/field.rb +37 -1
- data/app/models/carnival/field.rb.orig +157 -0
- data/app/models/carnival/model_helper.rb +19 -3
- data/app/presenters/carnival/base_admin_presenter.rb +38 -6
- data/app/view_objects/carnival/nested_form_options.rb +135 -0
- data/app/views/carnival/base_admin/edit.html.haml +1 -1
- data/app/views/carnival/base_admin/index.html.haml +3 -3
- data/app/views/carnival/base_admin/load_dependent_select_options.html.haml +5 -0
- data/app/views/carnival/base_admin/new.html.haml +1 -1
- data/app/views/carnival/base_admin/show.html.haml +5 -2
- data/app/views/carnival/shared/_item_buttons.html.haml +1 -1
- data/app/views/carnival/shared/form/_field.html.haml +9 -1
- data/app/views/carnival/shared/form/_field.html.haml.orig +29 -0
- data/app/views/carnival/shared/form/_form.html.haml +64 -3
- data/app/views/carnival/shared/form/_inner_form.html.haml +1 -35
- data/app/views/carnival/shared/form/_nested_form.html.haml +20 -0
- data/app/views/carnival/shared/form/_nested_form_options.html.haml +29 -0
- data/app/views/carnival/shared/show/_show_as_list.html.haml +4 -0
- data/app/views/layouts/carnival/_menu.html.haml +6 -5
- data/config/locales/carnival.pt-br.yml +10 -6
- data/lib/carnival.rb +4 -0
- data/lib/carnival/config.rb +3 -1
- data/lib/carnival/routes.rb +2 -1
- data/lib/carnival/version.rb +1 -1
- data/lib/carnival/version.rb.orig +7 -0
- data/lib/generators/carnival/templates/carnival_initializer.rb +59 -48
- data/test/dummy/app/controllers/admin/people_controller.rb +1 -1
- data/test/dummy/app/controllers/admin/states_controller.rb +1 -1
- data/test/dummy/app/models/admin/city.rb +1 -0
- data/test/dummy/app/models/admin/state.rb +1 -0
- data/test/dummy/app/presenters/admin/person_presenter.rb +4 -2
- data/test/dummy/app/presenters/admin/state_presenter.rb +15 -5
- data/test/dummy/config/initializers/carnival_initializer.rb +7 -2
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/seeds.rb +15 -1
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/bullet.log +366 -1094
- data/test/dummy/log/development.log +20675 -53911
- data/test/dummy/log/test.log +785 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/01c1d1cbb942f60130f0aa01d50c98d2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/02b691bcf7570e21acab45d320ac92cf +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/049c6f2079e2e93f96fd228df8c265ba +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0d9971c4a3b5017a7d2122508b66bb12 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/0f7b5da581fb3730800607447951008a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{07e2c1c7f749a9d38b1649aec1d98730 → 1205c92fa474a4de8d08f2774c450103} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/141987f5d019e60604cd75d2e340942f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/147e4215ac96fd8b8d373567ae00ed47 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/1634e1287a9914e738e710919b7cd6e4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/16c6027bc506317d8266573d0ae1b510 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/16e4094498947b5f36bfbb490b94d025 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2109e2acf993625dc0a3f05e7e0af523 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/21e89993e0f6f1b465e0de70e76b77f3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2684dad966b304ec2aee0149dc77c657 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2908a36318747c72030e94441a2579c4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{d3b5d5784361e5eb827fbcdb0332258f → 2a85e7b776e55125671b84c4ed5a9f56} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/30c8c2e6ca355103a267133f6b45b0ce +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/31177aaa32db75be241353c5819450b4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/31a6581dfe5a788b2b450403959a97c5 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/32daf8a3bfd9da8ab261f5002f66389f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/33dfbc7bdde795abfd1031ceaa315dc8 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{197f549b9c46ec6679bddac8e4065948 → 36ac7d3c94b129447c85c4abea55a674} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/39d34c0caaa6f36d684fac1898a7f88f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3a2fdd82041ab4b5ce8a082ec9b270fb +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{aaf9dac7bb02577a8005e39ca9225482 → 3aa40071fc24bbafb6d0d4d36b91be70} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3ac0f4fad0d3e6d3d13d4ed2189dcabe +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3d8100b6e405407290dcf994ef05e0b7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3f89739d959e11df6c20fa6ea13c1044 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/3fd8a2a00bb4ebd69a3ecac257dbe536 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4423cb4765f66f187ffcb3be911c3600 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/44dd8eb9e41f4103d9f40dfd6b4ae2ae +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/45b86c586ed942b09cec2190b3c45c5a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/47ce692a80d5b075614c2489d7e3a142 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/499338aa610d84045d1a0f081960c6fc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4a7a4dcd9fea9bd2e287771c51f96631 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4bd7e9214a07840040d269fdbf523e97 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4c36f4196d9df171251bea6f3b587fe3 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/4e4b1f24c5e69f2f305f6d6483a1605c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5090d7ea741c7f63994eb7b62e757f8f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/536648929c703c8c5e964b502b2095ff +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{b632a78e3341b622d2afbcb5312f9da0 → 55d16ecf7bea794f8130ad57090cf849} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/565023fdd3960225e817ec043b2d9474 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/577f4d9c0b4703cbfffd7159a232e60e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5a4d2d875f1d8ab987ab653f896d1c39 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5b0d5ead11b1996d8c04250256d5f1d4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5c8a4c90b3525681a2173b93b9d55293 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5e7998a2046d512312e432aef40d3e22 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5eacf8d05b2a79f57d54ee047a51e223 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/5ff6c7a42ff7a4d062640d9211b42275 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/604d964a22a33e7a1dc917eb10328fb6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/611bcab6d1ba6d887fc27c1b9f6f2ac4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6808736d34ec24fb10203097ff009a4d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6b57b684590d7c01cfa80052144dd2df +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6c257cb7126b2e5bda4c42d414e39786 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6ce5945ed85a31ec875a9973b5a3d3bc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6d806eaa317f200bbf2832a0abf1c1cc +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/6e6e4eaedc6398f0557ca2fe922c970d +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/706dcf8ec253808fea35ae06a4b408b1 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{3636240cbc1f10d05a7e27f44c330bf9 → 7a5d26a333ef57f4cb3f6148d201aabd} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7cfe3fa955d677396ed9e22193559a64 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7e154ca951644e8aa1a2c6221f08db4f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/822d6436044fe88b0b3fbc6f3458ff88 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8576d7c22dbd8222ab27a6c47f56a65c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/88144c375f9e329812d0302be96e0eab +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8a4b32386b5d8554473df478badd6ef9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/8bc60f31f479cd0263d897aa45b88750 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{5d4c2ae09c50a0b53500e334aa699c8a → 8bee3d374e40eec902852521ab7bb59e} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/918ab452d9c4634682ff94ffbd89e16f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9406ab6f0dd16a8cd5802c3c74df86ce +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9455de99a5c68705427bbec9e50865ce +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/958dd41e5252627471b2b65116401512 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9658141bfa282274f1da9155c32ae206 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/996ac001c901711cabb64b7e1940c54a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9aec27b5fa2afdfa28068452ece0e6f0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9db7e75f3fa621ef08ade7ffda96e39f +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/9dc853d92b5d774afadacc451965059c +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a125dd8e84a82fc90705bd3710fb93c2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a1c5386d742fb4d01bea977ed28f4a96 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a2ea0bd40e08492898f032af3756ebf9 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a30288f737d428b0feb2a78b3aab9c69 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a40d723f9a6ad5b541009b8f05ce6533 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/a908448dd851cae431aa2b4bde9b5a98 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/aa5708f6fbe7528d49c127a7f89a2511 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ad7b50123ad008ac0730bbbdf76a6bfe +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/b271e3537645a42480b3ba7bca2342f4 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{662125e0a3b8f685abafe02e03c6f442 → b9089c33a95ef4a20cce25cc95ce5d25} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ba891185d4fda83f4c16e6bb8139359b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/bea8fc4b9fc9ae163aa3e82041be2542 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{6f6ec88ead28d25410be2a6f62ec79b1 → c5e6bcf3743cc436e9c5e728e7968918} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c72101732682999b6ca050f007fc6467 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c8927e934e7960fc7907b6fc02ea7f08 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/c980544b5828a643ecaa8e784897c2c2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ca0e1997bc6c40f955a42ee777299750 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cc2c3f8b87c5b787305412a3076058db +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{6ad4d1acfed3cffae46c712b7c08af08 → d0f105bf22b1327c9d92c8695d4eb9cd} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d16461dfcae4b782f721ebd81e4f8740 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{5dff23c7dbd41b1db43fea8c8d933e94 → d30e267e67b877123ca48b32ba67d0b3} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d81122f6f2520c8f0785425936756e20 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dbf160a6439a8d0b792ff46cf0a612f6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dc829340258cc36c0df423725df54649 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dcedf863f6acc3e1f21ec11434a77bf7 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/dd326f3f4fd1c7fd075b58d6cb623a25 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/de060f82711b4b5c465f17b140eb2a61 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e0352d0f97751491adbe6a94832772af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e1d6efce94e71965434d2dde64fd8410 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e4298973f799acdce289752c24bfddf2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e4900a6e69f874e98b87c7c7b23f7f5a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e62e56f99e228e3467663224450f0a9b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/e9c81ca91323dab8977ffd8a459cab06 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{c3f8745dd91cb1b9a0c076a692369c4a → ea4b1e470711396062a4dba82f0823e6} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/eccab0d41d08e156ccd2f36f85949356 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f035bed7351cb6f6e2bf1250125d3d4b +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f1e75c209067b23f5c0c7bf2006c43d0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f31e05a23db2e9dfc9207658cda7b799 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{3fdb709b3417757576eff80c0ec26b75 → f4428df54ac764385fa3d1c156fd8430} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f5c9348795319821f3309d4e03bb9fdb +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f631443b06d6b36e666344dbaf0b64f0 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f71bbedf97979d3cfe44077a64d3e98a +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/{8e22d55d0b7b958a3904e7428269df65 → f795ed856980e9033fa3603aa61bac8d} +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7ab949c8c6b7ef3f2b743ebd98f9f59 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fc4b3bb94f52c27dfb87395841a7cb62 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fc79e1609ba401a4408c71182ef89b3e +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fd1e0a44b82fc47f26c7adec9d918911 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/fe9a0ccc2a407c74780c85e66882e888 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/ff3b0a569330823bd5599af14ee70cc8 +0 -0
- metadata +239 -222
- data/app/assets/stylesheets/carnival/noty_theme_default.css +0 -185
- data/test/dummy/tmp/cache/assets/development/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/22e50c67b95bf23b653e7a6768d38749 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2a4d4d7ea99972ea41453ec4e6bad058 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/58ce7bbd3c0d5ae2c59e5fcd6692d8ce +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/7e60927c780355f751c11cc4581b0c51 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/84e6a879569ca7546a93558488a6ff70 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d2ea65cc83e604dee36a5316b567e3e2 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d554039ac665d1a72c5af06725134a59 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/eed84a44f4e3915a39ea98ce25dc2570 +0 -0
- data/test/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
@@ -0,0 +1,157 @@
|
|
1
|
+
module Carnival
|
2
|
+
class Field
|
3
|
+
|
4
|
+
attr_accessor :size, :column, :line, :name, :params
|
5
|
+
|
6
|
+
def initialize(name, params={})
|
7
|
+
@params = params
|
8
|
+
@name = name
|
9
|
+
set_position_by_params
|
10
|
+
end
|
11
|
+
|
12
|
+
def name
|
13
|
+
@name.to_s
|
14
|
+
end
|
15
|
+
|
16
|
+
def css_class
|
17
|
+
if @params[:css_class]
|
18
|
+
return @params[:css_class]
|
19
|
+
else
|
20
|
+
return ""
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def date_filter?
|
25
|
+
@params[:date_filter]
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_date_filter
|
29
|
+
if @params[:date_filter_default]
|
30
|
+
@params[:date_filter_default]
|
31
|
+
else
|
32
|
+
date_filter_periods.first.first
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def date_filter_periods
|
37
|
+
if @params[:date_filter_periods]
|
38
|
+
@params[:date_filter_periods]
|
39
|
+
else
|
40
|
+
{:today => ["#{Date.today}", "#{Date.today}"],
|
41
|
+
:yesterday => ["#{Date.today - 1.day}", "#{Date.today - 1.day}"],
|
42
|
+
:this_week => ["#{Date.today.beginning_of_week}", "#{Date.today.end_of_week}"],
|
43
|
+
:last_week => ["#{(Date.today - 1.week).beginning_of_week}", "#{(Date.today - 1.week).end_of_week}"],
|
44
|
+
:this_month => ["#{Date.today.beginning_of_month}", "#{Date.today.end_of_month}"],
|
45
|
+
:last_month => ["#{(Date.today - 1.month).beginning_of_month}", "#{(Date.today - 1.month).end_of_month}"],
|
46
|
+
:this_year => ["#{Date.today.beginning_of_year}", "#{Date.today.end_of_year}"],
|
47
|
+
:last_year => ["#{(Date.today - 1.year).beginning_of_year}", "#{(Date.today - 1.year).end_of_year}"]
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
def default_sortable?
|
52
|
+
@params[:sortable] && @params[:sortable].class == Hash && @params[:sortable][:default] == true
|
53
|
+
end
|
54
|
+
|
55
|
+
def default_sort_direction
|
56
|
+
if default_sortable?
|
57
|
+
if @params[:sortable][:direction]
|
58
|
+
return @params[:sortable][:direction]
|
59
|
+
end
|
60
|
+
end
|
61
|
+
return :asc
|
62
|
+
end
|
63
|
+
|
64
|
+
def depends_on
|
65
|
+
@params[:depends_on]
|
66
|
+
end
|
67
|
+
|
68
|
+
def nested_form?
|
69
|
+
@params[:nested_form]
|
70
|
+
end
|
71
|
+
|
72
|
+
def nested_form_allow_destroy?
|
73
|
+
@params[:nested_form_allow_destroy]
|
74
|
+
end
|
75
|
+
|
76
|
+
def nested_form_modes? (mode)
|
77
|
+
associate = get_associate_nested_form_mode
|
78
|
+
return true if associate.present? && mode == :associate
|
79
|
+
return @params[:nested_form_modes].include?(mode) unless @params[:nested_form_modes].nil?
|
80
|
+
return false
|
81
|
+
end
|
82
|
+
|
83
|
+
def nested_form_scope
|
84
|
+
return nil if !nested_form_modes? :associate
|
85
|
+
associate_mode = get_associate_nested_form_mode
|
86
|
+
return nil if associate_mode.is_a? Symbol
|
87
|
+
return associate_mode[:scope] if associate_mode[:scope].present?
|
88
|
+
end
|
89
|
+
|
90
|
+
def sortable?
|
91
|
+
<<<<<<< HEAD
|
92
|
+
return true if @params[:sortable].nil?
|
93
|
+
@params[:sortable]
|
94
|
+
=======
|
95
|
+
return true if @params[:sortable]
|
96
|
+
return true if @params[:sortable].class == Hash
|
97
|
+
return false
|
98
|
+
end
|
99
|
+
|
100
|
+
def sortable_params
|
101
|
+
return false if !sortable?
|
102
|
+
return @params[:sortable].to_json if @params[:sortable].class == Hash
|
103
|
+
return true
|
104
|
+
>>>>>>> master
|
105
|
+
end
|
106
|
+
|
107
|
+
def searchable?
|
108
|
+
@params[:searchable]
|
109
|
+
end
|
110
|
+
|
111
|
+
def advanced_searchable?
|
112
|
+
@params[:advanced_search]
|
113
|
+
end
|
114
|
+
|
115
|
+
def show_as_list
|
116
|
+
@params[:show_as_list]
|
117
|
+
end
|
118
|
+
|
119
|
+
def advanced_search_operator
|
120
|
+
return @params[:advanced_search][:operator] if advanced_searchable? and @params[:advanced_search][:operator].present?
|
121
|
+
:like
|
122
|
+
end
|
123
|
+
|
124
|
+
def valid_for_action?(action)
|
125
|
+
@params[:actions].include?(action)
|
126
|
+
end
|
127
|
+
|
128
|
+
def as
|
129
|
+
@params[:as]
|
130
|
+
end
|
131
|
+
|
132
|
+
def widget
|
133
|
+
@params[:widget].present? ? @params[:widget] : :input
|
134
|
+
end
|
135
|
+
|
136
|
+
private
|
137
|
+
def set_position_by_params
|
138
|
+
if @params[:position].present?
|
139
|
+
@line = @params[:position][:line]
|
140
|
+
@column = @params[:position][:column]
|
141
|
+
@size = @params[:position][:size]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
def get_associate_nested_form_mode
|
146
|
+
return nil if @params[:nested_form_modes].nil?
|
147
|
+
@params[:nested_form_modes].each do |mode|
|
148
|
+
if mode.is_a? Hash
|
149
|
+
return mode[:associate] if mode[:associate].present?
|
150
|
+
elsif mode.is_a? Symbol
|
151
|
+
return mode if mode == :associate
|
152
|
+
end
|
153
|
+
end
|
154
|
+
nil
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Carnival::ModelHelper
|
2
2
|
|
3
3
|
def to_label
|
4
|
-
self.respond_to?
|
4
|
+
self.respond_to?(:name) ? self.name : self.to_s
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.included mod
|
@@ -12,10 +12,12 @@ module Carnival::ModelHelper
|
|
12
12
|
def list_for_select(params = {})
|
13
13
|
select = []
|
14
14
|
select << ['', ''] if params[:add_empty_option]
|
15
|
+
query = all
|
16
|
+
query = query.where(params[:query]) if params[:query].present?
|
15
17
|
if params[:reverse]
|
16
|
-
select.concat
|
18
|
+
select.concat query.collect{|c|[c.to_label, c.id]}
|
17
19
|
else
|
18
|
-
select.concat
|
20
|
+
select.concat query.collect{|c|[c.id, c.to_label]}
|
19
21
|
end
|
20
22
|
select
|
21
23
|
end
|
@@ -25,5 +27,19 @@ module Carnival::ModelHelper
|
|
25
27
|
all.each {|object| list << [object.id, object.to_label] }
|
26
28
|
list
|
27
29
|
end
|
30
|
+
|
31
|
+
def get_elements_for_select(params = {})
|
32
|
+
return all if params[:carnival_scope].nil?
|
33
|
+
scopes = params[:carnival_scope][:scopes]
|
34
|
+
return all if scopes.empty?
|
35
|
+
model_object = params[:carnival_scope][:model_object]
|
36
|
+
conditions = {}
|
37
|
+
scopes.each do |scp|
|
38
|
+
value = model_object.send scp
|
39
|
+
conditions[scp] = value if !value.nil?
|
40
|
+
end
|
41
|
+
return where(conditions) if !conditions.empty?
|
42
|
+
[]
|
43
|
+
end
|
28
44
|
end
|
29
45
|
end
|
@@ -13,7 +13,10 @@ module Carnival
|
|
13
13
|
@base_query
|
14
14
|
end
|
15
15
|
|
16
|
-
|
16
|
+
def presenter_name
|
17
|
+
self.class.to_s
|
18
|
+
end
|
19
|
+
|
17
20
|
@@actions = {}
|
18
21
|
def self.action(name, params = {})
|
19
22
|
@@actions[presenter_class_name] = {} if @@actions[presenter_class_name].nil?
|
@@ -109,6 +112,10 @@ module Carnival
|
|
109
112
|
end
|
110
113
|
end
|
111
114
|
|
115
|
+
def controller_class_name
|
116
|
+
@@controller.class.name
|
117
|
+
end
|
118
|
+
|
112
119
|
def controller_name
|
113
120
|
namespace = extract_namespace
|
114
121
|
if namespace.present?
|
@@ -130,6 +137,14 @@ module Carnival
|
|
130
137
|
searchable_fields
|
131
138
|
end
|
132
139
|
|
140
|
+
def build_relation_field(field, model_object)
|
141
|
+
if is_relation_belongs_to?(field.name)
|
142
|
+
model_object.send("#{field.name}_build")
|
143
|
+
else
|
144
|
+
model_object.send(field.name).build
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
133
148
|
def must_render_field?(nested_in, field, model_object)
|
134
149
|
must_render = true
|
135
150
|
if nested_in.present?
|
@@ -198,22 +213,31 @@ module Carnival
|
|
198
213
|
end
|
199
214
|
|
200
215
|
def relation_field?(field)
|
201
|
-
model_class.reflect_on_association(field)
|
216
|
+
model_class.reflect_on_association(field.to_sym)
|
202
217
|
end
|
203
218
|
|
219
|
+
def is_relation_belongs_to?(field)
|
220
|
+
model_class.reflect_on_association(field.to_sym).macro == :belongs_to
|
221
|
+
end
|
204
222
|
|
205
223
|
def relation_label(field, record)
|
206
224
|
if relation_field?(field)
|
207
|
-
if
|
225
|
+
if is_relation_belongs_to?(field)
|
208
226
|
value = record.send(field.to_s)
|
209
227
|
return value.to_label if value.present?
|
210
228
|
else
|
211
|
-
return I18n.t("activerecord.
|
229
|
+
return I18n.t("activerecord.attributes.#{full_model_name}.#{field}")
|
212
230
|
end
|
213
231
|
end
|
214
232
|
return ""
|
215
233
|
end
|
216
234
|
|
235
|
+
def relation_model(field)
|
236
|
+
if is_relation_belongs_to?(field)
|
237
|
+
model_class.reflect_on_association(field).klass.name.constantize
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
217
241
|
def relation_path(field, record)
|
218
242
|
if relation_field?(field)
|
219
243
|
if is_namespaced? and !model_class.reflect_on_association(field).klass.name.pluralize.underscore.include?("/")
|
@@ -221,7 +245,7 @@ module Carnival
|
|
221
245
|
else
|
222
246
|
related_class = model_class.reflect_on_association(field).klass.name.pluralize.underscore
|
223
247
|
end
|
224
|
-
if
|
248
|
+
if is_relation_belongs_to?(field)
|
225
249
|
id = -1
|
226
250
|
id = record.send(model_class.reflect_on_association(field).foreign_key) if record.send(model_class.reflect_on_association(field).foreign_key).present?
|
227
251
|
params = {:controller => related_class, :action => :show, :id => id}
|
@@ -250,7 +274,15 @@ module Carnival
|
|
250
274
|
end
|
251
275
|
|
252
276
|
def presenter_to_field field, record
|
253
|
-
"#{extract_namespace}::#{field.name.singularize.classify}Presenter".constantize.send("new", :controller =>
|
277
|
+
"#{extract_namespace}::#{field.name.singularize.classify}Presenter".constantize.send("new", :controller => controller_to_field(field))
|
278
|
+
end
|
279
|
+
|
280
|
+
def controller_to_field field
|
281
|
+
"#{extract_namespace}::#{field.name.classify.pluralize}Controller".constantize.send("new")
|
282
|
+
end
|
283
|
+
|
284
|
+
def load_dependent_select_options_path
|
285
|
+
"/#{extract_namespace.downcase}/carnival-base/load_dependent_select_options"
|
254
286
|
end
|
255
287
|
|
256
288
|
protected
|
@@ -0,0 +1,135 @@
|
|
1
|
+
module Carnival
|
2
|
+
|
3
|
+
class NestedFormOptions
|
4
|
+
include Rails.application.routes.url_helpers
|
5
|
+
|
6
|
+
|
7
|
+
def initialize(model, presenter, field, items = nil)
|
8
|
+
@model = model
|
9
|
+
@presenter = presenter
|
10
|
+
@field = field
|
11
|
+
@available_options = items
|
12
|
+
@model_fields_ids = []
|
13
|
+
populate_model_items
|
14
|
+
populate_available_options if items.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def field
|
18
|
+
@field
|
19
|
+
end
|
20
|
+
|
21
|
+
def field_name
|
22
|
+
@field.name
|
23
|
+
end
|
24
|
+
|
25
|
+
def available_options
|
26
|
+
@available_options
|
27
|
+
end
|
28
|
+
|
29
|
+
def has_new_action?
|
30
|
+
@field.nested_form_modes?(:new)
|
31
|
+
end
|
32
|
+
|
33
|
+
def model_has_this_item? id
|
34
|
+
@model_fields_ids.include? id
|
35
|
+
end
|
36
|
+
|
37
|
+
def model_class_name_underscore
|
38
|
+
@model.class.name.underscore.gsub('/', '_')
|
39
|
+
end
|
40
|
+
|
41
|
+
def field_name_identifier
|
42
|
+
self.field_name.singularize.to_sym
|
43
|
+
end
|
44
|
+
|
45
|
+
def option_name
|
46
|
+
model_id = self.model_class_name_underscore
|
47
|
+
field_id = self.field_name_identifier
|
48
|
+
"#{model_id}[#{field_id}_ids][]"
|
49
|
+
end
|
50
|
+
|
51
|
+
def option_id item_option
|
52
|
+
model_id = self.model_class_name_underscore
|
53
|
+
field_id = self.field_name_identifier
|
54
|
+
"#{model_id}_#{field_id}_ids_#{item_option.id}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def option_css_class item
|
58
|
+
return "carnival-form-options-hide" if !self.model_has_this_item?(item.id)
|
59
|
+
end
|
60
|
+
|
61
|
+
def select_tag_id
|
62
|
+
"carnival-options-select-#{self.field_name_identifier}"
|
63
|
+
end
|
64
|
+
|
65
|
+
def check_box_html
|
66
|
+
|
67
|
+
end
|
68
|
+
|
69
|
+
def select_options
|
70
|
+
options = []
|
71
|
+
options << [I18n.t('nested_form.choose_an_option'), -1]
|
72
|
+
@available_options.each do |item|
|
73
|
+
props = {}
|
74
|
+
id = self.option_id(item)
|
75
|
+
props[:id] = "#{id}_select_option"
|
76
|
+
props[:disabled] = self.model_has_this_item?(item.id)
|
77
|
+
options << [item.to_label, id, props]
|
78
|
+
end
|
79
|
+
options
|
80
|
+
end
|
81
|
+
|
82
|
+
def scope_html_id
|
83
|
+
make_html_id_for scope_column_name
|
84
|
+
end
|
85
|
+
|
86
|
+
def scope_column_name
|
87
|
+
scope = @field.nested_form_scope
|
88
|
+
return nil if !@model.reflections[scope]
|
89
|
+
fkey = @model.reflections[scope].foreign_key
|
90
|
+
end
|
91
|
+
|
92
|
+
def scopeJSFunction
|
93
|
+
url = "#{@presenter.model_path(:index)}.json"
|
94
|
+
function_params = {}
|
95
|
+
function_params[:url] = url
|
96
|
+
function_params[:list_scope] = true
|
97
|
+
function_params[:model_class_name] = @model.class.name
|
98
|
+
function_params[:model_id] = @model.id
|
99
|
+
function_params[:field_name] = @field.name
|
100
|
+
function_params[:scope_name] = scope_column_name
|
101
|
+
function_params[:scope_html_id] = scope_html_id
|
102
|
+
function_params[:presenter_name] = @presenter.class.name
|
103
|
+
function_params[:controller_name] = @presenter.controller_class_name
|
104
|
+
function_params[:has_new_action] = self.has_new_action?
|
105
|
+
|
106
|
+
"getNestedFormOptions(#{function_params.to_json});"
|
107
|
+
end
|
108
|
+
|
109
|
+
def make_html_id_for(elem)
|
110
|
+
first = @model.class.name.gsub(/::/, '_').
|
111
|
+
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
112
|
+
tr("-", "_").
|
113
|
+
downcase
|
114
|
+
"#{first}_#{elem}"
|
115
|
+
end
|
116
|
+
|
117
|
+
private
|
118
|
+
|
119
|
+
def populate_model_items
|
120
|
+
list = @model.send(self.field_name)
|
121
|
+
@model_fields_ids = list.map {|i| i.id}
|
122
|
+
end
|
123
|
+
|
124
|
+
def populate_available_options
|
125
|
+
scopes = []
|
126
|
+
scopes << @field.nested_form_scope if @field.nested_form_scope.present?
|
127
|
+
carnival_scope = {carnival_scope: {scopes: scopes, model_object: @model}}
|
128
|
+
field_presenter = @presenter.presenter_to_field(@field, nil)
|
129
|
+
model_class = field_presenter.model_class
|
130
|
+
@available_options = model_class.get_elements_for_select(carnival_scope)
|
131
|
+
end
|
132
|
+
|
133
|
+
end
|
134
|
+
|
135
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
- index_path = caminho_modelo(:index)
|
2
2
|
.gray_border.with_margin_bottom
|
3
|
-
%h1= t("#{@model_presenter.model_name}.
|
3
|
+
%h1= t("#{@model_presenter.model_name}.edit", default: t('carnival.edit'))
|
4
4
|
.action_back
|
5
5
|
= link_to t('back'), index_path, class: 'back_link'
|
6
6
|
= render '/carnival/shared/form/form', button: t('update'), model_object: @model, model_presenter: @model_presenter, :url => @model_presenter.model_path(:show, :id => @model.id), :action => :edit
|
@@ -23,19 +23,19 @@
|
|
23
23
|
= render '/carnival/shared/scope', :params => params, presenter: presenter
|
24
24
|
.actions
|
25
25
|
- presenter.actions_for_page.each do |key, action|
|
26
|
-
= render '/carnival/shared/action_default', :label=>t("#{presenter.model_name}.#{action.name}"), :path=> action.path
|
26
|
+
= render '/carnival/shared/action_default', :label=>t("#{presenter.model_name}.#{action.name}", default: t("carnival.#{action.name}")), :path=> action.path
|
27
27
|
= render '/carnival/shared/period_filter', :params => params, presenter: presenter
|
28
28
|
|
29
29
|
%table{params}
|
30
30
|
%thead
|
31
31
|
%tr
|
32
32
|
-presenter.fields_for_action(:index).each do |key, field|
|
33
|
-
%th{"data-sortable" => "#{field.
|
33
|
+
%th{"data-sortable" => "#{field.sortable_params}"}= t("activerecord.attributes.#{presenter.full_model_name}.#{field.name}")
|
34
34
|
%th.buttons
|
35
35
|
%tbody
|
36
36
|
|
37
37
|
.table-tools.table-download-links
|
38
|
-
= link_to t('download_as_csv'), "javascript:exportTable('csv');"
|
38
|
+
= link_to t('download_as_csv'), "javascript:exportTable('csv');" if presenter.has_action?(:csv)
|
39
39
|
= link_to t('download_as_pdf'), presenter.model_path(:index, {:format => 'pdf'}) if presenter.has_action?(:pdf)
|
40
40
|
:javascript
|
41
41
|
function exportTable(format){
|