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
|
-
|
1
|
+
document.addEventListener("spree:load", function() {
|
2
2
|
function TransferVariant (variant1) {
|
3
3
|
// refactor variant1
|
4
4
|
this.variant = variant1
|
@@ -16,13 +16,26 @@ $(function () {
|
|
16
16
|
this.destination = $('#transfer_destination_location_id')
|
17
17
|
this.source.change(this.populate_destination.bind(this))
|
18
18
|
$('#transfer_receive_stock').change(this.receive_stock_change.bind(this))
|
19
|
-
|
19
|
+
|
20
|
+
$.ajax({
|
21
|
+
url: Spree.routes.stock_locations_api_v2 + '?per_page=1000',
|
22
|
+
type: 'GET',
|
23
|
+
data: {
|
24
|
+
fields: {
|
25
|
+
stock_location: 'name'
|
26
|
+
}
|
27
|
+
},
|
28
|
+
headers: Spree.apiV2Authentication()
|
29
|
+
}).then(function (json) {
|
20
30
|
this.locations = (function () {
|
21
|
-
var ref = data
|
31
|
+
var ref = json.data
|
22
32
|
var results = []
|
23
33
|
var i, len
|
24
34
|
for (i = 0, len = ref.length; i < len; i++) {
|
25
|
-
results.push(
|
35
|
+
results.push({
|
36
|
+
id: ref[i].id,
|
37
|
+
name: ref[i].attributes.name
|
38
|
+
})
|
26
39
|
}
|
27
40
|
return results
|
28
41
|
})()
|
@@ -73,7 +86,7 @@ $(function () {
|
|
73
86
|
if (this.is_source_location_hidden()) {
|
74
87
|
return this.populate_select(this.destination)
|
75
88
|
} else {
|
76
|
-
return this.populate_select(this.destination,
|
89
|
+
return this.populate_select(this.destination, this.source.val())
|
77
90
|
}
|
78
91
|
}
|
79
92
|
|
@@ -110,12 +123,12 @@ $(function () {
|
|
110
123
|
}
|
111
124
|
|
112
125
|
TransferVariants.prototype._search_transfer_variants = function () {
|
113
|
-
return this.build_select(Spree.url(Spree.routes.
|
126
|
+
return this.build_select(Spree.url(Spree.routes.variants_api_v2), 'product_name_or_sku_cont')
|
114
127
|
}
|
115
128
|
|
116
129
|
TransferVariants.prototype._search_transfer_stock_items = function () {
|
117
130
|
var stockLocationId = $('#transfer_source_location_id').val()
|
118
|
-
return this.build_select(Spree.
|
131
|
+
return this.build_select(Spree.routes.stock_items_api_v2 + '?filter[stock_location_id_eq]=' + stockLocationId + '&include=variant', 'variant_product_name_or_variant_sku_cont')
|
119
132
|
}
|
120
133
|
|
121
134
|
TransferVariants.prototype.format_variant_result = function (result) {
|
@@ -128,11 +141,14 @@ $(function () {
|
|
128
141
|
}
|
129
142
|
|
130
143
|
function formattedVariantList(obj) {
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
144
|
+
return {
|
145
|
+
id: obj.id,
|
146
|
+
text: obj.name,
|
147
|
+
name: obj.name,
|
148
|
+
sku: obj.sku,
|
149
|
+
options_text: obj.options_text,
|
150
|
+
variant: obj
|
151
|
+
}
|
136
152
|
}
|
137
153
|
|
138
154
|
TransferVariants.prototype.build_select = function (url, query) {
|
@@ -142,27 +158,40 @@ $(function () {
|
|
142
158
|
url: url,
|
143
159
|
datatype: 'json',
|
144
160
|
data: function (params) {
|
145
|
-
var
|
146
|
-
|
161
|
+
var filter = {}
|
162
|
+
filter[query] = params.term
|
163
|
+
|
147
164
|
return {
|
148
|
-
|
149
|
-
|
165
|
+
filter: filter,
|
166
|
+
fields: {
|
167
|
+
'variant': 'name,sku,options_text'
|
168
|
+
}
|
150
169
|
}
|
151
170
|
},
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
}
|
162
|
-
}
|
171
|
+
headers: Spree.apiV2Authentication(),
|
172
|
+
success: function(data) {
|
173
|
+
var JSONAPIDeserializer = require('jsonapi-serializer').Deserializer
|
174
|
+
new JSONAPIDeserializer({ keyForAttribute: 'snake_case' }).deserialize(data, function (_err, variants) {
|
175
|
+
jsonApiVariants = variants
|
176
|
+
})
|
177
|
+
},
|
178
|
+
processResults: function (json) {
|
179
|
+
if (json && json.data && jsonApiVariants) {
|
180
|
+
var res = {}
|
163
181
|
|
164
|
-
|
165
|
-
|
182
|
+
if (json.links.self.match(/platform\/variants/)) {
|
183
|
+
res = jsonApiVariants.map(function (variant) {
|
184
|
+
return formattedVariantList(variant)
|
185
|
+
})
|
186
|
+
} else {
|
187
|
+
res = jsonApiVariants.map(function (variant) {
|
188
|
+
return formattedVariantList(variant.variant)
|
189
|
+
})
|
190
|
+
}
|
191
|
+
|
192
|
+
return {
|
193
|
+
results: res
|
194
|
+
}
|
166
195
|
}
|
167
196
|
}
|
168
197
|
},
|
@@ -218,7 +247,7 @@ $(function () {
|
|
218
247
|
|
219
248
|
TransferAddVariants.prototype.find_or_add = function (variant) {
|
220
249
|
var existing = _.find(this.variants, function (v) {
|
221
|
-
return v.id === variant.id
|
250
|
+
return v.id.toString() === variant[0].id
|
222
251
|
})
|
223
252
|
if (existing) {
|
224
253
|
return existing
|
@@ -231,14 +260,15 @@ $(function () {
|
|
231
260
|
|
232
261
|
TransferAddVariants.prototype.remove_variant = function (target) {
|
233
262
|
var v
|
234
|
-
var variantId =
|
263
|
+
var variantId = target.data('variantId').toString()
|
264
|
+
|
235
265
|
this.variants = (function () {
|
236
266
|
var ref = this.variants
|
237
267
|
var results = []
|
238
268
|
var i, len
|
239
269
|
for (i = 0, len = ref.length; i < len; i++) {
|
240
270
|
v = ref[i]
|
241
|
-
if (v.id !== variantId) {
|
271
|
+
if (v.id.toString() !== variantId) {
|
242
272
|
results.push(v)
|
243
273
|
}
|
244
274
|
}
|
@@ -2,12 +2,10 @@ $.fn.taxonAutocomplete = function() {
|
|
2
2
|
'use strict'
|
3
3
|
|
4
4
|
function formatTaxonList(values) {
|
5
|
-
console.warn('taxonAutocomplete is deprecated and will be removed in Spree 5.0')
|
6
|
-
|
7
5
|
return values.map(function (obj) {
|
8
6
|
return {
|
9
7
|
id: obj.id,
|
10
|
-
text: obj.pretty_name
|
8
|
+
text: obj.attributes.pretty_name
|
11
9
|
}
|
12
10
|
})
|
13
11
|
}
|
@@ -17,26 +15,29 @@ $.fn.taxonAutocomplete = function() {
|
|
17
15
|
placeholder: Spree.translations.taxon_placeholder,
|
18
16
|
minimumInputLength: 2,
|
19
17
|
ajax: {
|
20
|
-
url: Spree.routes.
|
18
|
+
url: Spree.routes.taxons_api_v2,
|
21
19
|
dataType: 'json',
|
22
20
|
data: function (params) {
|
23
21
|
return {
|
24
|
-
|
22
|
+
filter: {
|
25
23
|
name_cont: params.term
|
26
24
|
},
|
27
|
-
|
25
|
+
fields: {
|
26
|
+
taxon: 'pretty_name'
|
27
|
+
}
|
28
28
|
}
|
29
29
|
},
|
30
|
+
headers: Spree.apiV2Authentication(),
|
30
31
|
processResults: function(data) {
|
31
32
|
return {
|
32
|
-
results: formatTaxonList(data.
|
33
|
+
results: formatTaxonList(data.data)
|
33
34
|
}
|
34
35
|
}
|
35
36
|
}
|
36
37
|
})
|
37
38
|
}
|
38
39
|
|
39
|
-
|
40
|
+
document.addEventListener("spree:load", function() {
|
40
41
|
var productTaxonSelector = document.getElementById('product_taxon_ids')
|
41
42
|
if (productTaxonSelector == null) return
|
42
43
|
if (productTaxonSelector.hasAttribute('data-autocomplete-url-value')) return
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/* global productTemplate */
|
2
|
-
|
2
|
+
document.addEventListener("spree:load", function() {
|
3
3
|
window.productTemplate = Handlebars.compile($('#product_template').text())
|
4
4
|
var taxonProducts = $('#taxon_products')
|
5
5
|
var taxonId = $('#taxon_id')
|
@@ -14,23 +14,26 @@ $(function () {
|
|
14
14
|
swapThreshold: 0.9,
|
15
15
|
forceFallback: true,
|
16
16
|
onEnd: function (evt) {
|
17
|
-
|
18
|
-
var newIndex = evt.newIndex
|
19
|
-
return $.ajax({
|
20
|
-
url: Spree.routes.classifications_api_v2 + '/' + classificationId.toString() + '/reposition',
|
21
|
-
headers: Spree.apiV2Authentication(),
|
22
|
-
method: 'PUT',
|
23
|
-
dataType: 'json',
|
24
|
-
data: {
|
25
|
-
classification: {
|
26
|
-
position: newIndex
|
27
|
-
}
|
28
|
-
}
|
29
|
-
})
|
17
|
+
handleClassificationReposition(evt)
|
30
18
|
}
|
31
19
|
})
|
32
20
|
}
|
33
21
|
|
22
|
+
function handleClassificationReposition(evt) {
|
23
|
+
var classificationId = evt.item.getAttribute('data-classification-id')
|
24
|
+
var data = {
|
25
|
+
classification: {
|
26
|
+
position: parseInt(evt.newIndex, 10) + 1
|
27
|
+
}
|
28
|
+
}
|
29
|
+
var requestData = {
|
30
|
+
uri: Spree.routes.classifications_api_v2 + '/' + classificationId,
|
31
|
+
method: 'PATCH',
|
32
|
+
dataBody: data,
|
33
|
+
}
|
34
|
+
spreeFetchRequest(requestData)
|
35
|
+
}
|
36
|
+
|
34
37
|
if (taxonId.length > 0) {
|
35
38
|
taxonId.select2({
|
36
39
|
placeholder: Spree.translations.find_a_taxon,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
/* global variantTemplate */
|
2
2
|
// variant autocompletion
|
3
|
-
|
3
|
+
document.addEventListener("spree:load", function() {
|
4
4
|
var variantAutocompleteTemplate = $('#variant_autocomplete_template')
|
5
5
|
if (variantAutocompleteTemplate.length > 0) {
|
6
6
|
window.variantTemplate = Handlebars.compile(variantAutocompleteTemplate.text())
|
@@ -14,8 +14,8 @@ function formatVariantResult(variant) {
|
|
14
14
|
return variant.text
|
15
15
|
}
|
16
16
|
|
17
|
-
if (variant['images'][0] !== undefined && variant['images'][0].
|
18
|
-
variant.image = variant.images[0].
|
17
|
+
if (variant['images'][0] !== undefined && variant['images'][0].transformed_url !== undefined) {
|
18
|
+
variant.image = variant.images[0].transformed_url
|
19
19
|
}
|
20
20
|
return $(variantTemplate({
|
21
21
|
variant: variant
|
@@ -30,23 +30,31 @@ $.fn.variantAutocomplete = function () {
|
|
30
30
|
minimumInputLength: 3,
|
31
31
|
quietMillis: 200,
|
32
32
|
ajax: {
|
33
|
-
url: Spree.url(Spree.routes.
|
33
|
+
url: Spree.url(Spree.routes.variants_api_v2),
|
34
34
|
dataType: 'json',
|
35
35
|
data: function (params) {
|
36
36
|
var query = {
|
37
|
-
|
37
|
+
filter: {
|
38
38
|
search_by_product_name_or_sku: params.term
|
39
39
|
},
|
40
|
-
|
40
|
+
include: 'images,stock_items.stock_location',
|
41
|
+
image_transformation: {
|
42
|
+
size: '100x100'
|
43
|
+
}
|
41
44
|
}
|
42
45
|
|
43
46
|
return query;
|
44
47
|
},
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
headers: Spree.apiV2Authentication(),
|
49
|
+
success: function(data) {
|
50
|
+
var JSONAPIDeserializer = require('jsonapi-serializer').Deserializer
|
51
|
+
new JSONAPIDeserializer({ keyForAttribute: 'snake_case' }).deserialize(data, function (_err, variants) {
|
52
|
+
jsonApiVariants = variants
|
53
|
+
window.variants = variants
|
54
|
+
})
|
55
|
+
},
|
56
|
+
processResults: function (_data) {
|
57
|
+
return { results: jsonApiVariants } // we need to return deserialized json api data
|
50
58
|
}
|
51
59
|
},
|
52
60
|
templateResult: formatVariantResult,
|
@@ -1,21 +1,13 @@
|
|
1
|
-
//= require modernizr
|
2
1
|
//= require purify
|
3
2
|
//= require sortable
|
4
|
-
//= require flatpickr
|
5
3
|
//= require jquery3
|
6
|
-
//= require popper
|
7
|
-
//= require bootstrap-sprockets
|
8
4
|
//= require handlebars
|
9
5
|
//= require cleave
|
10
|
-
//= require js.cookie
|
11
|
-
//= require jquery.jstree/jquery.jstree
|
12
6
|
//= require jquery_ujs
|
13
7
|
//= require jquery-ui/widgets/autocomplete
|
14
8
|
//= require select2-full
|
15
9
|
//= require sweetalert2
|
16
10
|
//= require tinymce
|
17
|
-
//= require spree/backend/global/tinymce
|
18
|
-
|
19
11
|
//= require underscore-min.js
|
20
12
|
//= require jsonapi-serializer.min
|
21
13
|
|
@@ -53,9 +45,6 @@
|
|
53
45
|
//= require spree/backend/stock_movement
|
54
46
|
//= require spree/backend/stock_transfer
|
55
47
|
//= require spree/backend/taxon_autocomplete
|
56
|
-
//= require spree/backend/taxon_permalink_preview
|
57
|
-
//= require spree/backend/taxon_tree_menu
|
58
|
-
//= require spree/backend/taxonomy
|
59
48
|
//= require spree/backend/taxons
|
60
49
|
//= require spree/backend/users/edit
|
61
50
|
//= require spree/backend/user_picker
|
@@ -64,47 +53,38 @@
|
|
64
53
|
//= require spree/backend/zone
|
65
54
|
|
66
55
|
Spree.routes.clear_cache = Spree.adminPathFor('general_settings/clear_cache')
|
67
|
-
Spree.routes.checkouts_api = Spree.pathFor('api/v1/checkouts')
|
68
|
-
Spree.routes.classifications_api = Spree.pathFor('api/v1/classifications')
|
69
|
-
Spree.routes.option_types_api = Spree.pathFor('api/v1/option_types')
|
70
|
-
Spree.routes.option_values_api = Spree.pathFor('api/v1/option_values')
|
71
|
-
Spree.routes.orders_api = Spree.pathFor('api/v1/orders')
|
72
|
-
Spree.routes.products_api = Spree.pathFor('api/v1/products')
|
73
|
-
Spree.routes.shipments_api = Spree.pathFor('api/v1/shipments')
|
74
|
-
Spree.routes.checkouts_api = Spree.pathFor('api/v1/checkouts')
|
75
|
-
Spree.routes.stock_locations_api = Spree.pathFor('api/v1/stock_locations')
|
76
|
-
Spree.routes.taxon_products_api = Spree.pathFor('api/v1/taxons/products')
|
77
|
-
Spree.routes.taxons_api = Spree.pathFor('api/v1/taxons')
|
78
|
-
Spree.routes.users_api = Spree.pathFor('api/v1/users')
|
79
|
-
Spree.routes.variants_api = Spree.pathFor('api/v1/variants')
|
80
56
|
|
81
57
|
Spree.routes.edit_product = function (productId) {
|
82
58
|
return Spree.adminPathFor('products/' + productId + '/edit')
|
83
59
|
}
|
84
|
-
|
85
|
-
Spree.
|
86
|
-
return Spree.pathFor('api/v1/orders/' + orderId + '/payments')
|
87
|
-
}
|
88
|
-
|
89
|
-
Spree.routes.stock_items_api = function (stockLocationId) {
|
90
|
-
return Spree.pathFor('api/v1/stock_locations/' + stockLocationId + '/stock_items')
|
60
|
+
Spree.routes.apply_coupon_code = function (orderId) {
|
61
|
+
return Spree.pathFor('api/v2/platform/orders/' + orderId + '/apply_coupon_code')
|
91
62
|
}
|
92
63
|
|
93
64
|
// API v2
|
94
65
|
Spree.routes.countries_api_v2 = Spree.pathFor('api/v2/platform/countries')
|
95
66
|
Spree.routes.classifications_api_v2 = Spree.pathFor('api/v2/platform/classifications')
|
67
|
+
Spree.routes.line_items_api_v2 = Spree.pathFor('api/v2/platform/line_items')
|
96
68
|
Spree.routes.menus_api_v2 = Spree.pathFor('api/v2/platform/menus')
|
97
69
|
Spree.routes.menus_items_api_v2 = Spree.pathFor('api/v2/platform/menu_items')
|
98
70
|
Spree.routes.option_types_api_v2 = Spree.pathFor('api/v2/platform/option_types')
|
99
71
|
Spree.routes.option_values_api_v2 = Spree.pathFor('api/v2/platform/option_values')
|
72
|
+
Spree.routes.orders_api_v2 = Spree.pathFor('api/v2/platform/orders')
|
100
73
|
Spree.routes.pages_api_v2 = Spree.pathFor('api/v2/platform/cms_pages')
|
74
|
+
Spree.routes.payments_api_v2 = Spree.pathFor('/api/v2/platform/payments')
|
101
75
|
Spree.routes.products_api_v2 = Spree.pathFor('/api/v2/platform/products')
|
102
76
|
Spree.routes.sections_api_v2 = Spree.pathFor('/api/v2/platform/cms_sections')
|
77
|
+
Spree.routes.shipments_api_v2 = Spree.pathFor('/api/v2/platform/shipments')
|
78
|
+
Spree.routes.stock_items_api_v2 = Spree.pathFor('/api/v2/platform/stock_items')
|
79
|
+
Spree.routes.stock_locations_api_v2 = Spree.pathFor('/api/v2/platform/stock_locations')
|
103
80
|
Spree.routes.taxons_api_v2 = Spree.pathFor('/api/v2/platform/taxons')
|
104
81
|
Spree.routes.users_api_v2 = Spree.pathFor('api/v2/platform/users')
|
82
|
+
Spree.routes.variants_api_v2 = Spree.pathFor('api/v2/platform/variants')
|
105
83
|
|
106
84
|
Spree.apiV2Authentication = function() {
|
107
|
-
|
108
|
-
|
85
|
+
if (typeof(OAUTH_TOKEN) !== 'undefined') {
|
86
|
+
return {
|
87
|
+
'Authorization': 'Bearer ' + OAUTH_TOKEN
|
88
|
+
}
|
109
89
|
}
|
110
90
|
}
|
@@ -2,7 +2,7 @@
|
|
2
2
|
function Spree () {}
|
3
3
|
|
4
4
|
Spree.ready = function (callback) {
|
5
|
-
return
|
5
|
+
return document.addEventListener("spree:load", function() {
|
6
6
|
return callback(jQuery)
|
7
7
|
})
|
8
8
|
}
|
@@ -67,12 +67,5 @@ Spree.ajax = function (urlOrSettings, settings) {
|
|
67
67
|
}
|
68
68
|
}
|
69
69
|
|
70
|
-
Spree.routes = {
|
71
|
-
states_search: Spree.pathFor('api/v1/states'),
|
72
|
-
apply_coupon_code: function (orderId) {
|
73
|
-
return Spree.pathFor('api/v1/orders/' + orderId + '/apply_coupon_code')
|
74
|
-
},
|
75
|
-
cart: Spree.pathFor('cart')
|
76
|
-
}
|
77
|
-
|
70
|
+
Spree.routes = {}
|
78
71
|
Spree.url_params = {}
|
@@ -0,0 +1,62 @@
|
|
1
|
+
#itemImgContainer {
|
2
|
+
width: 200px;
|
3
|
+
img {
|
4
|
+
max-width: 100%;
|
5
|
+
}
|
6
|
+
}
|
7
|
+
|
8
|
+
#sortableTreeArea {
|
9
|
+
.space-buttons {
|
10
|
+
box-shadow: -11px 0 16px 6px white;
|
11
|
+
z-index: 9;
|
12
|
+
a {
|
13
|
+
margin: 2px;
|
14
|
+
}
|
15
|
+
}
|
16
|
+
|
17
|
+
.sortable-tree-item-row {
|
18
|
+
overflow: hidden;
|
19
|
+
border: 1px solid $border-color;
|
20
|
+
margin: 2px;
|
21
|
+
background-color: white;
|
22
|
+
}
|
23
|
+
|
24
|
+
.sortable-tree-item {
|
25
|
+
border: solid 1px transparent;
|
26
|
+
padding: 0;
|
27
|
+
background-color: var(--light);
|
28
|
+
|
29
|
+
[data-sortable-tree-parent-id-value] {
|
30
|
+
margin-left: 25px;
|
31
|
+
background-color: var(--light);
|
32
|
+
}
|
33
|
+
|
34
|
+
@include media-breakpoint-up(sm) {
|
35
|
+
[data-sortable-tree-parent-id-value] {
|
36
|
+
margin-left: 50px;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
|
41
|
+
.sortable-chosen {
|
42
|
+
border: 1px dashed var(--gray);
|
43
|
+
border-radius: 5px;
|
44
|
+
}
|
45
|
+
|
46
|
+
.item_image_holder {
|
47
|
+
position: relative;
|
48
|
+
border: 1px solid $border-color;
|
49
|
+
border-radius: 7px;
|
50
|
+
overflow: hidden;
|
51
|
+
width: 45px;
|
52
|
+
height: 45px;
|
53
|
+
img {
|
54
|
+
position: absolute;
|
55
|
+
left: 50%;
|
56
|
+
top: 50%;
|
57
|
+
height: 100%;
|
58
|
+
width: auto;
|
59
|
+
transform: translate(-50%,-50%);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
@@ -29,9 +29,12 @@
|
|
29
29
|
|
30
30
|
@import 'shared/base';
|
31
31
|
@import 'shared/forms';
|
32
|
+
@import 'shared/sortable_tree';
|
32
33
|
|
33
34
|
@import 'views/menus';
|
34
35
|
@import 'views/cms_pages';
|
36
|
+
@import 'views/digitals';
|
35
37
|
@import 'views/order_payments';
|
36
38
|
@import 'views/product_properties';
|
37
39
|
@import 'views/prototypes';
|
40
|
+
@import 'views/taxonomies'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
div.digital-container {
|
2
|
+
border: 1px solid $gray-500;
|
3
|
+
background-color: #fefefe;
|
4
|
+
border-radius: $border-radius;
|
5
|
+
overflow: hidden;
|
6
|
+
display: flex;
|
7
|
+
justify-content: center;
|
8
|
+
margin: auto;
|
9
|
+
|
10
|
+
.delete-digital-info-container {
|
11
|
+
white-space: nowrap;
|
12
|
+
overflow: hidden;
|
13
|
+
text-overflow: ellipsis;
|
14
|
+
}
|
15
|
+
|
16
|
+
.delete-digital-button-container {
|
17
|
+
min-width: 44px;
|
18
|
+
flex-grow: 0;
|
19
|
+
a {
|
20
|
+
padding: 3px;
|
21
|
+
height: 32px;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
|
25
|
+
.delete-digital-icon-container {
|
26
|
+
width: 50px;
|
27
|
+
flex-grow: 0;
|
28
|
+
svg {
|
29
|
+
color: $gray-600;
|
30
|
+
align-self: center;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
@@ -17,7 +17,6 @@ module Spree
|
|
17
17
|
layout 'spree/layouts/admin'
|
18
18
|
|
19
19
|
before_action :authorize_admin
|
20
|
-
before_action :generate_admin_api_key
|
21
20
|
before_action :load_stores
|
22
21
|
|
23
22
|
helper_method :admin_oauth_token
|
@@ -56,14 +55,6 @@ module Spree
|
|
56
55
|
end
|
57
56
|
end
|
58
57
|
|
59
|
-
# Need to generate an API key for a user due to some backend actions
|
60
|
-
# requiring authentication to the Spree API
|
61
|
-
def generate_admin_api_key
|
62
|
-
if (user = try_spree_current_user) && user.spree_api_key.blank?
|
63
|
-
user.generate_spree_api_key!
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
58
|
def flash_message_for(object, event_sym)
|
68
59
|
resource_desc = object.class.model_name.human
|
69
60
|
resource_desc += " \"#{object.name}\"" if (object.persisted? || object.destroyed?) && object.respond_to?(:name) && object.name.present? && !object.is_a?(Spree::Order)
|
@@ -95,7 +86,7 @@ module Spree
|
|
95
86
|
|
96
87
|
def admin_oauth_application
|
97
88
|
@admin_oauth_application ||= begin
|
98
|
-
|
89
|
+
Spree::OauthApplication.find_or_create_by!(name: 'Admin Panel', scopes: 'admin', redirect_uri: '')
|
99
90
|
end
|
100
91
|
end
|
101
92
|
|
@@ -105,9 +96,9 @@ module Spree
|
|
105
96
|
return unless user
|
106
97
|
|
107
98
|
@admin_oauth_token ||= begin
|
108
|
-
|
109
|
-
|
110
|
-
|
99
|
+
Spree::OauthAccessToken.active_for(user).where(application_id: admin_oauth_application.id).last ||
|
100
|
+
Spree::OauthAccessToken.create!(
|
101
|
+
resource_owner: user,
|
111
102
|
application_id: admin_oauth_application.id,
|
112
103
|
scopes: admin_oauth_application.scopes
|
113
104
|
)
|