spree_backend 3.6.6 → 3.7.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/spree/backend.js +7 -7
- data/app/assets/javascripts/spree/backend/address_states.js +21 -21
- data/app/assets/javascripts/spree/backend/adjustments.js +25 -0
- data/app/assets/javascripts/spree/backend/admin.js +253 -244
- data/app/assets/javascripts/spree/backend/calculator.js +14 -13
- data/app/assets/javascripts/spree/backend/checkouts/edit.js +48 -52
- data/app/assets/javascripts/spree/backend/gateway.js +11 -10
- data/app/assets/javascripts/spree/backend/general_settings.js +18 -0
- data/app/assets/javascripts/spree/backend/handlebar_extensions.js +6 -6
- data/app/assets/javascripts/spree/backend/line_items.js +72 -0
- data/app/assets/javascripts/spree/backend/line_items_on_order_edit.js +48 -47
- data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +10 -10
- data/app/assets/javascripts/spree/backend/option_value_picker.js +13 -14
- data/app/assets/javascripts/spree/backend/orders/edit.js +3 -4
- data/app/assets/javascripts/spree/backend/payments/edit.js +230 -0
- data/app/assets/javascripts/spree/backend/payments/new.js +31 -31
- data/app/assets/javascripts/spree/backend/product_picker.js +15 -15
- data/app/assets/javascripts/spree/backend/progress.js +8 -0
- data/app/assets/javascripts/spree/backend/promotions.js +102 -107
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.js +5 -0
- data/app/assets/javascripts/spree/backend/returns/return_item_selection.js +32 -33
- data/app/assets/javascripts/spree/backend/shipments.js +246 -241
- data/app/assets/javascripts/spree/backend/spree-select2.js +3 -3
- data/app/assets/javascripts/spree/backend/states.js +8 -8
- data/app/assets/javascripts/spree/backend/stock_location.js +4 -3
- data/app/assets/javascripts/spree/backend/stock_management.js +13 -0
- data/app/assets/javascripts/spree/backend/stock_movement.js +35 -0
- data/app/assets/javascripts/spree/backend/stock_transfer.js +260 -0
- data/app/assets/javascripts/spree/backend/tag_picker.js +21 -21
- data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +13 -13
- data/app/assets/javascripts/spree/backend/taxon_permalink_preview.js +8 -9
- data/app/assets/javascripts/spree/backend/taxon_tree_menu.js +35 -0
- data/app/assets/javascripts/spree/backend/taxonomy.js +165 -0
- data/app/assets/javascripts/spree/backend/taxons.js +122 -0
- data/app/assets/javascripts/spree/backend/user_picker.js +11 -11
- data/app/assets/javascripts/spree/backend/users/edit.js +14 -15
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js +61 -0
- data/app/assets/javascripts/spree/backend/variant_management.js +14 -0
- data/app/assets/javascripts/spree/backend/zone.js +44 -0
- data/app/controllers/spree/admin/countries_controller.rb +3 -3
- data/app/controllers/spree/admin/customer_returns_controller.rb +1 -0
- data/app/controllers/spree/admin/general_settings_controller.rb +1 -0
- data/app/controllers/spree/admin/orders_controller.rb +4 -4
- data/app/controllers/spree/admin/payment_methods_controller.rb +1 -0
- data/app/controllers/spree/admin/payments_controller.rb +3 -2
- data/app/controllers/spree/admin/products_controller.rb +3 -1
- data/app/controllers/spree/admin/promotions_controller.rb +1 -0
- data/app/controllers/spree/admin/properties_controller.rb +1 -0
- data/app/controllers/spree/admin/reports_controller.rb +4 -4
- data/app/controllers/spree/admin/resource_controller.rb +3 -1
- data/app/controllers/spree/admin/return_authorizations_controller.rb +1 -1
- data/app/controllers/spree/admin/return_index_controller.rb +1 -0
- data/app/controllers/spree/admin/shipping_methods_controller.rb +2 -0
- data/app/controllers/spree/admin/store_credits_controller.rb +1 -2
- data/app/controllers/spree/admin/users_controller.rb +3 -1
- data/app/helpers/spree/admin/base_helper.rb +8 -5
- data/app/helpers/spree/admin/{general_settings_helper.rb → currency_helper.rb} +4 -3
- data/app/helpers/spree/admin/navigation_helper.rb +0 -8
- data/app/helpers/spree/admin/orders_helper.rb +2 -1
- data/app/models/spree/admin/resource.rb +1 -0
- data/app/views/spree/admin/orders/_line_items.html.erb +3 -1
- data/app/views/spree/admin/orders/_shipment_manifest.html.erb +3 -1
- data/app/views/spree/admin/orders/index.html.erb +15 -8
- data/app/views/spree/admin/products/index.html.erb +2 -2
- data/app/views/spree/admin/promotions/index.html.erb +4 -4
- data/app/views/spree/admin/properties/index.html.erb +2 -2
- data/app/views/spree/admin/return_index/customer_returns.html.erb +1 -1
- data/app/views/spree/admin/return_index/return_authorizations.html.erb +2 -2
- data/app/views/spree/admin/shared/_order_summary.html.erb +6 -0
- data/app/views/spree/admin/store_credits/_form.html.erb +15 -6
- data/app/views/spree/admin/store_credits/edit.html.erb +1 -1
- data/app/views/spree/admin/store_credits/new.html.erb +1 -1
- data/app/views/spree/admin/users/_addresses_form.html.erb +1 -1
- data/app/views/spree/admin/users/index.html.erb +8 -8
- data/app/views/spree/admin/users/items.html.erb +3 -1
- data/app/views/spree/admin/variants/index.html.erb +2 -2
- data/lib/generators/spree/backend/copy_views/copy_views_generator.rb +1 -1
- data/lib/spree/backend/callbacks.rb +1 -0
- data/spree_backend.gemspec +2 -2
- data/vendor/assets/javascripts/jquery.jstree/jquery.jstree.js +4358 -4358
- data/vendor/assets/javascripts/js.cookie.js +165 -0
- metadata +28 -28
- data/app/assets/javascripts/spree/backend/adjustments.js.coffee +0 -17
- data/app/assets/javascripts/spree/backend/general_settings.js.coffee +0 -15
- data/app/assets/javascripts/spree/backend/line_items.js.coffee +0 -64
- data/app/assets/javascripts/spree/backend/payments/edit.js.coffee +0 -145
- data/app/assets/javascripts/spree/backend/progress.js.coffee +0 -6
- data/app/assets/javascripts/spree/backend/returns/expedited_exchanges_warning.coffee +0 -4
- data/app/assets/javascripts/spree/backend/stock_management.js.coffee +0 -9
- data/app/assets/javascripts/spree/backend/stock_movement.js.coffee +0 -19
- data/app/assets/javascripts/spree/backend/stock_transfer.js.coffee +0 -201
- data/app/assets/javascripts/spree/backend/taxon_tree_menu.js.coffee +0 -22
- data/app/assets/javascripts/spree/backend/taxonomy.js.coffee +0 -153
- data/app/assets/javascripts/spree/backend/taxons.js.coffee +0 -82
- data/app/assets/javascripts/spree/backend/variant_autocomplete.js.coffee +0 -38
- data/app/assets/javascripts/spree/backend/variant_management.js.coffee +0 -10
- data/app/assets/javascripts/spree/backend/zone.js.coffee +0 -43
- data/vendor/assets/javascripts/jquery.cookie.js +0 -117
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20586007b7156b7717edaee7ca99c428fc7f1b5cbfded241b9a607440cc2e511
|
4
|
+
data.tar.gz: ad2c2d66d03ca5b084be641af8cf1df7cc51c33c915038868fe804ea3a6b6760
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7136bc70ffbb2f5d44299a06fe6e7be4fdc55fbb10e4b6f06abd2b9728629a918b68f94cfbb1985ac0dc6f3e1cbc7571f709629ef738c27a9b25462beb842194
|
7
|
+
data.tar.gz: 5deb6bb8ea7249cf0248424cf26198b4ae98f372d9f2bf1c9fd689cd24359b61800ae351b0f694b05139e389b6fa16f7646ea674f06803373426a148189d630f
|
@@ -2,7 +2,7 @@
|
|
2
2
|
//= require bootstrap-sprockets
|
3
3
|
//= require handlebars
|
4
4
|
//= require jquery
|
5
|
-
//= require
|
5
|
+
//= require js.cookie
|
6
6
|
//= require jquery.jstree/jquery.jstree
|
7
7
|
//= require jquery_ujs
|
8
8
|
//= require jquery-ui/widgets/datepicker
|
@@ -67,14 +67,14 @@ Spree.routes.users_api = Spree.pathFor('api/v1/users')
|
|
67
67
|
Spree.routes.tags_api = Spree.pathFor('api/v1/tags')
|
68
68
|
Spree.routes.variants_api = Spree.pathFor('api/v1/variants')
|
69
69
|
|
70
|
-
Spree.routes.edit_product = function(
|
71
|
-
return Spree.adminPathFor('products/' +
|
70
|
+
Spree.routes.edit_product = function (productId) {
|
71
|
+
return Spree.adminPathFor('products/' + productId + '/edit')
|
72
72
|
}
|
73
73
|
|
74
|
-
Spree.routes.payments_api = function(
|
75
|
-
return Spree.pathFor('api/v1/orders/' +
|
74
|
+
Spree.routes.payments_api = function (orderId) {
|
75
|
+
return Spree.pathFor('api/v1/orders/' + orderId + '/payments')
|
76
76
|
}
|
77
77
|
|
78
|
-
Spree.routes.stock_items_api = function(
|
79
|
-
return Spree.pathFor('api/v1/stock_locations/' +
|
78
|
+
Spree.routes.stock_items_api = function (stockLocationId) {
|
79
|
+
return Spree.pathFor('api/v1/stock_locations/' + stockLocationId + '/stock_items')
|
80
80
|
}
|
@@ -1,33 +1,33 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
// eslint-disable-next-line camelcase, no-unused-vars
|
2
|
+
function update_state (region, done) {
|
3
|
+
'use strict'
|
3
4
|
|
4
|
-
var country = $('span#' + region + 'country .select2').select2('val')
|
5
|
-
var
|
6
|
-
var
|
5
|
+
var country = $('span#' + region + 'country .select2').select2('val')
|
6
|
+
var stateSelect = $('span#' + region + 'state select.select2')
|
7
|
+
var stateInput = $('span#' + region + 'state input.state_name')
|
7
8
|
|
8
9
|
$.get(Spree.routes.states_search + '?country_id=' + country, function (data) {
|
9
|
-
var states = data.states
|
10
|
+
var states = data.states
|
10
11
|
if (states.length > 0) {
|
11
|
-
|
12
|
-
var
|
12
|
+
stateSelect.html('')
|
13
|
+
var statesWithBlank = [{
|
13
14
|
name: '',
|
14
15
|
id: ''
|
15
|
-
}].concat(states)
|
16
|
-
$.each(
|
16
|
+
}].concat(states)
|
17
|
+
$.each(statesWithBlank, function (pos, state) {
|
17
18
|
var opt = $(document.createElement('option'))
|
18
19
|
.prop('value', state.id)
|
19
|
-
.html(state.name)
|
20
|
-
|
21
|
-
})
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
.html(state.name)
|
21
|
+
stateSelect.append(opt)
|
22
|
+
})
|
23
|
+
stateSelect.prop('disabled', false).show()
|
24
|
+
stateSelect.select2()
|
25
|
+
stateInput.hide().prop('disabled', true)
|
26
26
|
} else {
|
27
|
-
|
28
|
-
|
27
|
+
stateInput.prop('disabled', false).show()
|
28
|
+
stateSelect.select2('destroy').hide()
|
29
29
|
}
|
30
30
|
|
31
|
-
if(done) done()
|
32
|
-
})
|
31
|
+
if (done) done()
|
32
|
+
})
|
33
33
|
};
|
@@ -0,0 +1,25 @@
|
|
1
|
+
/* global order_number, show_flash */
|
2
|
+
$(function () {
|
3
|
+
$('[data-hook=adjustments_new_coupon_code] #add_coupon_code').click(function () {
|
4
|
+
var couponCode = $('#coupon_code').val()
|
5
|
+
if (couponCode.length === 0) {
|
6
|
+
return
|
7
|
+
}
|
8
|
+
$.ajax({
|
9
|
+
type: 'PUT',
|
10
|
+
url: Spree.url(Spree.routes.apply_coupon_code(order_number)),
|
11
|
+
data: {
|
12
|
+
coupon_code: couponCode,
|
13
|
+
token: Spree.api_key
|
14
|
+
}
|
15
|
+
}).done(function () {
|
16
|
+
window.location.reload()
|
17
|
+
}).fail(function (message) {
|
18
|
+
if (message.responseJSON['error']) {
|
19
|
+
show_flash('error', message.responseJSON['error'])
|
20
|
+
} else {
|
21
|
+
show_flash('error', 'There was a problem adding this coupon code.')
|
22
|
+
}
|
23
|
+
})
|
24
|
+
})
|
25
|
+
})
|
@@ -4,193 +4,199 @@ under the spree namespace that do stuff we find helpful.
|
|
4
4
|
Hopefully, this will evolve into a propper class.
|
5
5
|
**/
|
6
6
|
|
7
|
-
|
7
|
+
/* global Cookies, AUTH_TOKEN, order_number */
|
8
8
|
|
9
|
+
jQuery(function ($) {
|
9
10
|
// Add some tips
|
10
|
-
$('.with-tip').tooltip()
|
11
|
-
|
12
|
-
$('.js-show-index-filters').click(function(){
|
13
|
-
$(
|
14
|
-
$(this).parents(
|
15
|
-
$(
|
16
|
-
})
|
17
|
-
|
18
|
-
$('#main-sidebar').find('[data-toggle="collapse"]').on('click', function()
|
19
|
-
{
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
else {
|
24
|
-
$(this).find('.icon-chevron-down').removeClass('icon-chevron-down').addClass('icon-chevron-left');
|
25
|
-
}
|
11
|
+
$('.with-tip').tooltip()
|
12
|
+
|
13
|
+
$('.js-show-index-filters').click(function () {
|
14
|
+
$('.filter-well').slideToggle()
|
15
|
+
$(this).parents('.filter-wrap').toggleClass('collapsed')
|
16
|
+
$('span.icon', $(this)).toggleClass('icon-chevron-down')
|
17
|
+
})
|
18
|
+
|
19
|
+
$('#main-sidebar').find('[data-toggle="collapse"]').on('click', function () {
|
20
|
+
if ($(this).find('.icon-chevron-left').length === 1) {
|
21
|
+
$(this).find('.icon-chevron-left').removeClass('icon-chevron-left').addClass('icon-chevron-down')
|
22
|
+
} else {
|
23
|
+
$(this).find('.icon-chevron-down').removeClass('icon-chevron-down').addClass('icon-chevron-left')
|
26
24
|
}
|
27
|
-
)
|
25
|
+
})
|
28
26
|
|
29
27
|
// Sidebar nav toggle functionality
|
30
|
-
|
31
|
-
|
32
|
-
var
|
33
|
-
var
|
34
|
-
var sidebar = $('#main-sidebar');
|
28
|
+
$('#sidebar-toggle').on('click', function () {
|
29
|
+
var wrapper = $('#wrapper')
|
30
|
+
var main = $('#main-part')
|
31
|
+
var sidebar = $('#main-sidebar')
|
35
32
|
|
36
33
|
// these should match `spree/backend/app/helpers/spree/admin/navigation_helper.rb#main_part_classes`
|
37
|
-
var mainWrapperCollapsedClasses = 'col-xs-12 sidebar-collapsed'
|
38
|
-
var mainWrapperExpandedClasses = 'col-xs-9 col-xs-offset-3 col-md-10 col-md-offset-2'
|
34
|
+
var mainWrapperCollapsedClasses = 'col-xs-12 sidebar-collapsed'
|
35
|
+
var mainWrapperExpandedClasses = 'col-xs-9 col-xs-offset-3 col-md-10 col-md-offset-2'
|
39
36
|
|
40
|
-
wrapper.toggleClass('sidebar-minimized')
|
41
|
-
sidebar.toggleClass('hidden-xs')
|
37
|
+
wrapper.toggleClass('sidebar-minimized')
|
38
|
+
sidebar.toggleClass('hidden-xs')
|
42
39
|
main
|
43
40
|
.toggleClass(mainWrapperCollapsedClasses)
|
44
|
-
.toggleClass(mainWrapperExpandedClasses)
|
41
|
+
.toggleClass(mainWrapperExpandedClasses)
|
45
42
|
|
46
43
|
if (wrapper.hasClass('sidebar-minimized')) {
|
47
|
-
|
44
|
+
Cookies.set('sidebar-minimized', 'true', { path: '/admin' })
|
48
45
|
} else {
|
49
|
-
|
46
|
+
Cookies.set('sidebar-minimized', 'false', { path: '/admin' })
|
50
47
|
}
|
51
|
-
})
|
48
|
+
})
|
52
49
|
|
53
|
-
$('.sidebar-menu-item').mouseover(function(){
|
54
|
-
if($('#wrapper').hasClass('sidebar-minimized')){
|
55
|
-
$(this).addClass('menu-active')
|
56
|
-
$(this).find('ul.nav').addClass('submenu-active')
|
50
|
+
$('.sidebar-menu-item').mouseover(function () {
|
51
|
+
if ($('#wrapper').hasClass('sidebar-minimized')) {
|
52
|
+
$(this).addClass('menu-active')
|
53
|
+
$(this).find('ul.nav').addClass('submenu-active')
|
57
54
|
}
|
58
|
-
})
|
59
|
-
$('.sidebar-menu-item').mouseout(function(){
|
60
|
-
if($('#wrapper').hasClass('sidebar-minimized')){
|
61
|
-
$(this).removeClass('menu-active')
|
62
|
-
$(this).find('ul.nav').removeClass('submenu-active')
|
55
|
+
})
|
56
|
+
$('.sidebar-menu-item').mouseout(function () {
|
57
|
+
if ($('#wrapper').hasClass('sidebar-minimized')) {
|
58
|
+
$(this).removeClass('menu-active')
|
59
|
+
$(this).find('ul.nav').removeClass('submenu-active')
|
63
60
|
}
|
64
|
-
})
|
61
|
+
})
|
65
62
|
|
66
63
|
// TODO: remove this js temp behaviour and fix this decent
|
67
64
|
// Temp quick search
|
68
65
|
// When there was a search term, copy it
|
69
|
-
$(
|
66
|
+
$('.js-quick-search').val($('.js-quick-search-target').val())
|
70
67
|
// Catch the quick search form submit and submit the real form
|
71
|
-
$(
|
72
|
-
$(
|
73
|
-
$(
|
74
|
-
return false
|
75
|
-
})
|
68
|
+
$('#quick-search').submit(function () {
|
69
|
+
$('.js-quick-search-target').val($('.js-quick-search').val())
|
70
|
+
$('#table-filter form').submit()
|
71
|
+
return false
|
72
|
+
})
|
76
73
|
|
77
74
|
// Main menu active item submenu show
|
78
|
-
var
|
79
|
-
|
80
|
-
|
75
|
+
var activeItem = $('#main-sidebar').find('.selected')
|
76
|
+
activeItem.closest('.nav-pills').addClass('in')
|
77
|
+
activeItem.closest('.nav-sidebar')
|
81
78
|
.find('.icon-chevron-left')
|
82
79
|
.removeClass('icon-chevron-left')
|
83
|
-
.addClass('icon-chevron-down')
|
80
|
+
.addClass('icon-chevron-down')
|
84
81
|
|
85
82
|
// Replace ▼ and ▲ in sort_link with nicer icons
|
86
|
-
$(
|
83
|
+
$('.sort_link').each(function () {
|
87
84
|
// Remove the in the text
|
88
|
-
var
|
89
|
-
|
90
|
-
if(
|
91
|
-
$(this).text(
|
92
|
-
$(this).append('<span class="icon icon-chevron-down"></span>')
|
93
|
-
} else if(
|
94
|
-
$(this).text(
|
95
|
-
$(this).append('<span class="icon icon-chevron-up"></span>')
|
85
|
+
var sortLinkText = $(this).text().replace('\xA0', '')
|
86
|
+
|
87
|
+
if (sortLinkText.indexOf('▼') >= 0) {
|
88
|
+
$(this).text(sortLinkText.replace('▼', ''))
|
89
|
+
$(this).append('<span class="icon icon-chevron-down"></span>')
|
90
|
+
} else if (sortLinkText.indexOf('▲') >= 0) {
|
91
|
+
$(this).text(sortLinkText.replace('▲', ''))
|
92
|
+
$(this).append('<span class="icon icon-chevron-up"></span>')
|
96
93
|
}
|
97
|
-
})
|
94
|
+
})
|
98
95
|
|
99
96
|
// Clickable ransack filters
|
100
|
-
$(
|
101
|
-
var
|
102
|
-
var
|
97
|
+
$('.js-add-filter').click(function () {
|
98
|
+
var ransackField = $(this).data('ransack-field')
|
99
|
+
var ransackValue = $(this).data('ransack-value')
|
100
|
+
|
101
|
+
$('#' + ransackField).val(ransackValue)
|
102
|
+
$('#table-filter form').submit()
|
103
|
+
})
|
103
104
|
|
104
|
-
|
105
|
-
$(
|
106
|
-
});
|
105
|
+
$(document).on('click', '.js-delete-filter', function () {
|
106
|
+
var ransackField = $(this).parents('.js-filter').data('ransack-field')
|
107
107
|
|
108
|
-
|
109
|
-
|
108
|
+
$('#' + ransackField).val('')
|
109
|
+
$('#table-filter form').submit()
|
110
|
+
})
|
110
111
|
|
111
|
-
|
112
|
-
|
113
|
-
|
112
|
+
function ransackField (value) {
|
113
|
+
switch (value) {
|
114
|
+
case 'Date Range':
|
115
|
+
return 'Start'
|
116
|
+
case '':
|
117
|
+
return 'Stop'
|
118
|
+
default:
|
119
|
+
return value.trim()
|
120
|
+
}
|
121
|
+
}
|
114
122
|
|
115
|
-
$(
|
116
|
-
var $this = $(this)
|
123
|
+
$('.js-filterable').each(function () {
|
124
|
+
var $this = $(this)
|
117
125
|
|
118
126
|
if ($this.val()) {
|
119
|
-
var
|
120
|
-
var
|
121
|
-
var label = $('label[for="' +
|
127
|
+
var ransackValue, filter
|
128
|
+
var ransackFieldId = $this.attr('id')
|
129
|
+
var label = $('label[for="' + ransackFieldId + '"]')
|
122
130
|
|
123
|
-
if ($this.is(
|
124
|
-
|
131
|
+
if ($this.is('select')) {
|
132
|
+
ransackValue = $this.find('option:selected').text()
|
125
133
|
} else {
|
126
|
-
|
134
|
+
ransackValue = $this.val()
|
127
135
|
}
|
128
136
|
|
129
|
-
label = label.text() + ': ' +
|
130
|
-
filter = '<span class="js-filter label label-default" data-ransack-field="' + ransack_field + '">' + label + '<span class="icon icon-delete js-delete-filter"></span></span>';
|
137
|
+
label = ransackField(label.text()) + ': ' + ransackValue
|
131
138
|
|
132
|
-
|
139
|
+
filter = '<span class="js-filter label label-default" data-ransack-field="' + ransackFieldId + '">' + label + '<span class="icon icon-delete js-delete-filter"></span></span>'
|
140
|
+
$('.js-filters').append(filter).show()
|
133
141
|
}
|
134
|
-
})
|
142
|
+
})
|
135
143
|
|
136
144
|
// per page dropdown
|
137
145
|
// preserves all selected filters / queries supplied by user
|
138
146
|
// changes only per_page value
|
139
|
-
$(
|
140
|
-
var form
|
141
|
-
var url
|
142
|
-
var value = $(this).val().toString()
|
147
|
+
$('.js-per-page-select').change(function () {
|
148
|
+
var form = $(this).closest('.js-per-page-form')
|
149
|
+
var url = form.attr('action')
|
150
|
+
var value = $(this).val().toString()
|
143
151
|
if (url.match(/\?/)) {
|
144
|
-
url +=
|
152
|
+
url += '&per_page=' + value
|
145
153
|
} else {
|
146
|
-
url +=
|
154
|
+
url += '?per_page=' + value
|
147
155
|
}
|
148
|
-
window.location = url
|
149
|
-
})
|
156
|
+
window.location = url
|
157
|
+
})
|
150
158
|
|
151
159
|
// injects per_page settings to all available search forms
|
152
160
|
// so when user changes some filters / queries per_page is preserved
|
153
|
-
$(document).ready(function() {
|
154
|
-
var perPageDropdown = $(
|
161
|
+
$(document).ready(function () {
|
162
|
+
var perPageDropdown = $('.js-per-page-select:first')
|
155
163
|
if (perPageDropdown.length) {
|
156
|
-
var perPageValue = perPageDropdown.val().toString()
|
157
|
-
var perPageInput = '<input type="hidden" name="per_page" value=' + perPageValue + ' />'
|
158
|
-
$(
|
164
|
+
var perPageValue = perPageDropdown.val().toString()
|
165
|
+
var perPageInput = '<input type="hidden" name="per_page" value=' + perPageValue + ' />'
|
166
|
+
$('#table-filter form').append(perPageInput)
|
159
167
|
}
|
160
|
-
})
|
168
|
+
})
|
161
169
|
|
162
170
|
// Make flash messages disappear
|
163
|
-
setTimeout(
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
flash_div = $('<div class="alert alert-' + type + '" />');
|
174
|
-
$('#content').prepend(flash_div);
|
171
|
+
setTimeout(function () { $('.alert-auto-disappear').slideUp() }, 5000)
|
172
|
+
})
|
173
|
+
|
174
|
+
$.fn.visible = function (cond) { this[ cond ? 'show' : 'hide' ]() }
|
175
|
+
// eslint-disable-next-line camelcase
|
176
|
+
function show_flash (type, message) {
|
177
|
+
var flashDiv = $('.alert-' + type)
|
178
|
+
if (flashDiv.length === 0) {
|
179
|
+
flashDiv = $('<div class="alert alert-' + type + '" />')
|
180
|
+
$('#content').prepend(flashDiv)
|
175
181
|
}
|
176
|
-
|
182
|
+
flashDiv.html(message).show().delay(10000).slideUp()
|
177
183
|
}
|
178
184
|
|
179
|
-
|
180
185
|
// Apply to individual radio button that makes another element visible when checked
|
181
|
-
$.fn.radioControlsVisibilityOfElement = function(dependentElementSelector){
|
182
|
-
if(!this.get(0)){ return
|
183
|
-
showValue = this.get(0).value
|
184
|
-
radioGroup = $("input[name='" + this.get(0).name + "']")
|
185
|
-
radioGroup.each(function(){
|
186
|
-
$(this).click(function(){
|
186
|
+
$.fn.radioControlsVisibilityOfElement = function (dependentElementSelector) {
|
187
|
+
if (!this.get(0)) { return }
|
188
|
+
var showValue = this.get(0).value
|
189
|
+
var radioGroup = $("input[name='" + this.get(0).name + "']")
|
190
|
+
radioGroup.each(function () {
|
191
|
+
$(this).click(function () {
|
192
|
+
// eslint-disable-next-line eqeqeq
|
187
193
|
$(dependentElementSelector).visible(this.checked && this.value == showValue)
|
188
|
-
})
|
189
|
-
if(this.checked){ this.click() }
|
190
|
-
})
|
194
|
+
})
|
195
|
+
if (this.checked) { this.click() }
|
196
|
+
})
|
191
197
|
}
|
192
|
-
|
193
|
-
handle_date_picker_fields
|
198
|
+
// eslint-disable-next-line camelcase
|
199
|
+
function handle_date_picker_fields () {
|
194
200
|
$('.datepicker').datepicker({
|
195
201
|
dateFormat: Spree.translations.date_picker,
|
196
202
|
dayNames: Spree.translations.abbr_day_names,
|
@@ -199,184 +205,187 @@ handle_date_picker_fields = function(){
|
|
199
205
|
monthNames: Spree.translations.month_names,
|
200
206
|
prevText: Spree.translations.previous,
|
201
207
|
nextText: Spree.translations.next,
|
202
|
-
showOn:
|
203
|
-
})
|
208
|
+
showOn: 'focus'
|
209
|
+
})
|
204
210
|
|
205
211
|
// Correctly display range dates
|
206
|
-
$('.date-range-filter .datepicker-from').datepicker('option', 'onSelect', function(selectedDate) {
|
207
|
-
$(
|
208
|
-
})
|
209
|
-
$('.date-range-filter .datepicker-to').datepicker('option', 'onSelect', function(selectedDate) {
|
210
|
-
$(
|
211
|
-
})
|
212
|
+
$('.date-range-filter .datepicker-from').datepicker('option', 'onSelect', function (selectedDate) {
|
213
|
+
$('.date-range-filter .datepicker-to').datepicker('option', 'minDate', selectedDate)
|
214
|
+
})
|
215
|
+
$('.date-range-filter .datepicker-to').datepicker('option', 'onSelect', function (selectedDate) {
|
216
|
+
$('.date-range-filter .datepicker-from').datepicker('option', 'maxDate', selectedDate)
|
217
|
+
})
|
212
218
|
}
|
213
219
|
|
214
|
-
$(document).ready(function(){
|
215
|
-
handle_date_picker_fields()
|
216
|
-
$(
|
217
|
-
target = $(this).data(
|
218
|
-
$(target).hide()
|
220
|
+
$(document).ready(function () {
|
221
|
+
handle_date_picker_fields()
|
222
|
+
$('.observe_field').on('change', function () {
|
223
|
+
var target = $(this).data('update')
|
224
|
+
$(target).hide()
|
219
225
|
$.ajax({ dataType: 'html',
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
})
|
227
|
-
})
|
228
|
-
|
229
|
-
var uniqueId = 1
|
230
|
-
$('.spree_add_fields').click(function() {
|
231
|
-
var target = $(this).data(
|
232
|
-
var
|
233
|
-
var
|
234
|
-
|
235
|
-
var el = $(this)
|
236
|
-
el.val(
|
237
|
-
el.prop(
|
238
|
-
el.prop(
|
226
|
+
url: $(this).data('base-url') + encodeURIComponent($(this).val()),
|
227
|
+
type: 'get',
|
228
|
+
success: function (data) {
|
229
|
+
$(target).html(data)
|
230
|
+
$(target).show()
|
231
|
+
}
|
232
|
+
})
|
233
|
+
})
|
234
|
+
|
235
|
+
var uniqueId = 1
|
236
|
+
$('.spree_add_fields').click(function () {
|
237
|
+
var target = $(this).data('target')
|
238
|
+
var newTableRow = $(target + ' tr:visible:last').clone()
|
239
|
+
var newId = new Date().getTime() + (uniqueId++)
|
240
|
+
newTableRow.find('input, select').each(function () {
|
241
|
+
var el = $(this)
|
242
|
+
el.val('')
|
243
|
+
el.prop('id', el.prop('id').replace(/\d+/, newId))
|
244
|
+
el.prop('name', el.prop('name').replace(/\d+/, newId))
|
239
245
|
})
|
240
246
|
// When cloning a new row, set the href of all icons to be an empty "#"
|
241
247
|
// This is so that clicking on them does not perform the actions for the
|
242
248
|
// duplicated row
|
243
|
-
|
244
|
-
var el = $(this)
|
245
|
-
el.prop('href', '#')
|
249
|
+
newTableRow.find('a').each(function () {
|
250
|
+
var el = $(this)
|
251
|
+
el.prop('href', '#')
|
246
252
|
})
|
247
|
-
$(target).prepend(
|
253
|
+
$(target).prepend(newTableRow)
|
248
254
|
})
|
249
255
|
|
250
|
-
$('body').on('click', '.delete-resource', function() {
|
251
|
-
var el = $(this)
|
252
|
-
if (confirm(el.data(
|
256
|
+
$('body').on('click', '.delete-resource', function () {
|
257
|
+
var el = $(this)
|
258
|
+
if (confirm(el.data('confirm'))) {
|
253
259
|
$.ajax({
|
254
260
|
type: 'POST',
|
255
|
-
url: $(this).prop(
|
261
|
+
url: $(this).prop('href'),
|
256
262
|
data: {
|
257
263
|
_method: 'delete',
|
258
264
|
authenticity_token: AUTH_TOKEN
|
259
265
|
},
|
260
266
|
dataType: 'script',
|
261
|
-
success: function(response) {
|
262
|
-
var $
|
263
|
-
if ($
|
264
|
-
el.parents(
|
265
|
-
$(this).remove()
|
266
|
-
})
|
267
|
+
success: function (response) {
|
268
|
+
var $flashElement = $('.alert-success')
|
269
|
+
if ($flashElement.length) {
|
270
|
+
el.parents('tr').fadeOut('hide', function () {
|
271
|
+
$(this).remove()
|
272
|
+
})
|
267
273
|
}
|
268
274
|
},
|
269
|
-
error: function(response, textStatus, errorThrown) {
|
270
|
-
show_flash('error', response.responseText)
|
275
|
+
error: function (response, textStatus, errorThrown) {
|
276
|
+
show_flash('error', response.responseText)
|
271
277
|
}
|
272
|
-
})
|
278
|
+
})
|
273
279
|
}
|
274
|
-
return false
|
275
|
-
})
|
276
|
-
|
277
|
-
$('body').on('click', 'a.spree_remove_fields', function() {
|
278
|
-
el = $(this)
|
279
|
-
el.prev(
|
280
|
-
el.closest(
|
281
|
-
if (el.prop(
|
282
|
-
el.parents(
|
283
|
-
}else if (el.prop(
|
280
|
+
return false
|
281
|
+
})
|
282
|
+
|
283
|
+
$('body').on('click', 'a.spree_remove_fields', function () {
|
284
|
+
var el = $(this)
|
285
|
+
el.prev('input[type=hidden]').val('1')
|
286
|
+
el.closest('.fields').hide()
|
287
|
+
if (el.prop('href').substr(-1) === '#') {
|
288
|
+
el.parents('tr').fadeOut('hide')
|
289
|
+
} else if (el.prop('href')) {
|
284
290
|
$.ajax({
|
285
291
|
type: 'POST',
|
286
|
-
url: el.prop(
|
292
|
+
url: el.prop('href'),
|
287
293
|
data: {
|
288
294
|
_method: 'delete',
|
289
295
|
authenticity_token: AUTH_TOKEN
|
290
296
|
},
|
291
|
-
success: function(response) {
|
292
|
-
el.parents(
|
293
|
-
$(this).remove()
|
294
|
-
})
|
297
|
+
success: function (response) {
|
298
|
+
el.parents('tr').fadeOut('hide', function () {
|
299
|
+
$(this).remove()
|
300
|
+
})
|
295
301
|
},
|
296
|
-
error: function(response, textStatus, errorThrown) {
|
297
|
-
show_flash('error', response.responseText)
|
302
|
+
error: function (response, textStatus, errorThrown) {
|
303
|
+
show_flash('error', response.responseText)
|
298
304
|
}
|
299
305
|
|
300
306
|
})
|
301
307
|
}
|
302
|
-
return false
|
303
|
-
})
|
304
|
-
|
305
|
-
$('body').on('click', '.select_properties_from_prototype', function(){
|
306
|
-
$(
|
307
|
-
var
|
308
|
-
$.ajax({ dataType: 'script',
|
309
|
-
|
310
|
-
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
|
308
|
+
return false
|
309
|
+
})
|
310
|
+
|
311
|
+
$('body').on('click', '.select_properties_from_prototype', function () {
|
312
|
+
$('#busy_indicator').show()
|
313
|
+
var clickedLink = $(this)
|
314
|
+
$.ajax({ dataType: 'script',
|
315
|
+
url: clickedLink.prop('href'),
|
316
|
+
type: 'get',
|
317
|
+
success: function (data) {
|
318
|
+
clickedLink.parent('td').parent('tr').hide()
|
319
|
+
$('#busy_indicator').hide()
|
320
|
+
}
|
321
|
+
})
|
322
|
+
return false
|
323
|
+
})
|
316
324
|
|
317
325
|
// Fix sortable helper
|
318
|
-
var fixHelper = function(e, ui) {
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
}
|
324
|
-
|
325
|
-
$('table.sortable').ready(function(){
|
326
|
-
var
|
326
|
+
var fixHelper = function (e, ui) {
|
327
|
+
ui.children().each(function () {
|
328
|
+
$(this).width($(this).width())
|
329
|
+
})
|
330
|
+
return ui
|
331
|
+
}
|
332
|
+
|
333
|
+
$('table.sortable').ready(function () {
|
334
|
+
var tdCount = $(this).find('tbody tr:first-child td').length
|
327
335
|
$('table.sortable tbody').sortable(
|
328
336
|
{
|
329
337
|
handle: '.handle',
|
330
338
|
helper: fixHelper,
|
331
339
|
placeholder: 'ui-sortable-placeholder',
|
332
|
-
update: function(event, ui) {
|
333
|
-
var tbody = this
|
334
|
-
$(
|
335
|
-
positions = {}
|
336
|
-
$.each($('tr', tbody), function(position, obj){
|
337
|
-
reg = /spree_(\w+_?)+_(\d+)
|
338
|
-
parts = reg.exec($(obj).prop('id'))
|
340
|
+
update: function (event, ui) {
|
341
|
+
var tbody = this
|
342
|
+
$('#progress').show()
|
343
|
+
var positions = {}
|
344
|
+
$.each($('tr', tbody), function (position, obj) {
|
345
|
+
var reg = /spree_(\w+_?)+_(\d+)/
|
346
|
+
var parts = reg.exec($(obj).prop('id'))
|
339
347
|
if (parts) {
|
340
|
-
positions['positions['+parts[2]+']'] = position+1
|
348
|
+
positions['positions[' + parts[2] + ']'] = position + 1
|
341
349
|
}
|
342
|
-
})
|
350
|
+
})
|
343
351
|
$.ajax({
|
344
352
|
type: 'POST',
|
345
353
|
dataType: 'script',
|
346
|
-
url: $(ui.item).closest(
|
354
|
+
url: $(ui.item).closest('table.sortable').data('sortable-link'),
|
347
355
|
data: positions,
|
348
|
-
success: function(data){ $(
|
349
|
-
})
|
356
|
+
success: function (data) { $('#progress').hide() }
|
357
|
+
})
|
350
358
|
},
|
351
359
|
start: function (event, ui) {
|
352
360
|
// Set correct height for placehoder (from dragged tr)
|
353
361
|
ui.placeholder.height(ui.item.height())
|
354
362
|
// Fix placeholder content to make it correct width
|
355
|
-
ui.placeholder.html("<td colspan='"+(
|
363
|
+
ui.placeholder.html("<td colspan='" + (tdCount - 1) + "'></td><td class='actions'></td>")
|
356
364
|
},
|
357
365
|
stop: function (event, ui) {
|
358
366
|
// Fix odd/even classes after reorder
|
359
|
-
$(
|
360
|
-
$(
|
367
|
+
$('table.sortable tr:even').removeClass('odd even').addClass('even')
|
368
|
+
$('table.sortable tr:odd').removeClass('odd even').addClass('odd')
|
361
369
|
}
|
362
370
|
|
363
|
-
})
|
364
|
-
})
|
371
|
+
})
|
372
|
+
})
|
365
373
|
|
366
|
-
$('a.dismiss').click(function() {
|
367
|
-
$(this).parent().fadeOut()
|
368
|
-
})
|
374
|
+
$('a.dismiss').click(function () {
|
375
|
+
$(this).parent().fadeOut()
|
376
|
+
})
|
369
377
|
|
370
|
-
window.Spree.advanceOrder = function() {
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
378
|
+
window.Spree.advanceOrder = function () {
|
379
|
+
$.ajax({
|
380
|
+
type: 'PUT',
|
381
|
+
async: false,
|
382
|
+
data: {
|
383
|
+
token: Spree.api_key
|
384
|
+
},
|
385
|
+
// eslint-disable-next-line camelcase
|
386
|
+
url: Spree.url(Spree.routes.checkouts_api + '/' + order_number + '/advance')
|
387
|
+
}).done(function () {
|
388
|
+
window.location.reload()
|
389
|
+
})
|
381
390
|
}
|
382
|
-
})
|
391
|
+
})
|