spree_backend 4.2.4 → 4.3.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +1 -1
  3. data/app/assets/config/spree_backend_manifest.js +129 -0
  4. data/app/assets/images/backend-arrows-fullscreen.svg +3 -0
  5. data/app/assets/images/backend-box.svg +3 -0
  6. data/app/assets/images/backend-circle-fill.svg +3 -0
  7. data/app/assets/images/backend-circle.svg +3 -0
  8. data/app/assets/images/backend-default-layout.svg +6 -0
  9. data/app/assets/images/backend-eye-slash-fill.svg +4 -0
  10. data/app/assets/images/backend-file-richtext.svg +4 -0
  11. data/app/assets/images/backend-fullscreen-exit.svg +3 -0
  12. data/app/assets/images/backend-fullscreen.svg +3 -0
  13. data/app/assets/images/backend-mobile.svg +5 -0
  14. data/app/assets/images/backend-pages.svg +10 -0
  15. data/app/assets/images/backend-phone.svg +4 -0
  16. data/app/assets/images/backend-reversed-layout.svg +6 -0
  17. data/app/assets/images/backend-spree-icon.svg +1 -0
  18. data/app/assets/images/backend-spree-logo.svg +6 -0
  19. data/app/assets/images/backend-store.svg +2 -13
  20. data/app/assets/images/backend-translate.svg +4 -0
  21. data/app/assets/images/backend-users.svg +2 -5
  22. data/app/assets/images/backend-window-sidebar.svg +4 -0
  23. data/app/assets/images/noimage/backend-missing-image.svg +4 -0
  24. data/app/assets/images/noimage/large.png +0 -0
  25. data/app/assets/images/noimage/mini.png +0 -0
  26. data/app/assets/images/noimage/product.png +0 -0
  27. data/app/assets/images/noimage/small.png +0 -0
  28. data/app/assets/javascripts/spree/backend/address_states.es6 +44 -0
  29. data/app/assets/javascripts/spree/backend/admin.js +45 -307
  30. data/app/assets/javascripts/spree/backend/checkouts/edit.js +22 -13
  31. data/app/assets/javascripts/spree/backend/cms/_index.es6 +4 -0
  32. data/app/assets/javascripts/spree/backend/cms/links.es6 +25 -0
  33. data/app/assets/javascripts/spree/backend/cms/live_preview.es6 +34 -0
  34. data/app/assets/javascripts/spree/backend/cms/page.es6 +133 -0
  35. data/app/assets/javascripts/spree/backend/cms/section.es6 +43 -0
  36. data/app/assets/javascripts/spree/backend/global/_index.js +11 -0
  37. data/app/assets/javascripts/spree/backend/global/alerts.es6 +66 -0
  38. data/app/assets/javascripts/spree/backend/global/api_functions.es6 +5 -0
  39. data/app/assets/javascripts/spree/backend/global/bootstrap.es6 +15 -0
  40. data/app/assets/javascripts/spree/backend/global/flatpickr.es6 +22 -0
  41. data/app/assets/javascripts/spree/backend/global/info_alert.es6 +38 -0
  42. data/app/assets/javascripts/spree/backend/global/radio_panel_toggle.es6 +18 -0
  43. data/app/assets/javascripts/spree/backend/global/ransack.es6 +108 -0
  44. data/app/assets/javascripts/spree/backend/global/responsive_menus.es6 +56 -0
  45. data/app/assets/javascripts/spree/backend/global/select2_autocomplete.es6 +156 -0
  46. data/app/assets/javascripts/spree/backend/global/select2_populate.es6 +61 -0
  47. data/app/assets/javascripts/spree/backend/global/side_scroll_indication.es6 +137 -0
  48. data/app/assets/javascripts/spree/backend/global/sortable.es6 +35 -0
  49. data/app/assets/javascripts/spree/backend/global/tinymce.es6 +11 -0
  50. data/app/assets/javascripts/spree/backend/menus/_index.es6 +2 -0
  51. data/app/assets/javascripts/spree/backend/menus/menu.es6 +57 -0
  52. data/app/assets/javascripts/spree/backend/menus/menu_item.es6 +26 -0
  53. data/app/assets/javascripts/spree/backend/option_type_autocomplete.js +13 -17
  54. data/app/assets/javascripts/spree/backend/option_value_picker.js +10 -22
  55. data/app/assets/javascripts/spree/backend/payments/edit.js +1 -1
  56. data/app/assets/javascripts/spree/backend/payments/new.js +18 -5
  57. data/app/assets/javascripts/spree/backend/spree-select2.js +19 -1
  58. data/app/assets/javascripts/spree/backend/stock_location.js +1 -2
  59. data/app/assets/javascripts/spree/backend/taxon_autocomplete.js +7 -1
  60. data/app/assets/javascripts/spree/backend/taxons.js +74 -73
  61. data/app/assets/javascripts/spree/backend/user_picker.js +7 -10
  62. data/app/assets/javascripts/spree/backend.js +28 -1
  63. data/app/assets/javascripts/spree.js +78 -0
  64. data/app/assets/stylesheets/spree/backend/components/_filters.scss +1 -3
  65. data/app/assets/stylesheets/spree/backend/components/_main.scss +0 -1
  66. data/app/assets/stylesheets/spree/backend/components/_navbar.scss +35 -0
  67. data/app/assets/stylesheets/spree/backend/components/_navigation.scss +13 -0
  68. data/app/assets/stylesheets/spree/backend/components/_sidebar.scss +0 -1
  69. data/app/assets/stylesheets/spree/backend/components/_tables.scss +4 -5
  70. data/app/assets/stylesheets/spree/backend/global/_mixins.scss +59 -0
  71. data/app/assets/stylesheets/spree/backend/plugins/_nav_x.scss +95 -0
  72. data/app/assets/stylesheets/spree/backend/plugins/{select2_bootstrap4.scss → _select2_bootstrap4.scss} +0 -0
  73. data/app/assets/stylesheets/spree/backend/plugins/_sweetalert2_custom.scss +100 -0
  74. data/app/assets/stylesheets/spree/backend/plugins/_tinymce_custom.scss +4 -0
  75. data/app/assets/stylesheets/spree/backend/shared/_base.scss +75 -25
  76. data/app/assets/stylesheets/spree/backend/shared/_forms.scss +8 -0
  77. data/app/assets/stylesheets/spree/backend/spree_admin.css.scss +5 -0
  78. data/app/assets/stylesheets/spree/backend/views/_cms_pages.scss +148 -0
  79. data/app/assets/stylesheets/spree/backend/views/_menus.scss +61 -0
  80. data/app/controllers/concerns/spree/admin/order_concern.rb +24 -0
  81. data/app/controllers/concerns/spree/admin/product_concern.rb +11 -0
  82. data/app/controllers/spree/admin/base_controller.rb +63 -3
  83. data/app/controllers/spree/admin/cms_pages_controller.rb +29 -0
  84. data/app/controllers/spree/admin/cms_sections_controller.rb +15 -0
  85. data/app/controllers/spree/admin/customer_returns_controller.rb +4 -5
  86. data/app/controllers/spree/admin/errors_controller.rb +11 -0
  87. data/app/controllers/spree/admin/general_settings_controller.rb +1 -1
  88. data/app/controllers/spree/admin/images_controller.rb +8 -22
  89. data/app/controllers/spree/admin/log_entries_controller.rb +4 -3
  90. data/app/controllers/spree/admin/menu_items_controller.rb +33 -0
  91. data/app/controllers/spree/admin/menus_controller.rb +32 -0
  92. data/app/controllers/spree/admin/option_types_controller.rb +1 -1
  93. data/app/controllers/spree/admin/orders/customer_details_controller.rb +6 -11
  94. data/app/controllers/spree/admin/orders_controller.rb +23 -31
  95. data/app/controllers/spree/admin/payment_methods_controller.rb +17 -4
  96. data/app/controllers/spree/admin/payments_controller.rb +5 -10
  97. data/app/controllers/spree/admin/prices_controller.rb +2 -2
  98. data/app/controllers/spree/admin/products_controller.rb +21 -10
  99. data/app/controllers/spree/admin/promotion_actions_controller.rb +1 -1
  100. data/app/controllers/spree/admin/promotion_rules_controller.rb +1 -1
  101. data/app/controllers/spree/admin/promotions_controller.rb +3 -3
  102. data/app/controllers/spree/admin/prototypes_controller.rb +1 -1
  103. data/app/controllers/spree/admin/reimbursements_controller.rb +1 -1
  104. data/app/controllers/spree/admin/reports_controller.rb +5 -1
  105. data/app/controllers/spree/admin/resource_controller.rb +32 -5
  106. data/app/controllers/spree/admin/return_index_controller.rb +1 -1
  107. data/app/controllers/spree/admin/state_changes_controller.rb +2 -7
  108. data/app/controllers/spree/admin/stock_items_controller.rb +2 -2
  109. data/app/controllers/spree/admin/stock_locations_controller.rb +2 -2
  110. data/app/controllers/spree/admin/stock_movements_controller.rb +1 -1
  111. data/app/controllers/spree/admin/stock_transfers_controller.rb +1 -1
  112. data/app/controllers/spree/admin/store_credits_controller.rb +13 -8
  113. data/app/controllers/spree/admin/stores_controller.rb +14 -17
  114. data/app/controllers/spree/admin/taxons_controller.rb +9 -5
  115. data/app/controllers/spree/admin/users_controller.rb +9 -7
  116. data/app/controllers/spree/admin/variants_controller.rb +16 -15
  117. data/app/helpers/spree/admin/base_helper.rb +52 -14
  118. data/app/helpers/spree/admin/cms_helper.rb +15 -0
  119. data/app/helpers/spree/admin/menu_helper.rb +30 -0
  120. data/app/helpers/spree/admin/stores_helper.rb +21 -0
  121. data/app/models/spree/backend_configuration.rb +2 -0
  122. data/app/views/spree/admin/adjustments/_adjustment.html.erb +7 -5
  123. data/app/views/spree/admin/cms_pages/_form.html.erb +135 -0
  124. data/app/views/spree/admin/cms_pages/_live_preview_area.html.erb +61 -0
  125. data/app/views/spree/admin/cms_pages/_section_template.html.erb +16 -0
  126. data/app/views/spree/admin/cms_pages/edit.html.erb +21 -0
  127. data/app/views/spree/admin/cms_pages/index.html.erb +84 -0
  128. data/app/views/spree/admin/cms_pages/new.html.erb +8 -0
  129. data/app/views/spree/admin/cms_sections/_form.html.erb +69 -0
  130. data/app/views/spree/admin/cms_sections/edit.html.erb +19 -0
  131. data/app/views/spree/admin/cms_sections/new.html.erb +11 -0
  132. data/app/views/spree/admin/cms_sections/types/_featured_article.html.erb +50 -0
  133. data/app/views/spree/admin/cms_sections/types/_hero_image.html.erb +62 -0
  134. data/app/views/spree/admin/cms_sections/types/_image_gallery.html.erb +177 -0
  135. data/app/views/spree/admin/cms_sections/types/_product_carousel.html.erb +5 -0
  136. data/app/views/spree/admin/cms_sections/types/_rich_text_content.html.erb +4 -0
  137. data/app/views/spree/admin/cms_sections/types/_side_by_side_images.html.erb +121 -0
  138. data/app/views/spree/admin/countries/index.html.erb +5 -3
  139. data/app/views/spree/admin/customer_returns/_reimbursements_table.html.erb +6 -4
  140. data/app/views/spree/admin/customer_returns/_return_item_decision.html.erb +9 -7
  141. data/app/views/spree/admin/customer_returns/index.html.erb +4 -2
  142. data/app/views/spree/admin/errors/forbidden.html.erb +0 -0
  143. data/app/views/spree/admin/images/index.html.erb +8 -4
  144. data/app/views/spree/admin/menu_items/_form.html.erb +115 -0
  145. data/app/views/spree/admin/menu_items/edit.html.erb +11 -0
  146. data/app/views/spree/admin/menu_items/new.html.erb +11 -0
  147. data/app/views/spree/admin/menus/_form.html.erb +19 -0
  148. data/app/views/spree/admin/menus/edit.html.erb +57 -0
  149. data/app/views/spree/admin/menus/index.html.erb +90 -0
  150. data/app/views/spree/admin/menus/nested_menu_items/_item_bar.html.erb +30 -0
  151. data/app/views/spree/admin/menus/new.html.erb +22 -0
  152. data/app/views/spree/admin/option_types/_form.html.erb +3 -0
  153. data/app/views/spree/admin/option_types/_option_value_fields.html.erb +5 -1
  154. data/app/views/spree/admin/option_types/index.html.erb +5 -3
  155. data/app/views/spree/admin/orders/_channel_form.html.erb +2 -2
  156. data/app/views/spree/admin/orders/_line_items.html.erb +10 -8
  157. data/app/views/spree/admin/orders/_shipment.html.erb +26 -18
  158. data/app/views/spree/admin/orders/_shipment_manifest.html.erb +11 -9
  159. data/app/views/spree/admin/orders/customer_details/_autocomplete.js.erb +2 -2
  160. data/app/views/spree/admin/orders/index.html.erb +100 -101
  161. data/app/views/spree/admin/payment_methods/_form.html.erb +6 -4
  162. data/app/views/spree/admin/payment_methods/edit.html.erb +1 -1
  163. data/app/views/spree/admin/payment_methods/index.html.erb +22 -3
  164. data/app/views/spree/admin/payment_methods/new.html.erb +1 -1
  165. data/app/views/spree/admin/payments/_list.html.erb +9 -7
  166. data/app/views/spree/admin/prices/_variant_prices.html.erb +7 -14
  167. data/app/views/spree/admin/product_properties/_product_property_fields.html.erb +9 -7
  168. data/app/views/spree/admin/products/_autocomplete.js.erb +10 -6
  169. data/app/views/spree/admin/products/_form.html.erb +35 -5
  170. data/app/views/spree/admin/products/index.html.erb +15 -14
  171. data/app/views/spree/admin/products/new.html.erb +6 -1
  172. data/app/views/spree/admin/products/stock.html.erb +71 -68
  173. data/app/views/spree/admin/promotion_categories/index.html.erb +5 -3
  174. data/app/views/spree/admin/promotions/_form.html.erb +7 -0
  175. data/app/views/spree/admin/promotions/actions/_create_item_adjustments.html.erb +1 -0
  176. data/app/views/spree/admin/promotions/calculators/_default_fields.html.erb +2 -1
  177. data/app/views/spree/admin/promotions/index.html.erb +33 -34
  178. data/app/views/spree/admin/properties/_form.html.erb +6 -0
  179. data/app/views/spree/admin/properties/index.html.erb +19 -3
  180. data/app/views/spree/admin/prototypes/_form.html.erb +1 -1
  181. data/app/views/spree/admin/prototypes/_prototypes.html.erb +8 -6
  182. data/app/views/spree/admin/prototypes/index.html.erb +5 -3
  183. data/app/views/spree/admin/reimbursement_types/index.html.erb +5 -3
  184. data/app/views/spree/admin/reports/index.html.erb +1 -1
  185. data/app/views/spree/admin/reports/sales_total.html.erb +1 -1
  186. data/app/views/spree/admin/return_authorizations/_form.html.erb +2 -2
  187. data/app/views/spree/admin/return_authorizations/index.html.erb +7 -5
  188. data/app/views/spree/admin/return_index/customer_returns.html.erb +4 -2
  189. data/app/views/spree/admin/return_index/return_authorizations.html.erb +5 -3
  190. data/app/views/spree/admin/roles/index.html.erb +5 -3
  191. data/app/views/spree/admin/shared/_account_nav.html.erb +5 -5
  192. data/app/views/spree/admin/shared/_address_form.html.erb +5 -4
  193. data/app/views/spree/admin/shared/_content_header.html.erb +20 -6
  194. data/app/views/spree/admin/shared/_head.html.erb +2 -1
  195. data/app/views/spree/admin/shared/_header.html.erb +7 -10
  196. data/app/views/spree/admin/shared/_link_fields.html.erb +22 -0
  197. data/app/views/spree/admin/shared/_main_menu.html.erb +19 -4
  198. data/app/views/spree/admin/shared/_order_tabs.html.erb +1 -10
  199. data/app/views/spree/admin/shared/_paths.html.erb +8 -0
  200. data/app/views/spree/admin/shared/_refunds.html.erb +4 -2
  201. data/app/views/spree/admin/shared/_sidebar.html.erb +1 -1
  202. data/app/views/spree/admin/shared/_store_switcher.html.erb +23 -0
  203. data/app/views/spree/admin/shared/_table_filter.html.erb +6 -6
  204. data/app/views/spree/admin/shared/_translations.html.erb +2 -0
  205. data/app/views/spree/admin/shared/cms/_spree_product.html.erb +14 -0
  206. data/app/views/spree/admin/shared/cms/_spree_taxon.html.erb +14 -0
  207. data/app/views/spree/admin/shared/linkables/_home_page.html.erb +3 -0
  208. data/app/views/spree/admin/shared/linkables/_spree_cms_page.erb +28 -0
  209. data/app/views/spree/admin/shared/linkables/_spree_product.html.erb +20 -0
  210. data/app/views/spree/admin/shared/linkables/_spree_taxon.html.erb +22 -0
  211. data/app/views/spree/admin/shared/linkables/_url.html.erb +16 -0
  212. data/app/views/spree/admin/shared/named_types/_index.html.erb +7 -5
  213. data/app/views/spree/admin/shared/sub_menu/_configuration.html.erb +1 -3
  214. data/app/views/spree/admin/shared/sub_menu/_content.html.erb +4 -0
  215. data/app/views/spree/admin/shared/sub_menu/_stock.html.erb +4 -0
  216. data/app/views/spree/admin/shipping_categories/index.html.erb +5 -3
  217. data/app/views/spree/admin/shipping_methods/index.html.erb +5 -3
  218. data/app/views/spree/admin/states/_state_list.html.erb +5 -3
  219. data/app/views/spree/admin/stock_locations/index.html.erb +5 -3
  220. data/app/views/spree/admin/stock_transfers/index.html.erb +5 -4
  221. data/app/views/spree/admin/stock_transfers/new.html.erb +9 -7
  222. data/app/views/spree/admin/store_credit_categories/index.html.erb +5 -3
  223. data/app/views/spree/admin/store_credits/index.html.erb +7 -5
  224. data/app/views/spree/admin/stores/_form.html.erb +12 -2
  225. data/app/views/spree/admin/stores/index.html.erb +12 -10
  226. data/app/views/spree/admin/tax_categories/index.html.erb +5 -3
  227. data/app/views/spree/admin/tax_rates/index.html.erb +5 -3
  228. data/app/views/spree/admin/taxonomies/_list.html.erb +5 -3
  229. data/app/views/spree/admin/taxons/_form.html.erb +1 -1
  230. data/app/views/spree/admin/users/_addresses_form.html.erb +2 -4
  231. data/app/views/spree/admin/users/_lifetime_stats.html.erb +16 -4
  232. data/app/views/spree/admin/users/index.html.erb +5 -3
  233. data/app/views/spree/admin/users/items.html.erb +1 -1
  234. data/app/views/spree/admin/variants/_autocomplete.js.erb +6 -2
  235. data/app/views/spree/admin/variants/_autocomplete_line_items_stock.js.erb +18 -12
  236. data/app/views/spree/admin/variants/_autocomplete_stock.js.erb +12 -8
  237. data/app/views/spree/admin/variants/_split.js.erb +9 -7
  238. data/app/views/spree/admin/variants/index.html.erb +8 -5
  239. data/app/views/spree/admin/zones/index.html.erb +5 -3
  240. data/app/views/spree/layouts/admin.html.erb +16 -16
  241. data/config/initializers/assets.rb +5 -1
  242. data/config/routes.rb +14 -2
  243. data/lib/generators/spree/backend/install/install_generator.rb +22 -0
  244. data/lib/generators/spree/backend/install/templates/vendor/assets/javascripts/spree/backend/all.js +8 -0
  245. data/lib/generators/spree/backend/install/templates/vendor/assets/stylesheets/spree/backend/all.css +9 -0
  246. data/lib/spree/backend/engine.rb +4 -11
  247. data/lib/spree/backend.rb +7 -4
  248. data/lib/spree_backend.rb +0 -2
  249. data/spec/fixtures/files/favicon.ico +0 -0
  250. data/spec/fixtures/files/icon_512x512.png +0 -0
  251. data/spree_backend.gemspec +16 -11
  252. data/vendor/assets/javascripts/cleave.js +8 -0
  253. data/vendor/assets/javascripts/jsonapi-serializer.min.js +8 -0
  254. data/vendor/assets/javascripts/jsuri.js +458 -0
  255. data/vendor/assets/javascripts/sortable.js +2 -3709
  256. data/vendor/assets/javascripts/sweetalert2.js +2 -0
  257. metadata +208 -42
  258. data/app/assets/javascripts/spree/backend/address_states.js +0 -44
  259. data/app/assets/javascripts/spree/frontend/backend.js +0 -1
  260. data/app/assets/stylesheets/spree/frontend/backend.css +0 -1
  261. data/app/views/spree/admin/orders/_store_form.html.erb +0 -18
