wallaby 5.0.1 → 5.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -3
- data/app/assets/images/wallaby/404.png +0 -0
- data/app/assets/images/wallaby/422.png +0 -0
- data/app/assets/images/wallaby/500.png +0 -0
- data/app/assets/javascripts/wallaby/application.js +1 -15
- data/app/assets/javascripts/wallaby/auto_select.js +77 -0
- data/app/assets/javascripts/wallaby/base.js +17 -0
- data/app/assets/javascripts/wallaby/setup.js.erb +60 -0
- data/app/assets/stylesheets/wallaby/application.scss +1 -51
- data/app/assets/stylesheets/wallaby/base/_layout.scss +257 -9
- data/app/assets/stylesheets/wallaby/base/_layout_desktop.scss +53 -0
- data/app/assets/stylesheets/wallaby/base/_mixins.scss +119 -0
- data/app/assets/stylesheets/wallaby/base/_override.scss +10 -0
- data/app/assets/stylesheets/wallaby/base/_vars.scss +72 -2
- data/app/assets/stylesheets/wallaby/base.scss +27 -0
- data/app/assets/stylesheets/wallaby/components/_auto_select.scss +119 -0
- data/app/assets/stylesheets/wallaby/components/_auto_select_desktop.scss +7 -0
- data/app/assets/stylesheets/wallaby/components/_color_square.scss +8 -0
- data/app/assets/stylesheets/wallaby/components/_filters.scss +14 -0
- data/app/assets/stylesheets/wallaby/components/_links.scss +25 -0
- data/app/assets/stylesheets/wallaby/components/_pagination.scss +35 -91
- data/app/assets/stylesheets/wallaby/components/_query.scss +101 -0
- data/app/assets/stylesheets/wallaby/components/_text.scss +6 -6
- data/app/assets/stylesheets/wallaby/pages/_error.scss +108 -0
- data/app/assets/stylesheets/wallaby/pages/_form.scss +40 -0
- data/app/assets/stylesheets/wallaby/pages/_index.scss +193 -0
- data/app/assets/stylesheets/wallaby/pages/_index_desktop.scss +22 -0
- data/app/assets/stylesheets/wallaby/pages/_show.scss +21 -0
- data/app/controllers/wallaby/abstract_resources_controller.rb +334 -0
- data/app/controllers/wallaby/application_controller.rb +45 -15
- data/app/controllers/wallaby/base_controller.rb +30 -0
- data/app/controllers/wallaby/resources_controller.rb +2 -131
- data/app/controllers/wallaby/secure_controller.rb +38 -24
- data/app/routes/wallaby/resources_router.rb +40 -43
- data/app/security/ability.rb +4 -28
- data/app/views/layouts/wallaby/application.html.erb +11 -6
- data/app/views/layouts/wallaby/error.html.erb +26 -4
- data/app/views/wallaby/error.html.erb +11 -0
- data/app/views/wallaby/error.json.jbuilder +8 -0
- data/app/views/wallaby/{shared → resources}/_flash_messages.html.erb +0 -0
- data/app/views/wallaby/resources/_footer.html.erb +1 -0
- data/app/views/wallaby/resources/_form.html.erb +2 -2
- data/app/views/wallaby/resources/_header.html.erb +38 -0
- data/app/views/wallaby/resources/_imodal.html.erb +13 -0
- data/app/views/wallaby/resources/_index_actions.html.erb +4 -1
- data/app/views/wallaby/resources/_index_filters.html.erb +23 -0
- data/app/views/wallaby/resources/_index_pagination.html.erb +63 -0
- data/app/views/wallaby/resources/_index_query.html.erb +23 -0
- data/app/views/wallaby/resources/_logo.html.erb +1 -0
- data/app/views/wallaby/resources/_navs.html.erb +9 -0
- data/app/views/wallaby/resources/_resource_actions.html.erb +3 -3
- data/app/views/wallaby/resources/{shared/_resource_nav.html.erb → _resource_navs.html.erb} +6 -6
- data/app/views/wallaby/resources/_title.html.erb +1 -0
- data/app/views/wallaby/resources/_user_menu.html.erb +5 -0
- data/app/views/wallaby/resources/bad_request.json.jbuilder +7 -0
- data/app/views/wallaby/resources/edit.html.erb +16 -12
- data/app/views/wallaby/resources/form/_belongs_to.html.erb +63 -12
- data/app/views/wallaby/resources/form/_bigint.html.erb +10 -1
- data/app/views/wallaby/resources/form/_bigserial.html.erb +18 -0
- data/app/views/wallaby/resources/form/_binary.html.erb +11 -2
- data/app/views/wallaby/resources/form/_bit.html.erb +10 -1
- data/app/views/wallaby/resources/form/_bit_varying.html.erb +10 -1
- data/app/views/wallaby/resources/form/_blob.html.erb +21 -0
- data/app/views/wallaby/resources/form/_boolean.html.erb +9 -0
- data/app/views/wallaby/resources/form/_box.html.erb +21 -0
- data/app/views/wallaby/resources/form/_cidr.html.erb +13 -1
- data/app/views/wallaby/resources/form/_circle.html.erb +21 -0
- data/app/views/wallaby/resources/form/_citext.html.erb +11 -2
- data/app/views/wallaby/resources/form/_color.html.erb +11 -2
- data/app/views/wallaby/resources/form/_date.html.erb +12 -3
- data/app/views/wallaby/resources/form/_daterange.html.erb +14 -5
- data/app/views/wallaby/resources/form/_datetime.html.erb +12 -3
- data/app/views/wallaby/resources/form/_decimal.html.erb +10 -1
- data/app/views/wallaby/resources/form/_dropdown.html.erb +18 -0
- data/app/views/wallaby/resources/form/_email.html.erb +9 -0
- data/app/views/wallaby/resources/form/_file.html.erb +21 -0
- data/app/views/wallaby/resources/form/_float.html.erb +10 -1
- data/app/views/wallaby/resources/form/_has_and_belongs_to_many.html.erb +53 -7
- data/app/views/wallaby/resources/form/_has_many.html.erb +52 -7
- data/app/views/wallaby/resources/form/_has_one.html.erb +10 -2
- data/app/views/wallaby/resources/form/_hstore.html.erb +12 -5
- data/app/views/wallaby/resources/form/_inet.html.erb +13 -1
- data/app/views/wallaby/resources/form/_int4range.html.erb +11 -2
- data/app/views/wallaby/resources/form/_int8range.html.erb +11 -2
- data/app/views/wallaby/resources/form/_integer.html.erb +10 -1
- data/app/views/wallaby/resources/form/_json.html.erb +13 -6
- data/app/views/wallaby/resources/form/_jsonb.html.erb +13 -6
- data/app/views/wallaby/resources/form/_line.html.erb +21 -0
- data/app/views/wallaby/resources/form/_longblob.html.erb +21 -0
- data/app/views/wallaby/resources/form/_longtext.html.erb +30 -0
- data/app/views/wallaby/resources/form/_lseg.html.erb +21 -0
- data/app/views/wallaby/resources/form/_ltree.html.erb +17 -1
- data/app/views/wallaby/resources/form/_macaddr.html.erb +13 -1
- data/app/views/wallaby/resources/form/_markdown.html.erb +29 -0
- data/app/views/wallaby/resources/form/_mediumblob.html.erb +21 -0
- data/app/views/wallaby/resources/form/_mediumtext.html.erb +30 -0
- data/app/views/wallaby/resources/form/_money.html.erb +10 -1
- data/app/views/wallaby/resources/form/_numrange.html.erb +11 -2
- data/app/views/wallaby/resources/form/_password.html.erb +14 -1
- data/app/views/wallaby/resources/form/_path.html.erb +17 -0
- data/app/views/wallaby/resources/form/_point.html.erb +11 -2
- data/app/views/wallaby/resources/form/_polygon.html.erb +17 -0
- data/app/views/wallaby/resources/form/_serial.html.erb +18 -0
- data/app/views/wallaby/resources/form/_sti.html.erb +18 -0
- data/app/views/wallaby/resources/form/_string.html.erb +14 -1
- data/app/views/wallaby/resources/form/_text.html.erb +11 -2
- data/app/views/wallaby/resources/form/_time.html.erb +12 -3
- data/app/views/wallaby/resources/form/_tinyblob.html.erb +21 -0
- data/app/views/wallaby/resources/form/_tinytext.html.erb +30 -0
- data/app/views/wallaby/resources/form/_tsrange.html.erb +14 -5
- data/app/views/wallaby/resources/form/_tstzrange.html.erb +14 -5
- data/app/views/wallaby/resources/form/_tsvector.html.erb +9 -0
- data/app/views/wallaby/resources/form/_unsigned_bigint.html.erb +18 -0
- data/app/views/wallaby/resources/form/_unsigned_decimal.html.erb +18 -0
- data/app/views/wallaby/resources/form/_unsigned_float.html.erb +18 -0
- data/app/views/wallaby/resources/form/_unsigned_integer.html.erb +18 -0
- data/app/views/wallaby/resources/form/_uuid.html.erb +10 -1
- data/app/views/wallaby/resources/form/_xml.html.erb +11 -5
- data/app/views/wallaby/resources/form.json.jbuilder +5 -0
- data/app/views/wallaby/{core → resources}/home.html.erb +1 -1
- data/app/views/wallaby/resources/index/_belongs_to.html.erb +5 -1
- data/app/views/wallaby/resources/index/_bigint.html.erb +4 -0
- data/app/views/wallaby/resources/index/_bigserial.html.erb +5 -0
- data/app/views/wallaby/resources/index/_binary.html.erb +5 -1
- data/app/views/wallaby/resources/index/_bit.html.erb +4 -0
- data/app/views/wallaby/resources/index/_bit_varying.html.erb +4 -0
- data/app/views/wallaby/resources/index/_blob.html.erb +5 -0
- data/app/views/wallaby/resources/index/_boolean.html.erb +5 -1
- data/app/views/wallaby/resources/index/_box.html.erb +16 -0
- data/app/views/wallaby/resources/index/_cidr.html.erb +5 -1
- data/app/views/wallaby/resources/index/_circle.html.erb +16 -0
- data/app/views/wallaby/resources/index/_citext.html.erb +5 -1
- data/app/views/wallaby/resources/index/_color.html.erb +6 -1
- data/app/views/wallaby/resources/index/_date.html.erb +4 -0
- data/app/views/wallaby/resources/index/_daterange.html.erb +5 -1
- data/app/views/wallaby/resources/index/_datetime.html.erb +5 -1
- data/app/views/wallaby/resources/index/_decimal.html.erb +4 -0
- data/app/views/wallaby/resources/index/_email.html.erb +4 -0
- data/app/views/wallaby/resources/index/_float.html.erb +4 -0
- data/app/views/wallaby/resources/index/_has_and_belongs_to_many.html.erb +6 -2
- data/app/views/wallaby/resources/index/_has_many.html.erb +6 -2
- data/app/views/wallaby/resources/index/_has_one.html.erb +5 -1
- data/app/views/wallaby/resources/index/_hstore.html.erb +6 -2
- data/app/views/wallaby/resources/index/_inet.html.erb +5 -1
- data/app/views/wallaby/resources/index/_int4range.html.erb +4 -0
- data/app/views/wallaby/resources/index/_int8range.html.erb +4 -0
- data/app/views/wallaby/resources/index/_integer.html.erb +4 -0
- data/app/views/wallaby/resources/index/_json.html.erb +5 -2
- data/app/views/wallaby/resources/index/_jsonb.html.erb +5 -2
- data/app/views/wallaby/resources/index/_line.html.erb +16 -0
- data/app/views/wallaby/resources/index/_longblob.html.erb +5 -0
- data/app/views/wallaby/resources/index/_longtext.html.erb +16 -0
- data/app/views/wallaby/resources/index/_lseg.html.erb +16 -0
- data/app/views/wallaby/resources/index/_ltree.html.erb +5 -1
- data/app/views/wallaby/resources/index/_macaddr.html.erb +4 -0
- data/app/views/wallaby/resources/index/_mediumblob.html.erb +5 -0
- data/app/views/wallaby/resources/index/_mediumtext.html.erb +16 -0
- data/app/views/wallaby/resources/index/_money.html.erb +4 -0
- data/app/views/wallaby/resources/index/_numrange.html.erb +4 -0
- data/app/views/wallaby/resources/index/_password.html.erb +9 -0
- data/app/views/wallaby/resources/index/_path.html.erb +16 -0
- data/app/views/wallaby/resources/index/_point.html.erb +4 -0
- data/app/views/wallaby/resources/index/_polygon.html.erb +16 -0
- data/app/views/wallaby/resources/index/_raw.html.erb +9 -0
- data/app/views/wallaby/resources/index/_serial.html.erb +5 -0
- data/app/views/wallaby/resources/index/_sti.html.erb +16 -0
- data/app/views/wallaby/resources/index/_string.html.erb +5 -1
- data/app/views/wallaby/resources/index/_text.html.erb +5 -1
- data/app/views/wallaby/resources/index/_time.html.erb +4 -0
- data/app/views/wallaby/resources/index/_tinyblob.html.erb +5 -0
- data/app/views/wallaby/resources/index/_tinytext.html.erb +16 -0
- data/app/views/wallaby/resources/index/_tsrange.html.erb +5 -1
- data/app/views/wallaby/resources/index/_tstzrange.html.erb +5 -1
- data/app/views/wallaby/resources/index/_tsvector.html.erb +5 -1
- data/app/views/wallaby/resources/index/_unsigned_bigint.html.erb +5 -0
- data/app/views/wallaby/resources/index/_unsigned_decimal.html.erb +5 -0
- data/app/views/wallaby/resources/index/_unsigned_float.html.erb +5 -0
- data/app/views/wallaby/resources/index/_unsigned_integer.html.erb +5 -0
- data/app/views/wallaby/resources/index/_uuid.html.erb +5 -1
- data/app/views/wallaby/resources/index/_xml.html.erb +5 -1
- data/app/views/wallaby/resources/index.csv.erb +26 -0
- data/app/views/wallaby/resources/index.html.erb +47 -59
- data/app/views/wallaby/resources/index.json.jbuilder +5 -0
- data/app/views/wallaby/resources/new.html.erb +12 -11
- data/app/views/wallaby/resources/show/_belongs_to.html.erb +5 -1
- data/app/views/wallaby/resources/show/_bigint.html.erb +4 -0
- data/app/views/wallaby/resources/show/_bigserial.html.erb +5 -0
- data/app/views/wallaby/resources/show/_binary.html.erb +5 -1
- data/app/views/wallaby/resources/show/_bit.html.erb +4 -0
- data/app/views/wallaby/resources/show/_bit_varying.html.erb +4 -0
- data/app/views/wallaby/resources/show/_blob.html.erb +5 -0
- data/app/views/wallaby/resources/show/_boolean.html.erb +5 -1
- data/app/views/wallaby/resources/show/_box.html.erb +9 -0
- data/app/views/wallaby/resources/show/_cidr.html.erb +5 -1
- data/app/views/wallaby/resources/show/_circle.html.erb +9 -0
- data/app/views/wallaby/resources/show/_citext.html.erb +4 -0
- data/app/views/wallaby/resources/show/_color.html.erb +6 -1
- data/app/views/wallaby/resources/show/_date.html.erb +4 -0
- data/app/views/wallaby/resources/show/_daterange.html.erb +4 -0
- data/app/views/wallaby/resources/show/_datetime.html.erb +4 -0
- data/app/views/wallaby/resources/show/_decimal.html.erb +4 -0
- data/app/views/wallaby/resources/show/_email.html.erb +4 -0
- data/app/views/wallaby/resources/show/_float.html.erb +4 -0
- data/app/views/wallaby/resources/show/_has_and_belongs_to_many.html.erb +6 -2
- data/app/views/wallaby/resources/show/_has_many.html.erb +6 -2
- data/app/views/wallaby/resources/show/_has_one.html.erb +5 -1
- data/app/views/wallaby/resources/show/_hstore.html.erb +4 -0
- data/app/views/wallaby/resources/show/_image.html.erb +9 -0
- data/app/views/wallaby/resources/show/_inet.html.erb +5 -1
- data/app/views/wallaby/resources/show/_int4range.html.erb +4 -0
- data/app/views/wallaby/resources/show/_int8range.html.erb +4 -0
- data/app/views/wallaby/resources/show/_integer.html.erb +4 -0
- data/app/views/wallaby/resources/show/_json.html.erb +4 -0
- data/app/views/wallaby/resources/show/_jsonb.html.erb +4 -0
- data/app/views/wallaby/resources/show/_line.html.erb +9 -0
- data/app/views/wallaby/resources/show/_longblob.html.erb +5 -0
- data/app/views/wallaby/resources/show/_longtext.html.erb +5 -0
- data/app/views/wallaby/resources/show/_lseg.html.erb +9 -0
- data/app/views/wallaby/resources/show/_ltree.html.erb +4 -0
- data/app/views/wallaby/resources/show/_macaddr.html.erb +4 -0
- data/app/views/wallaby/resources/show/_mediumblob.html.erb +5 -0
- data/app/views/wallaby/resources/show/_mediumtext.html.erb +5 -0
- data/app/views/wallaby/resources/show/_money.html.erb +4 -0
- data/app/views/wallaby/resources/show/_numrange.html.erb +4 -0
- data/app/views/wallaby/resources/show/_password.html.erb +9 -0
- data/app/views/wallaby/resources/show/_path.html.erb +9 -0
- data/app/views/wallaby/resources/show/_point.html.erb +4 -0
- data/app/views/wallaby/resources/show/_polygon.html.erb +9 -0
- data/app/views/wallaby/resources/show/_raw.html.erb +9 -0
- data/app/views/wallaby/resources/show/_serial.html.erb +5 -0
- data/app/views/wallaby/resources/show/_sti.html.erb +5 -0
- data/app/views/wallaby/resources/show/_string.html.erb +4 -0
- data/app/views/wallaby/resources/show/_text.html.erb +4 -0
- data/app/views/wallaby/resources/show/_time.html.erb +4 -0
- data/app/views/wallaby/resources/show/_tinyblob.html.erb +5 -0
- data/app/views/wallaby/resources/show/_tinytext.html.erb +5 -0
- data/app/views/wallaby/resources/show/_tsrange.html.erb +4 -0
- data/app/views/wallaby/resources/show/_tstzrange.html.erb +4 -0
- data/app/views/wallaby/resources/show/_tsvector.html.erb +4 -0
- data/app/views/wallaby/resources/show/_unsigned_bigint.html.erb +5 -0
- data/app/views/wallaby/resources/show/_unsigned_decimal.html.erb +5 -0
- data/app/views/wallaby/resources/show/_unsigned_float.html.erb +5 -0
- data/app/views/wallaby/resources/show/_unsigned_integer.html.erb +5 -0
- data/app/views/wallaby/resources/show/_uuid.html.erb +4 -0
- data/app/views/wallaby/resources/show/_xml.html.erb +4 -0
- data/app/views/wallaby/resources/show.html.erb +14 -24
- data/app/views/wallaby/resources/show.json.jbuilder +5 -0
- data/config/brakeman.ignore +26 -0
- data/config/locales/wallaby.en.yml +91 -0
- data/config/massa.yml +45 -0
- data/config/rails_best_practices.yml +42 -0
- data/config/routes.rb +29 -23
- data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder/association_builder.rb +39 -0
- data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder/polymorphic_builder.rb +44 -0
- data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder/sti_builder.rb +42 -0
- data/lib/adaptors/wallaby/active_record/model_decorator/fields_builder.rb +41 -94
- data/lib/adaptors/wallaby/active_record/model_decorator/title_field_finder.rb +24 -14
- data/lib/adaptors/wallaby/active_record/model_decorator.rb +118 -64
- data/lib/adaptors/wallaby/active_record/model_finder.rb +44 -15
- data/lib/adaptors/wallaby/active_record/model_pagination_provider.rb +30 -0
- data/lib/adaptors/wallaby/active_record/model_service_provider/normalizer.rb +42 -0
- data/lib/adaptors/wallaby/active_record/model_service_provider/permitter.rb +64 -0
- data/lib/adaptors/wallaby/active_record/model_service_provider/querier/transformer.rb +70 -0
- data/lib/adaptors/wallaby/active_record/model_service_provider/querier.rb +102 -0
- data/lib/adaptors/wallaby/active_record/model_service_provider/validator.rb +29 -0
- data/lib/adaptors/wallaby/active_record/model_service_provider.rb +137 -0
- data/lib/adaptors/wallaby/active_record.rb +4 -1
- data/lib/decorators/wallaby/abstract_resource_decorator.rb +74 -0
- data/lib/decorators/wallaby/resource_decorator.rb +5 -76
- data/lib/errors/wallaby/model_not_found.rb +5 -1
- data/lib/errors/wallaby/not_found.rb +4 -0
- data/lib/errors/wallaby/resource_not_found.rb +5 -1
- data/lib/forms/wallaby/form_builder.rb +42 -19
- data/lib/helpers/wallaby/application_helper.rb +34 -24
- data/lib/helpers/wallaby/base_helper.rb +52 -0
- data/lib/helpers/wallaby/form_helper.rb +40 -16
- data/lib/helpers/wallaby/index_helper.rb +59 -0
- data/lib/helpers/wallaby/links_helper.rb +150 -81
- data/lib/helpers/wallaby/resources_helper.rb +41 -46
- data/lib/helpers/wallaby/secure_helper.rb +36 -19
- data/lib/helpers/wallaby/styling_helper.rb +53 -44
- data/lib/interfaces/wallaby/mode.rb +19 -12
- data/lib/interfaces/wallaby/model_decorator.rb +176 -50
- data/lib/interfaces/wallaby/model_finder.rb +7 -3
- data/lib/interfaces/wallaby/model_pagination_provider.rb +104 -0
- data/lib/interfaces/wallaby/model_service_provider.rb +71 -0
- data/lib/paginators/wallaby/abstract_resource_paginator.rb +23 -0
- data/lib/paginators/wallaby/resource_paginator.rb +6 -0
- data/lib/parsers/wallaby/parser.rb +32 -0
- data/lib/responders/wallaby/abstract_responder.rb +68 -0
- data/lib/responders/wallaby/resources_responder.rb +6 -0
- data/lib/servicers/wallaby/abstract_model_servicer.rb +48 -0
- data/lib/servicers/wallaby/model_servicer.rb +5 -0
- data/lib/services/wallaby/link_options_normalizer.rb +16 -0
- data/lib/services/wallaby/lookup_context_wrapper.rb +23 -30
- data/lib/services/wallaby/map/mode_mapper.rb +19 -0
- data/lib/services/wallaby/map/model_class_collector.rb +41 -0
- data/lib/services/wallaby/map/model_class_mapper.rb +24 -0
- data/lib/services/wallaby/map.rb +76 -39
- data/lib/services/wallaby/partial_renderer.rb +60 -0
- data/lib/services/wallaby/prefixes_builder.rb +54 -0
- data/lib/services/wallaby/sorting/hash_builder.rb +16 -0
- data/lib/services/wallaby/sorting/link_builder.rb +45 -0
- data/lib/services/wallaby/sorting/next_builder.rb +54 -0
- data/lib/services/wallaby/url_for.rb +36 -0
- data/lib/tree/wallaby/node.rb +17 -0
- data/lib/utils/wallaby/utils.rb +67 -22
- data/lib/wallaby/configuration/features.rb +12 -0
- data/lib/wallaby/configuration/metadata.rb +12 -0
- data/lib/wallaby/configuration/models.rb +27 -12
- data/lib/wallaby/configuration/pagination.rb +12 -0
- data/lib/wallaby/configuration/security.rb +55 -24
- data/lib/wallaby/configuration.rb +38 -19
- data/lib/wallaby/engine.rb +84 -39
- data/lib/wallaby/version.rb +1 -1
- data/lib/wallaby.rb +22 -3
- metadata +200 -55
- data/app/assets/javascripts/wallaby/form.js +0 -8
- data/app/assets/stylesheets/wallaby/base/_functions.scss +0 -0
- data/app/assets/stylesheets/wallaby/base/_normalize.scss +0 -0
- data/app/assets/stylesheets/wallaby/base/_reset.scss +0 -0
- data/app/assets/stylesheets/wallaby/components/_forms.scss +0 -53
- data/app/assets/stylesheets/wallaby/components/_nav.scss +0 -19
- data/app/assets/stylesheets/wallaby/components/_tables.scss +0 -78
- data/app/assets/stylesheets/wallaby/form.scss +0 -11
- data/app/controllers/wallaby/core_controller.rb +0 -28
- data/app/views/layouts/wallaby/_footer.html.erb +0 -2
- data/app/views/layouts/wallaby/_header.html.erb +0 -57
- data/app/views/layouts/wallaby/_navs.html.erb +0 -1
- data/app/views/wallaby/errors/access_denied.html.erb +0 -1
- data/app/views/wallaby/errors/not_authenticated.html.erb +0 -1
- data/app/views/wallaby/errors/not_found.html.erb +0 -6
- data/app/views/wallaby/errors/unprocessable_entity.erb +0 -1
- data/config/locales/en.yml +0 -29
- data/lib/adaptors/wallaby/active_record/model_operator/normalizer.rb +0 -44
- data/lib/adaptors/wallaby/active_record/model_operator/permitter.rb +0 -50
- data/lib/adaptors/wallaby/active_record/model_operator/querier.rb +0 -47
- data/lib/adaptors/wallaby/active_record/model_operator/validator.rb +0 -16
- data/lib/adaptors/wallaby/active_record/model_operator.rb +0 -82
- data/lib/errors/wallaby/deprecated.rb +0 -4
- data/lib/errors/wallaby/operation_not_found.rb +0 -4
- data/lib/handlers/wallaby/cached_compiled_erb.rb +0 -14
- data/lib/helpers/wallaby/core_helper.rb +0 -50
- data/lib/helpers/wallaby/paginatable_helper.rb +0 -9
- data/lib/helpers/wallaby/sorting_helper.rb +0 -43
- data/lib/interfaces/wallaby/model_operator.rb +0 -31
- data/lib/services/wallaby/decorator_finder.rb +0 -16
- data/lib/services/wallaby/model_servicer.rb +0 -38
- data/lib/services/wallaby/servicer_finder.rb +0 -5
@@ -0,0 +1,193 @@
|
|
1
|
+
.index {
|
2
|
+
.resources__header {
|
3
|
+
> nav {
|
4
|
+
@include divider;
|
5
|
+
margin-left: 6px;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
.resources {
|
10
|
+
section {
|
11
|
+
margin-bottom: 4px;
|
12
|
+
}
|
13
|
+
|
14
|
+
&__not-found {
|
15
|
+
font-size: 24px;
|
16
|
+
padding-left: 105px;
|
17
|
+
padding-top: 140px;
|
18
|
+
position: relative;
|
19
|
+
text-align: left;
|
20
|
+
|
21
|
+
img {
|
22
|
+
height: 80px;
|
23
|
+
margin-left: -90px;
|
24
|
+
margin-top: 12px;
|
25
|
+
position: absolute;
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
&__data, &__actions {
|
30
|
+
@extend .table;
|
31
|
+
border-collapse: separate;
|
32
|
+
margin-bottom: 0;
|
33
|
+
|
34
|
+
tbody td.resource__actions {
|
35
|
+
min-width: 85px;
|
36
|
+
text-align: right;
|
37
|
+
|
38
|
+
a {
|
39
|
+
@extend .fa, .fa-info;
|
40
|
+
|
41
|
+
background-color: $light-primary-color;
|
42
|
+
border-radius: 2px;
|
43
|
+
border: none;
|
44
|
+
color: $white;
|
45
|
+
display: inline-block;
|
46
|
+
height: 16px;
|
47
|
+
line-height: 16px;
|
48
|
+
margin-right: 3px;
|
49
|
+
text-align: center;
|
50
|
+
text-decoration: none;
|
51
|
+
width: 16px;
|
52
|
+
|
53
|
+
&:hover {
|
54
|
+
background-color: $default-primary-color;
|
55
|
+
color: $white;
|
56
|
+
}
|
57
|
+
|
58
|
+
&.resource__update {
|
59
|
+
@extend .fa-pencil;
|
60
|
+
background-color: $light-yellow-color;
|
61
|
+
|
62
|
+
&:hover {
|
63
|
+
background-color: $default-yellow-color;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
&.resource__destroy {
|
68
|
+
@extend .fa-remove;
|
69
|
+
background-color: $light-red-color;
|
70
|
+
|
71
|
+
&:hover {
|
72
|
+
background-color: $default-red-color;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
&:last-child {
|
77
|
+
margin-right: 0px;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
thead tr th, tbody tr td {
|
83
|
+
background-color: white;
|
84
|
+
border: none;
|
85
|
+
border-bottom: 6px solid $background-color;
|
86
|
+
font-weight: normal;
|
87
|
+
height: 40px;
|
88
|
+
padding: 8px 12px;
|
89
|
+
white-space: nowrap;
|
90
|
+
}
|
91
|
+
|
92
|
+
thead tr th {
|
93
|
+
color: $light-grey-color;
|
94
|
+
font-weight: bold;
|
95
|
+
line-height: 20px;
|
96
|
+
position: relative;
|
97
|
+
text-transform: uppercase;
|
98
|
+
|
99
|
+
a {
|
100
|
+
border-bottom: none;
|
101
|
+
display: block;
|
102
|
+
padding-right: 11px;
|
103
|
+
position: relative;
|
104
|
+
transition: 0.5s;
|
105
|
+
|
106
|
+
&:before {
|
107
|
+
@extend .fa;
|
108
|
+
color: $light-primary-color;
|
109
|
+
margin-top: -6px;
|
110
|
+
position: absolute;
|
111
|
+
right: 0;
|
112
|
+
top: 50%;
|
113
|
+
transition: 0.5s;
|
114
|
+
}
|
115
|
+
|
116
|
+
&:hover {
|
117
|
+
color: $default-primary-color;
|
118
|
+
&:before {
|
119
|
+
color: $default-primary-color;
|
120
|
+
content: $fa-var-sort-asc;
|
121
|
+
}
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
&.asc {
|
126
|
+
a {
|
127
|
+
&:before {
|
128
|
+
content: $fa-var-sort-asc;
|
129
|
+
}
|
130
|
+
&:hover {
|
131
|
+
&:before {
|
132
|
+
content: $fa-var-sort-desc;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
}
|
136
|
+
}
|
137
|
+
|
138
|
+
&.desc {
|
139
|
+
a {
|
140
|
+
&:before {
|
141
|
+
content: $fa-var-sort-desc;
|
142
|
+
}
|
143
|
+
&:hover {
|
144
|
+
&:before {
|
145
|
+
content: $fa-var-sort;
|
146
|
+
}
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
tbody tr {
|
153
|
+
td {
|
154
|
+
a {
|
155
|
+
display: inline-block;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
}
|
159
|
+
}
|
160
|
+
|
161
|
+
&__actions {
|
162
|
+
position: absolute;
|
163
|
+
right: 0;
|
164
|
+
top: 0;
|
165
|
+
width: inherit;
|
166
|
+
|
167
|
+
thead tr th {
|
168
|
+
@extend .fa;
|
169
|
+
display: table-cell;
|
170
|
+
font-size: 14px;
|
171
|
+
|
172
|
+
&:before, &:after {
|
173
|
+
display: inline-block;
|
174
|
+
margin-top: -10px;
|
175
|
+
position: absolute;
|
176
|
+
top: 50%;
|
177
|
+
}
|
178
|
+
|
179
|
+
&.resources--forward:after {
|
180
|
+
content: $fa-var-angle-double-right;
|
181
|
+
right: 16px;
|
182
|
+
}
|
183
|
+
|
184
|
+
&.resources--backward:before {
|
185
|
+
content: $fa-var-angle-double-left;
|
186
|
+
left: 16px;
|
187
|
+
}
|
188
|
+
}
|
189
|
+
}
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
@import '_index_desktop';
|
@@ -0,0 +1,22 @@
|
|
1
|
+
@media (min-width: $screen-sm-min) {
|
2
|
+
body.index {
|
3
|
+
padding-top: 131px;
|
4
|
+
|
5
|
+
.resources__header {
|
6
|
+
padding-top: 15px;
|
7
|
+
}
|
8
|
+
|
9
|
+
.resources {
|
10
|
+
section {
|
11
|
+
margin-bottom: 24px;
|
12
|
+
}
|
13
|
+
|
14
|
+
&__not-found img {
|
15
|
+
margin-left: -95px;
|
16
|
+
margin-top: -21px;
|
17
|
+
}
|
18
|
+
}
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
|
@@ -0,0 +1,21 @@
|
|
1
|
+
.show {
|
2
|
+
section {
|
3
|
+
dl {
|
4
|
+
margin: 0;
|
5
|
+
padding: 15px 20px;
|
6
|
+
}
|
7
|
+
|
8
|
+
dt {
|
9
|
+
border-bottom: 1px solid $background-color;
|
10
|
+
color: $default-primary-color;
|
11
|
+
font-style: italic;
|
12
|
+
font-weight: bold;
|
13
|
+
padding-bottom: 8px;
|
14
|
+
text-transform: uppercase;
|
15
|
+
}
|
16
|
+
|
17
|
+
dd {
|
18
|
+
padding-top: 8px;
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,334 @@
|
|
1
|
+
module Wallaby
|
2
|
+
# Generic CRUD controller
|
3
|
+
class AbstractResourcesController < ::Wallaby::BaseController
|
4
|
+
self.responder = ResourcesResponder
|
5
|
+
respond_to :html
|
6
|
+
respond_to :json
|
7
|
+
respond_to :csv, only: :index
|
8
|
+
helper ResourcesHelper
|
9
|
+
helper_method :resource_id, :resource, :collection,
|
10
|
+
:current_model_decorator, :authorizer
|
11
|
+
|
12
|
+
# Fetch resources name from its class name
|
13
|
+
def self.resources_name
|
14
|
+
return unless self < ::Wallaby::ResourcesController
|
15
|
+
Map.resources_name_map name.gsub('Controller', EMPTY_STRING)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Find model class from its resources name
|
19
|
+
def self.model_class
|
20
|
+
return unless self < ::Wallaby::ResourcesController
|
21
|
+
Map.model_class_map resources_name
|
22
|
+
end
|
23
|
+
|
24
|
+
# home page
|
25
|
+
def home
|
26
|
+
# do nothing
|
27
|
+
end
|
28
|
+
|
29
|
+
# Index page to list data
|
30
|
+
def index
|
31
|
+
authorize! :index, current_model_class
|
32
|
+
yield if block_given? # after_index
|
33
|
+
respond_with collection
|
34
|
+
end
|
35
|
+
|
36
|
+
# Form page for creation
|
37
|
+
# You could override this method in subclasses in the following ways:
|
38
|
+
# - To perform action before `new` is run
|
39
|
+
#
|
40
|
+
# ```
|
41
|
+
# def new
|
42
|
+
# # do something beforehand
|
43
|
+
# super
|
44
|
+
# end
|
45
|
+
# ```
|
46
|
+
#
|
47
|
+
# - To perform action after `new`, but before rendering.
|
48
|
+
# The reason is that we use responder at the end of the action
|
49
|
+
#
|
50
|
+
# ```
|
51
|
+
# def new
|
52
|
+
# super do
|
53
|
+
# # do something after new
|
54
|
+
# end
|
55
|
+
# end
|
56
|
+
# ```
|
57
|
+
#
|
58
|
+
# - To perform completely different action
|
59
|
+
#
|
60
|
+
# ```
|
61
|
+
# def new
|
62
|
+
# # do something completely different
|
63
|
+
# end
|
64
|
+
# ```
|
65
|
+
def new
|
66
|
+
authorize! :new, resource
|
67
|
+
yield if block_given? # after_new
|
68
|
+
respond_with resource
|
69
|
+
end
|
70
|
+
|
71
|
+
# Data creation
|
72
|
+
# You could override this method in subclasses in the following ways:
|
73
|
+
# - To perform action before `new` is run
|
74
|
+
#
|
75
|
+
# ```
|
76
|
+
# def create
|
77
|
+
# # do something beforehand
|
78
|
+
# super
|
79
|
+
# end
|
80
|
+
# ```
|
81
|
+
#
|
82
|
+
# - To perform action after `create`, but before rendering.
|
83
|
+
# The reason is that we use responder at the end of the action
|
84
|
+
#
|
85
|
+
# ```
|
86
|
+
# def create
|
87
|
+
# super do
|
88
|
+
# # do something after create
|
89
|
+
# end
|
90
|
+
# end
|
91
|
+
# ```
|
92
|
+
#
|
93
|
+
# - To perform completely different action
|
94
|
+
#
|
95
|
+
# ```
|
96
|
+
# def create
|
97
|
+
# # do something completely different
|
98
|
+
# end
|
99
|
+
# ```
|
100
|
+
def create
|
101
|
+
authorize! :create, resource
|
102
|
+
current_model_service.create resource, params
|
103
|
+
yield if block_given? # after_create
|
104
|
+
respond_with resource, location: helpers.show_path(resource)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Show page for a single record
|
108
|
+
# You could override this method in subclasses in the following ways:
|
109
|
+
# - To perform action before `show` is run
|
110
|
+
#
|
111
|
+
# ```
|
112
|
+
# def show
|
113
|
+
# # do something beforehand
|
114
|
+
# super
|
115
|
+
# end
|
116
|
+
# ```
|
117
|
+
#
|
118
|
+
# - To perform action after `show`, but before rendering.
|
119
|
+
# The reason is that we use responder at the end of the action
|
120
|
+
#
|
121
|
+
# ```
|
122
|
+
# def show
|
123
|
+
# super do
|
124
|
+
# # do something after show
|
125
|
+
# end
|
126
|
+
# end
|
127
|
+
# ```
|
128
|
+
#
|
129
|
+
# - To perform completely different action
|
130
|
+
#
|
131
|
+
# ```
|
132
|
+
# def show
|
133
|
+
# # do something completely different
|
134
|
+
# end
|
135
|
+
# ```
|
136
|
+
def show
|
137
|
+
authorize! :show, resource
|
138
|
+
yield if block_given? # after_show
|
139
|
+
respond_with resource
|
140
|
+
end
|
141
|
+
|
142
|
+
# Edit page for a single record
|
143
|
+
# You could override this method in subclasses in the following ways:
|
144
|
+
# - To perform action before `edit` is run
|
145
|
+
#
|
146
|
+
# ```
|
147
|
+
# def edit
|
148
|
+
# # do something beforehand
|
149
|
+
# super
|
150
|
+
# end
|
151
|
+
# ```
|
152
|
+
#
|
153
|
+
# - To perform action after `edit`, but before rendering.
|
154
|
+
# The reason is that we use responder at the end of the action
|
155
|
+
#
|
156
|
+
# ```
|
157
|
+
# def edit
|
158
|
+
# super do
|
159
|
+
# # do something after edit
|
160
|
+
# end
|
161
|
+
# end
|
162
|
+
# ```
|
163
|
+
#
|
164
|
+
# - To perform completely different action
|
165
|
+
#
|
166
|
+
# ```
|
167
|
+
# def edit
|
168
|
+
# # do something completely different
|
169
|
+
# end
|
170
|
+
# ```
|
171
|
+
def edit
|
172
|
+
authorize! :edit, resource
|
173
|
+
yield if block_given? # after_edit
|
174
|
+
respond_with resource
|
175
|
+
end
|
176
|
+
|
177
|
+
# Date update
|
178
|
+
# You could override this method in subclasses in the following ways:
|
179
|
+
# - To perform action before `update` is run
|
180
|
+
#
|
181
|
+
# ```
|
182
|
+
# def update
|
183
|
+
# # do something beforehand
|
184
|
+
# super
|
185
|
+
# end
|
186
|
+
# ```
|
187
|
+
#
|
188
|
+
# - To perform action after `update`, but before rendering.
|
189
|
+
# The reason is that we use responder at the end of the action
|
190
|
+
#
|
191
|
+
# ```
|
192
|
+
# def update
|
193
|
+
# super do
|
194
|
+
# # do something after update
|
195
|
+
# end
|
196
|
+
# end
|
197
|
+
# ```
|
198
|
+
#
|
199
|
+
# - To perform completely different action
|
200
|
+
#
|
201
|
+
# ```
|
202
|
+
# def update
|
203
|
+
# # do something completely different
|
204
|
+
# end
|
205
|
+
# ```
|
206
|
+
def update
|
207
|
+
authorize! :update, resource
|
208
|
+
current_model_service.update resource, params
|
209
|
+
yield if block_given? # after_update
|
210
|
+
respond_with resource, location: helpers.show_path(resource)
|
211
|
+
end
|
212
|
+
|
213
|
+
# Data deletion
|
214
|
+
# You could override this method in subclasses in the following ways:
|
215
|
+
# - To perform action before `destroy` is run
|
216
|
+
#
|
217
|
+
# ```
|
218
|
+
# def destroy
|
219
|
+
# # do something beforehand
|
220
|
+
# super
|
221
|
+
# end
|
222
|
+
# ```
|
223
|
+
#
|
224
|
+
# - To perform action after `destroy`, but before rendering.
|
225
|
+
# The reason is that we use responder at the end of the action
|
226
|
+
#
|
227
|
+
# ```
|
228
|
+
# def destroy
|
229
|
+
# super do
|
230
|
+
# # do something after destroy
|
231
|
+
# end
|
232
|
+
# end
|
233
|
+
# ```
|
234
|
+
#
|
235
|
+
# - To perform completely different action
|
236
|
+
#
|
237
|
+
# ```
|
238
|
+
# def destroy
|
239
|
+
# # do something completely different
|
240
|
+
# end
|
241
|
+
# ```
|
242
|
+
def destroy
|
243
|
+
authorize! :destroy, resource
|
244
|
+
current_model_service.destroy resource, params
|
245
|
+
yield if block_given? # after_destroy
|
246
|
+
respond_with resource, location: helpers.index_path(current_model_class)
|
247
|
+
end
|
248
|
+
|
249
|
+
protected
|
250
|
+
|
251
|
+
# Override origin ActionView::ViewPaths::ClassMethods#_prefixes
|
252
|
+
# to add more paths so that it could look up partials in the following
|
253
|
+
# order:
|
254
|
+
# - mounted_path/resources_name/action_name (e.g. `admin/products/index)
|
255
|
+
# - mounted_path/resources_name (e.g. `admin/products)
|
256
|
+
# - full_path_of_custom_resources_controller/action_name
|
257
|
+
# (e.g. `management/custom_products/index)
|
258
|
+
# - full_path_of_custom_resources_controller
|
259
|
+
# (e.g. `management/custom_products)
|
260
|
+
# - wallaby_resources_controller_name/action_name
|
261
|
+
# (e.g. `wallaby/resources/index)
|
262
|
+
# - wallaby_resources_controller_name
|
263
|
+
# (e.g. `wallaby/resources)
|
264
|
+
def _prefixes
|
265
|
+
@_prefixes ||= PrefixesBuilder.new(
|
266
|
+
super, controller_path, current_resources_name, params
|
267
|
+
).build
|
268
|
+
end
|
269
|
+
|
270
|
+
# A wrapped lookup content
|
271
|
+
# Its aim is to render string partial when given partial is not found
|
272
|
+
def lookup_context
|
273
|
+
@_lookup_context ||= LookupContextWrapper.new super
|
274
|
+
end
|
275
|
+
|
276
|
+
# Current model service to take care of all the CRUD actions
|
277
|
+
# For how to override model service, see (Wallaby::ModelServicer)
|
278
|
+
def current_model_service
|
279
|
+
@current_model_service ||= begin
|
280
|
+
model_class = current_model_class
|
281
|
+
Map.servicer_map(model_class).new model_class, authorizer
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
# To paginate the collection but only when either `page` or `per` param is
|
286
|
+
# given, or requesting HTML response
|
287
|
+
# @see Wallaby::ModelServicer#paginate
|
288
|
+
def paginate(query)
|
289
|
+
if params[:page] || params[:per] || request.format.symbol == :html
|
290
|
+
current_model_service.paginate(query, params)
|
291
|
+
else
|
292
|
+
query
|
293
|
+
end
|
294
|
+
end
|
295
|
+
|
296
|
+
# To whitelist the params for CRUD actions
|
297
|
+
# @see Wallaby::ModelServicer#permit
|
298
|
+
def resource_params
|
299
|
+
@resource_params ||= current_model_service.permit params
|
300
|
+
end
|
301
|
+
|
302
|
+
# Shorthand of params[:id]
|
303
|
+
def resource_id
|
304
|
+
params[:id]
|
305
|
+
end
|
306
|
+
|
307
|
+
# @return [#each] a collection of all the records
|
308
|
+
def collection
|
309
|
+
@collection ||= paginate current_model_service.collection params
|
310
|
+
end
|
311
|
+
|
312
|
+
# @return either persisted or unpersisted resource instance
|
313
|
+
def resource
|
314
|
+
@resource ||=
|
315
|
+
if resource_id.present?
|
316
|
+
current_model_service.find resource_id, resource_params
|
317
|
+
else
|
318
|
+
current_model_service.new resource_params
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
# Get current model decorator so that we could retrive metadata for given
|
323
|
+
# model class.
|
324
|
+
def current_model_decorator
|
325
|
+
@current_model_decorator ||= helpers.model_decorator current_model_class
|
326
|
+
end
|
327
|
+
|
328
|
+
# A wrapper method for authorizer
|
329
|
+
# @todo to add support to pundit in the future
|
330
|
+
def authorizer
|
331
|
+
current_ability
|
332
|
+
end
|
333
|
+
end
|
334
|
+
end
|
@@ -1,21 +1,51 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
module Wallaby
|
2
|
+
# Wallaby's application controller
|
3
|
+
# It defaults to inherit from ::ApplicationController, which can be configured
|
4
|
+
# via `Wallaby.configuration.base_controller`
|
5
|
+
# It only contains the error handling logics
|
6
|
+
class ApplicationController < configuration.base_controller
|
7
|
+
helper ApplicationHelper
|
3
8
|
|
4
|
-
|
5
|
-
Wallaby::ResourceNotFound,
|
6
|
-
Wallaby::ModelNotFound,
|
7
|
-
with: :not_found
|
8
|
-
rescue_from ActionController::ParameterMissing, with: :unprocessable_entity
|
9
|
+
ERROR_PATH = ERROR_LAYOUT = 'wallaby/error'.freeze
|
9
10
|
|
10
|
-
|
11
|
+
# NOTE: we want to see the error blown up in development environment
|
12
|
+
unless Rails.env.development?
|
13
|
+
rescue_from NotFound, with: :not_found
|
14
|
+
rescue_from ::ActionController::ParameterMissing, with: :bad_request
|
15
|
+
rescue_from ::ActiveRecord::StatementInvalid, with: :unprocessable_entity
|
16
|
+
end
|
11
17
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
18
|
+
layout 'wallaby/application'
|
19
|
+
|
20
|
+
# Not found page
|
21
|
+
def not_found(exception = nil)
|
22
|
+
error_rendering(exception, __callee__)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Bad request page
|
26
|
+
def bad_request(exception = nil)
|
27
|
+
error_rendering(exception, __callee__)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Unprocessable entity page
|
31
|
+
def unprocessable_entity(exception = nil)
|
32
|
+
error_rendering(exception, __callee__)
|
33
|
+
end
|
34
|
+
|
35
|
+
protected
|
36
|
+
|
37
|
+
def configuration
|
38
|
+
::Wallaby.configuration
|
39
|
+
end
|
40
|
+
|
41
|
+
# capture exceptions and display the error using error layout and view
|
42
|
+
def error_rendering(exception, symbol)
|
43
|
+
@exception = exception
|
44
|
+
@symbol = symbol
|
45
|
+
@code = Rack::Utils::SYMBOL_TO_STATUS_CODE[@symbol].to_i
|
16
46
|
|
17
|
-
|
18
|
-
|
19
|
-
|
47
|
+
Rails.logger.error @exception
|
48
|
+
render ERROR_PATH, layout: ERROR_LAYOUT, status: symbol
|
49
|
+
end
|
20
50
|
end
|
21
51
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Wallaby
|
2
|
+
# Base controller to provide basic helper methods for sub classes
|
3
|
+
class BaseController < ::Wallaby::SecureController
|
4
|
+
helper BaseHelper
|
5
|
+
helper_method \
|
6
|
+
:current_resources_name,
|
7
|
+
:current_model_class
|
8
|
+
|
9
|
+
before_action :authenticate_user!, except: [:status]
|
10
|
+
|
11
|
+
# health check
|
12
|
+
def healthy
|
13
|
+
render plain: 'healthy'
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
# @return [String] the resources name coming from params
|
19
|
+
def current_resources_name
|
20
|
+
@current_resources_name ||= params[:resources]
|
21
|
+
end
|
22
|
+
|
23
|
+
# @return [Class] the model class that links to the resources name
|
24
|
+
def current_model_class
|
25
|
+
@current_model_class ||=
|
26
|
+
self.class.respond_to?(:model_class) && self.class.model_class \
|
27
|
+
|| Map.model_class_map(current_resources_name)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|