spree_backend 4.3.0.rc3 → 4.3.0
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/global/select2_autocomplete.es6 +69 -93
- data/app/assets/javascripts/spree/backend/global/select2_populate.es6 +39 -13
- data/app/assets/stylesheets/spree/backend/shared/_base.scss +4 -0
- data/app/controllers/spree/admin/images_controller.rb +25 -8
- data/app/views/spree/admin/cms_sections/types/_hero_image.html.erb +3 -4
- data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +12 -15
- data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +2 -2
- data/app/views/spree/admin/images/index.html.erb +1 -1
- data/app/views/spree/admin/shared/cms/_spree_product.html.erb +23 -10
- data/app/views/spree/admin/shared/cms/_spree_taxon.html.erb +23 -10
- data/app/views/spree/admin/shared/linkables/_spree_cms_page.erb +1 -6
- metadata +11 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fd79c7d41af70e530135379477cad943762adefcda2c0069b061401a80aa1cb8
|
4
|
+
data.tar.gz: d382525f3b1cbbda22a0e01c75ec3eb650e9ee229a5fbe05d1b9bd52442137fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9420ad664486b5a2fbb73ee87d5eeaf2d176f6e476f872405db17d0ca7a0251e9140500807778db46868e66dd145294edc13d2aa5d56db9cb51dca25db284db6
|
7
|
+
data.tar.gz: 133e906040edfda99ec1495d1a04d59e339cf250d85694d6ed175aa2f06d78b7558ce502b6ba3359301fec0533d5323ea643ef9024334024e71d08450ddab930
|
@@ -1,37 +1,25 @@
|
|
1
1
|
// SELECT2 AUTOCOMPLETE JS
|
2
|
-
//
|
3
|
-
//
|
4
|
-
// as shown here: <select class="select2autocomplete"></select>.
|
2
|
+
// The JavaScript in this file allows Spree developers to set up Select2 autocomplete search
|
3
|
+
// using the API v2 by simply adding data attributes to a select element.
|
5
4
|
|
6
5
|
// REQUIRED ATTRIBUTES
|
7
|
-
//
|
8
|
-
//
|
9
|
-
//
|
10
|
-
// Example:
|
6
|
+
// You must provide a URL for the API V2, use the format shown below. See backend.js for other API V2 URL's.
|
7
|
+
// REQUIRED:
|
11
8
|
// data-autocomplete-url-value="products_api_v2"
|
12
9
|
|
13
|
-
//
|
14
|
-
//
|
15
|
-
//
|
16
|
-
//
|
17
|
-
//
|
18
|
-
// data-autocomplete-
|
19
|
-
// data-autocomplete-
|
20
|
-
// data-autocomplete-
|
21
|
-
// data-autocomplete-
|
22
|
-
// data-autocomplete-min-input-value="4" <- Minimum input for search | DEFAULT is: 3
|
23
|
-
// data-autocomplete-search-query-value="title_i_cont" <- Custom search query | DEFAULT is: 'name_i_cont'
|
24
|
-
// data-autocomplete-custom-return-id-value="permalink" <- Return a custom attribute rather than the ID | DEFAULT: returns id
|
10
|
+
// OPTIONAL:
|
11
|
+
// data-autocomplete-placeholder-value="Seach Pages" <- Sets the placeholder | DEFAULT is: 'Search'.
|
12
|
+
// data-autocomplete-clear-value=boolean <- Allow select2 to be cleared | DEFAULT is: false (no clear button).
|
13
|
+
// data-autocomplete-multiple-value=boolean <- Multiple or Single select | DEFAULT is: false (single).
|
14
|
+
// data-autocomplete-return-attr-value="pretty_name" <- Return Attribute. | DEFAULT is: 'name'.
|
15
|
+
// data-autocomplete-min-input-value="4" <- Minimum input for search | DEFAULT is: 3.
|
16
|
+
// data-autocomplete-search-query-value="title_i_cont" <- Custom search query | DEFAULT is: 'name_i_cont'.
|
17
|
+
// data-autocomplete-custom-return-id-value="permalink" <- Return a custom attribute | DEFAULT: returns id.
|
18
|
+
// data-autocomplete-debug-mode-value=boolean <- Turn on console loggin of data returned by the request.
|
25
19
|
//
|
26
|
-
//
|
27
|
-
//
|
28
|
-
//
|
29
|
-
// here we only want to retuen Pages that have linkable slugs, not homepages, and so we filter those using the
|
30
|
-
// data attributes shown below.
|
31
|
-
//
|
32
|
-
// Examples:
|
33
|
-
// data-autocomplete-additional-query-value="type_not_eq" <- Additional hard coded query | DEFAULT: null (not used)
|
34
|
-
// data-autocomplete-additional-term-value="Spree::Cms::Pages::Homepage" <- Additional hard coded term | DEFAULT: null (not used)
|
20
|
+
// Add your own custom URL params to the request as needed
|
21
|
+
// EXAMPLE:
|
22
|
+
// data-autocomplete-additional-url-params-value="filter[type_not_eq]=Spree::Cms::Pages::Homepage"
|
35
23
|
|
36
24
|
document.addEventListener('DOMContentLoaded', function() {
|
37
25
|
loadAutoCompleteParams()
|
@@ -45,10 +33,7 @@ function loadAutoCompleteParams() {
|
|
45
33
|
|
46
34
|
function buildParamsFromDataAttrs(element) {
|
47
35
|
$(element).select2Autocomplete({
|
48
|
-
// Required Attributes
|
49
36
|
apiUrl: Spree.routes[element.dataset.autocompleteUrlValue],
|
50
|
-
|
51
|
-
// Optional Attributes
|
52
37
|
placeholder: element.dataset.autocompletePlaceholderValue,
|
53
38
|
allow_clear: element.dataset.autocompleteClearValue,
|
54
39
|
multiple: element.dataset.autocompleteMultipleValue,
|
@@ -56,21 +41,17 @@ function buildParamsFromDataAttrs(element) {
|
|
56
41
|
minimum_input: element.dataset.autocompleteMinInputValue,
|
57
42
|
search_query: element.dataset.autocompleteSearchQueryValue,
|
58
43
|
custom_return_id: element.dataset.autocompleteCustomReturnIdValue,
|
59
|
-
|
60
|
-
|
61
|
-
additional_query: element.dataset.autocompleteAdditionalQueryValue,
|
62
|
-
additional_term: element.dataset.autocompleteAdditionalTermValue
|
44
|
+
additional_url_params: element.dataset.autocompleteAdditionalUrlParamsValue,
|
45
|
+
debug_mode: element.dataset.autocompleteDebugModeValue
|
63
46
|
})
|
64
47
|
}
|
65
48
|
|
66
|
-
// Can also be called directly as javastript.
|
67
49
|
$.fn.select2Autocomplete = function(params) {
|
68
|
-
|
69
|
-
|
70
|
-
const resourcePlural = apiUrl.match(/([^/]*)\/*$/)[1]
|
71
|
-
const resourceSingular = resourcePlural.slice(0, -1)
|
50
|
+
let apiUrl = null
|
51
|
+
let returnedFields
|
72
52
|
|
73
|
-
|
53
|
+
const resourcePlural = params.apiUrl.match(/([^/]*)\/*$/)[1]
|
54
|
+
const resourceSingular = resourcePlural.slice(0, -1)
|
74
55
|
const select2placeHolder = params.placeholder || Spree.translations.search
|
75
56
|
const select2Multiple = params.multiple || false
|
76
57
|
const select2allowClear = params.allow_clear || false
|
@@ -78,9 +59,32 @@ $.fn.select2Autocomplete = function(params) {
|
|
78
59
|
const minimumInput = params.minimum_input || 3
|
79
60
|
const searchQuery = params.search_query || 'name_i_cont'
|
80
61
|
const customReturnId = params.custom_return_id || null
|
81
|
-
const
|
82
|
-
const
|
62
|
+
const additionalUrlParams = params.additional_url_params || null
|
63
|
+
const DebugMode = params.debug_mode || null
|
64
|
+
|
65
|
+
//
|
66
|
+
// Set up a clean URL for sparseFields
|
67
|
+
if (customReturnId == null) {
|
68
|
+
returnedFields = returnAttribute
|
69
|
+
} else {
|
70
|
+
returnedFields = `${returnAttribute},${customReturnId}`
|
71
|
+
}
|
72
|
+
const sparseFields = `fields[${resourceSingular}]=${returnedFields}`
|
73
|
+
|
74
|
+
//
|
75
|
+
// Set up a clean URL for Additional URL Params
|
76
|
+
if (additionalUrlParams != null) {
|
77
|
+
// URL + Additional URL Params + Sparse Fields
|
78
|
+
apiUrl = `${params.apiUrl}?${additionalUrlParams}&${sparseFields}`
|
79
|
+
} else {
|
80
|
+
// URL + Sparse Fields (the default response for a noraml Select2)
|
81
|
+
apiUrl = `${params.apiUrl}?${sparseFields}`
|
82
|
+
}
|
83
83
|
|
84
|
+
if (DebugMode != null) console.log('Request URL:' + apiUrl)
|
85
|
+
|
86
|
+
//
|
87
|
+
// Format the returned values.
|
84
88
|
function formatList(values) {
|
85
89
|
if (customReturnId) {
|
86
90
|
return values.map(function(obj) {
|
@@ -99,58 +103,30 @@ $.fn.select2Autocomplete = function(params) {
|
|
99
103
|
}
|
100
104
|
}
|
101
105
|
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
filter: {
|
117
|
-
[searchQuery]: params.term
|
118
|
-
}
|
119
|
-
}
|
120
|
-
},
|
121
|
-
processResults: function(json) {
|
122
|
-
return {
|
123
|
-
results: formatList(json.data)
|
106
|
+
//
|
107
|
+
// Set-up Select2 and make AJAX request.
|
108
|
+
this.select2({
|
109
|
+
multiple: select2Multiple,
|
110
|
+
allowClear: select2allowClear,
|
111
|
+
placeholder: select2placeHolder,
|
112
|
+
minimumInputLength: minimumInput,
|
113
|
+
ajax: {
|
114
|
+
url: apiUrl,
|
115
|
+
headers: Spree.apiV2Authentication(),
|
116
|
+
data: function(params) {
|
117
|
+
return {
|
118
|
+
filter: {
|
119
|
+
[searchQuery]: params.term
|
124
120
|
}
|
125
121
|
}
|
126
|
-
}
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
placeholder: select2placeHolder,
|
133
|
-
minimumInputLength: minimumInput,
|
134
|
-
ajax: {
|
135
|
-
url: apiUrl,
|
136
|
-
headers: Spree.apiV2Authentication(),
|
137
|
-
data: function(params) {
|
138
|
-
return {
|
139
|
-
fields: {
|
140
|
-
[resourceSingular]: returnAttribute
|
141
|
-
},
|
142
|
-
filter: {
|
143
|
-
[searchQuery]: params.term,
|
144
|
-
[additionalQuery]: additionalTerm
|
145
|
-
}
|
146
|
-
}
|
147
|
-
},
|
148
|
-
processResults: function(json) {
|
149
|
-
return {
|
150
|
-
results: formatList(json.data)
|
151
|
-
}
|
122
|
+
},
|
123
|
+
processResults: function(json) {
|
124
|
+
if (DebugMode != null) console.log(json)
|
125
|
+
|
126
|
+
return {
|
127
|
+
results: formatList(json.data)
|
152
128
|
}
|
153
129
|
}
|
154
|
-
}
|
155
|
-
}
|
130
|
+
}
|
131
|
+
})
|
156
132
|
}
|
@@ -1,11 +1,9 @@
|
|
1
1
|
/**
|
2
2
|
populateSelectOptionsFromApi(params)
|
3
|
+
Allows you to easily fetch data from API (Platfrom v2) and populate an empty <select> with <option> tags, including a selected <option> tag.
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
including a selected <option> tag.
|
7
|
-
|
8
|
-
## EXAMPLE USE CASE called from ERB view file:
|
5
|
+
## EXAMPLE A
|
6
|
+
# Populating a list of all taxons including a selected item
|
9
7
|
|
10
8
|
populateSelectOptionsFromApi({
|
11
9
|
targetElement: '#mySelectElement',
|
@@ -16,6 +14,24 @@
|
|
16
14
|
selectedOption: <%= @menu_item.linked_resource_id %>
|
17
15
|
<% end %>
|
18
16
|
})
|
17
|
+
|
18
|
+
## EXAMPLE B
|
19
|
+
# Populating a single selected item using filter and returning an attribute other than the ID
|
20
|
+
|
21
|
+
<% if resource.link_one.present? %>
|
22
|
+
<script>
|
23
|
+
populateSelectOptionsFromApi({
|
24
|
+
targetElement: "#<%= save_to %>Select2",
|
25
|
+
apiUrl: Spree.routes.taxons_api_v2 + "?filter[permalink_matches]=<%= resource.send(save_to) %>",
|
26
|
+
returnValueFromAttributes: 'permalink',
|
27
|
+
returnOptionText: 'pretty_name',
|
28
|
+
|
29
|
+
<% if resource.send(save_to) %>
|
30
|
+
selectedOption: "<%= resource.send(save_to) %>"
|
31
|
+
<% end %>
|
32
|
+
})
|
33
|
+
</script>
|
34
|
+
<% end %>
|
19
35
|
**/
|
20
36
|
|
21
37
|
// eslint-disable-next-line no-unused-vars
|
@@ -32,30 +48,40 @@ const handleErrors = function(response) {
|
|
32
48
|
const createRequest = function(params, succeed, fail) {
|
33
49
|
const targetElement = params.targetElement
|
34
50
|
const apiUrl = params.apiUrl
|
35
|
-
const
|
51
|
+
const returnOptionText = params.returnOptionText
|
52
|
+
const returnValueFromAttributes = params.returnValueFromAttributes || null
|
36
53
|
const selectedOption = params.selectedOption
|
37
54
|
const selectEl = document.querySelector(targetElement)
|
38
55
|
|
39
56
|
fetch(apiUrl, { headers: Spree.apiV2Authentication() })
|
40
57
|
.then((response) => handleErrors(response))
|
41
|
-
.then((json) => succeed(json.data,
|
58
|
+
.then((json) => succeed(json.data, returnValueFromAttributes, returnOptionText, selectEl, selectedOption))
|
42
59
|
.catch((error) => fail(error, selectEl))
|
43
60
|
}
|
44
61
|
|
45
|
-
const updateSelectSuccess = function(parsedData,
|
62
|
+
const updateSelectSuccess = function(parsedData, returnValueFromAttributes, returnOptionText, selectEl, selectedOption) {
|
63
|
+
const selectedOpt = selectEl.querySelector('option[selected]')
|
64
|
+
|
46
65
|
parsedData.forEach((object) => {
|
47
66
|
const optionEl = document.createElement('option')
|
48
|
-
optionEl.value = object.id
|
49
|
-
optionEl.innerHTML = object.attributes[returnAttribute]
|
50
67
|
|
51
|
-
if (
|
68
|
+
if (returnValueFromAttributes == null) {
|
69
|
+
optionEl.value = object.id
|
70
|
+
if (parseInt(selectedOption, 10) === parseInt(object.id, 10)) optionEl.selected = true
|
71
|
+
} else {
|
72
|
+
optionEl.value = object.attributes[returnValueFromAttributes]
|
73
|
+
if (selectedOpt.value === object.attributes[returnValueFromAttributes]) {
|
74
|
+
selectedOpt.remove()
|
75
|
+
|
76
|
+
optionEl.setAttribute('selected', 'selected')
|
77
|
+
}
|
78
|
+
}
|
52
79
|
|
80
|
+
optionEl.innerHTML = object.attributes[returnOptionText]
|
53
81
|
selectEl.appendChild(optionEl)
|
54
82
|
})
|
55
83
|
}
|
56
84
|
|
57
85
|
const updateSelectError = function(error, selectEl) {
|
58
|
-
selectEl.disabled = true
|
59
|
-
|
60
86
|
console.log(error)
|
61
87
|
}
|
@@ -1,10 +1,7 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
3
|
class ImagesController < ResourceController
|
4
|
-
|
5
|
-
|
6
|
-
belongs_to 'spree/product', find_by: :slug
|
7
|
-
|
4
|
+
before_action :load_product
|
8
5
|
before_action :load_edit_data, except: :index
|
9
6
|
|
10
7
|
create.before :set_viewable
|
@@ -13,24 +10,44 @@ module Spree
|
|
13
10
|
private
|
14
11
|
|
15
12
|
def location_after_destroy
|
16
|
-
spree.admin_product_images_url(
|
13
|
+
spree.admin_product_images_url(@product)
|
17
14
|
end
|
18
15
|
|
19
16
|
def location_after_save
|
20
|
-
spree.admin_product_images_url(
|
17
|
+
spree.admin_product_images_url(@product)
|
21
18
|
end
|
22
19
|
|
23
20
|
def load_edit_data
|
24
|
-
@variants =
|
21
|
+
@variants = @product.variants.map do |variant|
|
25
22
|
[variant.sku_and_options_text, variant.id]
|
26
23
|
end
|
27
|
-
@variants.insert(0, [Spree.t(:all),
|
24
|
+
@variants.insert(0, [Spree.t(:all), @product.master_id])
|
28
25
|
end
|
29
26
|
|
30
27
|
def set_viewable
|
31
28
|
@image.viewable_type = 'Spree::Variant'
|
32
29
|
@image.viewable_id = params[:image][:viewable_id]
|
33
30
|
end
|
31
|
+
|
32
|
+
def load_product
|
33
|
+
@product = scope.friendly.find(params[:product_id])
|
34
|
+
end
|
35
|
+
|
36
|
+
def scope
|
37
|
+
current_store.products
|
38
|
+
end
|
39
|
+
|
40
|
+
def collection_url
|
41
|
+
spree.admin_product_images_url
|
42
|
+
end
|
43
|
+
|
44
|
+
def modle_class
|
45
|
+
Spree::Image
|
46
|
+
end
|
47
|
+
|
48
|
+
def collection
|
49
|
+
@collection ||= load_product.variant_images
|
50
|
+
end
|
34
51
|
end
|
35
52
|
end
|
36
53
|
end
|
@@ -37,10 +37,9 @@
|
|
37
37
|
<%= image_tag main_app.url_for(@cms_section.image_one) %>
|
38
38
|
</figure>
|
39
39
|
<% end %>
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
<% end %>
|
40
|
+
|
41
|
+
<%= f.file_field :image_one %>
|
42
|
+
<%= f.error_message_on :image_one %>
|
44
43
|
<% end %>
|
45
44
|
<small class="form-text text-muted"><%= Spree.t('admin.cms.hero.aspect_ratio') %></small>
|
46
45
|
</div>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
<div class="row">
|
24
24
|
<div class="col-12 col-md-4 mb-3">
|
25
|
-
<div class="card p-3">
|
25
|
+
<div id="image_a_details" class="card p-3">
|
26
26
|
<div class="text-center">
|
27
27
|
<h4 class="pb-2"><%= Spree.t('admin.cms.image_gallery.image_a') %></h4>
|
28
28
|
<%= f.field_container :image_one, class: ['form-group'] do %>
|
@@ -35,10 +35,9 @@
|
|
35
35
|
<%= image_tag main_app.url_for(@cms_section.image_one) %>
|
36
36
|
</figure>
|
37
37
|
<% end %>
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
<% end %>
|
38
|
+
|
39
|
+
<%= f.file_field :image_one %>
|
40
|
+
<%= f.error_message_on :image_one %>
|
42
41
|
<% end %>
|
43
42
|
</div>
|
44
43
|
<small class="text-muted mb-4"><%= Spree.t('admin.cms.image_gallery.square_image') %></small>
|
@@ -67,7 +66,7 @@
|
|
67
66
|
</div>
|
68
67
|
|
69
68
|
<div class="col-12 col-md-4 mb-3">
|
70
|
-
<div class="card p-3">
|
69
|
+
<div id="image_b_details" class="card p-3">
|
71
70
|
<div class="text-center">
|
72
71
|
<h4 class="pb-2"><%= Spree.t('admin.cms.image_gallery.image_b') %></h4>
|
73
72
|
<%= f.field_container :image_two, class: ['form-group'] do %>
|
@@ -80,10 +79,9 @@
|
|
80
79
|
<%= image_tag main_app.url_for(@cms_section.image_two) %>
|
81
80
|
</figure>
|
82
81
|
<% end %>
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
<% end %>
|
82
|
+
|
83
|
+
<%= f.file_field :image_two %>
|
84
|
+
<%= f.error_message_on :image_two %>
|
87
85
|
<% end %>
|
88
86
|
</div>
|
89
87
|
<small class="text-muted mb-4"><%= Spree.t('admin.cms.image_gallery.tall_image') %></small>
|
@@ -112,7 +110,7 @@
|
|
112
110
|
</div>
|
113
111
|
|
114
112
|
<div class="col-12 col-md-4 mb-3">
|
115
|
-
<div class="card p-3">
|
113
|
+
<div id="image_c_details" class="card p-3">
|
116
114
|
<div class="text-center">
|
117
115
|
<h4 class="pb-2"><%= Spree.t('admin.cms.image_gallery.image_c') %></h4>
|
118
116
|
<%= f.field_container :image_three, class: ['form-group'] do %>
|
@@ -125,10 +123,9 @@
|
|
125
123
|
<%= image_tag main_app.url_for(@cms_section.image_three) %>
|
126
124
|
</figure>
|
127
125
|
<% end %>
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
<% end %>
|
126
|
+
|
127
|
+
<%= f.file_field :image_three %>
|
128
|
+
<%= f.error_message_on :image_three %>
|
132
129
|
<% end %>
|
133
130
|
</div>
|
134
131
|
<small class="text-muted mb-4"><%= Spree.t('admin.cms.image_gallery.square_image') %></small>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<div class="row pb-0">
|
2
2
|
<div class="col-12 col-md-6 mb-3">
|
3
|
-
<div class="card p-3">
|
3
|
+
<div id="left_image_details" class="card p-3">
|
4
4
|
<div class="text-center">
|
5
5
|
<h4 class="pb-2"><%= Spree.t('admin.cms.side_by_side.left_image') %></h4>
|
6
6
|
<%= f.field_container :image_one, class: ['form-group'] do %>
|
@@ -51,7 +51,7 @@
|
|
51
51
|
</div>
|
52
52
|
|
53
53
|
<div class="col-12 col-md-6 mb-3">
|
54
|
-
<div class="card p-3">
|
54
|
+
<div id="right_image_details" class="card p-3">
|
55
55
|
<div class="text-center">
|
56
56
|
<h4 class="pb-2"><%= Spree.t('admin.cms.side_by_side.right_image') %></h4>
|
57
57
|
<%= f.field_container :image_two, class: ['form-group'] do %>
|
@@ -42,7 +42,7 @@
|
|
42
42
|
</td>
|
43
43
|
<td class="image">
|
44
44
|
<div class="admin-product-image-container small-img">
|
45
|
-
<%= link_to image_tag(main_app.url_for(image.url(:
|
45
|
+
<%= link_to image_tag(main_app.url_for(image.url(:product))), main_app.rails_blob_url(image.attachment) %>
|
46
46
|
</div>
|
47
47
|
</td>
|
48
48
|
<% if has_variants %>
|
@@ -1,14 +1,27 @@
|
|
1
1
|
<%= f.field_container save_to, class: ['form-group'] do %>
|
2
2
|
<%= f.label save_to, Spree.t('admin.cms.link_to_product') %>
|
3
|
-
<%= f.select save_to,
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
autocomplete_return_attr_value: 'name',
|
12
|
-
autocomplete_custom_return_id_value: 'slug' } %>
|
3
|
+
<%= f.select save_to, options_from_collection_for_select([resource], save_to, save_to, resource.send(save_to) || nil), { include_blank: true },
|
4
|
+
id: "cms_section_#{save_to}",
|
5
|
+
data: { autocomplete_placeholder_value: Spree.t('admin.navigation.seach_for_a_product'),
|
6
|
+
autocomplete_clear_value: true,
|
7
|
+
autocomplete_url_value: 'products_api_v2',
|
8
|
+
autocomplete_return_attr_value: 'name',
|
9
|
+
autocomplete_custom_return_id_value: 'slug' } %>
|
10
|
+
|
13
11
|
<%= f.error_message_on :save_to %>
|
14
12
|
<% end %>
|
13
|
+
|
14
|
+
<% if resource.link_one.present? %>
|
15
|
+
<script>
|
16
|
+
populateSelectOptionsFromApi({
|
17
|
+
targetElement: "#cms_section_<%= save_to %>",
|
18
|
+
apiUrl: Spree.routes.products_api_v2 + "?filter[slug_matches]=<%= resource.send(save_to) %>",
|
19
|
+
returnValueFromAttributes: 'slug',
|
20
|
+
returnOptionText: 'name',
|
21
|
+
|
22
|
+
<% if resource.send(save_to) %>
|
23
|
+
selectedOption: "<%= resource.send(save_to) %>"
|
24
|
+
<% end %>
|
25
|
+
})
|
26
|
+
</script>
|
27
|
+
<% end %>
|
@@ -1,14 +1,27 @@
|
|
1
1
|
<%= f.field_container save_to, class: ['form-group'] do %>
|
2
2
|
<%= f.label save_to, Spree.t('admin.cms.link_to_taxon') %>
|
3
|
-
<%= f.select save_to,
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
autocomplete_return_attr_value: 'permalink',
|
12
|
-
autocomplete_custom_return_id_value: 'permalink' } %>
|
3
|
+
<%= f.select save_to, options_from_collection_for_select([resource], save_to, save_to, resource.send(save_to) || nil), { include_blank: true },
|
4
|
+
id: "cms_section_#{save_to}",
|
5
|
+
data: { autocomplete_placeholder_value: Spree.t('admin.navigation.seach_for_a_taxon'),
|
6
|
+
autocomplete_clear_value: true,
|
7
|
+
autocomplete_url_value: 'taxons_api_v2',
|
8
|
+
autocomplete_return_attr_value: 'pretty_name',
|
9
|
+
autocomplete_custom_return_id_value: 'permalink' } %>
|
10
|
+
|
13
11
|
<%= f.error_message_on :save_to %>
|
14
12
|
<% end %>
|
13
|
+
|
14
|
+
<% if resource.link_one.present? %>
|
15
|
+
<script>
|
16
|
+
populateSelectOptionsFromApi({
|
17
|
+
targetElement: "#cms_section_<%= save_to %>",
|
18
|
+
apiUrl: Spree.routes.taxons_api_v2 + "?filter[permalink_matches]=<%= resource.send(save_to) %>",
|
19
|
+
returnValueFromAttributes: 'permalink',
|
20
|
+
returnOptionText: 'pretty_name',
|
21
|
+
|
22
|
+
<% if resource.send(save_to) %>
|
23
|
+
selectedOption: "<%= resource.send(save_to) %>"
|
24
|
+
<% end %>
|
25
|
+
})
|
26
|
+
</script>
|
27
|
+
<% end %>
|
@@ -16,12 +16,7 @@
|
|
16
16
|
autocomplete_url_value: 'pages_api_v2',
|
17
17
|
autocomplete_return_attr_value: 'title',
|
18
18
|
autocomplete_search_query_value: 'title_i_cont',
|
19
|
-
|
20
|
-
# Hard coded additional filter to filter out homepages from
|
21
|
-
# the results. Homepages don't have a slug, and we already have
|
22
|
-
# a dedicated Home Page link_to type.
|
23
|
-
autocomplete_additional_query_value: 'type_not_eq',
|
24
|
-
autocomplete_additional_term_value: 'Spree::Cms::Pages::Homepage' } %>
|
19
|
+
autocomplete_additional_url_params_value: 'filter[type_not_eq]=Spree::Cms::Pages::Homepage' } %>
|
25
20
|
|
26
21
|
<%= f.error_message_on :linked_resource_id %>
|
27
22
|
<small class="form-text text-muted"><%= resource.link %></small>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_backend
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.3.0
|
4
|
+
version: 4.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Schofield
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-09-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_api
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 4.3.0
|
20
|
+
version: 4.3.0
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 4.3.0
|
27
|
+
version: 4.3.0
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: spree_core
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
32
|
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 4.3.0
|
34
|
+
version: 4.3.0
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
39
|
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 4.3.0
|
41
|
+
version: 4.3.0
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: babel-transpiler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
@@ -818,9 +818,9 @@ licenses:
|
|
818
818
|
- BSD-3-Clause
|
819
819
|
metadata:
|
820
820
|
bug_tracker_uri: https://github.com/spree/spree/issues
|
821
|
-
changelog_uri: https://github.com/spree/spree/releases/tag/v4.3.0
|
821
|
+
changelog_uri: https://github.com/spree/spree/releases/tag/v4.3.0
|
822
822
|
documentation_uri: https://dev-docs.spreecommerce.org/
|
823
|
-
source_code_uri: https://github.com/spree/spree/tree/v4.3.0
|
823
|
+
source_code_uri: https://github.com/spree/spree/tree/v4.3.0
|
824
824
|
post_install_message:
|
825
825
|
rdoc_options: []
|
826
826
|
require_paths:
|
@@ -832,12 +832,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
832
832
|
version: '2.5'
|
833
833
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
834
834
|
requirements:
|
835
|
-
- - "
|
835
|
+
- - ">="
|
836
836
|
- !ruby/object:Gem::Version
|
837
|
-
version:
|
837
|
+
version: '0'
|
838
838
|
requirements:
|
839
839
|
- none
|
840
|
-
rubygems_version: 3.
|
840
|
+
rubygems_version: 3.1.4
|
841
841
|
signing_key:
|
842
842
|
specification_version: 4
|
843
843
|
summary: Admin Dashboard for Spree eCommerce platform
|