para 0.11.4 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (228) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/para/admin/main.scss +31 -0
  3. data/app/assets/stylesheets/para/admin/src/_affix.scss +7 -0
  4. data/app/assets/stylesheets/para/admin/src/_alert.scss +35 -0
  5. data/app/assets/stylesheets/para/admin/src/_base.scss +63 -0
  6. data/app/assets/stylesheets/para/admin/src/_bootstrap-variables.scss +766 -379
  7. data/app/assets/stylesheets/para/admin/src/_breadcrumb.scss +37 -0
  8. data/app/assets/stylesheets/para/admin/src/_buttons.scss +128 -0
  9. data/app/assets/stylesheets/para/admin/src/_checkable.scss +106 -0
  10. data/app/assets/stylesheets/para/admin/src/_common.scss +250 -0
  11. data/app/assets/stylesheets/para/admin/src/_dropdown.scss +52 -0
  12. data/app/assets/stylesheets/para/admin/src/_form.scss +359 -0
  13. data/app/assets/stylesheets/para/admin/src/_list.scss +96 -0
  14. data/app/assets/stylesheets/para/admin/src/_mixins.scss +109 -0
  15. data/app/assets/stylesheets/para/admin/src/_multi-select.scss +110 -0
  16. data/app/assets/stylesheets/para/admin/src/_navigation.scss +210 -0
  17. data/app/assets/stylesheets/para/admin/src/_navtabs.scss +68 -0
  18. data/app/assets/stylesheets/para/admin/src/_nested-many.scss +87 -0
  19. data/app/assets/stylesheets/para/admin/src/_nested_one.scss +26 -0
  20. data/app/assets/stylesheets/para/admin/src/_orderable.scss +48 -0
  21. data/app/assets/stylesheets/para/admin/src/_page-loading.scss +40 -0
  22. data/app/assets/stylesheets/para/admin/src/_pagination.scss +39 -0
  23. data/app/assets/stylesheets/para/admin/src/_panel.scss +61 -0
  24. data/app/assets/stylesheets/para/admin/src/_responsive.scss +133 -0
  25. data/app/assets/stylesheets/para/admin/src/_sorting.scss +43 -0
  26. data/app/assets/stylesheets/para/admin/src/_statcard.scss +46 -0
  27. data/app/assets/stylesheets/para/admin/src/_table.scss +36 -0
  28. data/app/assets/stylesheets/para/admin/src/_tree.scss +60 -0
  29. data/app/assets/stylesheets/para/admin/src/{_variables.sass → _variables.scss} +7 -7
  30. data/app/assets/stylesheets/para/admin/src/{_well.sass → _well.scss} +5 -4
  31. data/app/assets/stylesheets/para/admin.scss +15 -0
  32. data/app/assets/stylesheets/para/index.scss +1 -0
  33. data/app/assets/stylesheets/para/lib/datetimepicker.scss +15 -0
  34. data/app/assets/stylesheets/para/lib/fuelux.scss +46 -0
  35. data/app/assets/stylesheets/para/lib/jasny-bootstrap.scss +100 -0
  36. data/app/assets/stylesheets/para/lib/selectize.scss +129 -0
  37. data/app/assets/stylesheets/para/lib/slider.scss +14 -0
  38. data/app/controllers/para/admin/crud_resources_controller.rb +16 -9
  39. data/app/controllers/para/admin/imports_controller.rb +9 -9
  40. data/app/controllers/para/admin/jobs_controller.rb +7 -1
  41. data/app/controllers/para/admin/resources_controller.rb +17 -18
  42. data/app/controllers/para/admin/settings_component_controller.rb +2 -2
  43. data/app/helpers/para/admin/base_helper.rb +36 -25
  44. data/app/helpers/para/admin/page_helper.rb +8 -9
  45. data/app/helpers/para/flash_helper.rb +7 -28
  46. data/app/helpers/para/model_helper.rb +5 -8
  47. data/app/helpers/para/tree_helper.rb +4 -4
  48. data/app/javascripts/para/admin/async-progress.js +58 -0
  49. data/app/javascripts/para/admin/filters-form.js +12 -0
  50. data/app/javascripts/para/admin/job-tracker.js +33 -0
  51. data/app/javascripts/para/admin/table.js +58 -0
  52. data/app/javascripts/para/admin/tabs.js +110 -0
  53. data/app/javascripts/para/admin/theme_actions.js +39 -0
  54. data/app/javascripts/para/admin/tree.js +124 -0
  55. data/app/javascripts/para/application.js +2 -0
  56. data/app/javascripts/para/controllers/application.js +17 -0
  57. data/app/javascripts/para/controllers/index.js +10 -0
  58. data/app/javascripts/para/controllers/para_admin_flash_message_controller.js +48 -0
  59. data/app/javascripts/para/controllers/para_admin_modal_controller.js +43 -0
  60. data/app/javascripts/para/controllers/selectize_field_controller.js +142 -0
  61. data/app/javascripts/para/index.js +31 -0
  62. data/app/javascripts/para/inputs/material-input.js +7 -0
  63. data/app/javascripts/para/inputs/multi-select-input.js +343 -0
  64. data/app/javascripts/para/inputs/nested_many.js +151 -0
  65. data/app/javascripts/para/lib/fetch.js +41 -0
  66. data/app/javascripts/para/lib/page-loading.js +42 -0
  67. data/app/javascripts/para/simple_form_extension/colorpicker.js +30 -0
  68. data/app/javascripts/para/simple_form_extension/datetimepicker.js +115 -0
  69. data/app/javascripts/para/simple_form_extension/fileinput.js +57 -0
  70. data/app/javascripts/para/simple_form_extension/index.js +12 -0
  71. data/app/javascripts/para/simple_form_extension/selectize.js +160 -0
  72. data/app/javascripts/para/simple_form_extension/simple_form_extension_initialization.js +62 -0
  73. data/app/javascripts/para/simple_form_extension/slider.js +43 -0
  74. data/app/javascripts/para/simple_form_extension/spinbox.js +35 -0
  75. data/app/javascripts/para/vendor/bootstrap-colorpicker.js +1025 -0
  76. data/app/javascripts/para/vendor/bootstrap-slider.js +1610 -0
  77. data/app/javascripts/para/vendor/cocoon.js +150 -0
  78. data/app/javascripts/para/vendor/jquery.datetimepicker.js +2156 -0
  79. data/app/javascripts/para/vendor/jquery.js +3 -0
  80. data/app/javascripts/para/vendor/spinbox.js +438 -0
  81. data/app/javascripts/para/vendor/vertebra.js +224 -0
  82. data/app/views/admin/para/exporter/bases/_completed.html.haml +1 -1
  83. data/app/views/layouts/para/admin.html.haml +4 -2
  84. data/app/views/para/admin/imports/new.html.haml +12 -11
  85. data/app/views/para/admin/jobs/_completed.html.haml +1 -1
  86. data/app/views/para/admin/jobs/_failed.html.haml +1 -1
  87. data/app/views/para/admin/jobs/_job.html.haml +11 -0
  88. data/app/views/para/admin/jobs/show.html.haml +1 -10
  89. data/app/views/para/admin/resources/_add_button.html.haml +1 -1
  90. data/app/views/para/admin/resources/_exports_menu.html.haml +2 -2
  91. data/app/views/para/admin/resources/_filters.html.haml +1 -1
  92. data/app/views/para/admin/resources/_imports_menu.html.haml +2 -2
  93. data/app/views/para/admin/resources/_list.html.haml +27 -26
  94. data/app/views/para/admin/resources/_navigation.html.haml +10 -11
  95. data/app/views/para/admin/resources/_subclassable_add_button.html.haml +1 -1
  96. data/app/views/para/admin/shared/_flash.html.haml +18 -0
  97. data/app/views/para/admin/shared/_header.html.haml +1 -1
  98. data/app/views/para/form/_tabs.html.haml +1 -1
  99. data/app/views/para/inputs/_nested_many.html.haml +3 -3
  100. data/app/views/para/inputs/nested_many/_add.html.haml +1 -1
  101. data/app/views/para/inputs/nested_many/_add_with_subclasses.html.haml +2 -2
  102. data/app/views/para/inputs/nested_many/_container.html.haml +1 -1
  103. data/config/locales/fr.yml +1 -0
  104. data/lib/generators/para/install/install_generator.rb +10 -14
  105. data/lib/para/attribute_field/base.rb +3 -0
  106. data/lib/para/attribute_field/wysiwyg_editor.rb +15 -0
  107. data/lib/para/attribute_field.rb +1 -1
  108. data/lib/para/components_configuration.rb +1 -1
  109. data/lib/para/engine.rb +20 -22
  110. data/lib/para/ext/turbo_stream.rb +13 -0
  111. data/lib/para/ext.rb +1 -1
  112. data/lib/para/form_builder/containers.rb +33 -22
  113. data/lib/para/form_builder/nested_form.rb +6 -5
  114. data/lib/para/inputs/nested_many_input.rb +5 -0
  115. data/lib/para/markup/modal.rb +30 -15
  116. data/lib/para/markup/resources_buttons.rb +15 -11
  117. data/lib/para/model_field_parsers/wysiwyg_editor.rb +19 -0
  118. data/lib/para/model_field_parsers.rb +1 -1
  119. data/lib/para/version.rb +1 -1
  120. data/lib/para.rb +2 -8
  121. data/lib/simple_form_extension/components/icons.rb +13 -0
  122. data/lib/simple_form_extension/components/popovers.rb +46 -0
  123. data/lib/simple_form_extension/components.rb +8 -0
  124. data/lib/simple_form_extension/ext/form_builder.rb +20 -0
  125. data/lib/simple_form_extension/file_concern.rb +74 -0
  126. data/lib/simple_form_extension/inputs/boolean_input.rb +16 -0
  127. data/lib/simple_form_extension/inputs/collection_check_boxes_input.rb +15 -0
  128. data/lib/simple_form_extension/inputs/collection_radio_buttons_input.rb +15 -0
  129. data/lib/simple_form_extension/inputs/color_input.rb +37 -0
  130. data/lib/simple_form_extension/inputs/date_time_input.rb +48 -0
  131. data/lib/simple_form_extension/inputs/file_input.rb +41 -0
  132. data/lib/simple_form_extension/inputs/image_input.rb +110 -0
  133. data/lib/simple_form_extension/inputs/numeric_input.rb +27 -0
  134. data/lib/simple_form_extension/inputs/selectize_input.rb +210 -0
  135. data/lib/simple_form_extension/inputs/slider_input.rb +30 -0
  136. data/lib/simple_form_extension/inputs.rb +16 -0
  137. data/lib/simple_form_extension/railtie.rb +21 -0
  138. data/lib/simple_form_extension/resource_name_helper.rb +9 -0
  139. data/lib/simple_form_extension/translations.rb +7 -0
  140. data/lib/simple_form_extension/version.rb +3 -0
  141. data/lib/simple_form_extension.rb +30 -0
  142. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/alpha-horizontal.png +0 -0
  143. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/alpha.png +0 -0
  144. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/hue-horizontal.png +0 -0
  145. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/hue.png +0 -0
  146. data/vendor/assets/images/simple_form_extension/bootstrap-colorpicker/saturation.png +0 -0
  147. data/vendor/assets/stylesheets/bootstrap-colorpicker.scss +227 -0
  148. data/vendor/assets/stylesheets/bootstrap-slider.scss +246 -0
  149. data/vendor/assets/stylesheets/bootstrap.scss +6032 -0
  150. data/vendor/assets/stylesheets/jquery.datetimepicker.scss +568 -0
  151. metadata +120 -188
  152. data/app/assets/javascripts/admin/app.coffee +0 -1
  153. data/app/assets/javascripts/para/admin/async-progress.coffee +0 -29
  154. data/app/assets/javascripts/para/admin/filters-form.coffee +0 -11
  155. data/app/assets/javascripts/para/admin/job-tracker.coffee +0 -39
  156. data/app/assets/javascripts/para/admin/table.coffee +0 -44
  157. data/app/assets/javascripts/para/admin/tabs.coffee +0 -63
  158. data/app/assets/javascripts/para/admin/theme_actions.coffee +0 -25
  159. data/app/assets/javascripts/para/admin/tree.coffee +0 -105
  160. data/app/assets/javascripts/para/admin.coffee +0 -22
  161. data/app/assets/javascripts/para/application.js +0 -13
  162. data/app/assets/javascripts/para/inputs/material-input.coffee +0 -4
  163. data/app/assets/javascripts/para/inputs/multi-select-input.coffee +0 -174
  164. data/app/assets/javascripts/para/inputs/nested_many.coffee +0 -108
  165. data/app/assets/javascripts/para/lib/ajax.coffee +0 -11
  166. data/app/assets/javascripts/para/lib/remote-file-forms.coffee +0 -59
  167. data/app/assets/javascripts/para/lib/turbolinks-forms.coffee +0 -23
  168. data/app/assets/javascripts/para/lib/turbolinks-loading.coffee +0 -25
  169. data/app/assets/javascripts/para/lib/turbolinks-reloader.coffee +0 -19
  170. data/app/assets/stylesheets/para/admin/main.sass +0 -33
  171. data/app/assets/stylesheets/para/admin/src/_affix.sass +0 -4
  172. data/app/assets/stylesheets/para/admin/src/_alert.sass +0 -17
  173. data/app/assets/stylesheets/para/admin/src/_base.sass +0 -54
  174. data/app/assets/stylesheets/para/admin/src/_breadcrumb.sass +0 -32
  175. data/app/assets/stylesheets/para/admin/src/_buttons.sass +0 -107
  176. data/app/assets/stylesheets/para/admin/src/_checkable.sass +0 -94
  177. data/app/assets/stylesheets/para/admin/src/_common.sass +0 -202
  178. data/app/assets/stylesheets/para/admin/src/_dropdown.sass +0 -40
  179. data/app/assets/stylesheets/para/admin/src/_form.sass +0 -299
  180. data/app/assets/stylesheets/para/admin/src/_list.sass +0 -89
  181. data/app/assets/stylesheets/para/admin/src/_mixins.sass +0 -113
  182. data/app/assets/stylesheets/para/admin/src/_multi-select.sass +0 -91
  183. data/app/assets/stylesheets/para/admin/src/_navigation.sass +0 -171
  184. data/app/assets/stylesheets/para/admin/src/_navtabs.sass +0 -58
  185. data/app/assets/stylesheets/para/admin/src/_nested-many.sass +0 -75
  186. data/app/assets/stylesheets/para/admin/src/_nested_one.sass +0 -22
  187. data/app/assets/stylesheets/para/admin/src/_orderable.sass +0 -44
  188. data/app/assets/stylesheets/para/admin/src/_page-loading.sass +0 -39
  189. data/app/assets/stylesheets/para/admin/src/_pagination.sass +0 -34
  190. data/app/assets/stylesheets/para/admin/src/_panel.sass +0 -55
  191. data/app/assets/stylesheets/para/admin/src/_responsive.sass +0 -117
  192. data/app/assets/stylesheets/para/admin/src/_sorting.sass +0 -36
  193. data/app/assets/stylesheets/para/admin/src/_statcard.sass +0 -41
  194. data/app/assets/stylesheets/para/admin/src/_table.sass +0 -33
  195. data/app/assets/stylesheets/para/admin/src/_tree.sass +0 -52
  196. data/app/assets/stylesheets/para/admin.sass +0 -12
  197. data/app/assets/stylesheets/para/lib/compass/_support.scss +0 -447
  198. data/app/assets/stylesheets/para/lib/compass/css3/_box-shadow.scss +0 -88
  199. data/app/assets/stylesheets/para/lib/compass/css3/_images.scss +0 -152
  200. data/app/assets/stylesheets/para/lib/compass/css3/_inline-block.scss +0 -31
  201. data/app/assets/stylesheets/para/lib/compass/css3/_text-shadow.scss +0 -82
  202. data/app/assets/stylesheets/para/lib/compass/css3/_transform.scss +0 -590
  203. data/app/assets/stylesheets/para/lib/compass/css3/_transition.scss +0 -190
  204. data/app/assets/stylesheets/para/lib/compass/css3/_user-interface.scss +0 -71
  205. data/app/assets/stylesheets/para/lib/compass/utilities/general/_hacks.scss +0 -65
  206. data/app/assets/stylesheets/para/lib/datetimepicker.sass +0 -15
  207. data/app/assets/stylesheets/para/lib/fuelux.sass +0 -40
  208. data/app/assets/stylesheets/para/lib/jasny-bootstrap.sass +0 -97
  209. data/app/assets/stylesheets/para/lib/redactor.sass +0 -86
  210. data/app/assets/stylesheets/para/lib/selectize.sass +0 -111
  211. data/app/assets/stylesheets/para/lib/slider.sass +0 -12
  212. data/app/assets/stylesheets/para/plugins-includes.sass.erb +0 -1
  213. data/lib/para/attribute_field/redactor.rb +0 -22
  214. data/lib/para/ext/request_iframe_xhr.rb +0 -17
  215. data/lib/para/iframe_transport/middleware.rb +0 -58
  216. data/lib/para/iframe_transport.rb +0 -7
  217. data/lib/para/model_field_parsers/redactor.rb +0 -19
  218. data/vendor/assets/javascripts/jquery.iframe-transport.js +0 -260
  219. data/vendor/assets/javascripts/jquery.remote-modal-form.coffee +0 -145
  220. /data/app/assets/stylesheets/admin/{app.sass → app.scss} +0 -0
  221. /data/app/{assets/javascripts → javascripts}/para/plugins-includes.js.erb +0 -0
  222. /data/{vendor/assets/javascripts → app/javascripts/para/vendor}/Sortable.js +0 -0
  223. /data/{vendor/assets/javascripts → app/javascripts/para/vendor}/jasny-bootstrap.js +0 -0
  224. /data/{vendor/assets/javascripts → app/javascripts/para/vendor}/jquery.scrollto.js +0 -0
  225. /data/{vendor/assets/javascripts → app/javascripts/para/vendor}/jquery.sortable.js +0 -0
  226. /data/vendor/assets/stylesheets/{animate.css → animate.scss} +0 -0
  227. /data/vendor/assets/stylesheets/{hint.css → hint.scss} +0 -0
  228. /data/vendor/assets/stylesheets/{jasny-bootstrap.css → jasny-bootstrap.scss} +0 -0
