spree_backend 4.2.4 → 4.3.0.rc3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/app/assets/config/spree_backend_manifest.js +129 -0
- data/app/assets/images/backend-arrows-fullscreen.svg +3 -0
- data/app/assets/images/backend-box.svg +3 -0
- data/app/assets/images/backend-circle-fill.svg +3 -0
- data/app/assets/images/backend-circle.svg +3 -0
- data/app/assets/images/backend-default-layout.svg +6 -0
- data/app/assets/images/backend-eye-slash-fill.svg +4 -0
- data/app/assets/images/backend-file-richtext.svg +4 -0
- data/app/assets/images/backend-fullscreen-exit.svg +3 -0
- data/app/assets/images/backend-fullscreen.svg +3 -0
- data/app/assets/images/backend-mobile.svg +5 -0
- data/app/assets/images/backend-pages.svg +10 -0
- data/app/assets/images/backend-phone.svg +4 -0
- data/app/assets/images/backend-reversed-layout.svg +6 -0
- data/app/assets/images/backend-spree-icon.svg +1 -0
- data/app/assets/images/backend-spree-logo.svg +6 -0
- data/app/assets/images/backend-store.svg +2 -13
- data/app/assets/images/backend-translate.svg +4 -0
- data/app/assets/images/backend-users.svg +2 -5
- data/app/assets/images/backend-window-sidebar.svg +4 -0
- data/app/assets/images/noimage/backend-missing-image.svg +4 -0
- data/app/assets/images/noimage/large.png +0 -0
- data/app/assets/images/noimage/mini.png +0 -0
- data/app/assets/images/noimage/product.png +0 -0
- data/app/assets/images/noimage/small.png +0 -0
- data/app/assets/javascripts/spree/backend/address_states.es6 +44 -0
- data/app/assets/javascripts/spree/backend/admin.js +45 -307
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +22 -13
- data/app/assets/javascripts/spree/backend/cms/_index.es6 +4 -0
- data/app/assets/javascripts/spree/backend/cms/links.es6 +25 -0
- data/app/assets/javascripts/spree/backend/cms/live_preview.es6 +34 -0
- data/app/assets/javascripts/spree/backend/cms/page.es6 +133 -0
- data/app/assets/javascripts/spree/backend/cms/section.es6 +43 -0
- data/app/assets/javascripts/spree/backend/global/_index.js +11 -0
- data/app/assets/javascripts/spree/backend/global/alerts.es6 +66 -0
- data/app/assets/javascripts/spree/backend/global/api_functions.es6 +5 -0
- data/app/assets/javascripts/spree/backend/global/bootstrap.es6 +15 -0
- data/app/assets/javascripts/spree/backend/global/flatpickr.es6 +22 -0
- data/app/assets/javascripts/spree/backend/global/info_alert.es6 +38 -0
- data/app/assets/javascripts/spree/backend/global/radio_panel_toggle.es6 +18 -0
- data/app/assets/javascripts/spree/backend/global/ransack.es6 +108 -0
- data/app/assets/javascripts/spree/backend/global/responsive_menus.es6 +56 -0
- data/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 +156 -0
- data/app/assets/javascripts/spree/backend/global/select2_populate.es6 +61 -0
- data/app/assets/javascripts/spree/backend/global/side_scroll_indication.es6 +137 -0
- data/app/assets/javascripts/spree/backend/global/sortable.es6 +35 -0
- data/app/assets/javascripts/spree/backend/global/tinymce.es6 +11 -0
- data/app/assets/javascripts/spree/backend/menus/_index.es6 +2 -0
- data/app/assets/javascripts/spree/backend/menus/menu.es6 +57 -0
- data/app/assets/javascripts/spree/backend/menus/menu_item.es6 +26 -0
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +13 -17
- data/app/assets/javascripts/spree/backend/option_value_picker.js +10 -22
- data/app/assets/javascripts/spree/backend/payments/edit.js +1 -1
- data/app/assets/javascripts/spree/backend/payments/new.js +18 -5
- data/app/assets/javascripts/spree/backend/spree-select2.js +19 -1
- data/app/assets/javascripts/spree/backend/stock_location.js +1 -2
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +7 -1
- data/app/assets/javascripts/spree/backend/taxons.js +74 -73
- data/app/assets/javascripts/spree/backend/user_picker.js +7 -10
- data/app/assets/javascripts/spree/backend.js +28 -1
- data/app/assets/javascripts/spree.js +78 -0
- data/app/assets/stylesheets/spree/backend/components/_filters.scss +1 -3
- data/app/assets/stylesheets/spree/backend/components/_main.scss +0 -1
- data/app/assets/stylesheets/spree/backend/components/_navbar.scss +35 -0
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +13 -0
- data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +0 -1
- data/app/assets/stylesheets/spree/backend/components/_tables.scss +4 -5
- data/app/assets/stylesheets/spree/backend/global/_mixins.scss +59 -0
- data/app/assets/stylesheets/spree/backend/plugins/_nav_x.scss +95 -0
- data/app/assets/stylesheets/spree/backend/plugins/{select2_bootstrap4.scss → _select2_bootstrap4.scss} +0 -0
- data/app/assets/stylesheets/spree/backend/plugins/_sweetalert2_custom.scss +100 -0
- data/app/assets/stylesheets/spree/backend/plugins/_tinymce_custom.scss +4 -0
- data/app/assets/stylesheets/spree/backend/shared/_base.scss +75 -25
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +8 -0
- data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +5 -0
- data/app/assets/stylesheets/spree/backend/views/_cms_pages.scss +148 -0
- data/app/assets/stylesheets/spree/backend/views/_menus.scss +61 -0
- data/app/controllers/concerns/spree/admin/order_concern.rb +24 -0
- data/app/controllers/concerns/spree/admin/product_concern.rb +11 -0
- data/app/controllers/spree/admin/base_controller.rb +63 -3
- data/app/controllers/spree/admin/cms_pages_controller.rb +29 -0
- data/app/controllers/spree/admin/cms_sections_controller.rb +15 -0
- data/app/controllers/spree/admin/customer_returns_controller.rb +4 -5
- data/app/controllers/spree/admin/errors_controller.rb +11 -0
- data/app/controllers/spree/admin/general_settings_controller.rb +1 -1
- data/app/controllers/spree/admin/images_controller.rb +8 -22
- data/app/controllers/spree/admin/log_entries_controller.rb +4 -3
- data/app/controllers/spree/admin/menu_items_controller.rb +33 -0
- data/app/controllers/spree/admin/menus_controller.rb +32 -0
- data/app/controllers/spree/admin/option_types_controller.rb +1 -1
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +6 -11
- data/app/controllers/spree/admin/orders_controller.rb +23 -31
- data/app/controllers/spree/admin/payment_methods_controller.rb +17 -4
- data/app/controllers/spree/admin/payments_controller.rb +5 -10
- data/app/controllers/spree/admin/prices_controller.rb +2 -2
- data/app/controllers/spree/admin/products_controller.rb +21 -10
- data/app/controllers/spree/admin/promotion_actions_controller.rb +1 -1
- data/app/controllers/spree/admin/promotion_rules_controller.rb +1 -1
- data/app/controllers/spree/admin/promotions_controller.rb +3 -3
- data/app/controllers/spree/admin/prototypes_controller.rb +1 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +1 -1
- data/app/controllers/spree/admin/reports_controller.rb +5 -1
- data/app/controllers/spree/admin/resource_controller.rb +32 -5
- data/app/controllers/spree/admin/return_index_controller.rb +1 -1
- data/app/controllers/spree/admin/state_changes_controller.rb +2 -7
- data/app/controllers/spree/admin/stock_items_controller.rb +2 -2
- data/app/controllers/spree/admin/stock_locations_controller.rb +2 -2
- data/app/controllers/spree/admin/stock_movements_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_transfers_controller.rb +1 -1
- data/app/controllers/spree/admin/store_credits_controller.rb +13 -8
- data/app/controllers/spree/admin/stores_controller.rb +14 -17
- data/app/controllers/spree/admin/taxons_controller.rb +9 -5
- data/app/controllers/spree/admin/users_controller.rb +9 -7
- data/app/controllers/spree/admin/variants_controller.rb +16 -15
- data/app/helpers/spree/admin/base_helper.rb +52 -14
- data/app/helpers/spree/admin/cms_helper.rb +15 -0
- data/app/helpers/spree/admin/menu_helper.rb +30 -0
- data/app/helpers/spree/admin/stores_helper.rb +21 -0
- data/app/models/spree/backend_configuration.rb +2 -0
- data/app/views/spree/admin/adjustments/_adjustment.html.erb +7 -5
- data/app/views/spree/admin/cms_pages/_form.html.erb +135 -0
- data/app/views/spree/admin/cms_pages/_live_preview_area.html.erb +61 -0
- data/app/views/spree/admin/cms_pages/_section_template.html.erb +16 -0
- data/app/views/spree/admin/cms_pages/edit.html.erb +21 -0
- data/app/views/spree/admin/cms_pages/index.html.erb +84 -0
- data/app/views/spree/admin/cms_pages/new.html.erb +8 -0
- data/app/views/spree/admin/cms_sections/_form.html.erb +69 -0
- data/app/views/spree/admin/cms_sections/edit.html.erb +19 -0
- data/app/views/spree/admin/cms_sections/new.html.erb +11 -0
- data/app/views/spree/admin/cms_sections/types/_featured_article.html.erb +50 -0
- data/app/views/spree/admin/cms_sections/types/_hero_image.html.erb +62 -0
- data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +177 -0
- data/app/views/spree/admin/cms_sections/types/_product_carousel.html.erb +5 -0
- data/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erb +4 -0
- data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +121 -0
- data/app/views/spree/admin/countries/index.html.erb +5 -3
- data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +6 -4
- data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +9 -7
- data/app/views/spree/admin/customer_returns/index.html.erb +4 -2
- data/app/views/spree/admin/errors/forbidden.html.erb +0 -0
- data/app/views/spree/admin/images/index.html.erb +8 -4
- data/app/views/spree/admin/menu_items/_form.html.erb +115 -0
- data/app/views/spree/admin/menu_items/edit.html.erb +11 -0
- data/app/views/spree/admin/menu_items/new.html.erb +11 -0
- data/app/views/spree/admin/menus/_form.html.erb +19 -0
- data/app/views/spree/admin/menus/edit.html.erb +57 -0
- data/app/views/spree/admin/menus/index.html.erb +90 -0
- data/app/views/spree/admin/menus/nested_menu_items/_item_bar.html.erb +30 -0
- data/app/views/spree/admin/menus/new.html.erb +22 -0
- data/app/views/spree/admin/option_types/_form.html.erb +3 -0
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +5 -1
- data/app/views/spree/admin/option_types/index.html.erb +5 -3
- data/app/views/spree/admin/orders/_channel_form.html.erb +2 -2
- data/app/views/spree/admin/orders/_line_items.html.erb +10 -8
- data/app/views/spree/admin/orders/_shipment.html.erb +26 -18
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +11 -9
- data/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb +2 -2
- data/app/views/spree/admin/orders/index.html.erb +100 -101
- data/app/views/spree/admin/payment_methods/_form.html.erb +6 -4
- data/app/views/spree/admin/payment_methods/edit.html.erb +1 -1
- data/app/views/spree/admin/payment_methods/index.html.erb +22 -3
- data/app/views/spree/admin/payment_methods/new.html.erb +1 -1
- data/app/views/spree/admin/payments/_list.html.erb +9 -7
- data/app/views/spree/admin/prices/_variant_prices.html.erb +7 -14
- data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +9 -7
- data/app/views/spree/admin/products/_autocomplete.js.erb +10 -6
- data/app/views/spree/admin/products/_form.html.erb +35 -5
- data/app/views/spree/admin/products/index.html.erb +15 -14
- data/app/views/spree/admin/products/new.html.erb +6 -1
- data/app/views/spree/admin/products/stock.html.erb +71 -68
- data/app/views/spree/admin/promotion_categories/index.html.erb +5 -3
- data/app/views/spree/admin/promotions/_form.html.erb +7 -0
- data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +1 -0
- data/app/views/spree/admin/promotions/calculators/_default_fields.html.erb +2 -1
- data/app/views/spree/admin/promotions/index.html.erb +33 -34
- data/app/views/spree/admin/properties/_form.html.erb +6 -0
- data/app/views/spree/admin/properties/index.html.erb +19 -3
- data/app/views/spree/admin/prototypes/_form.html.erb +1 -1
- data/app/views/spree/admin/prototypes/_prototypes.html.erb +8 -6
- data/app/views/spree/admin/prototypes/index.html.erb +5 -3
- data/app/views/spree/admin/reimbursement_types/index.html.erb +5 -3
- data/app/views/spree/admin/reports/index.html.erb +1 -1
- data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
- data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
- data/app/views/spree/admin/return_authorizations/index.html.erb +7 -5
- data/app/views/spree/admin/return_index/customer_returns.html.erb +4 -2
- data/app/views/spree/admin/return_index/return_authorizations.html.erb +5 -3
- data/app/views/spree/admin/roles/index.html.erb +5 -3
- data/app/views/spree/admin/shared/_account_nav.html.erb +5 -5
- data/app/views/spree/admin/shared/_address_form.html.erb +5 -4
- data/app/views/spree/admin/shared/_content_header.html.erb +20 -6
- data/app/views/spree/admin/shared/_head.html.erb +2 -1
- data/app/views/spree/admin/shared/_header.html.erb +7 -10
- data/app/views/spree/admin/shared/_link_fields.html.erb +22 -0
- data/app/views/spree/admin/shared/_main_menu.html.erb +19 -4
- data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -10
- data/app/views/spree/admin/shared/_paths.html.erb +8 -0
- data/app/views/spree/admin/shared/_refunds.html.erb +4 -2
- data/app/views/spree/admin/shared/_sidebar.html.erb +1 -1
- data/app/views/spree/admin/shared/_store_switcher.html.erb +23 -0
- data/app/views/spree/admin/shared/_table_filter.html.erb +6 -6
- data/app/views/spree/admin/shared/_translations.html.erb +2 -0
- data/app/views/spree/admin/shared/cms/_spree_product.html.erb +14 -0
- data/app/views/spree/admin/shared/cms/_spree_taxon.html.erb +14 -0
- data/app/views/spree/admin/shared/linkables/_home_page.html.erb +3 -0
- data/app/views/spree/admin/shared/linkables/_spree_cms_page.erb +28 -0
- data/app/views/spree/admin/shared/linkables/_spree_product.html.erb +20 -0
- data/app/views/spree/admin/shared/linkables/_spree_taxon.html.erb +22 -0
- data/app/views/spree/admin/shared/linkables/_url.html.erb +16 -0
- data/app/views/spree/admin/shared/named_types/_index.html.erb +7 -5
- data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +1 -3
- data/app/views/spree/admin/shared/sub_menu/_content.html.erb +4 -0
- data/app/views/spree/admin/shared/sub_menu/_stock.html.erb +4 -0
- data/app/views/spree/admin/shipping_categories/index.html.erb +5 -3
- data/app/views/spree/admin/shipping_methods/index.html.erb +5 -3
- data/app/views/spree/admin/states/_state_list.html.erb +5 -3
- data/app/views/spree/admin/stock_locations/index.html.erb +5 -3
- data/app/views/spree/admin/stock_transfers/index.html.erb +5 -4
- data/app/views/spree/admin/stock_transfers/new.html.erb +9 -7
- data/app/views/spree/admin/store_credit_categories/index.html.erb +5 -3
- data/app/views/spree/admin/store_credits/index.html.erb +7 -5
- data/app/views/spree/admin/stores/_form.html.erb +12 -2
- data/app/views/spree/admin/stores/index.html.erb +12 -10
- data/app/views/spree/admin/tax_categories/index.html.erb +5 -3
- data/app/views/spree/admin/tax_rates/index.html.erb +5 -3
- data/app/views/spree/admin/taxonomies/_list.html.erb +5 -3
- data/app/views/spree/admin/taxons/_form.html.erb +1 -1
- data/app/views/spree/admin/users/_addresses_form.html.erb +2 -4
- data/app/views/spree/admin/users/_lifetime_stats.html.erb +16 -4
- data/app/views/spree/admin/users/index.html.erb +5 -3
- data/app/views/spree/admin/users/items.html.erb +1 -1
- data/app/views/spree/admin/variants/_autocomplete.js.erb +6 -2
- data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +18 -12
- data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +12 -8
- data/app/views/spree/admin/variants/_split.js.erb +9 -7
- data/app/views/spree/admin/variants/index.html.erb +8 -5
- data/app/views/spree/admin/zones/index.html.erb +5 -3
- data/app/views/spree/layouts/admin.html.erb +16 -16
- data/config/initializers/assets.rb +5 -1
- data/config/routes.rb +14 -2
- data/lib/generators/spree/backend/install/install_generator.rb +22 -0
- data/lib/generators/spree/backend/install/templates/vendor/assets/javascripts/spree/backend/all.js +8 -0
- data/lib/generators/spree/backend/install/templates/vendor/assets/stylesheets/spree/backend/all.css +9 -0
- data/lib/spree/backend/engine.rb +4 -11
- data/lib/spree/backend.rb +7 -4
- data/lib/spree_backend.rb +0 -2
- data/spec/fixtures/files/favicon.ico +0 -0
- data/spec/fixtures/files/icon_512x512.png +0 -0
- data/spree_backend.gemspec +16 -11
- data/vendor/assets/javascripts/cleave.js +8 -0
- data/vendor/assets/javascripts/jsonapi-serializer.min.js +8 -0
- data/vendor/assets/javascripts/jsuri.js +458 -0
- data/vendor/assets/javascripts/sortable.js +2 -3709
- data/vendor/assets/javascripts/sweetalert2.js +2 -0
- metadata +208 -42
- data/app/assets/javascripts/spree/backend/address_states.js +0 -44
- data/app/assets/javascripts/spree/frontend/backend.js +0 -1
- data/app/assets/stylesheets/spree/frontend/backend.css +0 -1
- data/app/views/spree/admin/orders/_store_form.html.erb +0 -18
@@ -28,13 +28,15 @@ function formatCustomerAddress(address, kind) {
|
|
28
28
|
$('#order_' + kind + '_address_attributes_zipcode').val(address.zipcode)
|
29
29
|
$('#order_' + kind + '_address_attributes_phone').val(address.phone)
|
30
30
|
$('#order_' + kind + '_address_attributes_phone').val(address.phone)
|
31
|
-
$('#order_' + kind + '_address_attributes_country_id').val(address.
|
31
|
+
$('#order_' + kind + '_address_attributes_country_id').val(address.country.id)
|
32
32
|
$('#order_' + kind + '_address_attributes_country_id').trigger('change')
|
33
33
|
|
34
34
|
var stateSelect = $('#order_' + kind + '_address_attributes_state_id')
|
35
35
|
|
36
|
-
|
37
|
-
|
36
|
+
updateAddressState(kind.charAt(0), function() {
|
37
|
+
if (address.state) {
|
38
|
+
stateSelect.val(address.state.id).trigger('change')
|
39
|
+
}
|
38
40
|
})
|
39
41
|
}
|
40
42
|
|
@@ -64,27 +66,34 @@ function formatCustomerSelection(customer) {
|
|
64
66
|
}
|
65
67
|
|
66
68
|
$.fn.customerAutocomplete = function() {
|
69
|
+
var jsonApiUsers = {}
|
70
|
+
|
67
71
|
this.select2({
|
68
72
|
minimumInputLength: 3,
|
69
73
|
placeholder: Spree.translations.choose_a_customer,
|
70
74
|
ajax: {
|
71
|
-
url: Spree.routes.
|
75
|
+
url: Spree.routes.users_api_v2,
|
72
76
|
datatype: 'json',
|
77
|
+
headers: Spree.apiV2Authentication(),
|
73
78
|
data: function (params) {
|
74
79
|
return {
|
75
|
-
|
80
|
+
filter: {
|
76
81
|
'm': 'or',
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
bill_address_firstname_start: params.term,
|
81
|
-
bill_address_lastname_start: params.term
|
82
|
+
email_i_cont: params.term,
|
83
|
+
addresses_firstname_start: params.term,
|
84
|
+
addresses_lastname_start: params.term
|
82
85
|
},
|
83
|
-
|
86
|
+
include: 'ship_address.country,ship_address.state,bill_address.country,bill_address.state'
|
84
87
|
}
|
85
88
|
},
|
86
|
-
|
87
|
-
|
89
|
+
success: function(data) {
|
90
|
+
var JSONAPIDeserializer = require('jsonapi-serializer').Deserializer
|
91
|
+
new JSONAPIDeserializer({ keyForAttribute: 'snake_case' }).deserialize(data, function (_err, users) {
|
92
|
+
jsonApiUsers = users
|
93
|
+
})
|
94
|
+
},
|
95
|
+
processResults: function (_data) {
|
96
|
+
return { results: jsonApiUsers } // we need to return deserialized json api data
|
88
97
|
}
|
89
98
|
},
|
90
99
|
templateResult: formatCustomerResult
|
@@ -0,0 +1,25 @@
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function() {
|
2
|
+
const linkSwitcher = $('.link_switcher').select2()
|
3
|
+
|
4
|
+
linkSwitcher.on('change', function() {
|
5
|
+
const selectedLinkToValue = $(this).val()
|
6
|
+
const linkSwitcherTarget = this.dataset.targetField || 'menu_item_link'
|
7
|
+
const activePanel = document.querySelector(`div[data-panel-id='${linkSwitcherTarget}']`)
|
8
|
+
const messagePanel = document.querySelector(`div[data-target-message-pannel='${linkSwitcherTarget}']`)
|
9
|
+
const panelType = activePanel.dataset.panelType
|
10
|
+
|
11
|
+
if (selectedLinkToValue === panelType) {
|
12
|
+
activePanel.classList = ''
|
13
|
+
activePanel.classList.add('d-block')
|
14
|
+
|
15
|
+
messagePanel.classList = ''
|
16
|
+
messagePanel.classList.add('d-none')
|
17
|
+
} else {
|
18
|
+
activePanel.classList = ''
|
19
|
+
activePanel.classList.add('d-none')
|
20
|
+
|
21
|
+
messagePanel.classList = ''
|
22
|
+
messagePanel.classList.add('d-block')
|
23
|
+
}
|
24
|
+
})
|
25
|
+
})
|
@@ -0,0 +1,34 @@
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function() {
|
2
|
+
const LiveViewSwitcher = document.getElementById('LiveViewSwitcher')
|
3
|
+
|
4
|
+
if (!LiveViewSwitcher) return
|
5
|
+
|
6
|
+
LiveViewSwitcher.addEventListener('click', function(event) {
|
7
|
+
if (event.target && event.target.matches("input[type='radio']")) {
|
8
|
+
switchLiveViewClass(event.target.id)
|
9
|
+
}
|
10
|
+
})
|
11
|
+
|
12
|
+
function switchLiveViewClass(value) {
|
13
|
+
const liveViewCont = document.getElementById('liveViewCont')
|
14
|
+
|
15
|
+
liveViewCont.classList = ''
|
16
|
+
liveViewCont.classList.add(value)
|
17
|
+
}
|
18
|
+
|
19
|
+
const cmsSectionEditorFullScreen = document.getElementById('cmsSectionEditorFullScreen')
|
20
|
+
|
21
|
+
cmsSectionEditorFullScreen.addEventListener('click', function(event) {
|
22
|
+
if (this.getAttribute('aria-pressed') === 'true') {
|
23
|
+
document.body.removeAttribute('data-sections-editor-full-screen')
|
24
|
+
} else {
|
25
|
+
document.body.setAttribute('data-sections-editor-full-screen', '')
|
26
|
+
}
|
27
|
+
})
|
28
|
+
|
29
|
+
const queryString = window.location.search;
|
30
|
+
const urlParams = new URLSearchParams(queryString);
|
31
|
+
const fullScreenMode = urlParams.get('section_editor_full_screen_mode')
|
32
|
+
|
33
|
+
if (fullScreenMode) cmsSectionEditorFullScreen.click()
|
34
|
+
})
|
@@ -0,0 +1,133 @@
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function() {
|
2
|
+
const pageVisabilityAttribute = document.querySelectorAll('[data-cms-page-id]')
|
3
|
+
const pageTypeSelector = document.getElementById('cms_page_type')
|
4
|
+
const el = document.getElementById('cmsPagesectionsArea')
|
5
|
+
|
6
|
+
if (pageTypeSelector) updateCmsPageType()
|
7
|
+
|
8
|
+
$(pageTypeSelector).on('change', function() { updateCmsPageType() })
|
9
|
+
|
10
|
+
if (el) {
|
11
|
+
Sortable.create(el, {
|
12
|
+
handle: '.move-handle',
|
13
|
+
ghostClass: 'moving-this',
|
14
|
+
animation: 550,
|
15
|
+
easing: 'cubic-bezier(1, 0, 0, 1)',
|
16
|
+
swapThreshold: 0.9,
|
17
|
+
forceFallback: true,
|
18
|
+
onEnd: function(evt) {
|
19
|
+
handleSectionReposition(evt)
|
20
|
+
}
|
21
|
+
})
|
22
|
+
}
|
23
|
+
|
24
|
+
pageVisabilityAttribute.forEach(function(elem) {
|
25
|
+
elem.addEventListener('change', function() {
|
26
|
+
handleTogglePageVisibility(this)
|
27
|
+
})
|
28
|
+
})
|
29
|
+
})
|
30
|
+
|
31
|
+
function handleTogglePageVisibility(obj) {
|
32
|
+
let checkedState = null
|
33
|
+
if (obj.checked) checkedState = true
|
34
|
+
|
35
|
+
const pageId = parseInt(obj.dataset.cmsPageId, 10)
|
36
|
+
|
37
|
+
const data = {
|
38
|
+
cms_page: {
|
39
|
+
visible: checkedState
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
fetch(Spree.routes.pages_api_v2 + `/${pageId}`, {
|
44
|
+
method: 'PATCH',
|
45
|
+
headers: {
|
46
|
+
Authorization: 'Bearer ' + OAUTH_TOKEN,
|
47
|
+
'Content-Type': 'application/json'
|
48
|
+
},
|
49
|
+
body: JSON.stringify(data)
|
50
|
+
})
|
51
|
+
.then(response => {
|
52
|
+
if (response.ok) {
|
53
|
+
reloadPreview()
|
54
|
+
toggleVisibilityState(obj)
|
55
|
+
} else {
|
56
|
+
// eslint-disable-next-line no-undef
|
57
|
+
spreeHandleApiRequestError(response)
|
58
|
+
}
|
59
|
+
})
|
60
|
+
.catch(err => { console.error(err) })
|
61
|
+
}
|
62
|
+
|
63
|
+
function toggleVisibilityState(obj) {
|
64
|
+
const statusHolder = document.getElementById('visibilityStatus')
|
65
|
+
const pageHidden = statusHolder.querySelector('.page_hidden')
|
66
|
+
const pageVisible = statusHolder.querySelector('.page_visible')
|
67
|
+
|
68
|
+
if (obj.checked) {
|
69
|
+
pageHidden.classList.add('d-none')
|
70
|
+
pageVisible.classList.remove('d-none')
|
71
|
+
} else {
|
72
|
+
pageVisible.classList.add('d-none')
|
73
|
+
pageHidden.classList.remove('d-none')
|
74
|
+
}
|
75
|
+
}
|
76
|
+
|
77
|
+
function reloadPreview() {
|
78
|
+
const liveLiewArea = document.getElementById('pageLivePreview')
|
79
|
+
|
80
|
+
if (!liveLiewArea) return
|
81
|
+
|
82
|
+
liveLiewArea.contentWindow.location.reload();
|
83
|
+
}
|
84
|
+
|
85
|
+
function handleSectionReposition(evt) {
|
86
|
+
const data = {
|
87
|
+
section_id: parseInt(evt.item.dataset.sectionId, 10),
|
88
|
+
new_position_idx: parseInt(evt.newIndex, 10)
|
89
|
+
}
|
90
|
+
|
91
|
+
fetch(Spree.routes.sections_api_v2 + '/reposition', {
|
92
|
+
method: 'PATCH',
|
93
|
+
headers: {
|
94
|
+
Authorization: 'Bearer ' + OAUTH_TOKEN,
|
95
|
+
'Content-Type': 'application/json'
|
96
|
+
},
|
97
|
+
body: JSON.stringify(data)
|
98
|
+
})
|
99
|
+
.then(response => {
|
100
|
+
if (response.ok) {
|
101
|
+
reloadPreview()
|
102
|
+
} else {
|
103
|
+
// eslint-disable-next-line no-undef
|
104
|
+
spreeHandleApiRequestError(response.status)
|
105
|
+
}
|
106
|
+
})
|
107
|
+
.catch(err => { console.error(err) })
|
108
|
+
}
|
109
|
+
|
110
|
+
function updateCmsPageType() {
|
111
|
+
const slugField = document.getElementById('cms_page_slug')
|
112
|
+
const updatePageType = document.getElementById('updatePageType')
|
113
|
+
|
114
|
+
if (!slugField) return
|
115
|
+
|
116
|
+
const selectedLinkType = $('#cms_page_type').val()
|
117
|
+
|
118
|
+
if (selectedLinkType === 'Spree::Cms::Pages::Homepage') {
|
119
|
+
slugField.disabled = true
|
120
|
+
} else {
|
121
|
+
slugField.disabled = false
|
122
|
+
}
|
123
|
+
|
124
|
+
if (!updatePageType) return
|
125
|
+
|
126
|
+
const existingType = updatePageType.dataset.pageType
|
127
|
+
|
128
|
+
if (selectedLinkType === existingType) {
|
129
|
+
updatePageType.classList.add('d-none')
|
130
|
+
} else {
|
131
|
+
updatePageType.classList.remove('d-none')
|
132
|
+
}
|
133
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function() {
|
2
|
+
const sectionKindSelector = $('#cms_section_type').select2()
|
3
|
+
const layoutSwitcher = $('#cms_section_layout_style').select2()
|
4
|
+
|
5
|
+
sectionKindSelector.on('change', function() {
|
6
|
+
const selectedValue = $(sectionKindSelector).val()
|
7
|
+
const message = document.getElementById('alertToClickUpdate')
|
8
|
+
const activeSectionKind = document.getElementById('CmsSectionType')
|
9
|
+
|
10
|
+
if (!activeSectionKind) return
|
11
|
+
|
12
|
+
const panelType = activeSectionKind.dataset.panelSectionType
|
13
|
+
|
14
|
+
if (selectedValue === panelType) {
|
15
|
+
activeSectionKind.classList = ''
|
16
|
+
activeSectionKind.classList.add('d-block')
|
17
|
+
|
18
|
+
message.classList = ''
|
19
|
+
message.classList.add('d-none')
|
20
|
+
} else {
|
21
|
+
activeSectionKind.classList = ''
|
22
|
+
activeSectionKind.classList.add('d-none')
|
23
|
+
|
24
|
+
message.classList = ''
|
25
|
+
message.classList.add('d-block')
|
26
|
+
}
|
27
|
+
});
|
28
|
+
|
29
|
+
if (!layoutSwitcher) return
|
30
|
+
|
31
|
+
layoutSwitcher.on('change', function() {
|
32
|
+
const layoutDefault = document.querySelector('#Default')
|
33
|
+
const layoutReverse = document.querySelector('#Reversed')
|
34
|
+
|
35
|
+
if (this.value === 'Default') {
|
36
|
+
layoutDefault.classList = 'd-block'
|
37
|
+
layoutReverse.classList = 'd-none'
|
38
|
+
} else {
|
39
|
+
layoutDefault.classList = 'd-none'
|
40
|
+
layoutReverse.classList = 'd-block'
|
41
|
+
}
|
42
|
+
})
|
43
|
+
})
|
@@ -0,0 +1,11 @@
|
|
1
|
+
//= require spree/backend/global/alerts
|
2
|
+
//= require spree/backend/global/bootstrap
|
3
|
+
//= require spree/backend/global/flatpickr
|
4
|
+
//= require spree/backend/global/ransack
|
5
|
+
//= require spree/backend/global/info_alert
|
6
|
+
//= require spree/backend/global/radio_panel_toggle
|
7
|
+
//= require spree/backend/global/responsive_menus
|
8
|
+
//= require spree/backend/global/select2_autocomplete
|
9
|
+
//= require spree/backend/global/select2_populate
|
10
|
+
//= require spree/backend/global/sortable
|
11
|
+
//= require spree/backend/global/side_scroll_indication
|
@@ -0,0 +1,66 @@
|
|
1
|
+
/* global Swal */
|
2
|
+
|
3
|
+
document.addEventListener('DOMContentLoaded', function() {
|
4
|
+
const alertEl = document.querySelectorAll('[data-alert-type]')
|
5
|
+
|
6
|
+
if (!alertEl) return
|
7
|
+
|
8
|
+
alertEl.forEach(function (elem) {
|
9
|
+
const alertType = elem.dataset.alertType
|
10
|
+
const alertMessage = elem.innerHTML
|
11
|
+
|
12
|
+
show_flash(alertType, alertMessage)
|
13
|
+
})
|
14
|
+
})
|
15
|
+
|
16
|
+
// eslint-disable-next-line camelcase
|
17
|
+
function show_flash(type, message) {
|
18
|
+
let sanitizedType = DOMPurify.sanitize(type)
|
19
|
+
const sanitizedMessage = DOMPurify.sanitize(message)
|
20
|
+
|
21
|
+
if (sanitizedType === 'notice') sanitizedType = 'info'
|
22
|
+
|
23
|
+
// Set up Swal toast alert defaults
|
24
|
+
const Toast = Swal.mixin({
|
25
|
+
toast: true,
|
26
|
+
position: 'bottom',
|
27
|
+
showConfirmButton: false,
|
28
|
+
showCloseButton: true,
|
29
|
+
timer: 4500,
|
30
|
+
timerProgressBar: false,
|
31
|
+
showClass: {
|
32
|
+
popup: 'animate__animated animate__fadeInUp animate__faster',
|
33
|
+
backdrop: '-',
|
34
|
+
icon: '-'
|
35
|
+
},
|
36
|
+
hideClass: {
|
37
|
+
popup: 'animate__animated animate__fadeOutDown animate__faster',
|
38
|
+
backdrop: '-',
|
39
|
+
icon: '-'
|
40
|
+
}
|
41
|
+
})
|
42
|
+
|
43
|
+
Toast.fire({
|
44
|
+
icon: sanitizedType,
|
45
|
+
title: sanitizedMessage
|
46
|
+
})
|
47
|
+
|
48
|
+
appendToFlashAlertsContainer(sanitizedMessage, sanitizedType)
|
49
|
+
}
|
50
|
+
|
51
|
+
function appendToFlashAlertsContainer (message, type) {
|
52
|
+
if (type === 'info') type = 'notice'
|
53
|
+
|
54
|
+
const parnetNode = document.querySelector('#FlashAlertsContainer')
|
55
|
+
const node = document.createElement('SPAN');
|
56
|
+
const textNode = document.createTextNode(message);
|
57
|
+
|
58
|
+
// Only the most recent alert should be left in the #FlashAlertsContainer.
|
59
|
+
parnetNode.innerHTML = ''
|
60
|
+
|
61
|
+
node.classList.add('d-none')
|
62
|
+
node.setAttribute('data-alert-type', type);
|
63
|
+
node.appendChild(textNode)
|
64
|
+
|
65
|
+
parnetNode.appendChild(node);
|
66
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// Use this file for Boostrap customization applied across the Spree Backend
|
2
|
+
|
3
|
+
document.addEventListener('DOMContentLoaded', function() {
|
4
|
+
$('.with-tip').each(function() {
|
5
|
+
$(this).tooltip({
|
6
|
+
container: $(this)
|
7
|
+
})
|
8
|
+
})
|
9
|
+
|
10
|
+
$('.with-tip').on('show.bs.tooltip', function(event) {
|
11
|
+
if (('ontouchstart' in window)) {
|
12
|
+
event.preventDefault()
|
13
|
+
}
|
14
|
+
})
|
15
|
+
})
|
@@ -0,0 +1,22 @@
|
|
1
|
+
document.addEventListener('DOMContentLoaded', function() {
|
2
|
+
flatpickr.setDefaults({
|
3
|
+
altInput: true,
|
4
|
+
time_24hr: true,
|
5
|
+
altInputClass: 'flatpickr-alt-input',
|
6
|
+
locale: Spree.translations.flatpickr_locale
|
7
|
+
})
|
8
|
+
|
9
|
+
var dateFrom = flatpickr('.datePickerFrom', {
|
10
|
+
onChange: function(selectedDates) {
|
11
|
+
dateTo.set('minDate', selectedDates[0])
|
12
|
+
}
|
13
|
+
})
|
14
|
+
|
15
|
+
var dateTo = flatpickr('.datePickerTo', {
|
16
|
+
onChange: function(selectedDates) {
|
17
|
+
dateFrom.set('maxDate', selectedDates[0])
|
18
|
+
}
|
19
|
+
})
|
20
|
+
|
21
|
+
flatpickr('.datepicker', {})
|
22
|
+
})
|
@@ -0,0 +1,38 @@
|
|
1
|
+
/* global Swal */
|
2
|
+
document.addEventListener('DOMContentLoaded', function() {
|
3
|
+
const infoToggle = document.querySelectorAll('[data-show-info]')
|
4
|
+
|
5
|
+
infoToggle.forEach(function(infoElem) {
|
6
|
+
infoElem.addEventListener('click', function() {
|
7
|
+
const alertType = infoElem.dataset.alertKind
|
8
|
+
const alertTitle = infoElem.dataset.alertTitle
|
9
|
+
const alertHtml = infoElem.dataset.alertHtml
|
10
|
+
const alertMessage = infoElem.dataset.alertMessage
|
11
|
+
|
12
|
+
showInfoAlert(alertType, alertTitle, alertMessage, alertHtml)
|
13
|
+
})
|
14
|
+
})
|
15
|
+
})
|
16
|
+
|
17
|
+
// eslint-disable-next-line no-unused-vars
|
18
|
+
function showInfoAlert(type = null, title = null, message = null, html = null) {
|
19
|
+
const infoAlert = Swal.mixin({
|
20
|
+
showConfirmButton: false,
|
21
|
+
showCloseButton: true,
|
22
|
+
timer: null,
|
23
|
+
timerProgressBar: false,
|
24
|
+
showClass: {
|
25
|
+
popup: 'animate__animated animate__fadeInUp animate__faster'
|
26
|
+
},
|
27
|
+
hideClass: {
|
28
|
+
popup: 'animate__animated animate__fadeOutDown animate__faster'
|
29
|
+
}
|
30
|
+
})
|
31
|
+
|
32
|
+
infoAlert.fire({
|
33
|
+
icon: type,
|
34
|
+
title: title,
|
35
|
+
text: message,
|
36
|
+
html: html
|
37
|
+
})
|
38
|
+
}
|