solidus_backend 2.7.4 → 2.9.2
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of solidus_backend might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +12 -8
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/spree/backend.js +0 -2
- data/app/assets/javascripts/spree/backend/adjustments.js +1 -1
- data/app/assets/javascripts/spree/backend/components/sortable_table.js +1 -0
- data/app/assets/javascripts/spree/backend/components/tabs.js +1 -0
- data/app/assets/javascripts/spree/backend/components/tooltips.js +21 -17
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/product_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/shipments.js +7 -1
- data/app/assets/javascripts/spree/backend/stock_management.js +18 -0
- data/app/assets/javascripts/spree/backend/store_credits.js +18 -2
- data/app/assets/javascripts/spree/backend/taxons.js +1 -1
- data/app/assets/javascripts/spree/backend/templates/orders/line_item.hbs +1 -1
- data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs +24 -25
- data/app/assets/javascripts/spree/backend/user_picker.js +1 -1
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/customer_select.js +1 -1
- data/app/assets/javascripts/spree/backend/views/order/summary.js +2 -2
- data/app/assets/javascripts/spree/backend/views/stock/add_stock_item.js +15 -4
- data/app/assets/javascripts/spree/backend/views/stock/edit_stock_item_row.js +46 -10
- data/app/assets/stylesheets/spree/backend/_bootstrap_custom.scss +24 -16
- data/app/assets/stylesheets/spree/backend/components/_breadcrumb.scss +12 -0
- data/app/assets/stylesheets/spree/backend/components/_buttons.scss +18 -0
- data/app/assets/stylesheets/spree/backend/components/_image_placeholder.scss +2 -2
- data/app/assets/stylesheets/spree/backend/components/_list_group.scss +2 -2
- data/app/assets/stylesheets/spree/backend/components/_messages.scss +20 -12
- data/app/assets/stylesheets/spree/backend/components/_navigation.scss +45 -11
- data/app/assets/stylesheets/spree/backend/components/_progress.scss +3 -3
- data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +1 -2
- data/app/assets/stylesheets/spree/backend/components/_tabs.scss +14 -13
- data/app/assets/stylesheets/spree/backend/globals/_deprecated_variables.scss +24 -0
- data/app/assets/stylesheets/spree/backend/globals/_deprecation.scss +10 -1
- data/app/assets/stylesheets/spree/backend/globals/_functions.scss +2 -0
- data/app/assets/stylesheets/spree/backend/globals/_variables.scss +88 -57
- data/app/assets/stylesheets/spree/backend/globals/_variables_override.scss +1 -0
- data/app/assets/stylesheets/spree/backend/globals/mixins/_caret.scss +1 -1
- data/app/assets/stylesheets/spree/backend/globals/mixins/_line_through.scss +1 -1
- data/app/assets/stylesheets/spree/backend/sections/_log_entries.scss +8 -2
- data/app/assets/stylesheets/spree/backend/sections/_orders.scss +25 -6
- data/app/assets/stylesheets/spree/backend/sections/_products.scss +3 -1
- data/app/assets/stylesheets/spree/backend/sections/_promotions.scss +5 -5
- data/app/assets/stylesheets/spree/backend/sections/_stock_management.scss +77 -2
- data/app/assets/stylesheets/spree/backend/sections/_style_guide.scss +4 -4
- data/app/assets/stylesheets/spree/backend/sections/_taxonomies.scss +1 -1
- data/app/assets/stylesheets/spree/backend/shared/_fonts.scss +15 -0
- data/app/assets/stylesheets/spree/backend/shared/_forms.scss +27 -7
- data/app/assets/stylesheets/spree/backend/shared/_header.scss +2 -2
- data/app/assets/stylesheets/spree/backend/shared/_icons.scss +5 -1
- data/app/assets/stylesheets/spree/backend/shared/_layout.scss +5 -4
- data/app/assets/stylesheets/spree/backend/shared/_tables.scss +11 -6
- data/app/assets/stylesheets/spree/backend/shared/_typography.scss +10 -6
- data/app/assets/stylesheets/spree/backend/spree_admin.scss +3 -1
- data/app/controllers/spree/admin/cancellations_controller.rb +2 -2
- data/app/controllers/spree/admin/customer_returns_controller.rb +8 -1
- data/app/controllers/spree/admin/locale_controller.rb +1 -1
- data/app/controllers/spree/admin/log_entries_controller.rb +3 -0
- data/app/controllers/spree/admin/orders/customer_details_controller.rb +8 -1
- data/app/controllers/spree/admin/orders_controller.rb +1 -12
- data/app/controllers/spree/admin/products_controller.rb +10 -6
- data/app/controllers/spree/admin/promotion_codes_controller.rb +19 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -1
- data/app/controllers/spree/admin/reimbursements_controller.rb +7 -2
- data/app/controllers/spree/admin/resource_controller.rb +1 -0
- data/app/controllers/spree/admin/store_credit_reasons_controller.rb +8 -0
- data/app/controllers/spree/admin/store_credits_controller.rb +11 -11
- data/app/controllers/spree/admin/users_controller.rb +4 -2
- data/app/helpers/spree/admin/base_helper.rb +9 -3
- data/app/helpers/spree/admin/navigation_helper.rb +1 -1
- data/app/helpers/spree/admin/promotions_helper.rb +15 -0
- data/app/models/spree/backend_configuration.rb +38 -21
- data/app/views/spree/admin/cancellations/index.html.erb +3 -1
- data/app/views/spree/admin/images/_image_row.html.erb +1 -1
- data/app/views/spree/admin/images/edit.html.erb +3 -3
- data/app/views/spree/admin/images/index.html.erb +3 -3
- data/app/views/spree/admin/log_entries/index.html.erb +1 -19
- data/app/views/spree/admin/option_types/edit.html.erb +1 -1
- data/app/views/spree/admin/orders/_carton_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/_line_items_edit_form.html.erb +1 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/confirm/_line_items.html.erb +3 -2
- data/app/views/spree/admin/orders/confirm/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/index.html.erb +1 -1
- data/app/views/spree/admin/payments/_capture_events.html.erb +15 -18
- data/app/views/spree/admin/payments/_list.html.erb +1 -1
- data/app/views/spree/admin/payments/_log_entries.html.erb +29 -0
- data/app/views/spree/admin/payments/show.html.erb +13 -6
- data/app/views/spree/admin/payments/source_forms/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
- data/app/views/spree/admin/payments/source_views/{_storecredit.html.erb → _store_credit.html.erb} +0 -0
- data/app/views/spree/admin/prices/_form.html.erb +1 -1
- data/app/views/spree/admin/product_properties/index.html.erb +1 -1
- data/app/views/spree/admin/products/_form.html.erb +23 -12
- data/app/views/spree/admin/products/edit.html.erb +5 -0
- data/app/views/spree/admin/products/index.html.erb +3 -1
- data/app/views/spree/admin/promotion_categories/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_code_batches/index.html.erb +1 -1
- data/app/views/spree/admin/promotion_codes/index.html.erb +5 -1
- data/app/views/spree/admin/promotion_codes/new.html.erb +31 -0
- data/app/views/spree/admin/promotions/_actions.html.erb +1 -1
- data/app/views/spree/admin/promotions/_activations_edit.html.erb +1 -1
- data/app/views/spree/admin/promotions/_form.html.erb +6 -5
- data/app/views/spree/admin/promotions/_rules.html.erb +1 -1
- data/app/views/spree/admin/promotions/edit.html.erb +3 -1
- data/app/views/spree/admin/promotions/index.html.erb +4 -4
- data/app/views/spree/admin/refunds/new.html.erb +1 -1
- data/app/views/spree/admin/reimbursements/edit.html.erb +2 -2
- data/app/views/spree/admin/shared/_address_form.html.erb +10 -3
- data/app/views/spree/admin/shared/_edit_resource_links.html.erb +1 -1
- data/app/views/spree/admin/shared/_head.html.erb +1 -3
- data/app/views/spree/admin/shared/_image.html.erb +2 -2
- data/app/views/spree/admin/shared/_modal.html.erb +1 -1
- data/app/views/spree/admin/shared/_product_sub_menu.html.erb +1 -1
- data/app/views/spree/admin/shared/_settings_checkout_tabs.html.erb +4 -0
- data/app/views/spree/admin/shared/_settings_sub_menu.html.erb +3 -3
- data/app/views/spree/admin/shared/_tabs.html.erb +3 -2
- data/app/views/spree/admin/shared/_variant_search.html.erb +1 -1
- data/app/views/spree/admin/shipping_methods/_form.html.erb +10 -10
- data/app/views/spree/admin/stock_items/_stock_management.html.erb +56 -38
- data/app/views/spree/admin/stock_locations/_form.html.erb +133 -121
- data/app/views/spree/admin/stock_locations/edit.html.erb +4 -2
- data/app/views/spree/admin/store_credit_reasons/edit.html.erb +15 -0
- data/app/views/spree/admin/store_credit_reasons/index.html.erb +56 -0
- data/app/views/spree/admin/store_credit_reasons/new.html.erb +18 -0
- data/app/views/spree/admin/store_credit_reasons/shared/_form.html.erb +15 -0
- data/app/views/spree/admin/store_credits/_store_credit_reason_field.html.erb +7 -0
- data/app/views/spree/admin/store_credits/edit_amount.html.erb +1 -1
- data/app/views/spree/admin/store_credits/edit_validity.html.erb +2 -2
- data/app/views/spree/admin/store_credits/index.html.erb +1 -1
- data/app/views/spree/admin/store_credits/show.html.erb +3 -3
- data/app/views/spree/admin/stores/_form.html.erb +1 -0
- data/app/views/spree/admin/style_guide/topics/typography/_colors.html.erb +30 -20
- data/app/views/spree/admin/style_guide/topics/typography/_fonts.html.erb +1 -1
- data/app/views/spree/admin/taxonomies/edit.html.erb +1 -1
- data/app/views/spree/admin/taxons/_form.html.erb +1 -1
- data/app/views/spree/admin/taxons/edit.html.erb +2 -2
- data/app/views/spree/admin/users/edit.html.erb +2 -2
- data/app/views/spree/admin/users/index.html.erb +2 -2
- data/app/views/spree/admin/users/items.html.erb +3 -1
- data/app/views/spree/admin/users/orders.html.erb +1 -1
- data/app/views/spree/admin/variants/_form.html.erb +1 -1
- data/app/views/spree/admin/variants/index.html.erb +1 -1
- data/app/views/spree/admin/zones/_state_members.html.erb +1 -1
- data/config/routes.rb +2 -8
- data/lib/spree/backend.rb +1 -1
- data/solidus_backend.gemspec +3 -4
- data/spec/controllers/spree/admin/base_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/cancellations_controller_spec.rb +7 -3
- data/spec/controllers/spree/admin/locale_controller_spec.rb +45 -0
- data/spec/controllers/spree/admin/orders/customer_details_controller_spec.rb +50 -2
- data/spec/controllers/spree/admin/orders_controller_spec.rb +25 -13
- data/spec/controllers/spree/admin/payments_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/products_controller_spec.rb +72 -0
- data/spec/controllers/spree/admin/promotion_codes_controller_spec.rb +13 -1
- data/spec/controllers/spree/admin/reimbursements_controller_spec.rb +11 -0
- data/spec/controllers/spree/admin/resource_controller_spec.rb +22 -0
- data/spec/controllers/spree/admin/stock_items_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/stock_locations_controller_spec.rb +1 -1
- data/spec/controllers/spree/admin/store_credits_controller_spec.rb +7 -7
- data/spec/features/admin/configuration/payment_methods_spec.rb +2 -2
- data/spec/features/admin/configuration/shipping_methods_spec.rb +2 -2
- data/spec/features/admin/homepage_spec.rb +1 -6
- data/spec/features/admin/locale_spec.rb +1 -2
- data/spec/features/admin/orders/adjustments_spec.rb +1 -1
- data/spec/features/admin/orders/customer_details_spec.rb +5 -7
- data/spec/features/admin/orders/customer_returns_spec.rb +28 -0
- data/spec/features/admin/orders/listing_spec.rb +2 -7
- data/spec/features/admin/orders/log_entries_spec.rb +2 -2
- data/spec/features/admin/orders/new_order_spec.rb +117 -0
- data/spec/features/admin/orders/new_refund_spec.rb +35 -0
- data/spec/features/admin/orders/order_details_spec.rb +10 -5
- data/spec/features/admin/orders/payments_spec.rb +82 -41
- data/spec/features/admin/orders/return_payment_state_spec.rb +3 -0
- data/spec/features/admin/orders/shipments_spec.rb +28 -0
- data/spec/features/admin/products/edit/products_spec.rb +25 -0
- data/spec/features/admin/products/edit/taxons_spec.rb +4 -0
- data/spec/features/admin/products/pricing_spec.rb +24 -6
- data/spec/features/admin/products/products_spec.rb +5 -5
- data/spec/features/admin/products/stock_management_spec.rb +27 -13
- data/spec/features/admin/products/variant_spec.rb +1 -1
- data/spec/features/admin/promotion_adjustments_spec.rb +12 -12
- data/spec/features/admin/promotions/option_value_rule_spec.rb +2 -2
- data/spec/features/admin/promotions/product_rule_spec.rb +1 -1
- data/spec/features/admin/promotions/promotion_spec.rb +52 -0
- data/spec/features/admin/promotions/tiered_calculator_spec.rb +1 -1
- data/spec/features/admin/promotions/user_rule_spec.rb +2 -2
- data/spec/features/admin/reimbursements_spec.rb +1 -1
- data/spec/features/admin/store_credits_spec.rb +51 -2
- data/spec/features/admin/taxons_spec.rb +35 -0
- data/spec/features/admin/users_spec.rb +44 -11
- data/spec/helpers/admin/navigation_helper_spec.rb +4 -2
- data/spec/helpers/admin/store_credit_events_helper_spec.rb +2 -2
- data/spec/javascripts/spec_helper.js +2 -0
- data/spec/models/spree/backend_configuration/menu_item_spec.rb +17 -0
- data/spec/models/spree/backend_configuration_spec.rb +22 -0
- data/spec/spec_helper.rb +2 -2
- data/spec/support/appear_before_matcher.rb +1 -1
- data/spec/support/feature/order_feature_helper.rb +1 -1
- data/spec/views/spree/admin/shared/navigation_footer_spec.rb +1 -1
- data/vendor/assets/fonts/inter/Inter-Regular.woff +0 -0
- data/vendor/assets/fonts/inter/Inter-Regular.woff2 +0 -0
- data/vendor/assets/fonts/inter/Inter-SemiBold.woff +0 -0
- data/vendor/assets/fonts/inter/Inter-SemiBold.woff2 +0 -0
- data/vendor/assets/javascripts/solidus_admin/select2_locales/select2_locale_en-US.js +10 -0
- data/vendor/assets/stylesheets/solidus_admin/bootstrap/_pagination.scss +4 -0
- metadata +38 -36
- data/.eslintrc +0 -21
- data/app/controllers/spree/admin/reports_controller.rb +0 -82
- data/app/views/spree/admin/reports/index.html.erb +0 -19
- data/app/views/spree/admin/reports/sales_total.html.erb +0 -35
- data/app/views/spree/admin/shared/_report_order_criteria.html.erb +0 -19
- data/app/views/spree/admin/store_credits/_update_reason_field.html.erb +0 -7
- data/spec/controllers/spree/admin/reports_controller_spec.rb +0 -133
- data/spec/features/admin/reports_spec.rb +0 -63
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6163ba6d77d3221cc770c66492bbfcd1558af588dbabf65ea1f16be1e226cad3
|
4
|
+
data.tar.gz: 2733f79263f19a150f18541efad616ca24f5500027982df8c5160b7cf26a7674
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d10ea54cc2aae32b27840529e8ef5b0ec7617542e1de479b977ab99383e6c673f2e4f779b7bcfe93962e1ecb45452c4de577ae9da4360793b6a64ce40ba33820
|
7
|
+
data.tar.gz: b827d361e91b68319dbef13ece7ded929114488efd412b0bcfafabe9d42d599a62266d2ac7fb858e4e85035470d493216b864ee561556f19aadb698dce05ce7d
|
data/README.md
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
# solidus\_backend
|
2
2
|
|
3
|
-
Backend contains the controllers, views, and assets making up the admin interface of
|
3
|
+
Backend contains the controllers, views, and assets making up the admin interface of Solidus.
|
4
4
|
|
5
5
|
## Assets
|
6
6
|
|
7
|
-
###
|
7
|
+
### JavaScript
|
8
8
|
|
9
9
|
Can be found in [app/assets/javascripts/spree/backend/](./app/assets/javascripts/spree/backend/)
|
10
10
|
|
11
|
-
Our scripts are written in a mix of
|
11
|
+
Our scripts are written in a mix of CoffeeScript and JavaScript (ES5). We can't
|
12
12
|
easily use a transpiler for ECMAScript >= 6 without adding additional steps for
|
13
13
|
applications using solidus\_admin.
|
14
14
|
|
15
15
|
Though we have existing CoffeeScript files, any new files should be in
|
16
|
-
|
16
|
+
JavaScript (ES5).
|
17
17
|
|
18
18
|
### Stylesheets
|
19
19
|
|
20
20
|
Can be found in [app/assets/stylesheets/spree/backend/](./app/assets/stylesheets/spree/backend/)
|
21
21
|
|
22
|
-
The stylesheets are written in SCSS and include all of [
|
22
|
+
The stylesheets are written in SCSS and include all of [Bourbon](http://bourbon.io/docs/) and [Bootstrap 4 alpha](http://v4-alpha.getbootstrap.com/).
|
23
23
|
|
24
24
|
When running the application there is a styleguide available at:
|
25
25
|
|
@@ -31,8 +31,12 @@ When running the application there is a styleguide available at:
|
|
31
31
|
|
32
32
|
Run the tests
|
33
33
|
|
34
|
-
|
34
|
+
```bash
|
35
|
+
bundle exec rspec
|
36
|
+
```
|
35
37
|
|
36
|
-
Run the
|
38
|
+
Run the JavaScript tests (must have [ChromeDriver](https://sites.google.com/a/chromium.org/chromedriver/) installed)
|
37
39
|
|
38
|
-
|
40
|
+
```bash
|
41
|
+
bundle exec teaspoon
|
42
|
+
```
|
Binary file
|
@@ -3,26 +3,30 @@ Spree.ready(function(){
|
|
3
3
|
|
4
4
|
$('body').tooltip({selector: '.with-tip'});
|
5
5
|
|
6
|
+
/*
|
7
|
+
* Poll tooltips to hide them if they are no longer being hovered.
|
8
|
+
*
|
9
|
+
* This is necessary to fix tooltips hanging around after their attached
|
10
|
+
* element has been removed from the DOM (and will therefore receive no
|
11
|
+
* mouseleave event). This may be unnecessary in a future version of
|
12
|
+
* bootstrap, which intends to solve this using MutationObserver.
|
13
|
+
*/
|
14
|
+
var removeDesyncedTooltip = function(tooltip) {
|
15
|
+
var interval = setInterval(function(){
|
16
|
+
if(!$(tooltip.element).is(":hover")) {
|
17
|
+
tooltip.dispose();
|
18
|
+
clearInterval(interval);
|
19
|
+
}
|
20
|
+
}, 200);
|
21
|
+
$(tooltip.element).on('hidden.bs.tooltip', function(){
|
22
|
+
clearInterval(interval);
|
23
|
+
});
|
24
|
+
};
|
25
|
+
|
6
26
|
$('body').on('inserted.bs.tooltip', function(e){
|
7
27
|
var $target = $(e.target);
|
8
28
|
var tooltip = $target.data('bs.tooltip');
|
9
|
-
|
10
|
-
/*
|
11
|
-
* Observe target changes to understand if we need to remove tooltips.
|
12
|
-
*
|
13
|
-
* This is necessary to fix tooltips hanging around after their attached
|
14
|
-
* element has been removed from the DOM (and will therefore receive no
|
15
|
-
* mouseleave event).
|
16
|
-
*/
|
17
|
-
var observer = new MutationObserver(function(mutations) {
|
18
|
-
// disconnect itself when content is changed, a new observer will
|
19
|
-
// be attached to this element when the new tooltip is created.
|
20
|
-
this.disconnect();
|
21
|
-
|
22
|
-
tooltip.hide();
|
23
|
-
});
|
24
|
-
observer.observe($target.get(0), { attributes: true });
|
25
|
-
|
29
|
+
removeDesyncedTooltip(tooltip);
|
26
30
|
var $tooltip = $("#" + $target.attr("aria-describedby"));
|
27
31
|
$tooltip.addClass("action-" + $target.data("action"));
|
28
32
|
});
|
@@ -23,7 +23,7 @@ Spree.ready(function () {
|
|
23
23
|
url: Spree.routes.option_type_search,
|
24
24
|
quietMillis: 200,
|
25
25
|
datatype: 'json',
|
26
|
-
params: { "headers": {
|
26
|
+
params: { "headers": { 'Authorization': 'Bearer ' + Spree.api_key } },
|
27
27
|
data: function (term) {
|
28
28
|
return {
|
29
29
|
q: { name_cont: term }
|
@@ -23,7 +23,7 @@ $.fn.productAutocomplete = function (options) {
|
|
23
23
|
ajax: {
|
24
24
|
url: Spree.routes.admin_product_search,
|
25
25
|
datatype: 'json',
|
26
|
-
params: { "headers": {
|
26
|
+
params: { "headers": { 'Authorization': 'Bearer ' + Spree.api_key } },
|
27
27
|
data: function (term, page) {
|
28
28
|
return {
|
29
29
|
q: {
|
@@ -1,4 +1,5 @@
|
|
1
1
|
// Shipments AJAX API
|
2
|
+
/* eslint no-extra-semi: "off", no-unused-vars: "off" */
|
2
3
|
|
3
4
|
var ShipmentAddVariantView = Backbone.View.extend({
|
4
5
|
events: {
|
@@ -85,7 +86,12 @@ adjustShipmentItems = function(shipment_number, variant_id, quantity){
|
|
85
86
|
window.location.reload();
|
86
87
|
},
|
87
88
|
error: function(response) {
|
88
|
-
|
89
|
+
json = response.responseJSON;
|
90
|
+
message = json.error;
|
91
|
+
for (error in json.errors) {
|
92
|
+
message += '<br />' + json.errors[error].join();
|
93
|
+
}
|
94
|
+
window.show_flash('error', message);
|
89
95
|
}
|
90
96
|
});
|
91
97
|
}
|
@@ -2,11 +2,29 @@ Spree.ready(function() {
|
|
2
2
|
$('.js-edit-stock-item').each(function() {
|
3
3
|
var $el = $(this);
|
4
4
|
var model = new Spree.Models.StockItem($el.data('stock-item'));
|
5
|
+
var trackInventory = $el.data('track-inventory');
|
6
|
+
var canEdit = $el.data('can-edit')
|
5
7
|
new Spree.Views.Stock.EditStockItemRow({
|
6
8
|
el: $el,
|
7
9
|
stockLocationName: $el.data('stock-location-name'),
|
8
10
|
model: model
|
9
11
|
});
|
12
|
+
|
13
|
+
if (trackInventory === false) {
|
14
|
+
$('.js-edit-stock-item input').attr({
|
15
|
+
disabled: true,
|
16
|
+
class: 'with-tip',
|
17
|
+
title: '"Track inventory" option disabled for this variant'
|
18
|
+
});
|
19
|
+
}
|
20
|
+
|
21
|
+
if (canEdit == false) {
|
22
|
+
$('.js-edit-stock-item input').attr({
|
23
|
+
disabled: true,
|
24
|
+
class: 'with-tip',
|
25
|
+
title: 'You do not have permission to manage stock'
|
26
|
+
});
|
27
|
+
}
|
10
28
|
});
|
11
29
|
|
12
30
|
$('.js-add-stock-item').each(function() {
|
@@ -9,9 +9,25 @@ Spree.ready(function() {
|
|
9
9
|
field.defaultValue = field.value;
|
10
10
|
textDisplay.textContent = field.value;
|
11
11
|
|
12
|
-
|
12
|
+
if (typeof data !== "undefined") {
|
13
|
+
// we are using jquery_ujs
|
14
|
+
message = data.message
|
15
|
+
} else {
|
16
|
+
// we are using rails-ujs
|
17
|
+
message = event.detail[0].message
|
18
|
+
}
|
19
|
+
|
20
|
+
show_flash('success', message);
|
13
21
|
}).on('ajax:error', function(event, xhr, status, error) {
|
14
|
-
|
22
|
+
if (typeof xhr !== "undefined") {
|
23
|
+
// we are using jquery_ujs
|
24
|
+
message = xhr.responseJSON.message
|
25
|
+
} else {
|
26
|
+
// we are using rails-ujs
|
27
|
+
message = event.detail[0].message
|
28
|
+
}
|
29
|
+
|
30
|
+
show_flash('error', message);
|
15
31
|
});
|
16
32
|
|
17
33
|
row.querySelector('.edit-memo').addEventListener('click', function() {
|
@@ -20,7 +20,7 @@
|
|
20
20
|
{{#if editing}}
|
21
21
|
<td class="line-item-qty-edit">
|
22
22
|
<form>
|
23
|
-
<input type="number" name="quantity" value="{{ line_item.quantity }}" min="
|
23
|
+
<input type="number" name="quantity" value="{{ line_item.quantity }}" min="1" class="line_item_quantity" size="5">
|
24
24
|
</form>
|
25
25
|
</td>
|
26
26
|
{{else}}
|
data/app/assets/javascripts/spree/backend/templates/stock_items/stock_location_stock_item.hbs
CHANGED
@@ -1,36 +1,35 @@
|
|
1
|
-
<td>{{stockLocationName}}</td>
|
2
|
-
<td>
|
1
|
+
<td class="stock-location-name">{{stockLocationName}}</td>
|
2
|
+
<td class="align-center">
|
3
3
|
<input id="backorderable-{{id}}"
|
4
4
|
name="backorderable"
|
5
5
|
type="checkbox"
|
6
6
|
value="backorderable"
|
7
|
-
{{#unless editing}} disabled="disabled" {{/unless}}
|
8
7
|
{{#if backorderable}} checked="checked" {{/if}}
|
9
8
|
>
|
10
9
|
</td>
|
10
|
+
<td class="align-center">
|
11
|
+
<span
|
12
|
+
{{#if negative}}
|
13
|
+
class="negative count-on-hand-display"
|
14
|
+
{{else}}
|
15
|
+
class="count-on-hand-display"
|
16
|
+
{{/if}}
|
17
|
+
>{{count_on_hand}}</span>
|
18
|
+
</td>
|
11
19
|
<td>
|
12
|
-
|
13
|
-
<
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
>
|
24
|
-
</form>
|
25
|
-
{{else}}
|
26
|
-
<span {{#if negative}}class="negative"{{/if}}>{{count_on_hand}}</span>
|
27
|
-
{{/if}}
|
20
|
+
<form>
|
21
|
+
<input
|
22
|
+
{{#if negative}}
|
23
|
+
class="fullwidth negative"
|
24
|
+
{{else}}
|
25
|
+
class="fullwidth"
|
26
|
+
{{/if}}
|
27
|
+
name="count_on_hand"
|
28
|
+
type="number"
|
29
|
+
value="0">
|
30
|
+
</form>
|
28
31
|
</td>
|
29
32
|
<td class="actions">
|
30
|
-
|
31
|
-
|
32
|
-
<a class="cancel fa fa-cancel icon_link with-tip no-text" data-action="cancel" href="#"></a>
|
33
|
-
{{else}}
|
34
|
-
<a class="edit fa fa-edit icon_link with-tip no-text" data-action="edit" href="#"></a>
|
35
|
-
{{/if}}
|
33
|
+
<a class="submit fa fa-check icon_link with-tip no-text" data-action="save" href="#"></a>
|
34
|
+
<a class="cancel fa fa-cancel icon_link with-tip no-text" data-action="cancel" href="#"></a>
|
36
35
|
</td>
|
@@ -22,7 +22,7 @@ $.fn.userAutocomplete = function () {
|
|
22
22
|
ajax: {
|
23
23
|
url: Spree.routes.users_api,
|
24
24
|
datatype: 'json',
|
25
|
-
params: { "headers": {
|
25
|
+
params: { "headers": { 'Authorization': 'Bearer ' + Spree.api_key } },
|
26
26
|
data: function (term) {
|
27
27
|
return {
|
28
28
|
q: {
|
@@ -27,7 +27,7 @@ Spree.Views.Order.CustomerSelect = Backbone.View.extend({
|
|
27
27
|
placeholder: Spree.translations.choose_a_customer,
|
28
28
|
ajax: {
|
29
29
|
url: Spree.routes.users_api,
|
30
|
-
params: { "headers": {
|
30
|
+
params: { "headers": { 'Authorization': 'Bearer ' + Spree.api_key } },
|
31
31
|
datatype: 'json',
|
32
32
|
data: function(term, page) {
|
33
33
|
return {
|
@@ -20,10 +20,10 @@ Spree.Views.Order.Summary = Backbone.View.extend({
|
|
20
20
|
this.$('dd.order-additional_tax_total').text(this.model.get("display_additional_tax_total"))
|
21
21
|
|
22
22
|
this.$('.order-shipment_state').toggleClass("hidden", !this.model.get("completed_at"))
|
23
|
-
this.$('dd.order-shipment_state').html(this.renderState('
|
23
|
+
this.$('dd.order-shipment_state').html(this.renderState('shipment_states', this.model.get("shipment_state")))
|
24
24
|
|
25
25
|
this.$('.order-payment_state').toggleClass("hidden", !this.model.get("completed_at"))
|
26
|
-
this.$('dd.order-payment_state').html(this.renderState('
|
26
|
+
this.$('dd.order-payment_state').html(this.renderState('payment_states', this.model.get("payment_state")))
|
27
27
|
},
|
28
28
|
|
29
29
|
renderState: function(translation_key, value) {
|
@@ -6,14 +6,23 @@ Spree.Views.Stock.AddStockItem = Backbone.View.extend({
|
|
6
6
|
},
|
7
7
|
|
8
8
|
events: {
|
9
|
-
"click .submit": "onSubmit"
|
9
|
+
"click .submit": "onSubmit",
|
10
|
+
"submit form": "onSubmit",
|
11
|
+
'input [name="count_on_hand"]': "onChange",
|
12
|
+
'change [name="stock_location_id"]': "onChange",
|
13
|
+
'click [name="backorderable"]': "onChange"
|
10
14
|
},
|
11
15
|
|
12
16
|
validate: function() {
|
13
|
-
|
14
|
-
locationSelectContainer.toggleClass('error', !this.$locationSelect.val());
|
17
|
+
this.$locationSelect.toggleClass('error', !this.$locationSelect.val());
|
15
18
|
this.$countInput.toggleClass('error', !this.$countInput.val());
|
16
|
-
return
|
19
|
+
return this.$locationSelect.hasClass('error') || this.$countInput.hasClass('error');
|
20
|
+
},
|
21
|
+
|
22
|
+
onChange: function (event) {
|
23
|
+
var $target = $(event.target)
|
24
|
+
if ($target.val() !== '') $target.removeClass('error');
|
25
|
+
this.$el.addClass('changed');
|
17
26
|
},
|
18
27
|
|
19
28
|
onSuccess: function() {
|
@@ -25,6 +34,7 @@ Spree.Views.Stock.AddStockItem = Backbone.View.extend({
|
|
25
34
|
stockLocationName: stockLocationName
|
26
35
|
});
|
27
36
|
editView.$el.insertBefore(this.$el);
|
37
|
+
editView.$el.addClass('stock-item-edit-row');
|
28
38
|
this.model = new Spree.Models.StockItem({
|
29
39
|
variant_id: this.model.get('variant_id'),
|
30
40
|
stock_location_id: this.model.get('stock_location_id')
|
@@ -58,6 +68,7 @@ Spree.Views.Stock.AddStockItem = Backbone.View.extend({
|
|
58
68
|
success: this.onSuccess.bind(this),
|
59
69
|
error: this.onError.bind(this)
|
60
70
|
};
|
71
|
+
this.$el.removeClass('changed');
|
61
72
|
this.model.save(null, options);
|
62
73
|
}
|
63
74
|
});
|
@@ -3,16 +3,18 @@ Spree.Views.Stock.EditStockItemRow = Backbone.View.extend({
|
|
3
3
|
|
4
4
|
initialize: function(options) {
|
5
5
|
this.stockLocationName = options.stockLocationName;
|
6
|
-
this.editing = false;
|
7
6
|
this.negative = this.model.attributes.count_on_hand < 0;
|
7
|
+
this.previousAttributes = _.clone(this.model.attributes);
|
8
|
+
this.listenTo(this.model, 'sync', this.onSuccess);
|
8
9
|
this.render();
|
9
10
|
},
|
10
11
|
|
11
12
|
events: {
|
12
|
-
"click .edit": "onEdit",
|
13
13
|
"click .submit": "onSubmit",
|
14
14
|
"submit form": "onSubmit",
|
15
|
-
"click .cancel": "onCancel"
|
15
|
+
"click .cancel": "onCancel",
|
16
|
+
'input [name="count_on_hand"]': "countOnHandChanged",
|
17
|
+
'input [name="backorderable"]': "backorderableChanged"
|
16
18
|
},
|
17
19
|
|
18
20
|
template: HandlebarsTemplates['stock_items/stock_location_stock_item'],
|
@@ -26,26 +28,58 @@ Spree.Views.Stock.EditStockItemRow = Backbone.View.extend({
|
|
26
28
|
_.extend(renderAttr, this.model.attributes);
|
27
29
|
this.$el.attr("data-variant-id", this.model.get('variant_id'));
|
28
30
|
this.$el.html(this.template(renderAttr));
|
31
|
+
this.$count_on_hand_display = this.$('.count-on-hand-display');
|
29
32
|
return this;
|
30
33
|
},
|
31
34
|
|
32
35
|
onEdit: function(ev) {
|
33
36
|
ev.preventDefault();
|
34
|
-
this.editing = true;
|
35
37
|
this.render();
|
36
38
|
},
|
37
39
|
|
38
40
|
onCancel: function(ev) {
|
39
41
|
ev.preventDefault();
|
40
|
-
this.model.set(this.
|
41
|
-
this.
|
42
|
+
this.model.set(this.previousAttributes);
|
43
|
+
this.$el.removeClass('changed');
|
42
44
|
this.render();
|
43
45
|
},
|
44
46
|
|
47
|
+
onChange: function() {
|
48
|
+
var count_on_hand_changed = this.previousAttributes.count_on_hand != this.model.attributes.count_on_hand;
|
49
|
+
var backorderable_changed = this.previousAttributes.backorderable != this.model.attributes.backorderable;
|
50
|
+
var changed = count_on_hand_changed || backorderable_changed;
|
51
|
+
|
52
|
+
this.$el.toggleClass('changed', changed);
|
53
|
+
},
|
54
|
+
|
55
|
+
backorderableChanged: function(ev) {
|
56
|
+
this.model.set("backorderable", ev.target.checked);
|
57
|
+
|
58
|
+
this.onChange();
|
59
|
+
},
|
60
|
+
|
61
|
+
countOnHandChanged: function(ev) {
|
62
|
+
var diff = parseInt(ev.currentTarget.value), newCount;
|
63
|
+
if (isNaN(diff)) diff = 0;
|
64
|
+
newCount = this.previousAttributes.count_on_hand + diff;
|
65
|
+
ev.preventDefault();
|
66
|
+
// Do not allow negative stock values
|
67
|
+
if (newCount < 0) {
|
68
|
+
ev.currentTarget.value = -1 * this.previousAttributes.count_on_hand;
|
69
|
+
this.$count_on_hand_display.text(0);
|
70
|
+
} else {
|
71
|
+
this.model.set("count_on_hand", newCount);
|
72
|
+
this.$count_on_hand_display.text(newCount);
|
73
|
+
}
|
74
|
+
|
75
|
+
this.onChange();
|
76
|
+
},
|
77
|
+
|
45
78
|
onSuccess: function() {
|
46
|
-
this.
|
79
|
+
this.$el.removeClass('changed');
|
80
|
+
this.previousAttributes = _.clone(this.model.attributes);
|
47
81
|
this.render();
|
48
|
-
|
82
|
+
this.$('[name="count_on_hand"]').focus();
|
49
83
|
},
|
50
84
|
|
51
85
|
onError: function(model, response, options) {
|
@@ -62,9 +96,11 @@ Spree.Views.Stock.EditStockItemRow = Backbone.View.extend({
|
|
62
96
|
backorderable: backorderable
|
63
97
|
});
|
64
98
|
var options = {
|
65
|
-
success:
|
99
|
+
success: function() {
|
100
|
+
show_flash("success", Spree.translations.updated_successfully);
|
101
|
+
},
|
66
102
|
error: this.onError.bind(this)
|
67
103
|
};
|
68
|
-
this.model.save({
|
104
|
+
this.model.save({}, options);
|
69
105
|
}
|
70
106
|
});
|