@@ -0,0 +1,124 @@
1
+ import { PATCH, fetch } from "../lib/fetch";
2
+
3
+ Para.ResourceTree = class ResourceTree {
4
+ constructor($el1) {
5
+ this.initializeSubTree = this.initializeSubTree.bind(this);
6
+ // Note : This method is called often (many times per second while we're dragging) and
7
+ // takes quite some processing.
8
+ this.isMovementValid = this.isMovementValid.bind(this);
9
+ this.handleOrderUpdated = this.handleOrderUpdated.bind(this);
10
+ this.$el = $el1;
11
+ this.initializeTree();
12
+ }
13
+
14
+ initializeTree() {
15
+ this.orderUrl = this.$el.data('url');
16
+ this.maxDepth = parseInt(this.$el.data('max-depth'));
17
+ // Each is needed here as the sortable jQuery plugin doesn't loop over each found node
18
+ // but initializes the tree on the first found element.
19
+ return $(".tree").each(this.initializeSubTree);
20
+ }
21
+
22
+ initializeSubTree(_i, el) {
23
+ return $(el).sortable({
24
+ group: "tree",
25
+ handle: ".handle",
26
+ draggable: ".node",
27
+ fallbackOnBody: true,
28
+ swapThreshold: 0.65,
29
+ animation: 150,
30
+ onSort: this.handleOrderUpdated,
31
+ onMove: this.isMovementValid
32
+ });
33
+ }
34
+
35
+ isMovementValid(e) {
36
+ var $movedNode, $movedNodeSubtrees, $target, finalSubtreeDeepnessAfterMove, movedNodeDeepness, movedNodeTreeDeepness, targetDeepness;
37
+ $movedNode = $(e.dragged);
38
+ $target = $(e.related);
39
+ // Calculate the deepness of the moved and target nodes
40
+ movedNodeDeepness = $movedNode.parents(".node").length - 1;
41
+ // If the target is a node, the moved node root deepness is gonna be the same as the
42
+ // the target one, else the tree's parent node is counted also
43
+ targetDeepness = $target.parents(".node").length - 1;
44
+ // Find the deepest node in the subtree of the moved node
45
+ $movedNodeSubtrees = $movedNode.find(".tree");
46
+ movedNodeTreeDeepness = 0;
47
+ // The movedNodeTreeDeepness is the maximum deepness of a child node of the current
48
+ // moved node, relative to the moved node
49
+ $movedNodeSubtrees.each((i, el) => {
50
+ var subtreeDeepness, subtreeRelativeDeepness;
51
+ subtreeDeepness = $(el).parents(".node").length - 1;
52
+ subtreeRelativeDeepness = subtreeDeepness - movedNodeDeepness;
53
+ return movedNodeTreeDeepness = Math.max(movedNodeTreeDeepness, subtreeRelativeDeepness);
54
+ });
55
+ // Calculate the final subtree deepness once we move the whole moved node subtree to
56
+ // its target position
57
+ finalSubtreeDeepnessAfterMove = movedNodeTreeDeepness + targetDeepness;
58
+ // We finally validate the move only if the final subtree deepness is lower than the
59
+ // maximum allowed depth
60
+ return finalSubtreeDeepnessAfterMove <= this.maxDepth;
61
+ }
62
+
63
+ handleOrderUpdated(e) {
64
+ var $el, j, len, treeLeaves;
65
+ // Get all involved tree leaves that may include a subtree
66
+ treeLeaves = [$(e.target), $(e.from), $(e.item).find('.tree')];
67
+ for (j = 0, len = treeLeaves.length; j < len; j++) {
68
+ $el = treeLeaves[j];
69
+ // Update their placeholder display wether they can be a drop target or not
70
+ this.handlePlaceholder($el);
71
+ }
72
+ // Save the tree structure on the server
73
+ this.updateOrder();
74
+ }
75
+
76
+ // This method checks wether a given tree leaf can be a drop target, depending
77
+ // on wether it's located at the maximum allowed depth for the tree or not, and adds or
78
+ // remove a the visual placeholder to indicate its droppable state.
79
+
80
+ handlePlaceholder($el) {
81
+ var $placeholder, hasChildren, parentsCount;
82
+ $placeholder = $el.find("> .placeholder");
83
+ parentsCount = $el.parents('.node').length - 1;
84
+ hasChildren = $el.find('> .node').length;
85
+ if (parentsCount >= this.maxDepth || hasChildren) {
86
+ $placeholder.hide();
87
+ return $el.children(".tree").each((index, el) => {
88
+ return this.handlePlaceholder($(el));
89
+ });
90
+ } else {
91
+ return $placeholder.show();
92
+ }
93
+ }
94
+
95
+ updateOrder() {
96
+ fetch(this.orderUrl, {
97
+ method: PATCH,
98
+ body: this.buildOrderedData()
99
+ });
100
+ }
101
+
102
+ buildOrderedData() {
103
+ const data = new FormData();
104
+
105
+ $(".node").each(function(index, el) {
106
+ const $el = $(el);
107
+ const resourceKey = `resources[${index}]`
108
+ const parentId = $el.parents(".node").last().data("id") || "";
109
+
110
+ data.append(`${resourceKey}[id]`, $el.data("id"));
111
+ data.append(`${resourceKey}[position]`, index);
112
+ data.append(`${resourceKey}[parent_id]`, parentId);
113
+ });
114
+
115
+ return data;
116
+ }
117
+ };
118
+
119
+ // TODO: Add flash message to display ordering success
120
+ $(document).on('turbo:load turbo:frame-load', function() {
121
+ return $('.root-tree').each(function(_i, el) {
122
+ return new Para.ResourceTree($(el));
123
+ });
124
+ });
@@ -0,0 +1,2 @@
1
+ // Initialize Para's scope object
2
+ window.Para = {}
@@ -0,0 +1,17 @@
1
+ import { Application } from "@hotwired/stimulus";
2
+
3
+ function startStimulusApplication() {
4
+ if (window.Stimulus) return window.Stimulus;
5
+
6
+ const application = Application.start();
7
+
8
+ // Configure Stimulus development experience
9
+ application.debug = false;
10
+ window.Stimulus = application;
11
+
12
+ return application;
13
+ }
14
+
15
+ const application = startStimulusApplication();
16
+
17
+ export { application };
@@ -0,0 +1,10 @@
1
+ import { application } from "./application";
2
+
3
+ import ParaAdminModalController from "./para_admin_modal_controller";
4
+ application.register("para-admin-modal", ParaAdminModalController);
5
+
6
+ import ParaAdminFlashMessageController from "./para_admin_flash_message_controller";
7
+ application.register("para-admin-flash-message", ParaAdminFlashMessageController);
8
+
9
+ import SelectizeFieldController from "./selectize_field_controller";
10
+ application.register("selectize-field", SelectizeFieldController);
@@ -0,0 +1,48 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ const FLASH_BASE_OFFSET = 10;
4
+
5
+ export default class extends Controller {
6
+ static targets = ["alert"];
7
+
8
+ connect() {
9
+ this.refreshTopOffset = this.refreshTopOffset.bind(this);
10
+
11
+ this.autoCloseTimer = setTimeout(() => this.close(), 10000);
12
+
13
+ this.refreshTopOffset();
14
+ window.addEventListener("resize", this.refreshTopOffset);
15
+
16
+ this.element.classList.add("in");
17
+ }
18
+
19
+ disconnect() {
20
+ this.cleanTimer();
21
+ window.removeEventListener("resize", this.refreshTopOffset);
22
+ }
23
+
24
+ close() {
25
+ this.element.classList.remove("in");
26
+ this.removeTimer = setTimeout(() => this.element.remove(), 500);
27
+ }
28
+
29
+ cleanTimer() {
30
+ if (this.autoCloseTimer) {
31
+ clearTimeout(this.autoCloseTimer);
32
+ }
33
+
34
+ if (this.removeTimer) {
35
+ clearTimeout(this.removeTimer);
36
+ }
37
+ }
38
+
39
+ refreshTopOffset() {
40
+ const headerHeight = document.querySelector("[data-header]")?.offsetHeight || 0;
41
+ const affixHeaderHeight =
42
+ document.querySelector("[data-affix-header]")?.offsetHeight || 0;
43
+
44
+ const offsetTop = headerHeight + affixHeaderHeight + FLASH_BASE_OFFSET;
45
+
46
+ this.element.parentElement.style.top = `${offsetTop}px`;
47
+ }
48
+ }
@@ -0,0 +1,43 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+
3
+ export default class extends Controller {
4
+ static values = {};
5
+ static targets = ["modal"];
6
+
7
+ connect() {}
8
+
9
+ disconnect() {
10
+ if (this.hasModalTarget) this.modalTarget.remove();
11
+ }
12
+
13
+ modalTargetConnected() {
14
+ this.modalTarget.classList.add('in', 'show');
15
+ this.displayBackdrop();
16
+ document.body.classList.add('modal-open');
17
+
18
+ $(this.element).simpleForm();
19
+ }
20
+
21
+ modalTargetDisconnected() {
22
+ this.closeModal();
23
+ }
24
+
25
+ closeModal() {
26
+ document.body.classList.remove('modal-open');
27
+
28
+ if (this.hasModalTarget) this.modalTarget.classList.remove('in', 'show');
29
+ this.backdropElement?.remove();
30
+ delete this.backdropElement;
31
+ }
32
+
33
+ displayBackdrop() {
34
+ if (this.backdropElement) return;
35
+
36
+ this.backdropElement = document.createElement('div');
37
+ this.backdropElement.classList.add(
38
+ 'modal-backdrop', 'fade', 'in', 'bg-primary', 'bg-primary-80-desktop'
39
+ );
40
+
41
+ this.element.appendChild(this.backdropElement);
42
+ }
43
+ }
@@ -0,0 +1,142 @@
1
+ import { Controller } from "@hotwired/stimulus";
2
+ import Selectize from '@selectize/selectize';
3
+
4
+ export default class extends Controller {
5
+ static values = {
6
+ "input": Array,
7
+ "creatable": Boolean,
8
+ "multi": Boolean,
9
+ "addTranslation": String,
10
+ "collection": Array,
11
+ "max-items": Number,
12
+ "sort-field": String,
13
+ "search-url": String,
14
+ "search-param": String,
15
+ "escape": Boolean
16
+ };
17
+
18
+ static targets = [];
19
+
20
+ connect() {
21
+ if (this.element.selectize) return;
22
+
23
+ // Clean previously initialized selectize DOM elements if any
24
+ if (this.element.nextSibling?.classList?.contains('selectize')) {
25
+ this.element.nextSibling.remove();
26
+ }
27
+
28
+ this.load = this.load.bind(this);
29
+
30
+ this.isSingle = !this.multiValue;
31
+
32
+ this.$el = $(this.element);
33
+ this.$el.selectize(this.options);
34
+
35
+ if (this.inputValue) this.initializeValue(this.inputValue);
36
+ }
37
+
38
+ get options() {
39
+ return {
40
+ mode: this.isSingle ? 'single' : 'multi',
41
+ maxItems: this.isSingle ? 1 : this.maxItemsValue,
42
+ sortField: this.sortFieldValue,
43
+ plugins: ['remove_button', 'clear_button'],
44
+ create: this.creatableValue,
45
+ render: this.renderOptions,
46
+ options: this.collectionValue,
47
+ load: this.load
48
+ };
49
+ }
50
+
51
+ initializeValue(options) {
52
+ if (this.isSingle) {
53
+ this.addAndSelect(options[0]);
54
+ } else {
55
+ options.forEach(option => this.addAndSelect(option));
56
+ }
57
+ }
58
+
59
+ addAndSelect(option) {
60
+ this.element.selectize.addOption(option);
61
+ return this.element.selectize.addItem(option.value);
62
+ }
63
+
64
+ load(query, callback) {
65
+ var data;
66
+
67
+ if (!(query.length && this.searchUrlValue)) {
68
+ return callback();
69
+ }
70
+
71
+ data = {};
72
+ data[this.searchParamValue] = query;
73
+
74
+ return $.ajax({
75
+ url: this.searchUrlValue,
76
+ type: 'GET',
77
+ data: data,
78
+ error: callback,
79
+ success: callback
80
+ });
81
+ }
82
+
83
+ get renderOptions() {
84
+ return {
85
+ option: (data, escape) => {
86
+ return `
87
+ <div data-value="${escape(data.value)}" class="item">
88
+ ${(this.escapeValue ? escape(data.text) : data.text)}
89
+ </div>
90
+ `;
91
+ },
92
+ item: (data, escape) => {
93
+ return `
94
+ <div data-value="${escape(data.value)}" data-selectable="" class="option">
95
+ ${(this.escapeValue ? escape(data.text) : data.text)}
96
+ </div>
97
+ `;
98
+ },
99
+ option_create: (data) => {
100
+ return `
101
+ <div class="create" data-selectable="">
102
+ ${this.addTranslationValue}
103
+ <strong>${data.input}</strong> ...
104
+ </div>
105
+ `;
106
+ }
107
+ };
108
+ }
109
+ }
110
+
111
+ // Fix for allowEmptyOption issue
112
+
113
+ // See : https://github.com/selectize/selectize.js/issues/967
114
+
115
+ hash_key = function(value) {
116
+ if (typeof value === 'undefined' || value === null) {
117
+ return null;
118
+ }
119
+ if (typeof value === 'boolean') {
120
+ if (value) {
121
+ return '1';
122
+ } else {
123
+ return '0';
124
+ }
125
+ }
126
+ return value + '';
127
+ };
128
+
129
+ $.extend(Selectize.prototype, {
130
+ registerOption: function(data) {
131
+ var key;
132
+ key = hash_key(data[this.settings.valueField]);
133
+ // Line 1187 of src/selectize.js should be changed
134
+ // if (!key || this.options.hasOwnProperty(key)) return false;
135
+ if (typeof key === 'undefined' || key === null || this.options.hasOwnProperty(key)) {
136
+ return false;
137
+ }
138
+ data.$order = data.$order || ++this.order;
139
+ this.options[key] = data;
140
+ return key;
141
+ }
142
+ });
@@ -0,0 +1,31 @@
1
+ import "./vendor/jquery";
2
+
3
+ import "bootstrap";
4
+ import "@selectize/selectize";
5
+ import "sortablejs";
6
+
7
+ import "./simple_form_extension";
8
+
9
+ import "./vendor/cocoon";
10
+ import "./vendor/vertebra";
11
+ import "./vendor/jasny-bootstrap";
12
+ import "./vendor/jquery.scrollto";
13
+ import "./vendor/jquery.sortable";
14
+
15
+ import "./application";
16
+
17
+ import "./lib/page-loading";
18
+
19
+ import "./inputs/material-input";
20
+ import "./inputs/multi-select-input";
21
+ import "./inputs/nested_many";
22
+
23
+ import "./admin/async-progress";
24
+ import "./admin/filters-form";
25
+ import "./admin/job-tracker";
26
+ import "./admin/table";
27
+ import "./admin/tabs";
28
+ import "./admin/theme_actions";
29
+ import "./admin/tree";
30
+
31
+ import "./controllers";
@@ -0,0 +1,7 @@
1
+ $(document).on('page:change turbo:load turbo:frame-load', function() {
2
+ return $('body').on('focusin focusout', 'input, select, textarea', function(e) {
3
+ var focused;
4
+ focused = e.type === 'focusin';
5
+ return $(e.target).closest('.form-group').toggleClass('focused', focused);
6
+ });
7
+ });