@@ -28,13 +28,15 @@ function formatCustomerAddress(address, kind) {
28
28
  $('#order_' + kind + '_address_attributes_zipcode').val(address.zipcode)
29
29
  $('#order_' + kind + '_address_attributes_phone').val(address.phone)
30
30
  $('#order_' + kind + '_address_attributes_phone').val(address.phone)
31
- $('#order_' + kind + '_address_attributes_country_id').val(address.country_id)
31
+ $('#order_' + kind + '_address_attributes_country_id').val(address.country.id)
32
32
  $('#order_' + kind + '_address_attributes_country_id').trigger('change')
33
33
 
34
34
  var stateSelect = $('#order_' + kind + '_address_attributes_state_id')
35
35
 
36
- update_state(kind.charAt(0), function() {
37
- stateSelect.val(address.state_id).trigger('change')
36
+ updateAddressState(kind.charAt(0), function() {
37
+ if (address.state) {
38
+ stateSelect.val(address.state.id).trigger('change')
39
+ }
38
40
  })
39
41
  }
40
42
 
@@ -64,27 +66,34 @@ function formatCustomerSelection(customer) {
64
66
  }
65
67
 
66
68
  $.fn.customerAutocomplete = function() {
69
+ var jsonApiUsers = {}
70
+
67
71
  this.select2({
68
72
  minimumInputLength: 3,
69
73
  placeholder: Spree.translations.choose_a_customer,
70
74
  ajax: {
71
- url: Spree.routes.users_api,
75
+ url: Spree.routes.users_api_v2,
72
76
  datatype: 'json',
77
+ headers: Spree.apiV2Authentication(),
73
78
  data: function (params) {
74
79
  return {
75
- q: {
80
+ filter: {
76
81
  'm': 'or',
77
- email_start: params.term,
78
- ship_address_firstname_start: params.term,
79
- ship_address_lastname_start: params.term,
80
- bill_address_firstname_start: params.term,
81
- bill_address_lastname_start: params.term
82
+ email_i_cont: params.term,
83
+ addresses_firstname_start: params.term,
84
+ addresses_lastname_start: params.term
82
85
  },
83
- token: Spree.api_key
86
+ include: 'ship_address.country,ship_address.state,bill_address.country,bill_address.state'
84
87
  }
85
88
  },
86
- processResults: function (data) {
87
- return { results: data.users }
89
+ success: function(data) {
90
+ var JSONAPIDeserializer = require('jsonapi-serializer').Deserializer
91
+ new JSONAPIDeserializer({ keyForAttribute: 'snake_case' }).deserialize(data, function (_err, users) {
92
+ jsonApiUsers = users
93
+ })
94
+ },
95
+ processResults: function (_data) {
96
+ return { results: jsonApiUsers } // we need to return deserialized json api data
88
97
  }
89
98
  },
90
99
  templateResult: formatCustomerResult
@@ -0,0 +1,4 @@
1
+ //= require spree/backend/cms/page
2
+ //= require spree/backend/cms/section
3
+ //= require spree/backend/cms/links
4
+ //= require spree/backend/cms/live_preview
@@ -0,0 +1,25 @@
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ const linkSwitcher = $('.link_switcher').select2()
3
+
4
+ linkSwitcher.on('change', function() {
5
+ const selectedLinkToValue = $(this).val()
6
+ const linkSwitcherTarget = this.dataset.targetField || 'menu_item_link'
7
+ const activePanel = document.querySelector(`div[data-panel-id='${linkSwitcherTarget}']`)
8
+ const messagePanel = document.querySelector(`div[data-target-message-pannel='${linkSwitcherTarget}']`)
9
+ const panelType = activePanel.dataset.panelType
10
+
11
+ if (selectedLinkToValue === panelType) {
12
+ activePanel.classList = ''
13
+ activePanel.classList.add('d-block')
14
+
15
+ messagePanel.classList = ''
16
+ messagePanel.classList.add('d-none')
17
+ } else {
18
+ activePanel.classList = ''
19
+ activePanel.classList.add('d-none')
20
+
21
+ messagePanel.classList = ''
22
+ messagePanel.classList.add('d-block')
23
+ }
24
+ })
25
+ })
@@ -0,0 +1,34 @@
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ const LiveViewSwitcher = document.getElementById('LiveViewSwitcher')
3
+
4
+ if (!LiveViewSwitcher) return
5
+
6
+ LiveViewSwitcher.addEventListener('click', function(event) {
7
+ if (event.target && event.target.matches("input[type='radio']")) {
8
+ switchLiveViewClass(event.target.id)
9
+ }
10
+ })
11
+
12
+ function switchLiveViewClass(value) {
13
+ const liveViewCont = document.getElementById('liveViewCont')
14
+
15
+ liveViewCont.classList = ''
16
+ liveViewCont.classList.add(value)
17
+ }
18
+
19
+ const cmsSectionEditorFullScreen = document.getElementById('cmsSectionEditorFullScreen')
20
+
21
+ cmsSectionEditorFullScreen.addEventListener('click', function(event) {
22
+ if (this.getAttribute('aria-pressed') === 'true') {
23
+ document.body.removeAttribute('data-sections-editor-full-screen')
24
+ } else {
25
+ document.body.setAttribute('data-sections-editor-full-screen', '')
26
+ }
27
+ })
28
+
29
+ const queryString = window.location.search;
30
+ const urlParams = new URLSearchParams(queryString);
31
+ const fullScreenMode = urlParams.get('section_editor_full_screen_mode')
32
+
33
+ if (fullScreenMode) cmsSectionEditorFullScreen.click()
34
+ })
@@ -0,0 +1,133 @@
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ const pageVisabilityAttribute = document.querySelectorAll('[data-cms-page-id]')
3
+ const pageTypeSelector = document.getElementById('cms_page_type')
4
+ const el = document.getElementById('cmsPagesectionsArea')
5
+
6
+ if (pageTypeSelector) updateCmsPageType()
7
+
8
+ $(pageTypeSelector).on('change', function() { updateCmsPageType() })
9
+
10
+ if (el) {
11
+ Sortable.create(el, {
12
+ handle: '.move-handle',
13
+ ghostClass: 'moving-this',
14
+ animation: 550,
15
+ easing: 'cubic-bezier(1, 0, 0, 1)',
16
+ swapThreshold: 0.9,
17
+ forceFallback: true,
18
+ onEnd: function(evt) {
19
+ handleSectionReposition(evt)
20
+ }
21
+ })
22
+ }
23
+
24
+ pageVisabilityAttribute.forEach(function(elem) {
25
+ elem.addEventListener('change', function() {
26
+ handleTogglePageVisibility(this)
27
+ })
28
+ })
29
+ })
30
+
31
+ function handleTogglePageVisibility(obj) {
32
+ let checkedState = null
33
+ if (obj.checked) checkedState = true
34
+
35
+ const pageId = parseInt(obj.dataset.cmsPageId, 10)
36
+
37
+ const data = {
38
+ cms_page: {
39
+ visible: checkedState
40
+ }
41
+ }
42
+
43
+ fetch(Spree.routes.pages_api_v2 + `/${pageId}`, {
44
+ method: 'PATCH',
45
+ headers: {
46
+ Authorization: 'Bearer ' + OAUTH_TOKEN,
47
+ 'Content-Type': 'application/json'
48
+ },
49
+ body: JSON.stringify(data)
50
+ })
51
+ .then(response => {
52
+ if (response.ok) {
53
+ reloadPreview()
54
+ toggleVisibilityState(obj)
55
+ } else {
56
+ // eslint-disable-next-line no-undef
57
+ spreeHandleApiRequestError(response)
58
+ }
59
+ })
60
+ .catch(err => { console.error(err) })
61
+ }
62
+
63
+ function toggleVisibilityState(obj) {
64
+ const statusHolder = document.getElementById('visibilityStatus')
65
+ const pageHidden = statusHolder.querySelector('.page_hidden')
66
+ const pageVisible = statusHolder.querySelector('.page_visible')
67
+
68
+ if (obj.checked) {
69
+ pageHidden.classList.add('d-none')
70
+ pageVisible.classList.remove('d-none')
71
+ } else {
72
+ pageVisible.classList.add('d-none')
73
+ pageHidden.classList.remove('d-none')
74
+ }
75
+ }
76
+
77
+ function reloadPreview() {
78
+ const liveLiewArea = document.getElementById('pageLivePreview')
79
+
80
+ if (!liveLiewArea) return
81
+
82
+ liveLiewArea.contentWindow.location.reload();
83
+ }
84
+
85
+ function handleSectionReposition(evt) {
86
+ const data = {
87
+ section_id: parseInt(evt.item.dataset.sectionId, 10),
88
+ new_position_idx: parseInt(evt.newIndex, 10)
89
+ }
90
+
91
+ fetch(Spree.routes.sections_api_v2 + '/reposition', {
92
+ method: 'PATCH',
93
+ headers: {
94
+ Authorization: 'Bearer ' + OAUTH_TOKEN,
95
+ 'Content-Type': 'application/json'
96
+ },
97
+ body: JSON.stringify(data)
98
+ })
99
+ .then(response => {
100
+ if (response.ok) {
101
+ reloadPreview()
102
+ } else {
103
+ // eslint-disable-next-line no-undef
104
+ spreeHandleApiRequestError(response.status)
105
+ }
106
+ })
107
+ .catch(err => { console.error(err) })
108
+ }
109
+
110
+ function updateCmsPageType() {
111
+ const slugField = document.getElementById('cms_page_slug')
112
+ const updatePageType = document.getElementById('updatePageType')
113
+
114
+ if (!slugField) return
115
+
116
+ const selectedLinkType = $('#cms_page_type').val()
117
+
118
+ if (selectedLinkType === 'Spree::Cms::Pages::Homepage') {
119
+ slugField.disabled = true
120
+ } else {
121
+ slugField.disabled = false
122
+ }
123
+
124
+ if (!updatePageType) return
125
+
126
+ const existingType = updatePageType.dataset.pageType
127
+
128
+ if (selectedLinkType === existingType) {
129
+ updatePageType.classList.add('d-none')
130
+ } else {
131
+ updatePageType.classList.remove('d-none')
132
+ }
133
+ }
@@ -0,0 +1,43 @@
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ const sectionKindSelector = $('#cms_section_type').select2()
3
+ const layoutSwitcher = $('#cms_section_layout_style').select2()
4
+
5
+ sectionKindSelector.on('change', function() {
6
+ const selectedValue = $(sectionKindSelector).val()
7
+ const message = document.getElementById('alertToClickUpdate')
8
+ const activeSectionKind = document.getElementById('CmsSectionType')
9
+
10
+ if (!activeSectionKind) return
11
+
12
+ const panelType = activeSectionKind.dataset.panelSectionType
13
+
14
+ if (selectedValue === panelType) {
15
+ activeSectionKind.classList = ''
16
+ activeSectionKind.classList.add('d-block')
17
+
18
+ message.classList = ''
19
+ message.classList.add('d-none')
20
+ } else {
21
+ activeSectionKind.classList = ''
22
+ activeSectionKind.classList.add('d-none')
23
+
24
+ message.classList = ''
25
+ message.classList.add('d-block')
26
+ }
27
+ });
28
+
29
+ if (!layoutSwitcher) return
30
+
31
+ layoutSwitcher.on('change', function() {
32
+ const layoutDefault = document.querySelector('#Default')
33
+ const layoutReverse = document.querySelector('#Reversed')
34
+
35
+ if (this.value === 'Default') {
36
+ layoutDefault.classList = 'd-block'
37
+ layoutReverse.classList = 'd-none'
38
+ } else {
39
+ layoutDefault.classList = 'd-none'
40
+ layoutReverse.classList = 'd-block'
41
+ }
42
+ })
43
+ })
@@ -0,0 +1,11 @@
1
+ //= require spree/backend/global/alerts
2
+ //= require spree/backend/global/bootstrap
3
+ //= require spree/backend/global/flatpickr
4
+ //= require spree/backend/global/ransack
5
+ //= require spree/backend/global/info_alert
6
+ //= require spree/backend/global/radio_panel_toggle
7
+ //= require spree/backend/global/responsive_menus
8
+ //= require spree/backend/global/select2_autocomplete
9
+ //= require spree/backend/global/select2_populate
10
+ //= require spree/backend/global/sortable
11
+ //= require spree/backend/global/side_scroll_indication
@@ -0,0 +1,66 @@
1
+ /* global Swal */
2
+
3
+ document.addEventListener('DOMContentLoaded', function() {
4
+ const alertEl = document.querySelectorAll('[data-alert-type]')
5
+
6
+ if (!alertEl) return
7
+
8
+ alertEl.forEach(function (elem) {
9
+ const alertType = elem.dataset.alertType
10
+ const alertMessage = elem.innerHTML
11
+
12
+ show_flash(alertType, alertMessage)
13
+ })
14
+ })
15
+
16
+ // eslint-disable-next-line camelcase
17
+ function show_flash(type, message) {
18
+ let sanitizedType = DOMPurify.sanitize(type)
19
+ const sanitizedMessage = DOMPurify.sanitize(message)
20
+
21
+ if (sanitizedType === 'notice') sanitizedType = 'info'
22
+
23
+ // Set up Swal toast alert defaults
24
+ const Toast = Swal.mixin({
25
+ toast: true,
26
+ position: 'bottom',
27
+ showConfirmButton: false,
28
+ showCloseButton: true,
29
+ timer: 4500,
30
+ timerProgressBar: false,
31
+ showClass: {
32
+ popup: 'animate__animated animate__fadeInUp animate__faster',
33
+ backdrop: '-',
34
+ icon: '-'
35
+ },
36
+ hideClass: {
37
+ popup: 'animate__animated animate__fadeOutDown animate__faster',
38
+ backdrop: '-',
39
+ icon: '-'
40
+ }
41
+ })
42
+
43
+ Toast.fire({
44
+ icon: sanitizedType,
45
+ title: sanitizedMessage
46
+ })
47
+
48
+ appendToFlashAlertsContainer(sanitizedMessage, sanitizedType)
49
+ }
50
+
51
+ function appendToFlashAlertsContainer (message, type) {
52
+ if (type === 'info') type = 'notice'
53
+
54
+ const parnetNode = document.querySelector('#FlashAlertsContainer')
55
+ const node = document.createElement('SPAN');
56
+ const textNode = document.createTextNode(message);
57
+
58
+ // Only the most recent alert should be left in the #FlashAlertsContainer.
59
+ parnetNode.innerHTML = ''
60
+
61
+ node.classList.add('d-none')
62
+ node.setAttribute('data-alert-type', type);
63
+ node.appendChild(textNode)
64
+
65
+ parnetNode.appendChild(node);
66
+ }
@@ -0,0 +1,5 @@
1
+ // eslint-disable-next-line no-unused-vars
2
+ function spreeHandleApiRequestError (response) {
3
+ // eslint-disable-next-line no-undef
4
+ show_flash('error', `API Error: ${response}`)
5
+ }
@@ -0,0 +1,15 @@
1
+ // Use this file for Boostrap customization applied across the Spree Backend
2
+
3
+ document.addEventListener('DOMContentLoaded', function() {
4
+ $('.with-tip').each(function() {
5
+ $(this).tooltip({
6
+ container: $(this)
7
+ })
8
+ })
9
+
10
+ $('.with-tip').on('show.bs.tooltip', function(event) {
11
+ if (('ontouchstart' in window)) {
12
+ event.preventDefault()
13
+ }
14
+ })
15
+ })
@@ -0,0 +1,22 @@
1
+ document.addEventListener('DOMContentLoaded', function() {
2
+ flatpickr.setDefaults({
3
+ altInput: true,
4
+ time_24hr: true,
5
+ altInputClass: 'flatpickr-alt-input',
6
+ locale: Spree.translations.flatpickr_locale
7
+ })
8
+
9
+ var dateFrom = flatpickr('.datePickerFrom', {
10
+ onChange: function(selectedDates) {
11
+ dateTo.set('minDate', selectedDates[0])
12
+ }
13
+ })
14
+
15
+ var dateTo = flatpickr('.datePickerTo', {
16
+ onChange: function(selectedDates) {
17
+ dateFrom.set('maxDate', selectedDates[0])
18
+ }
19
+ })
20
+
21
+ flatpickr('.datepicker', {})
22
+ })
@@ -0,0 +1,38 @@
1
+ /* global Swal */
2
+ document.addEventListener('DOMContentLoaded', function() {
3
+ const infoToggle = document.querySelectorAll('[data-show-info]')
4
+
5
+ infoToggle.forEach(function(infoElem) {
6
+ infoElem.addEventListener('click', function() {
7
+ const alertType = infoElem.dataset.alertKind
8
+ const alertTitle = infoElem.dataset.alertTitle
9
+ const alertHtml = infoElem.dataset.alertHtml
10
+ const alertMessage = infoElem.dataset.alertMessage
11
+
12
+ showInfoAlert(alertType, alertTitle, alertMessage, alertHtml)
13
+ })
14
+ })
15
+ })
16
+
17
+ // eslint-disable-next-line no-unused-vars
18
+ function showInfoAlert(type = null, title = null, message = null, html = null) {
19
+ const infoAlert = Swal.mixin({
20
+ showConfirmButton: false,
21
+ showCloseButton: true,
22
+ timer: null,
23
+ timerProgressBar: false,
24
+ showClass: {
25
+ popup: 'animate__animated animate__fadeInUp animate__faster'
26
+ },
27
+ hideClass: {
28
+ popup: 'animate__animated animate__fadeOutDown animate__faster'
29
+ }
30
+ })
31
+
32
+ infoAlert.fire({
33
+ icon: type,
34
+ title: title,
35
+ text: message,
36
+ html: html
37
+ })
38
+ }