spree_backend 4.3.0 → 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/{prototypes.scss → _prototypes.scss} +0 -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/_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 +6 -2
- 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
@@ -1,5 +1,5 @@
|
|
1
1
|
/* global show_flash */
|
2
|
-
|
2
|
+
document.addEventListener("spree:load", function() {
|
3
3
|
var extend = function (child, parent) {
|
4
4
|
for (var key in parent) {
|
5
5
|
if (hasProp.call(parent, key)) child[key] = parent[key]
|
@@ -13,54 +13,61 @@ jQuery(function ($) {
|
|
13
13
|
return child
|
14
14
|
}
|
15
15
|
var hasProp = {}.hasOwnProperty
|
16
|
-
var EditPaymentView, Payment, PaymentView, ShowPaymentView
|
17
|
-
orderId = $('#payments').data('order-id')
|
16
|
+
var EditPaymentView, Payment, PaymentView, ShowPaymentView
|
18
17
|
Payment = (function () {
|
19
|
-
function Payment (
|
20
|
-
this.url = Spree.
|
21
|
-
this.json = $.
|
22
|
-
|
23
|
-
|
18
|
+
function Payment (id) {
|
19
|
+
this.url = Spree.routes.payments_api_v2 + '/' + id
|
20
|
+
this.json = $.ajax({
|
21
|
+
dataType: "json",
|
22
|
+
url: this.url,
|
23
|
+
headers: Spree.apiV2Authentication(),
|
24
|
+
success: function (data) {
|
25
|
+
this.data = data.data
|
26
|
+
}.bind(this)
|
27
|
+
})
|
24
28
|
this.updating = false
|
25
29
|
}
|
26
30
|
|
27
31
|
Payment.prototype.if_editable = function (callback) {
|
28
32
|
return this.json.done(function (data) {
|
29
33
|
var ref
|
30
|
-
if ((ref = data.state) === 'checkout' || ref === 'pending') {
|
34
|
+
if ((ref = data.data.attributes.state) === 'checkout' || ref === 'pending') {
|
31
35
|
return callback()
|
32
36
|
}
|
33
37
|
})
|
34
38
|
}
|
35
39
|
|
36
|
-
Payment.prototype.update = function (attributes) {
|
40
|
+
Payment.prototype.update = function (attributes, onDone) {
|
37
41
|
this.updating = true
|
38
42
|
var jqXHR = $.ajax({
|
39
|
-
type: '
|
40
|
-
url: this.url
|
43
|
+
type: 'PATCH',
|
44
|
+
url: this.url,
|
41
45
|
data: {
|
42
46
|
payment: attributes
|
43
|
-
}
|
47
|
+
},
|
48
|
+
headers: Spree.apiV2Authentication()
|
44
49
|
})
|
45
50
|
jqXHR.always(function () {
|
46
51
|
this.updating = false
|
47
52
|
}.bind(this))
|
48
53
|
jqXHR.done(function (data) {
|
49
|
-
this.data = data
|
54
|
+
this.data = data.data
|
55
|
+
onDone()
|
50
56
|
}.bind(this))
|
51
57
|
jqXHR.fail(function () {
|
52
58
|
var response = (jqXHR.responseJSON && jqXHR.responseJSON.error) || jqXHR.statusText
|
53
59
|
show_flash('error', response)
|
60
|
+
onDone()
|
54
61
|
})
|
55
62
|
return jqXHR
|
56
63
|
}
|
57
64
|
|
58
65
|
Payment.prototype.amount = function () {
|
59
|
-
return this.data.amount
|
66
|
+
return this.data.attributes.amount
|
60
67
|
}
|
61
68
|
|
62
69
|
Payment.prototype.display_amount = function () {
|
63
|
-
return this.data.display_amount
|
70
|
+
return this.data.attributes.display_amount
|
64
71
|
}
|
65
72
|
return Payment
|
66
73
|
})()
|
@@ -189,11 +196,14 @@ jQuery(function ($) {
|
|
189
196
|
|
190
197
|
EditPaymentView.prototype.save = function () {
|
191
198
|
if (!this.payment.updating) {
|
192
|
-
return this.payment.update(
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
199
|
+
return this.payment.update(
|
200
|
+
{
|
201
|
+
amount: this.$input().val()
|
202
|
+
},
|
203
|
+
function () {
|
204
|
+
this.show()
|
205
|
+
}.bind(this)
|
206
|
+
)
|
197
207
|
}
|
198
208
|
}
|
199
209
|
|
@@ -223,7 +233,7 @@ jQuery(function ($) {
|
|
223
233
|
})(PaymentView)
|
224
234
|
return $('.admin tr[data-hook=payments_row]').each(function () {
|
225
235
|
var $el = $(this)
|
226
|
-
var payment = new Payment($el.attr('data-
|
236
|
+
var payment = new Payment($el.attr('data-id'))
|
227
237
|
return payment.if_editable(function () {
|
228
238
|
return new ShowPaymentView($el, payment)
|
229
239
|
})
|
@@ -6,24 +6,21 @@ $.fn.productAutocomplete = function (options) {
|
|
6
6
|
var multiple = typeof (options.multiple) !== 'undefined' ? options.multiple : true
|
7
7
|
var values = typeof (options.values) !== 'undefined' ? options.values : null
|
8
8
|
|
9
|
-
function formatProductList(products) {
|
10
|
-
return products.map(function(obj) {
|
11
|
-
return { id: obj.id, text: obj.name }
|
12
|
-
})
|
13
|
-
}
|
14
|
-
|
15
9
|
function addOptions(select, values) {
|
16
10
|
$.ajax({
|
17
|
-
url: Spree.routes.
|
11
|
+
url: Spree.routes.products_api_v2,
|
18
12
|
dataType: 'json',
|
19
13
|
data: {
|
20
|
-
|
14
|
+
filter: {
|
21
15
|
id_in: values
|
22
16
|
},
|
23
|
-
|
24
|
-
|
17
|
+
fields: {
|
18
|
+
product: 'name'
|
19
|
+
}
|
20
|
+
},
|
21
|
+
headers: Spree.apiV2Authentication(),
|
25
22
|
}).then(function (data) {
|
26
|
-
select.addSelect2Options(data.
|
23
|
+
select.addSelect2Options(data.data)
|
27
24
|
})
|
28
25
|
}
|
29
26
|
|
@@ -31,28 +28,22 @@ $.fn.productAutocomplete = function (options) {
|
|
31
28
|
multiple: multiple,
|
32
29
|
minimumInputLength: 3,
|
33
30
|
ajax: {
|
34
|
-
url: Spree.routes.
|
31
|
+
url: Spree.routes.products_api_v2,
|
35
32
|
dataType: 'json',
|
36
33
|
data: function (params) {
|
37
34
|
return {
|
38
|
-
|
35
|
+
filter: {
|
39
36
|
name_or_master_sku_cont: params.term
|
40
37
|
},
|
41
|
-
|
42
|
-
|
38
|
+
fields: {
|
39
|
+
product: 'name'
|
40
|
+
}
|
43
41
|
}
|
44
42
|
},
|
43
|
+
headers: Spree.apiV2Authentication(),
|
45
44
|
processResults: function(data) {
|
46
|
-
|
47
|
-
var results = formatProductList(products)
|
48
|
-
|
49
|
-
return {
|
50
|
-
results: results
|
51
|
-
}
|
45
|
+
return formatSelect2Options(data)
|
52
46
|
}
|
53
|
-
},
|
54
|
-
templateSelection: function(data, _container) {
|
55
|
-
return data.text
|
56
47
|
}
|
57
48
|
})
|
58
49
|
|
@@ -61,6 +52,6 @@ $.fn.productAutocomplete = function (options) {
|
|
61
52
|
}
|
62
53
|
}
|
63
54
|
|
64
|
-
|
55
|
+
document.addEventListener("spree:load", function() {
|
65
56
|
$('.product_picker').productAutocomplete()
|
66
57
|
})
|
@@ -1,8 +1,10 @@
|
|
1
|
-
|
1
|
+
document.addEventListener("spree:load", function() {
|
2
2
|
$(document).ajaxStart(function () {
|
3
|
-
|
3
|
+
Turbo.navigator.delegate.adapter.progressBar.setValue(0)
|
4
|
+
Turbo.navigator.delegate.adapter.progressBar.show()
|
4
5
|
})
|
5
6
|
$(document).ajaxStop(function () {
|
6
|
-
|
7
|
+
Turbo.navigator.delegate.adapter.progressBar.setValue(1)
|
8
|
+
Turbo.navigator.delegate.adapter.progressBar.hide()
|
7
9
|
})
|
8
10
|
})
|
@@ -16,10 +16,12 @@ function initProductActions () {
|
|
16
16
|
$warning.hide()
|
17
17
|
$settings.show()
|
18
18
|
$settings.find('input').removeProp('disabled')
|
19
|
+
$settings.find('select').removeProp('disabled')
|
19
20
|
} else {
|
20
21
|
$warning.show()
|
21
22
|
$settings.hide()
|
22
23
|
$settings.find('input').prop('disabled', 'disabled')
|
24
|
+
$settings.find('select').prop('disabled', 'disabled')
|
23
25
|
}
|
24
26
|
})
|
25
27
|
})
|
@@ -161,7 +163,7 @@ function initProductActions () {
|
|
161
163
|
})()
|
162
164
|
}
|
163
165
|
|
164
|
-
|
166
|
+
document.addEventListener("spree:load", function() {
|
165
167
|
var promotion_form = $('form.edit_promotion')
|
166
168
|
|
167
169
|
if (promotion_form.length) {
|
@@ -1,13 +1,13 @@
|
|
1
|
-
/* global shipments, variantStockTemplate, order_number */
|
1
|
+
/* global shipments, variantStockTemplate, order_number, order_id */
|
2
2
|
// Shipments AJAX API
|
3
|
-
|
3
|
+
document.addEventListener("spree:load", function() {
|
4
4
|
'use strict'
|
5
5
|
|
6
6
|
// handle variant selection, show stock level.
|
7
7
|
$('#add_variant_id').change(function () {
|
8
|
-
var variantId =
|
8
|
+
var variantId = $(this).val().toString()
|
9
9
|
var variant = _.find(window.variants, function (variant) {
|
10
|
-
return variant.id === variantId
|
10
|
+
return variant.id.toString() === variantId
|
11
11
|
})
|
12
12
|
|
13
13
|
$('#stock_details').html(variantStockTemplate({ variant: variant }))
|
@@ -45,22 +45,23 @@ $(document).ready(function () {
|
|
45
45
|
var shipmentNumber = del.data('shipment-number')
|
46
46
|
var variantId = del.data('variant-id')
|
47
47
|
// eslint-disable-next-line
|
48
|
-
var
|
49
|
-
var url = Spree.routes.shipments_api + '/' + shipmentNumber + '/remove'
|
48
|
+
var url = Spree.routes.shipments_api_v2 + '/' + shipmentNumber + '/remove_item'
|
50
49
|
|
51
50
|
toggleItemEdit()
|
52
51
|
|
53
52
|
$.ajax({
|
54
|
-
type: '
|
53
|
+
type: 'PATCH',
|
55
54
|
url: Spree.url(url),
|
56
55
|
data: {
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
shipment: {
|
57
|
+
variant_id: variantId
|
58
|
+
}
|
59
|
+
},
|
60
|
+
headers: Spree.apiV2Authentication()
|
60
61
|
}).done(function (msg) {
|
61
62
|
window.location.reload()
|
62
63
|
}).fail(function (msg) {
|
63
|
-
alert(msg.responseJSON.
|
64
|
+
alert(msg.responseJSON.error)
|
64
65
|
})
|
65
66
|
}
|
66
67
|
return false
|
@@ -69,18 +70,15 @@ $(document).ready(function () {
|
|
69
70
|
// handle ship click
|
70
71
|
$('[data-hook=admin_shipment_form] a.ship').on('click', function () {
|
71
72
|
var link = $(this)
|
72
|
-
var
|
73
|
-
var url = Spree.url(Spree.routes.shipments_api + '/' + shipmentNumber + '/ship.json')
|
73
|
+
var url = Spree.url(Spree.routes.shipments_api_v2 + '/' + link.data('shipment-number') + '/ship')
|
74
74
|
$.ajax({
|
75
|
-
type: '
|
75
|
+
type: 'PATCH',
|
76
76
|
url: url,
|
77
|
-
|
78
|
-
token: Spree.api_key
|
79
|
-
}
|
77
|
+
headers: Spree.apiV2Authentication()
|
80
78
|
}).done(function () {
|
81
79
|
window.location.reload()
|
82
80
|
}).fail(function (msg) {
|
83
|
-
alert(msg.responseJSON.
|
81
|
+
alert(msg.responseJSON.error)
|
84
82
|
})
|
85
83
|
})
|
86
84
|
|
@@ -96,22 +94,22 @@ $(document).ready(function () {
|
|
96
94
|
var shipmentNumber = link.data('shipment-number')
|
97
95
|
var selectedShippingRateId = link.parents('tbody').find("select#selected_shipping_rate_id[data-shipment-number='" + shipmentNumber + "']").val()
|
98
96
|
var unlock = link.parents('tbody').find("input[name='open_adjustment'][data-shipment-number='" + shipmentNumber + "']:checked").val()
|
99
|
-
var url = Spree.url(Spree.routes.
|
97
|
+
var url = Spree.url(Spree.routes.shipments_api_v2 + '/' + shipmentNumber + '.json')
|
100
98
|
|
101
99
|
$.ajax({
|
102
|
-
type: '
|
100
|
+
type: 'PATCH',
|
103
101
|
url: url,
|
104
102
|
data: {
|
105
103
|
shipment: {
|
106
104
|
selected_shipping_rate_id: selectedShippingRateId,
|
107
105
|
unlock: unlock
|
108
106
|
},
|
109
|
-
|
110
|
-
|
107
|
+
},
|
108
|
+
headers: Spree.apiV2Authentication()
|
111
109
|
}).done(function () {
|
112
110
|
window.location.reload()
|
113
111
|
}).fail(function (msg) {
|
114
|
-
alert(msg.responseJSON.
|
112
|
+
alert(msg.responseJSON.error)
|
115
113
|
})
|
116
114
|
})
|
117
115
|
|
@@ -128,16 +126,11 @@ $(document).ready(function () {
|
|
128
126
|
$('a.cancel-tracking').click(toggleTrackingEdit)
|
129
127
|
|
130
128
|
function createTrackingValueContent(data) {
|
131
|
-
|
132
|
-
return
|
133
|
-
})[0]
|
134
|
-
|
135
|
-
if (selectedShippingMethod && selectedShippingMethod.tracking_url) {
|
136
|
-
var shipmentTrackingUrl = selectedShippingMethod.tracking_url.replace(/:tracking/, data.tracking)
|
137
|
-
return '<a target="_blank" href="' + shipmentTrackingUrl + '">' + data.tracking + '<a>'
|
129
|
+
if (data.attributes.tracking_url && data.attributes.tracking) {
|
130
|
+
return '<a target="_blank" href="' + data.attributes.tracking_url + '">' + data.attributes.tracking + '<a>'
|
138
131
|
}
|
139
132
|
|
140
|
-
return data.tracking
|
133
|
+
return data.attributes.tracking
|
141
134
|
}
|
142
135
|
|
143
136
|
// handle tracking save
|
@@ -147,25 +140,25 @@ $(document).ready(function () {
|
|
147
140
|
var link = $(this)
|
148
141
|
var shipmentNumber = link.data('shipment-number')
|
149
142
|
var tracking = link.parents('tbody').find('input#tracking').val()
|
150
|
-
var url = Spree.url(Spree.routes.
|
143
|
+
var url = Spree.url(Spree.routes.shipments_api_v2 + '/' + shipmentNumber + '.json')
|
151
144
|
|
152
145
|
$.ajax({
|
153
|
-
type: '
|
146
|
+
type: 'PATCH',
|
154
147
|
url: url,
|
155
148
|
data: {
|
156
149
|
shipment: {
|
157
150
|
tracking: tracking
|
158
|
-
}
|
159
|
-
|
160
|
-
|
161
|
-
}).done(function (
|
151
|
+
}
|
152
|
+
},
|
153
|
+
headers: Spree.apiV2Authentication()
|
154
|
+
}).done(function (json) {
|
162
155
|
link.parents('tbody').find('tr.edit-tracking').toggle()
|
163
156
|
|
164
157
|
var show = link.parents('tbody').find('tr.show-tracking')
|
165
158
|
show.toggle()
|
166
159
|
|
167
|
-
if (data.tracking) {
|
168
|
-
show.find('.tracking-value').html($('<strong>').html(Spree.translations.tracking + ': ')).append(createTrackingValueContent(data))
|
160
|
+
if (json.data.attributes.tracking) {
|
161
|
+
show.find('.tracking-value').html($('<strong>').html(Spree.translations.tracking + ': ')).append(createTrackingValueContent(json.data))
|
169
162
|
} else {
|
170
163
|
show.find('.tracking-value').html(Spree.translations.no_tracking_present)
|
171
164
|
}
|
@@ -176,34 +169,36 @@ $(document).ready(function () {
|
|
176
169
|
function adjustShipmentItems(shipmentNumber, variantId, quantity) {
|
177
170
|
var shipment = _.findWhere(shipments, { number: shipmentNumber + '' })
|
178
171
|
var inventoryUnits = _.where(shipment.inventory_units, { variant_id: variantId })
|
179
|
-
var url = Spree.routes.
|
172
|
+
var url = Spree.routes.shipments_api_v2 + '/' + shipmentNumber
|
180
173
|
var previousQuantity = inventoryUnits.reduce(function (accumulator, currentUnit, _index, _array) {
|
181
174
|
return accumulator + currentUnit.quantity
|
182
175
|
}, 0)
|
183
176
|
var newQuantity = 0
|
184
177
|
|
185
178
|
if (previousQuantity < quantity) {
|
186
|
-
url += '/
|
179
|
+
url += '/add_item'
|
187
180
|
newQuantity = (quantity - previousQuantity)
|
188
181
|
} else if (previousQuantity > quantity) {
|
189
|
-
url += '/
|
182
|
+
url += '/remove_item'
|
190
183
|
newQuantity = (previousQuantity - quantity)
|
191
184
|
}
|
192
185
|
url += '.json'
|
193
186
|
|
194
187
|
if (newQuantity !== 0) {
|
195
188
|
$.ajax({
|
196
|
-
type: '
|
189
|
+
type: 'PATCH',
|
197
190
|
url: Spree.url(url),
|
198
191
|
data: {
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
192
|
+
shipment: {
|
193
|
+
variant_id: variantId,
|
194
|
+
quantity: newQuantity,
|
195
|
+
}
|
196
|
+
},
|
197
|
+
headers: Spree.apiV2Authentication()
|
203
198
|
}).done(function (msg) {
|
204
199
|
window.location.reload()
|
205
200
|
}).fail(function (msg) {
|
206
|
-
alert(msg.responseJSON.
|
201
|
+
alert(msg.responseJSON.error)
|
207
202
|
})
|
208
203
|
}
|
209
204
|
}
|
@@ -245,26 +240,28 @@ function startItemSplit(event) {
|
|
245
240
|
$.ajax({
|
246
241
|
type: 'GET',
|
247
242
|
async: false,
|
248
|
-
url: Spree.
|
243
|
+
url: Spree.routes.variants_api_v2 + '/' + variantId,
|
249
244
|
data: {
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
245
|
+
include: 'stock_items.stock_location'
|
246
|
+
},
|
247
|
+
headers: Spree.apiV2Authentication()
|
248
|
+
}).done(function (json) {
|
249
|
+
var JSONAPIDeserializer = require('jsonapi-serializer').Deserializer
|
250
|
+
new JSONAPIDeserializer({ keyForAttribute: 'snake_case' }).deserialize(json, function (_err, deserializedJson) {
|
251
|
+
variant = deserializedJson
|
252
|
+
|
253
|
+
var maxQuantity = link.closest('tr').data('item-quantity')
|
254
|
+
var splitItemTemplate = Handlebars.compile($('#variant_split_template').text())
|
255
|
+
|
256
|
+
link.closest('tr').after(splitItemTemplate({ variant: variant, shipments: shipments, max_quantity: maxQuantity }))
|
257
|
+
$('a.cancel-split').click(cancelItemSplit)
|
258
|
+
$('a.save-split').click(completeItemSplit)
|
259
|
+
|
260
|
+
$('#item_stock_location').select2({ width: 'resolve', placeholder: Spree.translations.item_stock_placeholder })
|
261
|
+
})
|
257
262
|
}).fail(function (msg) {
|
258
|
-
alert(msg.responseJSON.
|
263
|
+
alert(msg.responseJSON.error)
|
259
264
|
})
|
260
|
-
|
261
|
-
var maxQuantity = link.closest('tr').data('item-quantity')
|
262
|
-
var splitItemTemplate = Handlebars.compile($('#variant_split_template').text())
|
263
|
-
link.closest('tr').after(splitItemTemplate({ variant: variant, shipments: shipments, max_quantity: maxQuantity }))
|
264
|
-
$('a.cancel-split').click(cancelItemSplit)
|
265
|
-
$('a.save-split').click(completeItemSplit)
|
266
|
-
|
267
|
-
$('#item_stock_location').select2({ width: 'resolve', placeholder: Spree.translations.item_stock_placeholder })
|
268
265
|
}
|
269
266
|
|
270
267
|
function completeItemSplit(event) {
|
@@ -301,19 +298,20 @@ function completeItemSplit(event) {
|
|
301
298
|
}
|
302
299
|
|
303
300
|
var data = {
|
304
|
-
original_shipment_number: originalShipmentNumber,
|
305
301
|
variant_id: variantId,
|
306
|
-
quantity: quantity
|
307
|
-
token: Spree.api_key
|
302
|
+
quantity: quantity
|
308
303
|
}
|
309
304
|
|
310
305
|
$.ajax({
|
311
|
-
type: '
|
306
|
+
type: 'PATCH',
|
312
307
|
async: false,
|
313
|
-
url: Spree.url(Spree.routes.
|
314
|
-
data:
|
308
|
+
url: Spree.url(Spree.routes.shipments_api_v2 + '/' + originalShipmentNumber + path),
|
309
|
+
data: {
|
310
|
+
shipment: $.extend(data, additionalData)
|
311
|
+
},
|
312
|
+
headers: Spree.apiV2Authentication()
|
315
313
|
}).fail(function (msg) {
|
316
|
-
alert(msg.responseJSON.
|
314
|
+
alert(msg.responseJSON.error)
|
317
315
|
}).done(function (msg) {
|
318
316
|
window.location.reload()
|
319
317
|
})
|
@@ -347,17 +345,20 @@ function addVariantFromStockLocation(event) {
|
|
347
345
|
$.ajax({
|
348
346
|
type: 'POST',
|
349
347
|
// eslint-disable-next-line camelcase
|
350
|
-
url: Spree.
|
348
|
+
url: Spree.routes.shipments_api_v2,
|
351
349
|
data: {
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
350
|
+
shipment: {
|
351
|
+
order_id: order_id,
|
352
|
+
variant_id: variantId,
|
353
|
+
quantity: quantity,
|
354
|
+
stock_location_id: stockLocationId
|
355
|
+
}
|
356
|
+
},
|
357
|
+
headers: Spree.apiV2Authentication()
|
357
358
|
}).done(function (msg) {
|
358
359
|
window.location.reload()
|
359
360
|
}).fail(function (msg) {
|
360
|
-
alert(msg.responseJSON.
|
361
|
+
alert(msg.responseJSON.error)
|
361
362
|
})
|
362
363
|
} else {
|
363
364
|
// add to existing shipment
|
@@ -1,4 +1,4 @@
|
|
1
|
-
document.addEventListener(
|
1
|
+
document.addEventListener("spree:load", function() {
|
2
2
|
// Initiate a standard Select2 on any select element with the class .select2
|
3
3
|
// Remember to add a place holder in the HTML as needed.
|
4
4
|
$('select.select2').select2({})
|
@@ -1,18 +1,48 @@
|
|
1
1
|
/* global variantTemplate */
|
2
|
-
|
2
|
+
document.addEventListener("spree:load", function() {
|
3
3
|
var el = $('#stock_movement_stock_item_id')
|
4
|
+
var jsonApiVariants = {}
|
4
5
|
el.select2({
|
5
6
|
placeholder: 'Find a stock item', // translate
|
7
|
+
minimumInputLength: 3,
|
8
|
+
quietMillis: 200,
|
6
9
|
ajax: {
|
7
|
-
url: Spree.
|
8
|
-
data: function (
|
10
|
+
url: Spree.routes.stock_items_api_v2,
|
11
|
+
data: function (params, page) {
|
9
12
|
return {
|
10
|
-
|
11
|
-
variant_product_name_cont: term
|
13
|
+
filter: {
|
14
|
+
variant_product_name_cont: params.term,
|
15
|
+
stock_location_id_eq: el.data('stock-location-id')
|
16
|
+
},
|
17
|
+
include: 'variant',
|
18
|
+
image_transformation: {
|
19
|
+
size: '100x100'
|
20
|
+
},
|
21
|
+
fields: {
|
22
|
+
'variant': 'name,sku,options_text,images'
|
12
23
|
},
|
13
24
|
per_page: 50,
|
14
|
-
page: page
|
15
|
-
|
25
|
+
page: page
|
26
|
+
}
|
27
|
+
},
|
28
|
+
headers: Spree.apiV2Authentication(),
|
29
|
+
success: function(data) {
|
30
|
+
var JSONAPIDeserializer = require('jsonapi-serializer').Deserializer
|
31
|
+
new JSONAPIDeserializer({ keyForAttribute: 'snake_case' }).deserialize(data, function (_err, variants) {
|
32
|
+
jsonApiVariants = variants
|
33
|
+
})
|
34
|
+
},
|
35
|
+
processResults: function (json) {
|
36
|
+
var res = jsonApiVariants.map(function (stockItem) {
|
37
|
+
return {
|
38
|
+
id: stockItem.id,
|
39
|
+
text: stockItem.variant.name,
|
40
|
+
variant: stockItem.variant
|
41
|
+
}
|
42
|
+
})
|
43
|
+
|
44
|
+
return {
|
45
|
+
results: res
|
16
46
|
}
|
17
47
|
},
|
18
48
|
results: function (data, page) {
|
@@ -23,13 +53,28 @@ $(function () {
|
|
23
53
|
}
|
24
54
|
}
|
25
55
|
},
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
}
|
56
|
+
templateResult: function (stockItem) {
|
57
|
+
if (stockItem.loading) {
|
58
|
+
return stockItem.text
|
59
|
+
}
|
60
|
+
|
61
|
+
let variant = stockItem.variant
|
62
|
+
if (variant['images'][0] !== undefined && variant['images'][0].transformed_url !== undefined) {
|
63
|
+
variant.image = variant.images[0].transformed_url
|
64
|
+
}
|
65
|
+
return $(variantTemplate({
|
66
|
+
variant: variant
|
67
|
+
}))
|
30
68
|
},
|
31
|
-
|
32
|
-
|
69
|
+
templateSelection: function(stockItem) {
|
70
|
+
const variant = stockItem.variant
|
71
|
+
if (variant === undefined) {
|
72
|
+
return stockItem.text
|
73
|
+
} else if (!!variant.options_text && variant.options_text !== '') {
|
74
|
+
return variant.name + '(' + variant.options_text + ')'
|
75
|
+
} else {
|
76
|
+
return variant.name
|
77
|
+
}
|
33
78
|
}
|
34
79
|
})
|
35
80
|
})
|