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,343 @@
1
+ var ref, ref1,
2
+ boundMethodCheck = function(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new Error('Bound instance method accessed before binding'); } };
3
+
4
+ ref = Para.MultiSelectInput = (function() {
5
+ class MultiSelectInput extends Vertebra.View {
6
+ initialize() {
7
+ this.triggerSearch = this.triggerSearch.bind(this);
8
+ this.onSearchReturn = this.onSearchReturn.bind(this);
9
+ this.onItemAdded = this.onItemAdded.bind(this);
10
+ this.onItemRemoved = this.onItemRemoved.bind(this);
11
+ this.selectedItemsSorted = this.selectedItemsSorted.bind(this);
12
+
13
+ var el;
14
+ this.$searchField = this.$('[data-search-field]');
15
+ this.$selectedItems = this.$('[data-selected-items] tbody');
16
+ this.$availableItems = this.$('[data-available-items]');
17
+ this.$input = this.$('[data-multi-select-input-field]');
18
+ this.searchURL = this.$el.data('search-url');
19
+ this.orderable = this.$el.is('[data-orderable]');
20
+ this.searchParam = this.$searchField.attr('name');
21
+ this.noSelectedItemsTemplate = this.$('[data-no-selected-items]').data('no-selected-items');
22
+ this.noAvailableItemsTemplate = this.$('[data-no-available-items]').data('no-available-items');
23
+ this.throttledTriggerSearch = throttle(this.triggerSearch, 300, {
24
+ trailing: true
25
+ });
26
+ this.availableItems = [];
27
+ this.selectedItems = (function() {
28
+ var j, len, ref1, results1;
29
+ ref1 = this.$selectedItems.find('[data-selected-item-id]');
30
+ results1 = [];
31
+ for (j = 0, len = ref1.length; j < len; j++) {
32
+ el = ref1[j];
33
+ results1.push(this.buildSelectedItem(el));
34
+ }
35
+ return results1;
36
+ }).call(this);
37
+ this.refreshSelectedItems();
38
+ return this.refreshAvailableItems();
39
+ }
40
+
41
+ onSearchKeyUp() {
42
+ return this.throttledTriggerSearch();
43
+ }
44
+
45
+ triggerSearch() {
46
+ boundMethodCheck(this, ref);
47
+ return this.searchFor(this.$searchField.val());
48
+ }
49
+
50
+ searchFor(terms) {
51
+ var data, ref1;
52
+ terms = trim(terms);
53
+ if (terms === this.terms || (!terms && !this.terms)) {
54
+ return;
55
+ }
56
+ this.terms = terms;
57
+ this.setLoading(true);
58
+ if ((ref1 = this._currentSearchXHR) != null) {
59
+ ref1.abort();
60
+ }
61
+ data = this.$('[data-search-field-input]').serialize();
62
+ return this._currentSearchXHR = $.get(this.searchURL, data).done(this.onSearchReturn);
63
+ }
64
+
65
+ onSearchReturn(results) {
66
+ boundMethodCheck(this, ref);
67
+ this._currentSearchXHR = null;
68
+ this.setLoading(false);
69
+ this.$('[data-available-items] tbody').html(results);
70
+ return this.refreshAvailableItems();
71
+ }
72
+
73
+ refreshAvailableItems() {
74
+ var el, item, j, len, ref1;
75
+ ref1 = this.availableItems;
76
+ for (j = 0, len = ref1.length; j < len; j++) {
77
+ item = ref1[j];
78
+ item.destroy();
79
+ }
80
+ this.availableItems = (function() {
81
+ var k, len1, ref2, results1;
82
+ ref2 = this.$('[data-available-items] tr');
83
+ results1 = [];
84
+ for (k = 0, len1 = ref2.length; k < len1; k++) {
85
+ el = ref2[k];
86
+ results1.push(this.buildAvailableItem(el));
87
+ }
88
+ return results1;
89
+ }).call(this);
90
+ if (!this.availableItems.length) {
91
+ return this.showEmptyListHint(this.noAvailableItemsTemplate, this.$availableItems);
92
+ }
93
+ }
94
+
95
+ buildAvailableItem(el) {
96
+ var availableItem, j, len, ref1, selectedItem;
97
+ availableItem = new Para.MultiSelectAvailableItem({
98
+ el: el
99
+ });
100
+ ref1 = this.selectedItems;
101
+ for (j = 0, len = ref1.length; j < len; j++) {
102
+ selectedItem = ref1[j];
103
+ if (selectedItem.id === availableItem.id) {
104
+ availableItem.setSelected(true);
105
+ }
106
+ }
107
+ this.listenTo(availableItem, 'add', this.onItemAdded);
108
+ return availableItem;
109
+ }
110
+
111
+ onItemAdded(item) {
112
+ boundMethodCheck(this, ref);
113
+ return this.selectItem(item);
114
+ }
115
+
116
+ buildSelectedItem(el) {
117
+ var selectedItem;
118
+ selectedItem = new Para.MultiSelectSelectedItem({
119
+ el: el
120
+ });
121
+ this.listenTo(selectedItem, 'remove', this.onItemRemoved);
122
+ return selectedItem;
123
+ }
124
+
125
+ selectItem(item) {
126
+ var selectedItem;
127
+ if (this.alreadySelected(item)) {
128
+ return;
129
+ }
130
+ item.setSelected(true);
131
+ selectedItem = this.buildSelectedItem(item.$el.attr('data-selected-item-template'));
132
+ this.selectedItems.push(selectedItem);
133
+ return this.refreshSelectedItems();
134
+ }
135
+
136
+ alreadySelected(item) {
137
+ var j, len, ref1, selectedItem;
138
+ ref1 = this.selectedItems;
139
+ for (j = 0, len = ref1.length; j < len; j++) {
140
+ selectedItem = ref1[j];
141
+ if (selectedItem.id === item.id) {
142
+ return true;
143
+ }
144
+ }
145
+ return false;
146
+ }
147
+
148
+ refreshSelectedItems() {
149
+ var j, len, ref1, selectedItem, selectedItemIds;
150
+ this.$selectedItems.empty();
151
+ ref1 = this.selectedItems;
152
+ for (j = 0, len = ref1.length; j < len; j++) {
153
+ selectedItem = ref1[j];
154
+ selectedItem.renderTo(this.$selectedItems);
155
+ }
156
+ selectedItemIds = ((function() {
157
+ var k, len1, ref2, results1;
158
+ ref2 = this.selectedItems;
159
+ results1 = [];
160
+ for (k = 0, len1 = ref2.length; k < len1; k++) {
161
+ selectedItem = ref2[k];
162
+ results1.push(selectedItem.id);
163
+ }
164
+ return results1;
165
+ }).call(this)).join(', ');
166
+ this.$input.val(selectedItemIds);
167
+ if (this.selectedItems.length) {
168
+ return this.initializeOrderable();
169
+ } else {
170
+ return this.showEmptyListHint(this.noSelectedItemsTemplate, this.$selectedItems);
171
+ }
172
+ }
173
+
174
+ showEmptyListHint(template, $container) {
175
+ return $(template).appendTo($container);
176
+ }
177
+
178
+ onItemRemoved(selectedItem) {
179
+ var availableItem, index, item, itemIndex, j, k, len, len1, ref1, ref2;
180
+ boundMethodCheck(this, ref);
181
+ ref1 = this.selectedItems;
182
+ for (index = j = 0, len = ref1.length; j < len; index = ++j) {
183
+ item = ref1[index];
184
+ if (item.id === selectedItem.id) {
185
+ itemIndex = index;
186
+ }
187
+ }
188
+ this.selectedItems.splice(itemIndex, 1);
189
+ selectedItem.destroy();
190
+ this.refreshSelectedItems();
191
+ ref2 = this.availableItems;
192
+ for (k = 0, len1 = ref2.length; k < len1; k++) {
193
+ item = ref2[k];
194
+ if (item.id === selectedItem.id) {
195
+ availableItem = item;
196
+ }
197
+ }
198
+ if (availableItem) {
199
+ return availableItem.setSelected(false);
200
+ }
201
+ }
202
+
203
+ onAllItemsAdded() {
204
+ var availableItem, j, len, ref1, results1;
205
+ if (!this.availableItems.length) {
206
+ return;
207
+ }
208
+ ref1 = this.availableItems;
209
+ results1 = [];
210
+ for (j = 0, len = ref1.length; j < len; j++) {
211
+ availableItem = ref1[j];
212
+ results1.push(this.selectItem(availableItem));
213
+ }
214
+ return results1;
215
+ }
216
+
217
+ onAllItemsRemoved() {
218
+ var item, j, len, ref1, results1;
219
+ if (!this.selectedItems.length) {
220
+ return;
221
+ }
222
+ this.selectedItems = [];
223
+ this.refreshSelectedItems();
224
+ ref1 = this.availableItems;
225
+ results1 = [];
226
+ for (j = 0, len = ref1.length; j < len; j++) {
227
+ item = ref1[j];
228
+ results1.push(item.setSelected(false));
229
+ }
230
+ return results1;
231
+ }
232
+
233
+ initializeOrderable() {
234
+ var columnsCount;
235
+ if (!this.orderable) {
236
+ return;
237
+ }
238
+ columnsCount = this.$selectedItems.find('> tr > td').length;
239
+ this.$selectedItems.sortable('destroy');
240
+ this.$selectedItems.sortable({
241
+ handle: '.order-anchor',
242
+ animation: 150
243
+ });
244
+ return this.$selectedItems.on('sort', this.selectedItemsSorted);
245
+ }
246
+
247
+ selectedItemsSorted() {
248
+ var el, index, indices, j, len, ref1;
249
+ boundMethodCheck(this, ref);
250
+ indices = {};
251
+ ref1 = this.$selectedItems.find('[data-selected-item-id]');
252
+ for (index = j = 0, len = ref1.length; j < len; index = ++j) {
253
+ el = ref1[index];
254
+ indices[$(el).data('selected-item-id')] = index;
255
+ }
256
+ this.selectedItems.sort((a, b) => {
257
+ var aIndex, bIndex;
258
+ aIndex = indices[a.id];
259
+ bIndex = indices[b.id];
260
+ if (aIndex > bIndex) {
261
+ return 1;
262
+ } else {
263
+ return -1;
264
+ }
265
+ });
266
+ return this.refreshSelectedItems();
267
+ }
268
+
269
+ setLoading(state) {
270
+ this.$el.toggleClass('loading', state);
271
+ return this.$('.fa-search').toggleClass('fa-spin', state);
272
+ }
273
+
274
+ };
275
+
276
+ MultiSelectInput.prototype.events = {
277
+ 'keyup [data-search-field]': 'onSearchKeyUp',
278
+ 'click [data-add-all]': 'onAllItemsAdded',
279
+ 'click [data-remove-all]': 'onAllItemsRemoved'
280
+ };
281
+
282
+ return MultiSelectInput;
283
+
284
+ }).call(this);
285
+
286
+ Para.MultiSelectAvailableItem = (function() {
287
+ class MultiSelectAvailableItem extends Vertebra.View {
288
+ initialize() {
289
+ return this.id = this.$el.data('available-item-id');
290
+ }
291
+
292
+ addItem() {
293
+ return this.trigger('add', this);
294
+ }
295
+
296
+ setSelected(selected) {
297
+ this.selected = selected;
298
+ return this.$el.toggleClass('selected', this.selected);
299
+ }
300
+
301
+ };
302
+
303
+ MultiSelectAvailableItem.prototype.events = {
304
+ 'click [data-add-item]': 'addItem'
305
+ };
306
+
307
+ return MultiSelectAvailableItem;
308
+
309
+ }).call(this);
310
+
311
+ ref1 = Para.MultiSelectSelectedItem = class MultiSelectSelectedItem extends Vertebra.View {
312
+ constructor() {
313
+ super(...arguments);
314
+ this.removeItem = this.removeItem.bind(this);
315
+ }
316
+
317
+ initialize() {
318
+ return this.id = this.$el.data('selected-item-id');
319
+ }
320
+
321
+ bindEvents() {
322
+ return this.$('[data-remove-item]').on('click', this.removeItem);
323
+ }
324
+
325
+ renderTo($container) {
326
+ this.$el.appendTo($container);
327
+ return this.bindEvents();
328
+ }
329
+
330
+ removeItem(e) {
331
+ boundMethodCheck(this, ref1);
332
+ return this.trigger('remove', this);
333
+ }
334
+
335
+ };
336
+
337
+ $.simpleForm.onDomReady(function($document) {
338
+ return $document.find('[data-multi-select-input]').each(function(i, el) {
339
+ return new Para.MultiSelectInput({
340
+ el: el
341
+ });
342
+ });
343
+ });
@@ -0,0 +1,151 @@
1
+ Para.NestedManyField = class NestedManyField {
2
+ constructor($field1) {
3
+ this.stoppingPropagation = this.stoppingPropagation.bind(this);
4
+ this.afterInsertField = this.afterInsertField.bind(this);
5
+ this.beforeRemoveField = this.beforeRemoveField.bind(this);
6
+ // When a sub field is removed, update every sub field position
7
+ this.afterRemoveField = this.afterRemoveField.bind(this);
8
+ this.collapseShown = this.collapseShown.bind(this);
9
+ this.$field = $field1;
10
+ this.$fieldsList = this.$field.find('.fields-list');
11
+ this.initializeOrderable();
12
+ this.initializeCocoon();
13
+ this.$field.on('shown.bs.collapse', this.stoppingPropagation(this.collapseShown));
14
+ }
15
+
16
+ initializeOrderable() {
17
+ this.orderable = this.$field.hasClass('orderable');
18
+ if (!this.orderable) {
19
+ return;
20
+ }
21
+ return this.$fieldsList.sortable({
22
+ handle: '.order-anchor',
23
+ animation: 150,
24
+ onUpdate: $.proxy(this.handleOrderingUpdated, this)
25
+ });
26
+ }
27
+
28
+ handleOrderingUpdated() {
29
+ var formFields;
30
+ formFields = [];
31
+ return this.$fieldsList.find('.form-fields:visible').each(function(_i, el) {
32
+ var $el, $parent, isNestedField, j, len;
33
+ for (j = 0, len = formFields.length; j < len; j++) {
34
+ $parent = formFields[j];
35
+ isNestedField = $parent.find(el).length;
36
+ }
37
+ if (isNestedField) {
38
+ return;
39
+ }
40
+ $el = $(el);
41
+ $el.find('.resource-position-field:eq(0)').val(formFields.length);
42
+ return formFields.push($el);
43
+ });
44
+ }
45
+
46
+ initializeCocoon() {
47
+ this.$fieldsList.on('cocoon:after-insert', this.stoppingPropagation(this.afterInsertField));
48
+ this.$fieldsList.on('cocoon:before-remove', this.stoppingPropagation(this.beforeRemoveField));
49
+ return this.$fieldsList.on('cocoon:after-remove', this.stoppingPropagation(this.afterRemoveField));
50
+ }
51
+
52
+ stoppingPropagation(callback) {
53
+ return (e, ...args) => {
54
+ e.stopPropagation();
55
+ return callback(e, ...args);
56
+ };
57
+ }
58
+
59
+ afterInsertField(e, $element) {
60
+ var $collapsible;
61
+ if (($collapsible = $element.find('[data-open-on-insert="true"]')).length) {
62
+ this.openInsertedField($collapsible);
63
+ }
64
+ if (this.orderable) {
65
+ this.$fieldsList.sortable('destroy');
66
+ this.initializeOrderable();
67
+ this.handleOrderingUpdated();
68
+ }
69
+ return $element.simpleForm();
70
+ }
71
+
72
+ beforeRemoveField(e, $element) {
73
+ var $nextEl;
74
+ $nextEl = $element.next();
75
+ if ($nextEl.is('[data-attributes-mappings]') && !$element.is('[data-persisted]')) {
76
+ // Remove attributes mappings field for new records since it will try to
77
+ // create an empty nested resource otherwise
78
+ return $nextEl.remove();
79
+ }
80
+ }
81
+
82
+ afterRemoveField() {
83
+ return this.handleOrderingUpdated();
84
+ }
85
+
86
+ openInsertedField($field) {
87
+ var $target;
88
+ $target = $($field.attr('href'));
89
+ return $target.collapse('show');
90
+ }
91
+
92
+ collapseShown(e) {
93
+ var $target;
94
+ $target = $(e.target);
95
+ if ($target.is("[data-rendered]") || $target.data("rendered")) {
96
+ return this.initializeCollapseContent($target);
97
+ } else {
98
+ this.loadCollapseContent($target);
99
+ return this.scrollToTarget($target);
100
+ }
101
+ }
102
+
103
+ initializeCollapseContent($target) {
104
+ this.scrollToTarget($target);
105
+ return this.focusFirstField($target);
106
+ }
107
+
108
+ scrollToTarget($target) {
109
+ var $affixNavTabs, $field, scrollOffset;
110
+ $field = this.$field.find(`[data-toggle='collapse'][href='#${$target.attr('id')}']`);
111
+ scrollOffset = -($('[data-header]').outerHeight() + 30);
112
+ if (($affixNavTabs = $('[data-affix-header="tabs"]:eq(0)')).length) {
113
+ scrollOffset -= $affixNavTabs.outerHeight();
114
+ }
115
+ return $.scrollTo($field, 200, {
116
+ offset: scrollOffset
117
+ });
118
+ }
119
+
120
+ focusFirstField($target) {
121
+ return $target.find('input, textarea, select').eq('0').focus();
122
+ }
123
+
124
+ loadCollapseContent($target) {
125
+ var data, targetUrl;
126
+ targetUrl = $target.data("render-path");
127
+ if (!targetUrl) {
128
+ return;
129
+ }
130
+ data = {
131
+ "id": $target.data("id"),
132
+ "object_name": $target.data("object-name"),
133
+ "model_name": $target.data("model-name")
134
+ };
135
+ return $.get(targetUrl, data).then((resp) => {
136
+ var $content;
137
+ $content = $(resp);
138
+ $target.find("[data-nested-form-container]:eq(0)").html($content);
139
+ $content.simpleForm();
140
+ this.focusFirstField($target);
141
+ return $target.data("rendered", true);
142
+ });
143
+ }
144
+
145
+ };
146
+
147
+ $.simpleForm.onDomReady(function($document) {
148
+ return $document.find('.nested-many-field').each(function(i, el) {
149
+ return new Para.NestedManyField($(el));
150
+ });
151
+ });
@@ -0,0 +1,41 @@
1
+ import crossFetch from "cross-fetch";
2
+
3
+ export const GET = "GET";
4
+ export const POST = "POST";
5
+ export const PATCH = "PATCH";
6
+ export const DELETE = "DELETE";
7
+
8
+ // This method is a shortcut method for calling `fetch` with a setup that allows calling
9
+ // the Rails backend, preprocessing the response text or throwing an error if the response
10
+ // has a 400+ status code.
11
+ //
12
+ // This is useful to fetch a remote partial from the server or submit a sub-part of a form
13
+ // like used in the FormBranchConditionsEditorManager component.
14
+ //
15
+ export const fetch = (url, fetchOptions = {}) => {
16
+ const csrfToken = document.querySelector("meta[name='csrf-token']").content;
17
+
18
+ fetchOptions.headers = fetchOptions.headers || {};
19
+ fetchOptions.headers["X-CSRF-Token"] = csrfToken;
20
+
21
+ const options = {
22
+ method: "GET",
23
+ credentials: "include",
24
+ ...fetchOptions
25
+ };
26
+
27
+ return crossFetch(url, options).then(
28
+ // Handle the server response and potential form errors depending on the type of the
29
+ // response status code
30
+ response => {
31
+ if (response.ok) {
32
+ return response.text();
33
+ } else {
34
+ const error = new Error(response.statusText);
35
+ error.response = response;
36
+ throw error;
37
+ }
38
+ }
39
+ );
40
+ };
41
+
@@ -0,0 +1,42 @@
1
+ Para.PageLoading = class PageLoading {
2
+ constructor() {
3
+ this.start = this.start.bind(this);
4
+ this.stop = this.stop.bind(this);
5
+ }
6
+
7
+ start() {
8
+ return this.addLoadingMarkup();
9
+ }
10
+
11
+ stop() {
12
+ return this.removeLoadingMarkup();
13
+ }
14
+
15
+ addLoadingMarkup() {
16
+ $('<div/>', {
17
+ class: 'loading-overlay',
18
+ 'data-loading-overlay': true
19
+ }).prependTo('body');
20
+
21
+ $('<div/>', {
22
+ class: 'loading-spinner',
23
+ 'data-loading-spinner': true
24
+ }).prependTo('body');
25
+ }
26
+
27
+ removeLoadingMarkup() {
28
+ $('[data-loading-overlay]').remove();
29
+ return $('[data-loading-spinner]').remove();
30
+ }
31
+
32
+ };
33
+
34
+ // Global loading manager allowing to
35
+ Para.loadingManager = new Para.PageLoading();
36
+
37
+ $(document).on('turbo:before-fetch-request', Para.loadingManager.start);
38
+
39
+ $(document).on('turbo:load turbo:frame-load turbo:before-stream-render turbo:frame-missing turbo:fetch-request-error', function() {
40
+ Para.loadingManager.stop();
41
+ return $('body').on('submit', '[data-para-form]:not([data-remote])', Para.loadingManager.start);
42
+ });
@@ -0,0 +1,30 @@
1
+ var ColorPicker;
2
+
3
+ ColorPicker = class ColorPicker {
4
+ constructor($el) {
5
+ var $parent;
6
+ this.$el = $el;
7
+ if (($parent = this.$el.closest('[data-colorpicker-wrapper]')).length) {
8
+ $parent.colorpicker();
9
+ } else {
10
+ this.$el.colorpicker();
11
+ }
12
+ }
13
+
14
+ };
15
+
16
+ $.fn.simpleFormColorpicker = function() {
17
+ return this.each(function(i, el) {
18
+ var $input, instance;
19
+ $input = $(el);
20
+ if ($input.data('simple-form:colorpicker')) {
21
+ return;
22
+ }
23
+ instance = new ColorPicker($input);
24
+ return $input.data('simple-form:colorpicker', instance);
25
+ });
26
+ };
27
+
28
+ $.simpleForm.onDomReady(function($document) {
29
+ return $document.find('[data-colorpicker]').simpleFormColorpicker();
30
+ });