solidus_admin 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/LICENSE +23 -4
- data/README.md +6 -1
- data/Rakefile +15 -15
- data/app/assets/builds/solidus_admin/tailwind.css +722 -45
- data/app/assets/images/solidus_admin/remixicon.license.txt +196 -0
- data/app/assets/images/solidus_admin/remixicon.symbol.svg +4 -4
- data/app/blueprints/solidus_admin/state_blueprint.rb +13 -0
- data/app/components/concerns/solidus_admin/slotable_default.rb +42 -0
- data/app/components/solidus_admin/adjustment_reasons/edit/component.html.erb +6 -15
- data/app/components/solidus_admin/adjustment_reasons/edit/component.yml +0 -1
- data/app/components/solidus_admin/adjustment_reasons/index/component.rb +13 -13
- data/app/components/solidus_admin/adjustment_reasons/new/component.html.erb +6 -15
- data/app/components/solidus_admin/adjustment_reasons/new/component.yml +0 -1
- data/app/components/solidus_admin/base_component.rb +7 -3
- data/app/components/solidus_admin/layout/confirm/component.html.erb +18 -0
- data/app/components/solidus_admin/layout/confirm/component.js +21 -0
- data/app/components/solidus_admin/layout/confirm/component.rb +26 -0
- data/app/components/solidus_admin/layout/confirm/component.yml +4 -0
- data/app/components/solidus_admin/layout/flashes/alerts/component.html.erb +7 -0
- data/app/components/solidus_admin/layout/flashes/alerts/component.rb +19 -0
- data/app/components/solidus_admin/layout/flashes/component.html.erb +5 -0
- data/app/components/solidus_admin/layout/flashes/component.rb +4 -0
- data/app/components/solidus_admin/layout/flashes/toasts/component.html.erb +5 -0
- data/app/components/solidus_admin/layout/flashes/toasts/component.rb +9 -0
- data/app/components/solidus_admin/layout/navigation/account/component.html.erb +12 -1
- data/app/components/solidus_admin/layout/navigation/account/component.rb +4 -4
- data/app/components/solidus_admin/layout/page_helpers.rb +3 -9
- data/app/components/solidus_admin/layout/skip_link/component.rb +3 -3
- data/app/components/solidus_admin/option_types/edit/component.html.erb +44 -0
- data/app/components/solidus_admin/option_types/edit/component.rb +5 -0
- data/app/components/solidus_admin/option_types/edit/component.yml +10 -0
- data/app/components/solidus_admin/option_types/index/component.rb +22 -22
- data/app/components/solidus_admin/option_types/new/component.html.erb +16 -0
- data/app/components/solidus_admin/option_types/new/component.rb +4 -0
- data/app/components/solidus_admin/option_types/new/component.yml +4 -0
- data/app/components/solidus_admin/option_values/edit/component.html.erb +16 -0
- data/app/components/solidus_admin/option_values/edit/component.rb +4 -0
- data/app/components/solidus_admin/option_values/edit/component.yml +4 -0
- data/app/components/solidus_admin/option_values/new/component.html.erb +16 -0
- data/app/components/solidus_admin/option_values/new/component.rb +7 -0
- data/app/components/solidus_admin/option_values/new/component.yml +4 -0
- data/app/components/solidus_admin/option_values/table/component.rb +53 -0
- data/app/components/solidus_admin/option_values/table/component.yml +3 -0
- data/app/components/solidus_admin/orders/cart/component.html.erb +5 -7
- data/app/components/solidus_admin/orders/cart/result/component.html.erb +2 -2
- data/app/components/solidus_admin/orders/index/component.rb +26 -26
- data/app/components/solidus_admin/orders/show/address/component.html.erb +8 -20
- data/app/components/solidus_admin/orders/show/address/component.rb +7 -7
- data/app/components/solidus_admin/orders/show/address/component.yml +0 -1
- data/app/components/solidus_admin/orders/show/adjustments/index/adjustable/spree_shipment/component.rb +1 -1
- data/app/components/solidus_admin/orders/show/adjustments/index/component.rb +24 -21
- data/app/components/solidus_admin/orders/show/component.html.erb +2 -2
- data/app/components/solidus_admin/orders/show/component.rb +1 -1
- data/app/components/solidus_admin/orders/show/component.yml +0 -3
- data/app/components/solidus_admin/orders/show/customer_search/result/component.html.erb +2 -2
- data/app/components/solidus_admin/orders/show/email/component.html.erb +2 -2
- data/app/components/solidus_admin/payment_methods/edit/component.html.erb +13 -0
- data/app/components/solidus_admin/payment_methods/edit/component.rb +7 -0
- data/app/components/solidus_admin/payment_methods/edit/component.yml +2 -0
- data/app/components/solidus_admin/payment_methods/form/component.html.erb +29 -0
- data/app/components/solidus_admin/payment_methods/form/component.rb +34 -0
- data/app/components/solidus_admin/payment_methods/form/component.yml +15 -0
- data/app/components/solidus_admin/payment_methods/index/component.rb +24 -23
- data/app/components/solidus_admin/payment_methods/new/component.html.erb +12 -0
- data/app/components/solidus_admin/payment_methods/new/component.rb +7 -0
- data/app/components/solidus_admin/payment_methods/new/component.yml +2 -0
- data/app/components/solidus_admin/products/index/component.rb +26 -26
- data/app/components/solidus_admin/products/show/categories/new/component.html.erb +17 -0
- data/app/components/solidus_admin/products/show/categories/new/component.rb +17 -0
- data/app/components/solidus_admin/products/show/categories/new/component.yml +5 -0
- data/app/components/solidus_admin/products/show/component.html.erb +90 -66
- data/app/components/solidus_admin/products/show/component.rb +2 -2
- data/app/components/solidus_admin/products/show/component.yml +23 -11
- data/app/components/solidus_admin/products/status/component.rb +1 -1
- data/app/components/solidus_admin/products/stock/component.rb +7 -7
- data/app/components/solidus_admin/properties/edit/component.html.erb +5 -5
- data/app/components/solidus_admin/properties/index/component.rb +13 -13
- data/app/components/solidus_admin/properties/new/component.html.erb +5 -5
- data/app/components/solidus_admin/refund_reasons/edit/component.html.erb +6 -15
- data/app/components/solidus_admin/refund_reasons/edit/component.yml +0 -1
- data/app/components/solidus_admin/refund_reasons/index/component.rb +13 -13
- data/app/components/solidus_admin/refund_reasons/new/component.html.erb +6 -14
- data/app/components/solidus_admin/refund_reasons/new/component.yml +0 -1
- data/app/components/solidus_admin/refunds_and_returns/component.rb +7 -7
- data/app/components/solidus_admin/reimbursement_types/index/component.rb +2 -2
- data/app/components/solidus_admin/return_reasons/edit/component.html.erb +5 -14
- data/app/components/solidus_admin/return_reasons/index/component.rb +11 -11
- data/app/components/solidus_admin/return_reasons/new/component.html.erb +5 -14
- data/app/components/solidus_admin/roles/edit/component.html.erb +12 -12
- data/app/components/solidus_admin/roles/edit/component.yml +0 -1
- data/app/components/solidus_admin/roles/index/component.rb +12 -12
- data/app/components/solidus_admin/roles/new/component.html.erb +12 -12
- data/app/components/solidus_admin/roles/new/component.yml +0 -1
- data/app/components/solidus_admin/shipping/component.rb +5 -5
- data/app/components/solidus_admin/shipping_categories/edit/component.html.erb +4 -4
- data/app/components/solidus_admin/shipping_categories/edit/component.yml +0 -1
- data/app/components/solidus_admin/shipping_categories/index/component.rb +9 -9
- data/app/components/solidus_admin/shipping_categories/new/component.html.erb +4 -4
- data/app/components/solidus_admin/shipping_categories/new/component.yml +0 -1
- data/app/components/solidus_admin/shipping_methods/index/component.rb +10 -10
- data/app/components/solidus_admin/stock_items/edit/component.html.erb +5 -8
- data/app/components/solidus_admin/stock_items/edit/component.rb +2 -2
- data/app/components/solidus_admin/stock_items/index/component.rb +25 -25
- data/app/components/solidus_admin/stock_locations/edit/component.html.erb +16 -0
- data/app/components/solidus_admin/stock_locations/edit/component.rb +5 -0
- data/app/components/solidus_admin/stock_locations/edit/component.yml +2 -0
- data/app/components/solidus_admin/stock_locations/form/component.html.erb +65 -0
- data/app/components/solidus_admin/stock_locations/form/component.rb +11 -0
- data/app/components/solidus_admin/stock_locations/form/component.yml +19 -0
- data/app/components/solidus_admin/stock_locations/index/component.rb +94 -47
- data/app/components/solidus_admin/stock_locations/new/component.html.erb +16 -0
- data/app/components/solidus_admin/stock_locations/new/component.rb +16 -0
- data/app/components/solidus_admin/stock_locations/new/component.yml +2 -0
- data/app/components/solidus_admin/store_credit_reasons/edit/component.html.erb +5 -14
- data/app/components/solidus_admin/store_credit_reasons/edit/component.yml +0 -1
- data/app/components/solidus_admin/store_credit_reasons/index/component.rb +11 -11
- data/app/components/solidus_admin/store_credit_reasons/new/component.html.erb +5 -14
- data/app/components/solidus_admin/store_credit_reasons/new/component.yml +0 -1
- data/app/components/solidus_admin/stores/edit/component.html.erb +27 -0
- data/app/components/solidus_admin/stores/edit/component.rb +5 -0
- data/app/components/solidus_admin/stores/form/component.html.erb +102 -0
- data/app/components/solidus_admin/stores/form/component.rb +27 -0
- data/app/components/solidus_admin/stores/form/component.yml +17 -0
- data/app/components/solidus_admin/stores/index/component.rb +51 -22
- data/app/components/solidus_admin/stores/new/component.html.erb +16 -0
- data/app/components/solidus_admin/stores/new/component.rb +5 -0
- data/app/components/solidus_admin/stores/new/component.yml +2 -0
- data/app/components/solidus_admin/tax_categories/edit/component.html.erb +7 -15
- data/app/components/solidus_admin/tax_categories/edit/component.yml +0 -1
- data/app/components/solidus_admin/tax_categories/index/component.rb +17 -17
- data/app/components/solidus_admin/tax_categories/new/component.html.erb +7 -15
- data/app/components/solidus_admin/tax_categories/new/component.yml +0 -1
- data/app/components/solidus_admin/tax_rates/edit/component.html.erb +12 -0
- data/app/components/solidus_admin/tax_rates/edit/component.rb +5 -0
- data/app/components/solidus_admin/tax_rates/edit/component.yml +4 -0
- data/app/components/solidus_admin/tax_rates/form/component.html.erb +25 -0
- data/app/components/solidus_admin/tax_rates/form/component.rb +29 -0
- data/app/components/solidus_admin/tax_rates/form/component.yml +9 -0
- data/app/components/solidus_admin/tax_rates/index/component.rb +38 -20
- data/app/components/solidus_admin/tax_rates/new/component.html.erb +12 -0
- data/app/components/solidus_admin/tax_rates/new/component.rb +5 -0
- data/app/components/solidus_admin/tax_rates/new/component.yml +4 -0
- data/app/components/solidus_admin/taxes/component.rb +4 -4
- data/app/components/solidus_admin/taxonomies/index/component.rb +7 -7
- data/app/components/solidus_admin/turbo/target_frame/component.html.erb +5 -0
- data/app/components/solidus_admin/turbo/target_frame/component.rb +8 -0
- data/app/components/solidus_admin/ui/alert/component.html.erb +35 -0
- data/app/components/solidus_admin/ui/alert/component.rb +51 -0
- data/app/components/solidus_admin/ui/alert/component.yml +8 -0
- data/app/components/solidus_admin/ui/badge/component.rb +11 -11
- data/app/components/solidus_admin/ui/button/component.rb +84 -27
- data/app/components/solidus_admin/ui/button/component.yml +10 -0
- data/app/components/solidus_admin/ui/checkbox/component.rb +42 -0
- data/app/components/solidus_admin/ui/dropdown/component.rb +3 -3
- data/app/components/solidus_admin/ui/forms/address/component.html.erb +1 -48
- data/app/components/solidus_admin/ui/forms/address/component.rb +29 -6
- data/app/components/solidus_admin/ui/forms/address/fields/city_and_zipcode/component.html.erb +4 -0
- data/app/components/solidus_admin/ui/forms/address/fields/city_and_zipcode/component.rb +8 -0
- data/app/components/solidus_admin/ui/forms/address/fields/country_and_state/component.html.erb +39 -0
- data/app/components/solidus_admin/ui/forms/address/{component.js → fields/country_and_state/component.js} +2 -0
- data/app/components/solidus_admin/ui/forms/address/fields/country_and_state/component.rb +15 -0
- data/app/components/solidus_admin/ui/forms/address/fields/reverse_charge_fields/component.html.erb +7 -0
- data/app/components/solidus_admin/ui/forms/address/fields/reverse_charge_fields/component.rb +12 -0
- data/app/components/solidus_admin/ui/forms/address/fieldsets/base.rb +54 -0
- data/app/components/solidus_admin/ui/forms/address/fieldsets/contact/component.rb +16 -0
- data/app/components/solidus_admin/ui/forms/address/fieldsets/contact_info/component.rb +10 -0
- data/app/components/solidus_admin/ui/forms/address/fieldsets/location/component.rb +14 -0
- data/app/components/solidus_admin/ui/forms/checkbox/component.html.erb +14 -0
- data/app/components/solidus_admin/ui/forms/checkbox/component.rb +24 -31
- data/app/components/solidus_admin/ui/forms/field/component.html.erb +4 -4
- data/app/components/solidus_admin/ui/forms/field/component.rb +14 -18
- data/app/components/solidus_admin/ui/forms/input/component.rb +9 -18
- data/app/components/solidus_admin/ui/forms/search/result/component.rb +2 -2
- data/app/components/solidus_admin/ui/forms/select/component.html.erb +21 -0
- data/app/components/solidus_admin/ui/forms/select/component.rb +157 -0
- data/app/components/solidus_admin/ui/forms/switch/component.rb +4 -4
- data/app/components/solidus_admin/ui/icon/component.rb +4 -4
- data/app/components/solidus_admin/ui/icon/names.txt +973 -238
- data/app/components/solidus_admin/ui/modal/component.html.erb +2 -4
- data/app/components/solidus_admin/ui/modal/component.js +7 -1
- data/app/components/solidus_admin/ui/modal/component.rb +2 -2
- data/app/components/solidus_admin/ui/pages/index/component.rb +50 -19
- data/app/components/solidus_admin/ui/panel/component.rb +5 -9
- data/app/components/solidus_admin/ui/radio/component.rb +29 -0
- data/app/components/solidus_admin/ui/tab/component.rb +4 -4
- data/app/components/solidus_admin/ui/table/component.html.erb +11 -10
- data/app/components/solidus_admin/ui/table/component.js +18 -26
- data/app/components/solidus_admin/ui/table/component.rb +24 -18
- data/app/components/solidus_admin/ui/table/component.yml +1 -0
- data/app/components/solidus_admin/ui/table/ransack_filter/component.html.erb +1 -1
- data/app/components/solidus_admin/ui/table/ransack_filter/component.rb +7 -7
- data/app/components/solidus_admin/ui/thumbnail/component.rb +5 -5
- data/app/components/solidus_admin/ui/toast/component.html.erb +6 -6
- data/app/components/solidus_admin/ui/toast/component.rb +1 -1
- data/app/components/solidus_admin/ui/toggletip/component.rb +1 -1
- data/app/components/solidus_admin/users/addresses/component.html.erb +3 -5
- data/app/components/solidus_admin/users/addresses/component.rb +0 -30
- data/app/components/solidus_admin/users/addresses/component.yml +0 -7
- data/app/components/solidus_admin/users/edit/api_access/component.html.erb +6 -4
- data/app/components/solidus_admin/users/edit/api_access/component.yml +8 -2
- data/app/components/solidus_admin/users/edit/component.html.erb +15 -12
- data/app/components/solidus_admin/users/edit/component.rb +1 -33
- data/app/components/solidus_admin/users/edit/component.yml +0 -7
- data/app/components/solidus_admin/users/edit/tabs/component.rb +46 -0
- data/app/components/solidus_admin/users/edit/tabs/component.yml +6 -0
- data/app/components/solidus_admin/users/index/component.rb +20 -20
- data/app/components/solidus_admin/users/items/component.html.erb +1 -3
- data/app/components/solidus_admin/users/items/component.rb +18 -51
- data/app/components/solidus_admin/users/items/component.yml +0 -7
- data/app/components/solidus_admin/users/orders/component.html.erb +1 -3
- data/app/components/solidus_admin/users/orders/component.rb +9 -39
- data/app/components/solidus_admin/users/orders/component.yml +0 -6
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.html.erb +7 -8
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.rb +0 -5
- data/app/components/solidus_admin/users/store_credits/edit_amount/component.yml +0 -1
- data/app/components/solidus_admin/users/store_credits/edit_memo/component.html.erb +4 -4
- data/app/components/solidus_admin/users/store_credits/edit_memo/component.yml +0 -1
- data/app/components/solidus_admin/users/store_credits/edit_validity/component.html.erb +6 -7
- data/app/components/solidus_admin/users/store_credits/edit_validity/component.rb +0 -5
- data/app/components/solidus_admin/users/store_credits/index/component.html.erb +4 -6
- data/app/components/solidus_admin/users/store_credits/index/component.rb +10 -40
- data/app/components/solidus_admin/users/store_credits/index/component.yml +0 -6
- data/app/components/solidus_admin/users/store_credits/new/component.html.erb +12 -13
- data/app/components/solidus_admin/users/store_credits/new/component.rb +0 -9
- data/app/components/solidus_admin/users/store_credits/new/component.yml +0 -1
- data/app/components/solidus_admin/users/store_credits/show/component.html.erb +5 -7
- data/app/components/solidus_admin/users/store_credits/show/component.rb +8 -38
- data/app/components/solidus_admin/users/store_credits/show/component.yml +0 -6
- data/app/components/solidus_admin/users_and_roles/component.rb +4 -4
- data/app/components/solidus_admin/zones/edit/component.html.erb +1 -0
- data/app/components/solidus_admin/zones/edit/component.rb +4 -0
- data/app/components/solidus_admin/zones/form/component.html.erb +47 -0
- data/app/components/solidus_admin/zones/form/component.js +32 -0
- data/app/components/solidus_admin/zones/form/component.rb +23 -0
- data/app/components/solidus_admin/zones/form/component.yml +7 -0
- data/app/components/solidus_admin/zones/index/component.rb +57 -18
- data/app/components/solidus_admin/zones/new/component.html.erb +1 -0
- data/app/components/solidus_admin/zones/new/component.rb +4 -0
- data/app/controllers/concerns/solidus_admin/moveable.rb +31 -0
- data/app/controllers/solidus_admin/addresses_controller.rb +9 -11
- data/app/controllers/solidus_admin/adjustments_controller.rb +5 -6
- data/app/controllers/solidus_admin/base_controller.rb +8 -7
- data/app/controllers/solidus_admin/controller_helpers/authorization.rb +1 -1
- data/app/controllers/solidus_admin/controller_helpers/locale.rb +1 -1
- data/app/controllers/solidus_admin/controller_helpers/pagination.rb +37 -0
- data/app/controllers/solidus_admin/controller_helpers/search.rb +5 -5
- data/app/controllers/solidus_admin/controller_helpers/theme.rb +2 -2
- data/app/controllers/solidus_admin/customers_controller.rb +3 -3
- data/app/controllers/solidus_admin/line_items_controller.rb +3 -3
- data/app/controllers/solidus_admin/option_types_controller.rb +11 -32
- data/app/controllers/solidus_admin/option_values_controller.rb +54 -0
- data/app/controllers/solidus_admin/orders_controller.rb +25 -19
- data/app/controllers/solidus_admin/payment_methods_controller.rb +23 -28
- data/app/controllers/solidus_admin/product_option_types_controller.rb +5 -0
- data/app/controllers/solidus_admin/product_taxons_controller.rb +58 -0
- data/app/controllers/solidus_admin/products_controller.rb +24 -28
- data/app/controllers/solidus_admin/reimbursement_types_controller.rb +3 -3
- data/app/controllers/solidus_admin/resources_controller.rb +59 -20
- data/app/controllers/solidus_admin/shipping_methods_controller.rb +4 -4
- data/app/controllers/solidus_admin/states_controller.rb +30 -0
- data/app/controllers/solidus_admin/stock_items_controller.rb +11 -6
- data/app/controllers/solidus_admin/stock_locations_controller.rb +25 -26
- data/app/controllers/solidus_admin/store_credits_controller.rb +9 -9
- data/app/controllers/solidus_admin/stores_controller.rb +43 -9
- data/app/controllers/solidus_admin/tax_rates_controller.rb +9 -22
- data/app/controllers/solidus_admin/taxonomies_controller.rb +5 -21
- data/app/controllers/solidus_admin/users_controller.rb +16 -16
- data/app/controllers/solidus_admin/zones_controller.rb +6 -26
- data/app/helpers/solidus_admin/flash_helper.rb +14 -0
- data/app/helpers/solidus_admin/last_login_helper.rb +2 -2
- data/app/helpers/solidus_admin/permission_sets_helper.rb +3 -3
- data/app/helpers/solidus_admin/solidus_form_helper.rb +9 -0
- data/app/helpers/solidus_admin/stimulus_helper.rb +29 -0
- data/app/helpers/solidus_admin/void_elements_helper.rb +1 -1
- data/app/javascript/solidus_admin/application.js +10 -1
- data/app/javascript/solidus_admin/confirm_modal.js +24 -0
- data/app/javascript/solidus_admin/controllers/custom_validity_controller.js +12 -0
- data/app/javascript/solidus_admin/controllers/sortable_controller.js +9 -2
- data/app/javascript/solidus_admin/tom-select/plugins/patch_scroll.js +19 -0
- data/app/javascript/solidus_admin/tom-select/plugins/remote_with_pagination.js +67 -0
- data/app/javascript/solidus_admin/tom-select/plugins/stash_on_search.js +68 -0
- data/app/javascript/solidus_admin/tom-select/tom-select.js +11 -0
- data/app/javascript/solidus_admin/utils.js +40 -0
- data/app/javascript/solidus_admin/web_components/solidus_select.js +90 -0
- data/app/javascript/vendor/custom_elements.js +3 -0
- data/app/lib/solidus_admin/form_builder.rb +58 -0
- data/app/views/layouts/solidus_admin/application.html.erb +6 -8
- data/app/views/layouts/solidus_admin/preview.html.erb +1 -1
- data/app/views/solidus_admin/option_values/create.turbo_stream.erb +3 -0
- data/app/views/solidus_admin/option_values/destroy.turbo_stream.erb +3 -0
- data/app/views/solidus_admin/option_values/update.turbo_stream.erb +3 -0
- data/config/importmap.rb +9 -0
- data/config/initializers/view_component.rb +1 -1
- data/config/locales/option_types.en.yml +5 -1
- data/config/locales/option_values.en.yml +9 -0
- data/config/locales/payment_methods.en.yml +5 -1
- data/config/locales/product_taxons.en.yml +6 -0
- data/config/locales/products.en.yml +2 -0
- data/config/locales/solidus_select.yml +6 -0
- data/config/locales/stock_locations.en.yml +4 -0
- data/config/locales/stores.en.yml +22 -0
- data/config/locales/tax_rates.en.yml +4 -0
- data/config/locales/zones.en.yml +4 -0
- data/config/routes.rb +21 -9
- data/config/tailwind.config.js +6 -2
- data/docs/components.md +2 -2
- data/docs/index_pages.md +11 -5
- data/docs/stimulusjs.md +1 -1
- data/eslint.config.mjs +25 -0
- data/lib/generators/solidus_admin/component/component_generator.rb +10 -6
- data/lib/generators/solidus_admin/install/install_generator.rb +24 -5
- data/lib/generators/solidus_admin/install/templates/config/initializers/solidus_admin.rb.tt +6 -0
- data/lib/solidus_admin/admin_resources.rb +1 -1
- data/lib/solidus_admin/configuration.rb +14 -14
- data/lib/solidus_admin/engine.rb +3 -2
- data/lib/solidus_admin/importmap.rb +1 -1
- data/lib/solidus_admin/menu_item.rb +1 -1
- data/lib/solidus_admin/preview.rb +1 -0
- data/lib/solidus_admin/testing_support/admin_assets.rb +1 -1
- data/lib/solidus_admin/testing_support/feature_helpers.rb +77 -3
- data/lib/solidus_admin/testing_support/shared_examples/crud_resource_requests.rb +43 -36
- data/lib/solidus_admin/testing_support/shared_examples/moveable.rb +48 -0
- data/lib/solidus_admin/testing_support/shared_examples/promotion_categories_features.rb +5 -11
- data/lib/solidus_admin/version.rb +1 -1
- data/lib/tasks/tailwind.rake +1 -1
- data/solidus_admin.gemspec +24 -21
- metadata +173 -29
- data/.eslintrc.json +0 -7
- data/app/components/solidus_admin/products/show/component.js +0 -9
- data/app/components/solidus_admin/ui/forms/input/component.js +0 -15
- data/app/components/solidus_admin/users/edit/api_access/component.js +0 -9
- data/app/javascript/solidus_admin/controllers/confirm_controller.js +0 -21
- data/lib/solidus_admin/testing_support/shared_examples/bulk_delete_resources.rb +0 -20
- /data/app/{components/solidus_admin/ui/toast/component.js → javascript/solidus_admin/controllers/alert_animation_controller.js} +0 -0
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
module SolidusAdmin
|
|
4
4
|
class ComponentGenerator < Rails::Generators::NamedBase
|
|
5
|
-
source_root File.expand_path(
|
|
5
|
+
source_root File.expand_path("templates", __dir__)
|
|
6
6
|
|
|
7
7
|
argument :attributes, type: :array, default: [], banner: "attribute"
|
|
8
8
|
|
|
@@ -12,6 +12,10 @@ module SolidusAdmin
|
|
|
12
12
|
class_option :spec, type: :boolean, default: true
|
|
13
13
|
class_option :preview, type: :boolean, default: true
|
|
14
14
|
|
|
15
|
+
def setup_namespace
|
|
16
|
+
Rails::Generators.namespace = SolidusAdmin
|
|
17
|
+
end
|
|
18
|
+
|
|
15
19
|
def setup_inflections
|
|
16
20
|
# This is needed because the generator won't run the initialization process,
|
|
17
21
|
# in order to ensure that UI is not rendered as Ui we need to setup inflections
|
|
@@ -34,7 +38,7 @@ module SolidusAdmin
|
|
|
34
38
|
if options["preview"]
|
|
35
39
|
preview_destination_path = destination("_preview.rb", root: "spec/components/previews")
|
|
36
40
|
template "component_preview.rb", preview_destination_path
|
|
37
|
-
template "component_preview_overview.html.erb", preview_destination_path.sub(
|
|
41
|
+
template "component_preview_overview.html.erb", preview_destination_path.sub(".rb", "/overview.html.erb")
|
|
38
42
|
end
|
|
39
43
|
end
|
|
40
44
|
|
|
@@ -106,8 +110,8 @@ module SolidusAdmin
|
|
|
106
110
|
end
|
|
107
111
|
|
|
108
112
|
def stimulus_html
|
|
109
|
-
%
|
|
110
|
-
%
|
|
113
|
+
%(\n <label>Your name: <input data-action="input->#{stimulus_controller_name}#typed"/></label>) +
|
|
114
|
+
%(\n <p>Hello <span data-#{stimulus_controller_name}-target="output"></span></p>)
|
|
111
115
|
end
|
|
112
116
|
|
|
113
117
|
def i18n_html
|
|
@@ -119,11 +123,11 @@ module SolidusAdmin
|
|
|
119
123
|
"<p>Add #{class_name} HTML here</p>",
|
|
120
124
|
(attributes_html if attributes.present?),
|
|
121
125
|
(stimulus_html if options["js"]),
|
|
122
|
-
(i18n_html if options["i18n"])
|
|
126
|
+
(i18n_html if options["i18n"])
|
|
123
127
|
].compact.join("\n ")
|
|
124
128
|
end
|
|
125
129
|
|
|
126
|
-
def inline_html(indent:
|
|
130
|
+
def inline_html(indent: "")
|
|
127
131
|
@inline_html.gsub!(/^/, indent).strip
|
|
128
132
|
end
|
|
129
133
|
end
|
|
@@ -3,8 +3,9 @@
|
|
|
3
3
|
module SolidusAdmin
|
|
4
4
|
module Generators
|
|
5
5
|
class InstallGenerator < Rails::Generators::Base
|
|
6
|
-
class_option :
|
|
7
|
-
class_option :
|
|
6
|
+
class_option :alpha_features, type: :boolean, default: !!ENV["SOLIDUS_ADMIN_ALPHA_FEATURES"], desc: "Enable unstable alpha features currently in development."
|
|
7
|
+
class_option :lookbook, type: :boolean, default: !!ENV["SOLIDUS_ADMIN_LOOKBOOK"], desc: "Install Lookbook for component previews"
|
|
8
|
+
class_option :tailwind, type: :boolean, default: false, desc: "Install TailwindCSS for custom components"
|
|
8
9
|
|
|
9
10
|
source_root "#{__dir__}/templates"
|
|
10
11
|
|
|
@@ -18,7 +19,9 @@ module SolidusAdmin
|
|
|
18
19
|
end
|
|
19
20
|
|
|
20
21
|
def copy_initializer
|
|
21
|
-
template
|
|
22
|
+
template "config/initializers/solidus_admin.rb.tt",
|
|
23
|
+
"config/initializers/solidus_admin.rb",
|
|
24
|
+
enable_alpha_features: options[:alpha_features]
|
|
22
25
|
end
|
|
23
26
|
|
|
24
27
|
def ignore_tailwind_build_files
|
|
@@ -38,9 +41,25 @@ module SolidusAdmin
|
|
|
38
41
|
gem "actioncable"
|
|
39
42
|
end
|
|
40
43
|
|
|
41
|
-
|
|
44
|
+
require "bundler"
|
|
45
|
+
Bundler.with_unbundled_env do
|
|
46
|
+
run "bundle install"
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
route <<~RUBY
|
|
50
|
+
if Rails.env.development?
|
|
51
|
+
lookbook_root_path = "#{solidus_mount_point}lookbook"
|
|
42
52
|
|
|
43
|
-
|
|
53
|
+
constraints ->(req) { req.env["warden"]&.user&.admin? } do
|
|
54
|
+
mount Lookbook::Engine, at: lookbook_root_path
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
get lookbook_root_path, to: redirect { |_, req|
|
|
58
|
+
req.flash[:alert] = "Lookbook is only available to admin users."
|
|
59
|
+
"#{solidus_mount_point}admin/login"
|
|
60
|
+
}
|
|
61
|
+
end
|
|
62
|
+
RUBY
|
|
44
63
|
end
|
|
45
64
|
|
|
46
65
|
private
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
SolidusAdmin::Config.configure do |config|
|
|
4
|
+
# Enable alpha features.
|
|
5
|
+
#
|
|
6
|
+
# Do this at your own risk. Alpha features are still in development. Enabling
|
|
7
|
+
# this option will likely break some admin pages and components.
|
|
8
|
+
config.enable_alpha_features = <%= config[:enable_alpha_features] %>
|
|
9
|
+
|
|
4
10
|
# Path to the logo used in the admin interface.
|
|
5
11
|
#
|
|
6
12
|
# It needs to be a path to an image file accessible by Sprockets.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require
|
|
4
|
-
require
|
|
3
|
+
require "spree/preferences/configuration"
|
|
4
|
+
require "solidus_admin/component_registry"
|
|
5
5
|
|
|
6
6
|
module SolidusAdmin
|
|
7
7
|
# Configuration for the admin interface.
|
|
@@ -23,14 +23,14 @@ module SolidusAdmin
|
|
|
23
23
|
preference :importmap_cache_sweepers, :array, default: [
|
|
24
24
|
"#{ENGINE_ROOT}/app/assets/javascripts",
|
|
25
25
|
"#{ENGINE_ROOT}/app/javascript",
|
|
26
|
-
"#{ENGINE_ROOT}/app/components"
|
|
26
|
+
"#{ENGINE_ROOT}/app/components"
|
|
27
27
|
]
|
|
28
28
|
|
|
29
29
|
# List of paths to importmap files to be loaded.
|
|
30
30
|
#
|
|
31
31
|
# @see https://github.com/rails/importmap-rails#composing-import-maps
|
|
32
32
|
preference :importmap_paths, :array, default: [
|
|
33
|
-
"#{ENGINE_ROOT}/config/importmap.rb"
|
|
33
|
+
"#{ENGINE_ROOT}/config/importmap.rb"
|
|
34
34
|
]
|
|
35
35
|
|
|
36
36
|
# @!attribute [rw] low_stock_value
|
|
@@ -46,7 +46,7 @@ module SolidusAdmin
|
|
|
46
46
|
# Default: false
|
|
47
47
|
preference :enable_alpha_features, :boolean, default: false
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
alias_method :enable_alpha_features?, :enable_alpha_features
|
|
50
50
|
|
|
51
51
|
preference :storefront_product_path_proc, :proc, default: ->(_version) {
|
|
52
52
|
->(product) { "/products/#{product.slug}" }
|
|
@@ -124,7 +124,7 @@ module SolidusAdmin
|
|
|
124
124
|
key: "settings",
|
|
125
125
|
route: -> { spree.admin_stores_path },
|
|
126
126
|
icon: "settings-line",
|
|
127
|
-
position: 60
|
|
127
|
+
position: 60
|
|
128
128
|
}
|
|
129
129
|
]
|
|
130
130
|
end
|
|
@@ -158,7 +158,7 @@ module SolidusAdmin
|
|
|
158
158
|
when /^ri-/
|
|
159
159
|
item.icon.delete_prefix("ri-")
|
|
160
160
|
when String
|
|
161
|
-
|
|
161
|
+
"record-circle-line" # fallback on a generic icon
|
|
162
162
|
end
|
|
163
163
|
|
|
164
164
|
{
|
|
@@ -167,7 +167,7 @@ module SolidusAdmin
|
|
|
167
167
|
icon:,
|
|
168
168
|
route:,
|
|
169
169
|
children: item.children.map.with_index(&menu_item_to_hash),
|
|
170
|
-
match_path
|
|
170
|
+
match_path:
|
|
171
171
|
}
|
|
172
172
|
end
|
|
173
173
|
|
|
@@ -186,7 +186,7 @@ module SolidusAdmin
|
|
|
186
186
|
preference :current_user_method, :string, default: :spree_current_user
|
|
187
187
|
|
|
188
188
|
# The path used to logout the user in the admin interface.
|
|
189
|
-
preference :logout_link_path, :string, default:
|
|
189
|
+
preference :logout_link_path, :string, default: "/admin/logout"
|
|
190
190
|
|
|
191
191
|
# The HTTP method used to logout the user in the admin interface.
|
|
192
192
|
preference :logout_link_method, :string, default: :delete
|
|
@@ -194,18 +194,18 @@ module SolidusAdmin
|
|
|
194
194
|
# @!attribute [rw] themes
|
|
195
195
|
# @return [Hash] A hash containing the themes that are available for the admin panel
|
|
196
196
|
preference :themes, :hash, default: {
|
|
197
|
-
solidus:
|
|
198
|
-
solidus_dark:
|
|
199
|
-
solidus_dimmed:
|
|
197
|
+
solidus: "solidus_admin/application",
|
|
198
|
+
solidus_dark: "solidus_admin/dark",
|
|
199
|
+
solidus_dimmed: "solidus_admin/dimmed"
|
|
200
200
|
}
|
|
201
201
|
|
|
202
202
|
# @!attribute [rw] theme
|
|
203
203
|
# @return [String] Default admin theme name
|
|
204
|
-
preference :theme, :string, default:
|
|
204
|
+
preference :theme, :string, default: "solidus"
|
|
205
205
|
|
|
206
206
|
# @!attribute [rw] dark_theme
|
|
207
207
|
# @return [String] Default admin theme name
|
|
208
|
-
preference :dark_theme, :string, default:
|
|
208
|
+
preference :dark_theme, :string, default: "solidus_dark"
|
|
209
209
|
|
|
210
210
|
def theme_path(user_theme)
|
|
211
211
|
themes.fetch(user_theme&.to_sym, themes[theme.to_sym])
|
data/lib/solidus_admin/engine.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require "stimulus-rails"
|
|
4
4
|
require "turbo-rails"
|
|
5
5
|
require "view_component"
|
|
6
|
+
require "blueprinter"
|
|
6
7
|
|
|
7
8
|
module SolidusAdmin
|
|
8
9
|
class Engine < ::Rails::Engine
|
|
@@ -28,7 +29,7 @@ module SolidusAdmin
|
|
|
28
29
|
|
|
29
30
|
initializer "solidus_admin.inflections" do
|
|
30
31
|
# Support for UI as an acronym
|
|
31
|
-
ActiveSupport::Inflector.inflections { |inflect| inflect.acronym
|
|
32
|
+
ActiveSupport::Inflector.inflections { |inflect| inflect.acronym "UI" }
|
|
32
33
|
end
|
|
33
34
|
|
|
34
35
|
initializer "solidus_admin.importmap" do
|
|
@@ -60,7 +61,7 @@ module SolidusAdmin
|
|
|
60
61
|
initializer "solidus_admin.importmap.assets" do |app|
|
|
61
62
|
app.config.assets.paths += [
|
|
62
63
|
SolidusAdmin::Engine.root.join("app/javascript"),
|
|
63
|
-
SolidusAdmin::Engine.root.join("app/components")
|
|
64
|
+
SolidusAdmin::Engine.root.join("app/components")
|
|
64
65
|
]
|
|
65
66
|
end
|
|
66
67
|
|
|
@@ -75,7 +75,7 @@ module SolidusAdmin
|
|
|
75
75
|
# @param fullpath [String] the full path of the current request
|
|
76
76
|
# @return [Boolean]
|
|
77
77
|
def current?(url_helpers, fullpath)
|
|
78
|
-
path(url_helpers) == fullpath.gsub(/\?.*$/,
|
|
78
|
+
path(url_helpers) == fullpath.gsub(/\?.*$/, "")
|
|
79
79
|
end
|
|
80
80
|
|
|
81
81
|
# Returns whether the item should be marked as active
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
RSpec.configure do |config|
|
|
4
4
|
config.when_first_matching_example_defined(solidus_admin: true) do
|
|
5
5
|
config.before(:suite) do
|
|
6
|
-
system(
|
|
6
|
+
system("bin/rails solidus_admin:tailwindcss:build") or abort "Failed to build Tailwind CSS"
|
|
7
7
|
Rails.application.precompiled_assets
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -19,15 +19,89 @@ module SolidusAdmin
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def find_row(text)
|
|
22
|
-
find(
|
|
22
|
+
find("table tbody tr td", text:)
|
|
23
23
|
end
|
|
24
24
|
|
|
25
25
|
def find_row_checkbox(text)
|
|
26
|
-
|
|
26
|
+
find("table tbody tr", text:).find('td:first-child input[type="checkbox"]')
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def select_row(text)
|
|
30
|
-
find_row_checkbox(text).
|
|
30
|
+
find_row_checkbox(text).tap do |checkbox|
|
|
31
|
+
checkbox.check
|
|
32
|
+
checkbox.synchronize { checkbox.checked? }
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def panel(title:)
|
|
37
|
+
find("section", text: title).find(:xpath, "..")
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Select options from a "solidus-select" field
|
|
41
|
+
#
|
|
42
|
+
# @param value [String, Array<String>] which option(s) to select
|
|
43
|
+
# @param from [String] label of the select box
|
|
44
|
+
def solidus_select(value, from:)
|
|
45
|
+
input = find_field(from, visible: :all)
|
|
46
|
+
control = input.ancestor(".control")
|
|
47
|
+
dropdown = control.sibling(".dropdown", visible: :all)
|
|
48
|
+
|
|
49
|
+
# Make sure options are loaded
|
|
50
|
+
control.click
|
|
51
|
+
within(dropdown) { expect(first(".option", visible: :all)).to be }
|
|
52
|
+
|
|
53
|
+
Array.wrap(value).each do |val|
|
|
54
|
+
option = dropdown.first(".option", exact_text: val, minimum: 0, wait: 0)
|
|
55
|
+
if option
|
|
56
|
+
option.click
|
|
57
|
+
else
|
|
58
|
+
input.fill_in(with: val).send_keys(:return)
|
|
59
|
+
end
|
|
60
|
+
expect(control).to have_text(val)
|
|
61
|
+
end
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def solidus_unselect(value, from:)
|
|
65
|
+
input = find_field(from, visible: :all)
|
|
66
|
+
Array.wrap(value).each do |val|
|
|
67
|
+
item = input.sibling("div", text: val)
|
|
68
|
+
item.find("a").click
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def checkbox(locator)
|
|
73
|
+
find(:checkbox, locator)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def clear_search
|
|
77
|
+
within('div[role="search"]') do
|
|
78
|
+
find('button[aria-label="Clear"]').click
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
def solidus_select_control(field)
|
|
83
|
+
find_field(field, visible: :all).ancestor(".control")
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def accept_turbo_confirm(title)
|
|
87
|
+
yield
|
|
88
|
+
dialog = find("dialog", text: title)
|
|
89
|
+
within(dialog) { find_button(id: "confirm-accept").click }
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
def switch(locator, on: true)
|
|
93
|
+
checkbox = find(:label, text: locator).find(:checkbox)
|
|
94
|
+
on ? checkbox.check : checkbox.uncheck
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
def dialog(parent: "body", **options)
|
|
98
|
+
within(parent) do
|
|
99
|
+
find("dialog", visible: :all, **options)
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
def turbo_frame_modal
|
|
104
|
+
dialog(parent: find("turbo-frame", visible: :all))
|
|
31
105
|
end
|
|
32
106
|
end
|
|
33
107
|
end
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
RSpec.shared_examples_for
|
|
3
|
+
RSpec.shared_examples_for "CRUD resource requests" do |resource_name, except: []|
|
|
4
4
|
let(:admin_user) { create(:admin_user) }
|
|
5
5
|
let(:resource) { create(factory) }
|
|
6
6
|
|
|
@@ -8,86 +8,95 @@ RSpec.shared_examples_for 'CRUD resource requests' do |resource_name|
|
|
|
8
8
|
let(:factory) { resource_name.to_sym }
|
|
9
9
|
let(:url_helpers) { solidus_admin }
|
|
10
10
|
|
|
11
|
+
let(:resources_path) { url_helpers.public_send("#{resource_name.pluralize}_path") }
|
|
12
|
+
let(:new_resource_path) { url_helpers.public_send("new_#{resource_name}_path") }
|
|
13
|
+
let(:edit_resource_path) { url_helpers.public_send("edit_#{resource_name}_path", resource) }
|
|
14
|
+
let(:resource_path) { url_helpers.public_send("#{resource_name}_path", resource) }
|
|
15
|
+
|
|
16
|
+
let(:expected_after_create_path) { resources_path }
|
|
17
|
+
let(:expected_after_update_path) { resources_path }
|
|
18
|
+
let(:expected_after_destroy_path) { resources_path }
|
|
19
|
+
|
|
11
20
|
before do
|
|
12
21
|
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(admin_user)
|
|
13
22
|
end
|
|
14
23
|
|
|
15
|
-
describe "GET /index" do
|
|
24
|
+
describe "GET /index", unless: :index.in?(except) do
|
|
16
25
|
it "renders the index template with a 200 OK status" do
|
|
17
|
-
get
|
|
26
|
+
get resources_path
|
|
18
27
|
expect(response).to have_http_status(:ok)
|
|
19
28
|
end
|
|
20
29
|
end
|
|
21
30
|
|
|
22
|
-
describe "GET /new" do
|
|
31
|
+
describe "GET /new", unless: :new.in?(except) do
|
|
23
32
|
it "renders the new template with a 200 OK status" do
|
|
24
|
-
get
|
|
33
|
+
get new_resource_path
|
|
25
34
|
expect(response).to have_http_status(:ok)
|
|
26
35
|
end
|
|
27
36
|
end
|
|
28
37
|
|
|
29
|
-
describe "POST /create" do
|
|
38
|
+
describe "POST /create", unless: :create.in?(except) do
|
|
30
39
|
context "with valid parameters" do
|
|
31
40
|
it "creates a new #{resource_name.humanize}" do
|
|
32
41
|
expect {
|
|
33
|
-
post
|
|
42
|
+
post resources_path, params: {resource_name => valid_attributes}
|
|
34
43
|
}.to change(resource_class, :count).by(1)
|
|
35
44
|
end
|
|
36
45
|
|
|
37
|
-
it "redirects
|
|
38
|
-
post
|
|
39
|
-
expect(response).to redirect_to(
|
|
46
|
+
it "redirects with a 303 See Other status" do
|
|
47
|
+
post resources_path, params: {resource_name => valid_attributes}
|
|
48
|
+
expect(response).to redirect_to(expected_after_create_path)
|
|
40
49
|
expect(response).to have_http_status(:see_other)
|
|
41
50
|
end
|
|
42
51
|
|
|
43
52
|
it "displays a success flash message" do
|
|
44
|
-
post
|
|
53
|
+
post resources_path, params: {resource_name => valid_attributes}
|
|
45
54
|
follow_redirect!
|
|
46
55
|
expect(response.body).to include("#{resource_name.humanize} was successfully created.")
|
|
47
56
|
end
|
|
48
57
|
end
|
|
49
58
|
|
|
50
59
|
context "with invalid parameters" do
|
|
51
|
-
let(:invalid_attributes) { {
|
|
60
|
+
let(:invalid_attributes) { {name: "", code: "", active: true} }
|
|
52
61
|
|
|
53
62
|
it "does not create a new #{resource_name.humanize}" do
|
|
54
63
|
expect {
|
|
55
|
-
post
|
|
64
|
+
post resources_path, params: {resource_name => invalid_attributes}
|
|
56
65
|
}.not_to change(resource_class, :count)
|
|
57
66
|
end
|
|
58
67
|
|
|
59
68
|
it "renders the new template with unprocessable_entity status" do
|
|
60
|
-
post
|
|
69
|
+
post resources_path, params: {resource_name => invalid_attributes}
|
|
61
70
|
expect(response).to have_http_status(:unprocessable_entity)
|
|
62
71
|
end
|
|
63
72
|
end
|
|
64
73
|
end
|
|
65
74
|
|
|
66
|
-
describe "GET /edit" do
|
|
75
|
+
describe "GET /edit", unless: :edit.in?(except) do
|
|
67
76
|
it "renders the edit template with a 200 OK status" do
|
|
68
|
-
get
|
|
77
|
+
get edit_resource_path
|
|
69
78
|
expect(response).to have_http_status(:ok)
|
|
70
79
|
end
|
|
71
80
|
end
|
|
72
81
|
|
|
73
|
-
describe "PATCH /update" do
|
|
82
|
+
describe "PATCH /update", unless: :update.in?(except) do
|
|
74
83
|
context "with valid parameters" do
|
|
75
84
|
it "updates the #{resource_name.humanize}" do
|
|
76
|
-
patch
|
|
85
|
+
patch resource_path, params: {resource_name => valid_attributes}
|
|
77
86
|
resource.reload
|
|
78
87
|
valid_attributes.each do |attr, value|
|
|
79
88
|
expect(resource.public_send(attr)).to eq(value)
|
|
80
89
|
end
|
|
81
90
|
end
|
|
82
91
|
|
|
83
|
-
it "redirects
|
|
84
|
-
patch
|
|
85
|
-
expect(response).to redirect_to(
|
|
92
|
+
it "redirects with a 303 See Other status" do
|
|
93
|
+
patch resource_path, params: {resource_name => valid_attributes}
|
|
94
|
+
expect(response).to redirect_to(expected_after_update_path)
|
|
86
95
|
expect(response).to have_http_status(:see_other)
|
|
87
96
|
end
|
|
88
97
|
|
|
89
98
|
it "displays a success flash message" do
|
|
90
|
-
patch
|
|
99
|
+
patch resource_path, params: {resource_name => valid_attributes}
|
|
91
100
|
follow_redirect!
|
|
92
101
|
expect(response.body).to include("#{resource_name.humanize} was successfully updated.")
|
|
93
102
|
end
|
|
@@ -96,42 +105,40 @@ RSpec.shared_examples_for 'CRUD resource requests' do |resource_name|
|
|
|
96
105
|
context "with invalid parameters" do
|
|
97
106
|
it "does not update the #{resource_name.humanize}" do
|
|
98
107
|
expect {
|
|
99
|
-
patch
|
|
108
|
+
patch resource_path, params: {resource_name => invalid_attributes}
|
|
100
109
|
}.not_to change { resource.reload }
|
|
101
110
|
end
|
|
102
111
|
|
|
103
112
|
it "renders the edit template with unprocessable_entity status" do
|
|
104
|
-
patch
|
|
113
|
+
patch resource_path, params: {resource_name => invalid_attributes}
|
|
105
114
|
expect(response).to have_http_status(:unprocessable_entity)
|
|
106
115
|
end
|
|
107
116
|
end
|
|
108
117
|
end
|
|
109
118
|
|
|
110
|
-
describe "DELETE /destroy" do
|
|
111
|
-
it "deletes the #{resource_name.humanize} and redirects
|
|
119
|
+
describe "DELETE /destroy single", unless: :destroy_single.in?(except) do
|
|
120
|
+
it "deletes the #{resource_name.humanize} and redirects with a 303 See Other status" do
|
|
112
121
|
# This ensures resource exists prior to deletion.
|
|
113
122
|
resource
|
|
114
|
-
expect {
|
|
115
|
-
delete url_helpers.public_send("#{resource_name}_path", resource)
|
|
116
|
-
}.to change(resource_class, :count).by(-1)
|
|
123
|
+
expect { delete resource_path }.to change(resource_class, :count).by(-1)
|
|
117
124
|
|
|
118
|
-
expect(response).to redirect_to(
|
|
125
|
+
expect(response).to redirect_to(expected_after_destroy_path)
|
|
119
126
|
expect(response).to have_http_status(:see_other)
|
|
120
127
|
end
|
|
121
128
|
|
|
122
129
|
it "displays a success flash message after deletion" do
|
|
123
|
-
delete
|
|
130
|
+
delete resource_path
|
|
124
131
|
follow_redirect!
|
|
125
132
|
expect(response.body).to include("#{resource_name.humanize.pluralize} were successfully removed.")
|
|
126
133
|
end
|
|
134
|
+
end
|
|
127
135
|
|
|
128
|
-
|
|
136
|
+
describe "DELETE /destroy bulk", unless: :destroy_bulk.in?(except) do
|
|
137
|
+
it "allows to bulk delete resources" do
|
|
129
138
|
ids = [create(factory), create(factory)].map(&:id)
|
|
130
|
-
expect {
|
|
131
|
-
delete url_helpers.public_send("#{resource_name.pluralize}_path", id: ids)
|
|
132
|
-
}.to change { resource_class.count }.by(-ids.size)
|
|
139
|
+
expect { delete resources_path, params: {id: ids} }.to change { resource_class.count }.by(-ids.size)
|
|
133
140
|
|
|
134
|
-
expect(response).to redirect_to(
|
|
141
|
+
expect(response).to redirect_to(expected_after_destroy_path)
|
|
135
142
|
expect(response).to have_http_status(:see_other)
|
|
136
143
|
end
|
|
137
144
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
RSpec.shared_examples_for "requests: moveable" do
|
|
4
|
+
let(:admin_user) { create(:admin_user) }
|
|
5
|
+
let(:record) { create(factory, position: 1) }
|
|
6
|
+
let(:request_path) do
|
|
7
|
+
solidus_admin.send("move_#{record.model_name.singular_route_key}_path", record, format: :js)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
before do
|
|
11
|
+
allow_any_instance_of(SolidusAdmin::BaseController).to receive(:spree_current_user).and_return(admin_user)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
describe "PATCH /move" do
|
|
15
|
+
it "updates record's position" do
|
|
16
|
+
expect { patch request_path, params: {position: 2} }.to change { record.reload.position }.from(1).to(2)
|
|
17
|
+
expect(response).to have_http_status(:no_content)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
RSpec.shared_examples_for "features: sortable" do
|
|
23
|
+
let(:factory_attrs) { {} }
|
|
24
|
+
let(:scope) { "body" }
|
|
25
|
+
let(:handle) { nil }
|
|
26
|
+
|
|
27
|
+
before do
|
|
28
|
+
create(factory, displayed_attribute => "First", :position => 1, **factory_attrs)
|
|
29
|
+
create(factory, displayed_attribute => "Second", :position => 2, **factory_attrs)
|
|
30
|
+
visit path
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
it "allows sorting via drag and drop" do
|
|
34
|
+
within(scope) do
|
|
35
|
+
expect(find("[data-controller='sortable']").all(:xpath, "./*").first).to have_text("First")
|
|
36
|
+
expect(find("[data-controller='sortable']").all(:xpath, "./*").last).to have_text("Second")
|
|
37
|
+
|
|
38
|
+
rows = find("[data-controller='sortable']").all(:xpath, "./*")
|
|
39
|
+
target = rows[0]
|
|
40
|
+
source = rows[1]
|
|
41
|
+
source = source.find(handle) if handle
|
|
42
|
+
source.drag_to target
|
|
43
|
+
|
|
44
|
+
expect(find("[data-controller='sortable']").all(:xpath, "./*").first).to have_text("Second")
|
|
45
|
+
expect(find("[data-controller='sortable']").all(:xpath, "./*").last).to have_text("First")
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
RSpec.shared_examples_for 'promotion categories features' do
|
|
3
|
+
RSpec.shared_examples_for "promotion categories features" do
|
|
6
4
|
before { sign_in create(:admin_user, email: "admin@example.com") }
|
|
7
5
|
|
|
8
|
-
it "lists promotion categories" do
|
|
6
|
+
it "lists promotion categories", :js do
|
|
9
7
|
create(factory_name, name: "test1", code: "code1")
|
|
10
8
|
create(factory_name, name: "test2", code: "code2")
|
|
11
9
|
|
|
@@ -16,7 +14,7 @@ RSpec.shared_examples_for 'promotion categories features' do
|
|
|
16
14
|
expect(page).to be_axe_clean
|
|
17
15
|
end
|
|
18
16
|
|
|
19
|
-
it
|
|
17
|
+
it "allows to create new promo category" do
|
|
20
18
|
visit index_path
|
|
21
19
|
|
|
22
20
|
click_on "Add new"
|
|
@@ -36,7 +34,7 @@ RSpec.shared_examples_for 'promotion categories features' do
|
|
|
36
34
|
expect(model_class.count).to eq(1)
|
|
37
35
|
end
|
|
38
36
|
|
|
39
|
-
it
|
|
37
|
+
it "allows to update promo category" do
|
|
40
38
|
create(factory_name, name: "Soon to expire", code: "ste.1")
|
|
41
39
|
|
|
42
40
|
visit index_path
|
|
@@ -53,7 +51,7 @@ RSpec.shared_examples_for 'promotion categories features' do
|
|
|
53
51
|
expect(page).to have_content("exp.2")
|
|
54
52
|
end
|
|
55
53
|
|
|
56
|
-
it
|
|
54
|
+
it "allows to bulk delete promo category", :js do
|
|
57
55
|
create(factory_name, name: "Soon to expire", code: "ste.1")
|
|
58
56
|
create(factory_name, name: "Expired", code: "exp.2")
|
|
59
57
|
|
|
@@ -65,8 +63,4 @@ RSpec.shared_examples_for 'promotion categories features' do
|
|
|
65
63
|
expect(page).not_to have_content("Expired")
|
|
66
64
|
expect(model_class.count).to eq(1)
|
|
67
65
|
end
|
|
68
|
-
|
|
69
|
-
include_examples 'feature: bulk delete resources' do
|
|
70
|
-
let(:resource_factory) { factory_name }
|
|
71
|
-
end
|
|
72
66
|
end
|