spree_backend 4.3.3 → 4.4.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +222 -0
- data/.codeclimate.yml +36 -0
- data/.editorconfig +22 -0
- data/.eslintignore +7 -0
- data/.eslintrc.cjs +29 -0
- data/.gem_release.yml +4 -0
- data/.github/CONTRIBUTING.md +1 -0
- data/.github/ISSUE_TEMPLATE/bug_report.md +47 -0
- data/.github/ISSUE_TEMPLATE/feature_request.md +20 -0
- data/.github/ISSUE_TEMPLATE.md +39 -0
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/spelling_lint.yml +34 -0
- data/.gitignore +63 -0
- data/.rubocop.yml +197 -0
- data/.solargraph.yml +20 -0
- data/.stylelintignore +4 -0
- data/.stylelintrc +6 -0
- data/CODE_OF_CONDUCT.md +22 -0
- data/Gemfile +59 -3
- data/README.md +123 -0
- data/SECURITY.md +1 -0
- data/app/assets/config/spree_backend_manifest.js +1 -1
- data/app/assets/images/backend-cloud-arrow-up.svg +4 -0
- data/app/assets/images/backend-eye-open.svg +1 -1
- data/app/assets/images/backend-file-earmark-font.svg +4 -0
- data/app/assets/images/backend-file-earmark-image.svg +4 -0
- data/app/assets/images/backend-file-earmark-music.svg +4 -0
- data/app/assets/images/backend-file-earmark-pdf.svg +4 -0
- data/app/assets/images/backend-file-earmark-play.svg +4 -0
- data/app/assets/images/backend-file-earmark-spreadsheet.svg +3 -0
- data/app/assets/images/backend-file-earmark-zip.svg +4 -0
- data/app/assets/images/backend-file-earmark.svg +3 -0
- data/app/assets/images/backend-hdd.svg +4 -0
- data/app/assets/images/backend-link.svg +4 -0
- data/app/assets/images/backend-view.svg +1 -1
- data/app/assets/javascripts/spree/backend/adjustments.js +5 -5
- data/app/assets/javascripts/spree/backend/admin.js +4 -6
- data/app/assets/javascripts/spree/backend/calculator.js +1 -1
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +1 -1
- data/app/assets/javascripts/spree/backend/cms/links.es6 +1 -1
- data/app/assets/javascripts/spree/backend/cms/live_preview.es6 +1 -1
- data/app/assets/javascripts/spree/backend/cms/page.es6 +22 -40
- data/app/assets/javascripts/spree/backend/cms/section.es6 +1 -1
- data/app/assets/javascripts/spree/backend/gateway.js +1 -1
- data/app/assets/javascripts/spree/backend/general_settings.js +1 -1
- data/app/assets/javascripts/spree/backend/global/_index.js +3 -1
- data/app/assets/javascripts/spree/backend/global/alerts.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/animate_css.es6 +19 -0
- data/app/assets/javascripts/spree/backend/global/fetch_request_utility.es6 +114 -0
- data/app/assets/javascripts/spree/backend/global/flatpickr.es6 +2 -1
- data/app/assets/javascripts/spree/backend/global/info_alert.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/radio_panel_toggle.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/ransack.es6 +7 -5
- data/app/assets/javascripts/spree/backend/global/responsive_menus.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 +4 -4
- data/app/assets/javascripts/spree/backend/global/select2_populate.es6 +2 -2
- data/app/assets/javascripts/spree/backend/global/side_scroll_indication.es6 +2 -2
- data/app/assets/javascripts/spree/backend/global/sortable.es6 +1 -1
- data/app/assets/javascripts/spree/backend/global/tinymce.es6 +3 -2
- data/app/assets/javascripts/spree/backend/line_items.js +7 -9
- data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +23 -28
- data/app/assets/javascripts/spree/backend/menus/_index.es6 +0 -1
- data/app/assets/javascripts/spree/backend/menus/menu_item.es6 +1 -1
- data/app/assets/javascripts/spree/backend/multi_currency.js +2 -2
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/orders/edit.js +1 -1
- data/app/assets/javascripts/spree/backend/payments/edit.js +32 -22
- data/app/assets/javascripts/spree/backend/payments/new.js +1 -1
- data/app/assets/javascripts/spree/backend/product_picker.js +16 -25
- data/app/assets/javascripts/spree/backend/progress.js +5 -3
- data/app/assets/javascripts/spree/backend/promotions.js +3 -1
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js +1 -1
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +1 -1
- data/app/assets/javascripts/spree/backend/shipments.js +80 -79
- data/app/assets/javascripts/spree/backend/spree-select2.js +1 -1
- data/app/assets/javascripts/spree/backend/states.js +1 -1
- data/app/assets/javascripts/spree/backend/stock_location.js +1 -1
- data/app/assets/javascripts/spree/backend/stock_management.js +1 -1
- data/app/assets/javascripts/spree/backend/stock_movement.js +58 -13
- data/app/assets/javascripts/spree/backend/stock_transfer.js +62 -32
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +9 -8
- data/app/assets/javascripts/spree/backend/taxons.js +17 -14
- data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/users/edit.js +1 -1
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +19 -11
- data/app/assets/javascripts/spree/backend/variant_management.js +1 -1
- data/app/assets/javascripts/spree/backend/zone.js +1 -1
- data/app/assets/javascripts/spree/backend.js +13 -33
- data/app/assets/javascripts/spree.js +2 -9
- data/app/assets/stylesheets/spree/backend/components/_main.scss +8 -0
- data/app/assets/stylesheets/spree/backend/plugins/_nav_x.scss +1 -1
- data/app/assets/stylesheets/spree/backend/plugins/_select2_custom.scss +1 -1
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +1 -1
- data/app/assets/stylesheets/spree/backend/shared/_sortable_tree.scss +62 -0
- data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +3 -0
- data/app/assets/stylesheets/spree/backend/views/_digitals.scss +33 -0
- data/app/assets/stylesheets/spree/backend/views/_taxonomies.scss +3 -0
- data/app/controllers/spree/admin/base_controller.rb +4 -13
- data/app/controllers/spree/admin/digitals_controller.rb +33 -0
- data/app/controllers/spree/admin/general_settings_controller.rb +0 -5
- data/app/controllers/spree/admin/images_controller.rb +1 -1
- data/app/controllers/spree/admin/oauth_applications_controller.rb +17 -0
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +2 -2
- data/app/controllers/spree/admin/orders_controller.rb +10 -2
- data/app/controllers/spree/admin/payment_methods_controller.rb +2 -2
- data/app/controllers/spree/admin/payments_controller.rb +1 -1
- data/app/controllers/spree/admin/products_controller.rb +4 -2
- data/app/controllers/spree/admin/promotions_controller.rb +1 -1
- data/app/controllers/spree/admin/properties_controller.rb +1 -1
- data/app/controllers/spree/admin/resource_controller.rb +9 -4
- data/app/controllers/spree/admin/return_index_controller.rb +1 -1
- data/app/controllers/spree/admin/stock_transfers_controller.rb +2 -2
- data/app/controllers/spree/admin/store_credits_controller.rb +2 -2
- data/app/controllers/spree/admin/stores_controller.rb +2 -2
- data/app/controllers/spree/admin/taxons_controller.rb +23 -38
- data/app/controllers/spree/admin/users_controller.rb +6 -19
- data/app/controllers/spree/admin/variants_controller.rb +1 -2
- data/app/controllers/spree/admin/webhooks_subscribers_controller.rb +48 -0
- data/app/helpers/spree/admin/base_helper.rb +27 -9
- data/app/helpers/spree/admin/digital_helper.rb +28 -0
- data/app/helpers/spree/admin/menu_helper.rb +0 -21
- data/app/helpers/spree/admin/navigation_helper.rb +19 -9
- data/app/helpers/spree/admin/sortable_tree_helper.rb +31 -0
- data/app/helpers/spree/admin/stores_helper.rb +1 -1
- data/app/helpers/spree/admin/webhooks_subscribers_helper.rb +31 -0
- data/app/javascript/spree/dashboard/controllers/clipboard_controller.js +12 -0
- data/app/javascript/spree/dashboard/controllers/password_toggle_controller.js +14 -0
- data/app/javascript/spree/dashboard/controllers/sortable_tree_controller.js +55 -0
- data/app/javascript/spree/dashboard/controllers/spree_controller.js +25 -0
- data/app/javascript/spree/dashboard/controllers/upload_button_controller.js +13 -0
- data/app/javascript/spree/dashboard/controllers/webhooks_subscriber_events_controller.js +19 -0
- data/app/javascript/spree/dashboard/index.js +49 -0
- data/app/{assets/javascripts/spree/backend/global/bootstrap.es6 → javascript/spree/dashboard/utilities/bootstrap.js} +6 -2
- data/app/javascript/spree/dashboard/utilities/request_utility.js +54 -0
- data/app/models/spree/backend_configuration.rb +11 -0
- data/app/views/spree/admin/adjustments/_adjustments_table.html.erb +2 -2
- data/app/views/spree/admin/adjustments/_form.html.erb +2 -2
- data/app/views/spree/admin/adjustments/index.html.erb +1 -0
- data/app/views/spree/admin/cms_pages/_form.html.erb +8 -8
- data/app/views/spree/admin/cms_pages/edit.html.erb +1 -6
- data/app/views/spree/admin/cms_sections/_form.html.erb +2 -2
- data/app/views/spree/admin/cms_sections/types/_featured_article.html.erb +6 -6
- data/app/views/spree/admin/cms_sections/types/_hero_image.html.erb +6 -6
- data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +12 -12
- data/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erb +1 -1
- data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +12 -12
- data/app/views/spree/admin/countries/_form.html.erb +4 -4
- data/app/views/spree/admin/customer_returns/new.html.erb +1 -1
- data/app/views/spree/admin/digitals/_form.html.erb +35 -0
- data/app/views/spree/admin/digitals/index.html.erb +25 -0
- data/app/views/spree/admin/general_settings/edit.html.erb +1 -22
- data/app/views/spree/admin/menu_items/_form.html.erb +6 -6
- data/app/views/spree/admin/menus/_form.html.erb +3 -3
- data/app/views/spree/admin/menus/edit.html.erb +18 -18
- data/app/views/spree/admin/oauth_applications/_form.html.erb +22 -0
- data/app/views/spree/admin/oauth_applications/create.turbo_stream.erb +38 -0
- data/app/views/spree/admin/oauth_applications/edit.html.erb +13 -0
- data/app/views/spree/admin/oauth_applications/index.html.erb +51 -0
- data/app/views/spree/admin/oauth_applications/new.html.erb +15 -0
- data/app/views/spree/admin/option_types/_form.html.erb +3 -3
- data/app/views/spree/admin/option_types/_option_value_fields.html.erb +2 -2
- data/app/views/spree/admin/orders/_channel_form.html.erb +1 -1
- data/app/views/spree/admin/orders/_form.html.erb +1 -0
- data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -0
- data/app/views/spree/admin/orders/_order_actions.html.erb +6 -0
- data/app/views/spree/admin/orders/_search.html.erb +151 -0
- data/app/views/spree/admin/orders/index.html.erb +2 -151
- data/app/views/spree/admin/payment_methods/_form.html.erb +2 -2
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +19 -19
- data/app/views/spree/admin/products/index.html.erb +2 -0
- data/app/views/spree/admin/products/new.html.erb +6 -6
- data/app/views/spree/admin/promotion_actions/create.js.erb +1 -1
- data/app/views/spree/admin/promotion_categories/_form.html.erb +2 -2
- data/app/views/spree/admin/promotions/_form.html.erb +5 -5
- data/app/views/spree/admin/properties/_form.html.erb +3 -3
- data/app/views/spree/admin/prototypes/_form.html.erb +4 -4
- data/app/views/spree/admin/refunds/new.html.erb +2 -2
- data/app/views/spree/admin/reimbursement_types/_form.html.erb +2 -2
- data/app/views/spree/admin/return_authorizations/_form.html.erb +3 -3
- data/app/views/spree/admin/roles/_form.html.erb +1 -1
- data/app/views/spree/admin/shared/_account_nav.html.erb +1 -1
- data/app/views/spree/admin/shared/_address_form.html.erb +4 -4
- data/app/views/spree/admin/shared/_head.html.erb +4 -8
- data/app/views/spree/admin/shared/_main_menu.html.erb +12 -0
- data/app/views/spree/admin/shared/_new_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_tabs.html.erb +8 -0
- data/app/views/spree/admin/shared/_version.html.erb +1 -1
- data/app/views/spree/admin/shared/cms/_spree_product.html.erb +2 -2
- data/app/views/spree/admin/shared/cms/_spree_taxon.html.erb +2 -2
- data/app/views/spree/admin/shared/linkables/_spree_cms_page.erb +2 -2
- data/app/views/spree/admin/shared/linkables/_spree_product.html.erb +2 -2
- data/app/views/spree/admin/shared/linkables/_spree_taxon.html.erb +2 -2
- data/app/views/spree/admin/shared/linkables/_url.html.erb +1 -1
- data/app/views/spree/admin/shared/named_types/_form.html.erb +1 -1
- data/app/views/spree/admin/{menus/nested_menu_items/_item_bar.html.erb → shared/sortable_tree/_menu.html.erb} +10 -7
- data/app/views/spree/admin/shared/sortable_tree/_taxonomy.html.erb +34 -0
- data/app/views/spree/admin/shared/sub_menu/_apps.html.erb +3 -0
- data/app/views/spree/admin/shared/sub_menu/_integrations.html.erb +3 -0
- data/app/views/spree/admin/shipping_categories/_form.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +8 -8
- data/app/views/spree/admin/states/_form.html.erb +2 -2
- data/app/views/spree/admin/stock_locations/_form.html.erb +2 -2
- data/app/views/spree/admin/stock_movements/_form.html.erb +3 -3
- data/app/views/spree/admin/store_credit_categories/_form.html.erb +1 -1
- data/app/views/spree/admin/store_credits/_form.html.erb +4 -4
- data/app/views/spree/admin/stores/_form.html.erb +280 -227
- data/app/views/spree/admin/tax_categories/_form.html.erb +4 -4
- data/app/views/spree/admin/tax_rates/_form.html.erb +4 -3
- data/app/views/spree/admin/taxonomies/_form.html.erb +2 -2
- data/app/views/spree/admin/taxonomies/edit.html.erb +34 -29
- data/app/views/spree/admin/taxons/_form.html.erb +101 -57
- data/app/views/spree/admin/taxons/edit.html.erb +6 -3
- data/app/views/spree/admin/taxons/index.html.erb +1 -1
- data/app/views/spree/admin/taxons/new.html.erb +16 -0
- data/app/views/spree/admin/users/_form.html.erb +3 -3
- data/app/views/spree/admin/users/edit.html.erb +0 -40
- data/app/views/spree/admin/variants/_autocomplete.js.erb +5 -5
- data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +2 -2
- data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +6 -6
- data/app/views/spree/admin/variants/_split.js.erb +1 -1
- data/app/views/spree/admin/variants/index.html.erb +4 -1
- data/app/views/spree/admin/webhooks_subscribers/_form.html.erb +101 -0
- data/app/views/spree/admin/webhooks_subscribers/edit.html.erb +13 -0
- data/app/views/spree/admin/webhooks_subscribers/index.html.erb +47 -0
- data/app/views/spree/admin/webhooks_subscribers/new.html.erb +13 -0
- data/app/views/spree/admin/webhooks_subscribers/show.html.erb +59 -0
- data/app/views/spree/admin/zones/_country_members.html.erb +1 -1
- data/app/views/spree/admin/zones/_form.html.erb +2 -2
- data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
- data/app/views/spree/layouts/admin.html.erb +1 -11
- data/codespell.txt +8 -0
- data/config/locales/en.yml +273 -0
- data/config/routes.rb +8 -4
- data/lib/generators/spree/backend/install/install_generator.rb +4 -2
- data/lib/generators/spree/backend/install/templates/app/javascript/spree-dashboard.js +7 -0
- data/lib/spree/backend/engine.rb +2 -1
- data/lib/spree/backend/testing_support/capybara_utils.rb +53 -0
- data/lib/spree/backend/testing_support/flash.rb +38 -0
- data/lib/spree/backend/testing_support/flatpickr_capybara.rb +126 -0
- data/lib/spree/backend/version.rb +9 -0
- data/lib/spree/backend.rb +2 -1
- data/lib/spree_backend.rb +17 -0
- data/license.md +13 -0
- data/package.json +46 -0
- data/rollup.config.js +41 -0
- data/spree_backend.gemspec +17 -16
- data/vendor/assets/javascripts/purify.js +1 -1
- data/vendor/assets/stylesheets/animate.css +2 -4
- data/yarn.lock +959 -0
- metadata +120 -38
- data/app/assets/javascripts/spree/backend/menus/menu.es6 +0 -57
- data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +0 -11
- data/app/assets/javascripts/spree/backend/taxon_tree_menu.js +0 -35
- data/app/assets/javascripts/spree/backend/taxonomy.js +0 -178
- data/app/views/spree/admin/taxonomies/_js_head.html.erb +0 -7
- data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +0 -4564
- data/vendor/assets/javascripts/js.cookie.js +0 -163
- data/vendor/assets/javascripts/modernizr.js +0 -3
- data/vendor/assets/stylesheets/jquery.jstree/themes/spree/style.scss +0 -230
- data/vendor/assets/stylesheets/jquery.jstree/themes/spree/throbber.gif +0 -0
- /data/app/assets/stylesheets/spree/backend/views/{prototypes.scss → _prototypes.scss} +0 -0
@@ -1,4 +1,4 @@
|
|
1
|
-
document.addEventListener(
|
1
|
+
document.addEventListener("spree:load", function() {
|
2
2
|
const pageVisabilityAttribute = document.querySelectorAll('[data-cms-page-id]')
|
3
3
|
const pageTypeSelector = document.getElementById('cms_page_type')
|
4
4
|
const el = document.getElementById('cmsPagesectionsArea')
|
@@ -32,32 +32,24 @@ function handleTogglePageVisibility(obj) {
|
|
32
32
|
let checkedState = null
|
33
33
|
if (obj.checked) checkedState = true
|
34
34
|
|
35
|
-
const pageId =
|
35
|
+
const pageId = obj.dataset.cmsPageId
|
36
36
|
|
37
37
|
const data = {
|
38
38
|
cms_page: {
|
39
39
|
visible: checkedState
|
40
40
|
}
|
41
41
|
}
|
42
|
+
const requestData = {
|
43
|
+
uri: Spree.routes.pages_api_v2 + `/${pageId}`,
|
44
|
+
method: 'PATCH',
|
45
|
+
dataBody: data,
|
46
|
+
}
|
47
|
+
spreeFetchRequest(requestData, handleToggleSuccess)
|
42
48
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
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) })
|
49
|
+
function handleToggleSuccess() {
|
50
|
+
toggleVisibilityState(obj)
|
51
|
+
reloadPreview()
|
52
|
+
}
|
61
53
|
}
|
62
54
|
|
63
55
|
function toggleVisibilityState(obj) {
|
@@ -83,28 +75,18 @@ function reloadPreview() {
|
|
83
75
|
}
|
84
76
|
|
85
77
|
function handleSectionReposition(evt) {
|
78
|
+
const sectionId = evt.item.dataset.sectionId
|
86
79
|
const data = {
|
87
|
-
|
88
|
-
|
80
|
+
cms_section: {
|
81
|
+
position: parseInt(evt.newIndex, 10) + 1
|
82
|
+
}
|
89
83
|
}
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
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) })
|
84
|
+
const requestData = {
|
85
|
+
uri: `${Spree.routes.sections_api_v2}/${sectionId}`,
|
86
|
+
method: 'PATCH',
|
87
|
+
dataBody: data,
|
88
|
+
}
|
89
|
+
spreeFetchRequest(requestData, reloadPreview)
|
108
90
|
}
|
109
91
|
|
110
92
|
function updateCmsPageType() {
|
@@ -1,5 +1,6 @@
|
|
1
1
|
//= require spree/backend/global/alerts
|
2
|
-
//= require spree/backend/global/
|
2
|
+
//= require spree/backend/global/animate_css
|
3
|
+
//= require spree/backend/global/fetch_request_utility
|
3
4
|
//= require spree/backend/global/flatpickr
|
4
5
|
//= require spree/backend/global/ransack
|
5
6
|
//= require spree/backend/global/info_alert
|
@@ -9,3 +10,4 @@
|
|
9
10
|
//= require spree/backend/global/select2_populate
|
10
11
|
//= require spree/backend/global/sortable
|
11
12
|
//= require spree/backend/global/side_scroll_indication
|
13
|
+
//= require spree/backend/global/tinymce
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
2
|
+
|
3
|
+
//
|
4
|
+
// Handle clearing out of animation styles from complete animation.
|
5
|
+
const animateCSS = (element, animation, speed, prefix = 'animate__') =>
|
6
|
+
new Promise((resolve) => {
|
7
|
+
const animationName = `${prefix}${animation}`
|
8
|
+
const node = document.querySelector(element)
|
9
|
+
|
10
|
+
node.classList.add(`${prefix}animated`, animationName, prefix + speed)
|
11
|
+
|
12
|
+
function handleAnimationEnd(event) {
|
13
|
+
event.stopPropagation()
|
14
|
+
node.classList.remove(`${prefix}animated`, animationName)
|
15
|
+
resolve('Animation ended')
|
16
|
+
}
|
17
|
+
|
18
|
+
node.addEventListener('animationend', handleAnimationEnd, { once: true })
|
19
|
+
})
|
@@ -0,0 +1,114 @@
|
|
1
|
+
/* eslint-disable no-undef */
|
2
|
+
/* eslint-disable no-unused-vars */
|
3
|
+
|
4
|
+
//
|
5
|
+
// Shows the progress bar on fech requests
|
6
|
+
const showProgressIndicator = () => {
|
7
|
+
Turbo.navigator.delegate.adapter.progressBar.setValue(0)
|
8
|
+
Turbo.navigator.delegate.adapter.progressBar.show()
|
9
|
+
}
|
10
|
+
|
11
|
+
//
|
12
|
+
// Hides the progress bar on fech requests
|
13
|
+
const hideProgressIndicator = () => {
|
14
|
+
Turbo.navigator.delegate.adapter.progressBar.setValue(1)
|
15
|
+
Turbo.navigator.delegate.adapter.progressBar.hide()
|
16
|
+
}
|
17
|
+
|
18
|
+
//
|
19
|
+
// Handles the fetch request response.
|
20
|
+
// If the response has content it is returned, else if the response is a 204 no-content,
|
21
|
+
// the resolved text is returned.
|
22
|
+
const spreeHandleFetchRequestResponse = function(response) {
|
23
|
+
hideProgressIndicator()
|
24
|
+
|
25
|
+
if (response.status === 204) {
|
26
|
+
return response.text()
|
27
|
+
} else {
|
28
|
+
return response.json()
|
29
|
+
}
|
30
|
+
}
|
31
|
+
|
32
|
+
//
|
33
|
+
// Handles fech request errors by triggering the appropriate flash alert type and displaying
|
34
|
+
// the response message.
|
35
|
+
const spreeHandleFetchRequestError = function(data) {
|
36
|
+
if (data.error != null) {
|
37
|
+
show_flash('error', data.error)
|
38
|
+
} else if (data.message != null) {
|
39
|
+
show_flash('success', data.message)
|
40
|
+
} else if (data.exception != null) {
|
41
|
+
show_flash('info', data.exception)
|
42
|
+
} else if (data.detail != null) {
|
43
|
+
show_flash('info', data.detail)
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
//
|
48
|
+
// Reloads the window.
|
49
|
+
const spreeWindowReload = function() {
|
50
|
+
window.location.reload()
|
51
|
+
}
|
52
|
+
|
53
|
+
//
|
54
|
+
// SPREE FECTCH REQUEST
|
55
|
+
// Pass a json object containing your fetch request details and settings, you can also send a second optional
|
56
|
+
// argument, this second argument is your success response handler, and lastly a third argument that carries
|
57
|
+
// through a target element to the response method if needed, the second and third arguments are optional.
|
58
|
+
// When using spreeFetchRequest() the loading... progress bar, flash notice and errors are all handled for you.
|
59
|
+
//
|
60
|
+
// EXAMPLE SENDING A POST REQUEST TO CREATE A NEW SHIPMENT:
|
61
|
+
// const data = {
|
62
|
+
// order_id: 'H8213728798',
|
63
|
+
// variant_id: 2,
|
64
|
+
// quantity: 4,
|
65
|
+
// stock_location_id: 1
|
66
|
+
// }
|
67
|
+
//
|
68
|
+
// const requestData = {
|
69
|
+
// // request details
|
70
|
+
// uri: Spree.routes.shipments_api_v2,
|
71
|
+
// method: 'POST',
|
72
|
+
// dataBody: data,
|
73
|
+
//
|
74
|
+
// // Optional Settings
|
75
|
+
// // disableProgressIndicator: true, Allows you to disable the progress loader bar if needed.
|
76
|
+
// // formatDataBody: false If you have pre-formatted data, pass this option to stop the function performing the default stringify.
|
77
|
+
// }
|
78
|
+
// spreeFetchRequest(requestData, someCallbackFunction, this)
|
79
|
+
//
|
80
|
+
const spreeFetchRequest = function(requstData, success = null, target = null) {
|
81
|
+
if (!requstData.disableProgressIndicator === true) showProgressIndicator()
|
82
|
+
|
83
|
+
let requestDataBody
|
84
|
+
|
85
|
+
const requestUri = requstData.uri || null
|
86
|
+
const requestMethod = requstData.method || 'GET'
|
87
|
+
const requestContentType = requstData.ContentType || 'application/json'
|
88
|
+
|
89
|
+
if (requstData.formatDataBody === false) {
|
90
|
+
requestDataBody = requstData.dataBody
|
91
|
+
} else {
|
92
|
+
requestDataBody = JSON.stringify(requstData.dataBody) || null
|
93
|
+
}
|
94
|
+
|
95
|
+
if (requestUri == null) return
|
96
|
+
|
97
|
+
fetch(requestUri, {
|
98
|
+
method: requestMethod,
|
99
|
+
headers: {
|
100
|
+
'Authorization': 'Bearer ' + OAUTH_TOKEN,
|
101
|
+
'Content-Type': requestContentType
|
102
|
+
},
|
103
|
+
body: requestDataBody
|
104
|
+
})
|
105
|
+
.then((response) => spreeHandleFetchRequestResponse(response)
|
106
|
+
.then((data) => {
|
107
|
+
if (response.ok) {
|
108
|
+
if (success != null) success(data, target)
|
109
|
+
} else {
|
110
|
+
spreeHandleFetchRequestError(data)
|
111
|
+
}
|
112
|
+
}))
|
113
|
+
.catch(err => console.log(err))
|
114
|
+
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
document.addEventListener(
|
1
|
+
document.addEventListener("spree:load", function() {
|
2
2
|
flatpickr.setDefaults({
|
3
3
|
altInput: true,
|
4
4
|
time_24hr: true,
|
@@ -20,3 +20,4 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
20
20
|
|
21
21
|
flatpickr('.datepicker', {})
|
22
22
|
})
|
23
|
+
|
@@ -2,7 +2,7 @@
|
|
2
2
|
radioControlsVisibilityOfElement:
|
3
3
|
Apply to individual radio button that makes another element visible when checked
|
4
4
|
**/
|
5
|
-
document.addEventListener(
|
5
|
+
document.addEventListener("spree:load", function() {
|
6
6
|
$.fn.radioControlsVisibilityOfElement = function(dependentElementSelector) {
|
7
7
|
if (!this.get(0)) { return }
|
8
8
|
var showValue = this.get(0).value
|
@@ -1,4 +1,4 @@
|
|
1
|
-
document.addEventListener(
|
1
|
+
document.addEventListener("spree:load", function() {
|
2
2
|
const QuickSearchInput = document.getElementById('quick_search')
|
3
3
|
|
4
4
|
if (QuickSearchInput) {
|
@@ -80,7 +80,7 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
80
80
|
}
|
81
81
|
})
|
82
82
|
|
83
|
-
// per page
|
83
|
+
// per page drop-down
|
84
84
|
// preserves all selected filters / queries supplied by user
|
85
85
|
// changes only per_page value
|
86
86
|
$('.js-per-page-select').change(function() {
|
@@ -92,16 +92,18 @@ document.addEventListener('DOMContentLoaded', function() {
|
|
92
92
|
} else {
|
93
93
|
url += '?per_page=' + value
|
94
94
|
}
|
95
|
-
|
95
|
+
Turbo.visit(url)
|
96
96
|
})
|
97
97
|
|
98
98
|
// injects per_page settings to all available search forms
|
99
99
|
// so when user changes some filters / queries per_page is preserved
|
100
|
-
|
100
|
+
document.addEventListener("spree:load", function() {
|
101
101
|
var perPageDropdown = $('.js-per-page-select:first')
|
102
102
|
if (perPageDropdown.length) {
|
103
103
|
var perPageValue = perPageDropdown.val().toString()
|
104
|
-
var perPageInput = '<input type="hidden" name="per_page" value=' + perPageValue + ' />'
|
104
|
+
var perPageInput = '<input class="hidden_per_page_input" type="hidden" name="per_page" value=' + perPageValue + ' />'
|
105
|
+
|
106
|
+
$('.hidden_per_page_input').remove()
|
105
107
|
$('#table-filter form').append(perPageInput)
|
106
108
|
}
|
107
109
|
})
|
@@ -8,20 +8,20 @@
|
|
8
8
|
// data-autocomplete-url-value="products_api_v2"
|
9
9
|
|
10
10
|
// OPTIONAL:
|
11
|
-
// data-autocomplete-placeholder-value="
|
11
|
+
// data-autocomplete-placeholder-value="Search Pages" <- Sets the placeholder | DEFAULT is: 'Search'.
|
12
12
|
// data-autocomplete-clear-value=boolean <- Allow select2 to be cleared | DEFAULT is: false (no clear button).
|
13
13
|
// data-autocomplete-multiple-value=boolean <- Multiple or Single select | DEFAULT is: false (single).
|
14
14
|
// data-autocomplete-return-attr-value="pretty_name" <- Return Attribute. | DEFAULT is: 'name'.
|
15
15
|
// data-autocomplete-min-input-value="4" <- Minimum input for search | DEFAULT is: 3.
|
16
16
|
// data-autocomplete-search-query-value="title_i_cont" <- Custom search query | DEFAULT is: 'name_i_cont'.
|
17
17
|
// data-autocomplete-custom-return-id-value="permalink" <- Return a custom attribute | DEFAULT: returns id.
|
18
|
-
// data-autocomplete-debug-mode-value=boolean <- Turn on console
|
18
|
+
// data-autocomplete-debug-mode-value=boolean <- Turn on console login of data returned by the request.
|
19
19
|
//
|
20
20
|
// Add your own custom URL params to the request as needed
|
21
21
|
// EXAMPLE:
|
22
22
|
// data-autocomplete-additional-url-params-value="filter[type_not_eq]=Spree::Cms::Pages::Homepage"
|
23
23
|
|
24
|
-
document.addEventListener(
|
24
|
+
document.addEventListener("spree:load", function() {
|
25
25
|
loadAutoCompleteParams()
|
26
26
|
})
|
27
27
|
|
@@ -77,7 +77,7 @@ $.fn.select2Autocomplete = function(params) {
|
|
77
77
|
// URL + Additional URL Params + Sparse Fields
|
78
78
|
apiUrl = `${params.apiUrl}?${additionalUrlParams}&${sparseFields}`
|
79
79
|
} else {
|
80
|
-
// URL + Sparse Fields (the default response for a
|
80
|
+
// URL + Sparse Fields (the default response for a normal Select2)
|
81
81
|
apiUrl = `${params.apiUrl}?${sparseFields}`
|
82
82
|
}
|
83
83
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/**
|
2
2
|
populateSelectOptionsFromApi(params)
|
3
|
-
Allows you to easily fetch data from API (
|
3
|
+
Allows you to easily fetch data from API (Platform v2) and populate an empty <select> with <option> tags, including a selected <option> tag.
|
4
4
|
|
5
5
|
## EXAMPLE A
|
6
6
|
# Populating a list of all taxons including a selected item
|
@@ -67,7 +67,7 @@ const updateSelectSuccess = function(parsedData, returnValueFromAttributes, retu
|
|
67
67
|
|
68
68
|
if (returnValueFromAttributes == null) {
|
69
69
|
optionEl.value = object.id
|
70
|
-
if (
|
70
|
+
if (selectedOption === object.id) optionEl.selected = true
|
71
71
|
} else {
|
72
72
|
optionEl.value = object.attributes[returnValueFromAttributes]
|
73
73
|
if (selectedOpt.value === object.attributes[returnValueFromAttributes]) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
document.addEventListener(
|
1
|
+
document.addEventListener("spree:load", function () {
|
2
2
|
const navWrapper = document.querySelectorAll('[data-nav-x-wrapper]')
|
3
3
|
navWrapper.forEach(el => initHorizontalNav(el))
|
4
4
|
})
|
@@ -16,7 +16,7 @@ function initHorizontalNav (containerEl) {
|
|
16
16
|
const navContent = navContainer.querySelector('[data-nav-x-content]')
|
17
17
|
const activeNavItem = navContent.querySelector('.active')
|
18
18
|
|
19
|
-
// Trigger on
|
19
|
+
// Trigger on spree:load
|
20
20
|
setOverscrollIndicators()
|
21
21
|
|
22
22
|
if (activeNavItem) focusActiveItem(navContainer, activeNavItem)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* global toggleItemEdit, order_number */
|
2
|
-
|
2
|
+
document.addEventListener("spree:load", function() {
|
3
3
|
// handle edit click
|
4
4
|
$('a.edit-line-item').click(toggleLineItemEdit)
|
5
5
|
// handle cancel click
|
@@ -37,19 +37,19 @@ function toggleLineItemEdit () {
|
|
37
37
|
|
38
38
|
function lineItemURL (lineItemId) {
|
39
39
|
// eslint-disable-next-line camelcase
|
40
|
-
return Spree.routes.
|
40
|
+
return Spree.routes.line_items_api_v2 + '/' + lineItemId
|
41
41
|
}
|
42
42
|
|
43
43
|
function adjustLineItem (lineItemId, quantity) {
|
44
44
|
$.ajax({
|
45
|
-
type: '
|
45
|
+
type: 'PATCH',
|
46
46
|
url: Spree.url(lineItemURL(lineItemId)),
|
47
47
|
data: {
|
48
48
|
line_item: {
|
49
49
|
quantity: quantity
|
50
|
-
}
|
51
|
-
|
52
|
-
|
50
|
+
}
|
51
|
+
},
|
52
|
+
headers: Spree.apiV2Authentication(),
|
53
53
|
}).done(function () {
|
54
54
|
window.Spree.advanceOrder()
|
55
55
|
})
|
@@ -59,9 +59,7 @@ function deleteLineItem (lineItemId) {
|
|
59
59
|
$.ajax({
|
60
60
|
type: 'DELETE',
|
61
61
|
url: Spree.url(lineItemURL(lineItemId)),
|
62
|
-
headers:
|
63
|
-
'X-Spree-Token': Spree.api_key
|
64
|
-
}
|
62
|
+
headers: Spree.apiV2Authentication(),
|
65
63
|
}).done(function () {
|
66
64
|
$('#line-item-' + lineItemId).remove()
|
67
65
|
if ($('.line-items tr.line-item').length === 0) {
|
@@ -1,15 +1,15 @@
|
|
1
|
-
/* global variantLineItemTemplate, order_number */
|
1
|
+
/* global variantLineItemTemplate, order_number, order_id */
|
2
2
|
// This file contains the code for interacting with line items in the manual cart
|
3
|
-
|
3
|
+
document.addEventListener("spree:load", function() {
|
4
4
|
'use strict'
|
5
5
|
|
6
6
|
// handle variant selection, show stock level.
|
7
7
|
$('#add_line_item_variant_id').change(function () {
|
8
|
-
var variantId = $(this).val()
|
8
|
+
var variantId = $(this).val().toString()
|
9
9
|
|
10
10
|
var variant = _.find(window.variants, function (variant) {
|
11
11
|
// eslint-disable-next-line eqeqeq
|
12
|
-
return variant.id == variantId
|
12
|
+
return variant.id.toString() == variantId
|
13
13
|
})
|
14
14
|
$('#stock_details').html(variantLineItemTemplate({ variant: variant }))
|
15
15
|
$('#stock_details').show()
|
@@ -20,33 +20,28 @@ $(document).ready(function () {
|
|
20
20
|
function addVariant () {
|
21
21
|
$('#stock_details').hide()
|
22
22
|
var variantId = $('select.variant_autocomplete').val()
|
23
|
-
var quantity = $('input#variant_quantity').val()
|
23
|
+
var quantity = parseInt($('input#variant_quantity').val())
|
24
24
|
|
25
|
-
adjustLineItems(
|
25
|
+
adjustLineItems(order_id, variantId, quantity)
|
26
26
|
return 1
|
27
27
|
}
|
28
28
|
|
29
|
-
adjustLineItems = function(
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
quantity: quantity
|
39
|
-
},
|
40
|
-
token: Spree.api_key
|
41
|
-
}
|
42
|
-
}).done(function () {
|
43
|
-
window.Spree.advanceOrder()
|
44
|
-
window.location.reload()
|
45
|
-
}).fail(function (msg) {
|
46
|
-
if (typeof msg.responseJSON.message != 'undefined') {
|
47
|
-
alert(msg.responseJSON.message)
|
48
|
-
} else {
|
49
|
-
alert(msg.responseJSON.exception)
|
29
|
+
adjustLineItems = function(order_id, variant_id, quantity){
|
30
|
+
$.ajax({
|
31
|
+
type: 'POST',
|
32
|
+
url: Spree.routes.line_items_api_v2,
|
33
|
+
data: {
|
34
|
+
line_item: {
|
35
|
+
order_id: order_id,
|
36
|
+
variant_id: variant_id,
|
37
|
+
quantity: quantity
|
50
38
|
}
|
51
|
-
}
|
39
|
+
},
|
40
|
+
headers: Spree.apiV2Authentication()
|
41
|
+
}).done(function () {
|
42
|
+
window.Spree.advanceOrder()
|
43
|
+
window.location.reload()
|
44
|
+
}).fail(function (response) {
|
45
|
+
show_flash('error', response.responseJSON.error)
|
46
|
+
})
|
52
47
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
//= require spree/backend
|
2
2
|
|
3
|
-
|
3
|
+
document.addEventListener("spree:load", function() {
|
4
4
|
$.expr[':'].Contains = function (a, i, m) {
|
5
5
|
return (
|
6
6
|
(a.textContent || a.innerText || '')
|
@@ -32,7 +32,7 @@ $(document).ready(function () {
|
|
32
32
|
}
|
33
33
|
|
34
34
|
// ondomready
|
35
|
-
|
35
|
+
document.addEventListener("spree:load", function() {
|
36
36
|
listFilter($('#variant-prices'))
|
37
37
|
})
|
38
38
|
})
|
@@ -24,7 +24,7 @@ $.fn.optionTypeAutocomplete = function () {
|
|
24
24
|
})
|
25
25
|
}
|
26
26
|
|
27
|
-
|
27
|
+
document.addEventListener("spree:load", function() {
|
28
28
|
var productOptionTypeSelector = document.getElementById('product_option_type_ids')
|
29
29
|
if (productOptionTypeSelector == null) return
|
30
30
|
if (productOptionTypeSelector.hasAttribute('data-autocomplete-url-value')) return
|