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
@@ -18,24 +18,25 @@ module Para
18
18
  end
19
19
 
20
20
  name = (name_method && object.send(name_method)) || default_resource_name
21
- name = name.to_s.gsub(/(<\/p>|<br\s*\/?>)/, " ")
21
+ name = name.to_s.gsub(%r{(</p>|<br\s*/?>)}, ' ')
22
22
 
23
23
  template.sanitize(name, tags: [])
24
24
  end
25
25
  end
26
26
 
27
27
  def nested_resource_dom_id
28
- return "" unless nested?
28
+ return '' unless nested?
29
29
 
30
30
  @nested_resource_dom_id ||= [
31
31
  object.class.model_name.singular,
32
32
  (Time.now.to_f * 1000).to_i,
33
- (object.id || "_new_#{ nested_attribute_name }_id")
33
+ object.id || "_new_#{nested_attribute_name}_id"
34
34
  ].join('-')
35
35
  end
36
36
 
37
- def remove_association_button
38
- return "" unless allow_destroy?
37
+ def remove_association_button(allow_destroy_if:)
38
+ return '' unless allow_destroy?
39
+ return '' unless !allow_destroy_if || allow_destroy_if.call(object)
39
40
 
40
41
  template.content_tag(:div, class: 'panel-btns') do
41
42
  template.link_to_remove_association(
@@ -31,6 +31,7 @@ module Para
31
31
  subclasses: subclasses,
32
32
  add_button_label: add_button_label,
33
33
  add_button_class: add_button_class,
34
+ allow_destroy_if: allow_destroy_if,
34
35
  inset: inset?,
35
36
  uncollapsed: uncollapsed?,
36
37
  render_partial: render_partial?,
@@ -59,6 +60,10 @@ module Para
59
60
  @model ||= parent_model.reflect_on_association(attribute_name).klass
60
61
  end
61
62
 
63
+ def allow_destroy_if
64
+ options.fetch(:allow_destroy_if, nil)
65
+ end
66
+
62
67
  def inset?
63
68
  options.fetch(:inset, false)
64
69
  end
@@ -2,38 +2,53 @@ module Para
2
2
  module Markup
3
3
  class Modal < Para::Markup::Component
4
4
  def container(options = {}, &block)
5
- merge_class!(options, "modal")
6
- merge_class!(options, "fade") unless options.delete(:fade) == false
7
- merge_class!(options, "in") if options.delete(:displayed)
5
+ merge_class!(options, 'modal')
6
+ merge_class!(options, 'fade') unless options.delete(:fade) == false
7
+ merge_class!(options, 'in') if options.delete(:displayed)
8
8
 
9
9
  options.reverse_merge!(
10
- tabindex: "-1", role: "dialog", "aria-hidden" => "true", "aria-labelledby" => (options[:id] || "modal")
10
+ tabindex: '-1',
11
+ role: 'dialog',
12
+ 'aria-hidden' => 'true',
13
+ 'aria-labelledby' => options[:id]
11
14
  )
12
15
 
16
+ options[:data] ||= {}
17
+ options[:data]['para-admin-modal-target'] ||= 'modal'
18
+
13
19
  content_tag(:div, options) do
14
- content_tag(:div, class: "modal-dialog") do
15
- content_tag(:div, class: "modal-content") do
16
- capture { block.call(self) }
20
+ content_tag(:div, class: 'modal-dialog') do
21
+ content_tag(:div, class: 'modal-content') do
22
+ content_tag(:div, class: 'modal-inner') do
23
+ capture { block.call(self) }
24
+ end
17
25
  end
18
26
  end
19
27
  end
20
28
  end
21
29
 
22
30
  def header(options = {}, &block)
23
- merge_class!(options, "modal-header")
31
+ merge_class!(options, 'modal-header')
24
32
 
25
33
  content_tag(:div, options) do
26
- content_tag(:button, "&times;".html_safe, class: "close", type: "button",
27
- "data-dismiss" => "modal", "aria-hidden" => "true"
34
+ content_tag(
35
+ :button,
36
+ '&times;'.html_safe,
37
+ class: 'close',
38
+ type: 'button',
39
+ 'aria-hidden' => 'true',
40
+ data: {
41
+ action: 'click->para-admin-modal#closeModal'
42
+ }
28
43
  ) +
29
- content_tag(:h4, class: "modal-title") do
30
- capture { block.call }
31
- end
44
+ content_tag(:h4, class: 'modal-title') do
45
+ capture { block.call }
46
+ end
32
47
  end
33
48
  end
34
49
 
35
50
  def body(options = {}, &block)
36
- merge_class!(options, "modal-body")
51
+ merge_class!(options, 'modal-body')
37
52
 
38
53
  content_tag(:div, options) do
39
54
  capture { block.call }
@@ -41,7 +56,7 @@ module Para
41
56
  end
42
57
 
43
58
  def footer(options = {}, &block)
44
- merge_class!(options, "modal-footer")
59
+ merge_class!(options, 'modal-footer')
45
60
 
46
61
  content_tag(:div, options) do
47
62
  capture { block.call }
@@ -16,14 +16,12 @@ module Para
16
16
  )
17
17
 
18
18
  options = {
19
- method: :post,
20
19
  class: 'btn btn-sm btn-icon-info btn-shadow hint--left',
21
- aria: {
22
- label: ::I18n.t('para.shared.copy')
23
- }
20
+ data: { 'turbo-method': :post, 'turbo-frame': '_top' },
21
+ aria: { label: ::I18n.t('para.shared.copy') }
24
22
  }
25
23
 
26
- view.link_to(path, options) do
24
+ view.link_to(path, **options) do
27
25
  content_tag(:i, '', class: 'fa fa-copy')
28
26
  end
29
27
  end
@@ -35,7 +33,13 @@ module Para
35
33
  resource, action: :edit, return_to: view.request.fullpath
36
34
  )
37
35
 
38
- view.link_to(path, class: 'btn btn-sm btn-icon-primary btn-shadow hint--left', aria: { label: ::I18n.t('para.shared.edit') }) do
36
+ options = {
37
+ class: 'btn btn-sm btn-icon-primary btn-shadow hint--left',
38
+ data: { 'turbo-frame': '_top' },
39
+ aria: { label: ::I18n.t('para.shared.edit') }
40
+ }
41
+
42
+ view.link_to(path, **options) do
39
43
  content_tag(:i, '', class: 'fa fa-pencil')
40
44
  end
41
45
  end
@@ -46,20 +50,20 @@ module Para
46
50
  path = component.relation_path(resource, return_to: view.request.fullpath)
47
51
 
48
52
  options = {
49
- method: :delete,
53
+ class: 'btn btn-sm btn-icon-danger btn-shadow hint--left',
50
54
  data: {
51
- confirm: ::I18n.t('para.list.delete_confirmation')
55
+ 'turbo-method': :delete,
56
+ 'turbo-confirm': ::I18n.t('para.list.delete_confirmation')
52
57
  },
53
- class: 'btn btn-sm btn-icon-danger btn-shadow hint--left',
54
58
  aria: {
55
59
  label: ::I18n.t('para.shared.destroy')
56
60
  }
57
61
  }
58
62
 
59
- view.link_to(path, options) do
63
+ view.link_to(path, **options) do
60
64
  content_tag(:i, '', class: 'fa fa-times')
61
65
  end
62
66
  end
63
67
  end
64
68
  end
65
- end
69
+ end
@@ -0,0 +1,19 @@
1
+ module Para
2
+ module ModelFieldParsers
3
+ class WysiwygEditor < Para::ModelFieldParsers::Base
4
+ register :wysiwyg_editor, self
5
+
6
+ def parse!
7
+ %w[content description].each do |field_name|
8
+ field = fields_hash[field_name]
9
+
10
+ next unless field && field.type == :text
11
+
12
+ fields_hash[field_name] = Para::AttributeField::WysiwygEditor.new(
13
+ field.model, name: field_name
14
+ )
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -18,7 +18,7 @@ require 'para/model_field_parsers/devise'
18
18
  require 'para/model_field_parsers/paperclip'
19
19
  require 'para/model_field_parsers/orderable'
20
20
  require 'para/model_field_parsers/relations'
21
- require 'para/model_field_parsers/redactor'
21
+ require 'para/model_field_parsers/wysiwyg_editor'
22
22
  require 'para/model_field_parsers/globalize'
23
23
  require 'para/model_field_parsers/friendly_id'
24
24
  require 'para/model_field_parsers/store'
data/lib/para/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Para
4
- VERSION = '0.11.4'
4
+ VERSION = '0.12.0'
5
5
  end
data/lib/para.rb CHANGED
@@ -19,15 +19,10 @@ require 'friendly_id'
19
19
  require 'deep_cloneable'
20
20
  require 'closure_tree'
21
21
 
22
- require 'jquery-rails'
23
- require 'turbolinks'
24
- require 'sass-rails'
25
- require 'selectize-rails'
26
- require 'bootstrap-sass'
22
+ require 'turbo-rails'
23
+ # Used for fa_icon helper, but font awesome is loaded from the app that requires Para.
27
24
  require 'font-awesome-rails'
28
25
 
29
- require 'vertebra'
30
-
31
26
  require 'rails/routing_mapper'
32
27
  require 'rails/relation_length_validator'
33
28
 
@@ -49,7 +44,6 @@ module Para
49
44
  autoload :Breadcrumbs
50
45
  autoload :Cache
51
46
  autoload :Logging
52
- autoload :IframeTransport
53
47
  autoload :ActiveStorageDownloader
54
48
  end
55
49
 
@@ -0,0 +1,13 @@
1
+ module SimpleFormExtension
2
+ module Components
3
+ module Icons
4
+ def icon(wrapper_options)
5
+ icon_class unless options[:icon].nil?
6
+ end
7
+
8
+ def icon_class
9
+ template.content_tag(:i, '', class: options[:icon])
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,46 @@
1
+ module SimpleFormExtension
2
+ module Components
3
+ module Popovers
4
+
5
+ def popover(wrapper_options)
6
+ return nil unless options[:popover]
7
+
8
+ options = {
9
+ class: 'btn-popover fa fa-question-circle',
10
+ :rel => 'popover',
11
+ :'data-toggle' => 'popover',
12
+ :'data-container' => 'body',
13
+ :'data-title' => popover_title,
14
+ :'data-content' => popover_content,
15
+ :'data-placement' => popover_position,
16
+ :'data-trigger' => popover_tigger
17
+ }
18
+
19
+ template.content_tag(:i, '', options)
20
+ end
21
+
22
+
23
+ def popover_title
24
+ popover_options[:title]
25
+ end
26
+
27
+ def popover_content
28
+ popover_options[:content]
29
+ end
30
+
31
+ def popover_position
32
+ popover_options[:position] ||= "auto"
33
+ end
34
+
35
+ def popover_tigger
36
+ popover_options[:trigger] ||= "click"
37
+ end
38
+
39
+ private
40
+
41
+ def popover_options
42
+ options[:popover] ||= {}
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,8 @@
1
+ module SimpleFormExtension
2
+ module Components
3
+ extend ActiveSupport::Autoload
4
+
5
+ autoload :Icons
6
+ autoload :Popovers
7
+ end
8
+ end
@@ -0,0 +1,20 @@
1
+ require 'simple_form/form_builder'
2
+
3
+ module SimpleForm
4
+ class FormBuilder < ActionView::Helpers::FormBuilder
5
+ alias_method :_original_find_mapping, :find_mapping
6
+
7
+ def find_mapping(input_type)
8
+ camelized = if (klass = self.class.mappings[input_type])
9
+ name = klass.name
10
+ (name =~ /^SimpleForm::Inputs/) ? name.split("::").last : name
11
+ else
12
+ "#{ input_type.to_s.camelize }Input"
13
+ end
14
+
15
+ mapping = attempt_mapping(camelized, SimpleFormExtension::Inputs)
16
+ return (discovery_cache[input_type] = mapping) if mapping
17
+ _original_find_mapping(input_type)
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,74 @@
1
+ module SimpleFormExtension
2
+ module FileConcern
3
+ def existing_file_tag
4
+ return '' unless file_exists?
5
+
6
+ content_tag(:div, class: 'input-group help-block existing-file', data: { provides: 'existing-file'}) do
7
+ content_tag(:span, class: 'input-group-addon') do
8
+ "#{ _translate('file.existing_file') } : ".html_safe
9
+ end +
10
+
11
+ file_preview_and_remove_button
12
+ end
13
+ end
14
+
15
+ def file_preview_and_remove_button
16
+ return '' unless file_exists?
17
+
18
+ content_tag(:div, class: 'btn-group') do
19
+ template.link_to(file_url, class: 'btn btn-default ', target: '_blank', data: { toggle: 'existing-file' }) do
20
+ content_tag(:i, '', class: 'fa fa-file') +
21
+ "&nbsp;".html_safe +
22
+
23
+ existing_file_name
24
+ end +
25
+
26
+ remove_file_button
27
+ end
28
+ end
29
+
30
+ def existing_file_name
31
+ if paperclip_attachment_attached?
32
+ object.send(:"#{ attribute_name }_file_name").html_safe
33
+ elsif activestorage_attachment_attached?
34
+ attachment = object.send(attribute_name)
35
+ attachment.filename.to_s
36
+ end
37
+ end
38
+
39
+ def remove_file_button
40
+ return unless object.respond_to?(:"#{ remove_attachment_method }=")
41
+
42
+ content_tag(:button, class: 'btn btn-default', type: 'button', data: { dismiss: 'existing-file' }) do
43
+ content_tag(:i, '', class: 'fa fa-remove', data: { :'removed-class' => 'fa fa-refresh' }) +
44
+ @builder.hidden_field(remove_attachment_method, class: 'remove-file-input', value: nil)
45
+ end
46
+ end
47
+
48
+ def remove_attachment_method
49
+ options[:remove_method] || :"remove_#{ attribute_name }"
50
+ end
51
+
52
+ def file_exists?
53
+ @file_exists ||= paperclip_attachment_attached? || activestorage_attachment_attached?
54
+ end
55
+
56
+ def file_url
57
+ if paperclip_attachment_attached?
58
+ object.send(attribute_name)
59
+ elsif activestorage_attachment_attached?
60
+ template.polymorphic_url(object.send(attribute_name))
61
+ end
62
+ end
63
+
64
+ def paperclip_attachment_attached?
65
+ @paperclip_attachment_attached ||= object.try(:"#{ attribute_name }?")
66
+ end
67
+
68
+ def activestorage_attachment_attached?
69
+ @activestorage_attachment_attached ||=
70
+ object.try(attribute_name).try(:attached?) &&
71
+ object.try(attribute_name).blob&.persisted?
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,16 @@
1
+ module SimpleFormExtension
2
+ module Inputs
3
+ class BooleanInput < SimpleForm::Inputs::BooleanInput
4
+ def input(wrapper_options = nil)
5
+ input_html_options[:class] << "check_boxes"
6
+ super
7
+ end
8
+
9
+ private
10
+
11
+ def build_check_box(unchecked_value, options)
12
+ "#{@builder.check_box(attribute_name, input_html_options, checked_value, unchecked_value)} <i class=\"checkbox-icon\"></i>".html_safe
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ module SimpleFormExtension
2
+ module Inputs
3
+ class CollectionCheckBoxesInput < SimpleForm::Inputs::CollectionCheckBoxesInput
4
+ protected
5
+
6
+ def build_nested_boolean_style_item_tag(collection_builder)
7
+ "#{collection_builder.check_box} <i class=\"checkbox-icon\"></i> #{collection_builder.text}".html_safe
8
+ end
9
+
10
+ def item_wrapper_class
11
+ nested_boolean_style? ? "checkbox" : "checkbox-inline"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ module SimpleFormExtension
2
+ module Inputs
3
+ class CollectionRadioButtonsInput < SimpleForm::Inputs::CollectionRadioButtonsInput
4
+ protected
5
+
6
+ def build_nested_boolean_style_item_tag(collection_builder)
7
+ "#{collection_builder.radio_button} <i class=\"radio-icon\"></i> #{collection_builder.text}".html_safe
8
+ end
9
+
10
+ def item_wrapper_class
11
+ nested_boolean_style? ? "radio" : "radio-inline"
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,37 @@
1
+ module SimpleFormExtension
2
+ module Inputs
3
+ class ColorInput < SimpleForm::Inputs::Base
4
+ delegate :content_tag, to: :template
5
+
6
+ def input(wrapper_options = nil)
7
+ input_html_options[:class] << "colorpicker form-control"
8
+
9
+ input_html_options[:data] ||= {}
10
+ input_html_options[:data].merge!(
11
+ colorpicker: true,
12
+ format: format,
13
+ align: align
14
+ )
15
+
16
+ # Fetch value
17
+ color = object.send(attribute_name)
18
+
19
+ content_tag(:div, class: 'input-group color', data: { :'colorpicker-wrapper' => true }) do
20
+ @builder.text_field(attribute_name, input_html_options) +
21
+
22
+ content_tag(:span, class: 'input-group-addon') do
23
+ content_tag(:i, '')
24
+ end
25
+ end
26
+ end
27
+
28
+ def format
29
+ options[:format].presence || :hex
30
+ end
31
+
32
+ def align
33
+ options[:align].presence || :right
34
+ end
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,48 @@
1
+ module SimpleFormExtension
2
+ module Inputs
3
+ class DateTimeInput < SimpleForm::Inputs::DateTimeInput
4
+ include SimpleFormExtension::Translations
5
+
6
+ delegate :content_tag, to: :template
7
+
8
+ def input(wrapper_options = nil)
9
+ input_html_options[:class] << "form-control"
10
+
11
+ input_html_options[:data] ||= {}
12
+ input_html_options[:data].merge!(type_specific_option)
13
+
14
+ if (value = object.send(attribute_name).presence) && !input_html_options.key?(:value)
15
+ format = _translate("#{ input_type }.format.rails")
16
+ input_html_options[:value] = I18n.l(value, format: format)
17
+ end
18
+
19
+ content_tag(:div, class: 'input-group') do
20
+ @builder.text_field(attribute_name, input_html_options) +
21
+
22
+ content_tag(:span, class: 'input-group-btn') do
23
+ content_tag(:button, type: 'button', class: 'btn btn-default datetimepicker-trigger') do
24
+ content_tag(:i, '', class: "fa fa-#{ icon }")
25
+ end
26
+ end
27
+ end
28
+ end
29
+
30
+ private
31
+
32
+ def type_specific_option
33
+ options = { format: _translate("#{ input_type }.format.js") }
34
+
35
+ unless input_type == :time
36
+ options[:'week-start-day'] = _translate('shared.week_start_day')
37
+ options[:'format-date'] = _translate('date.format.js')
38
+ end
39
+
40
+ options
41
+ end
42
+
43
+ def icon
44
+ input_type == :time ? 'clock-o' : 'calendar'
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,41 @@
1
+ module SimpleFormExtension
2
+ module Inputs
3
+ class FileInput < SimpleForm::Inputs::Base
4
+ include SimpleFormExtension::Translations
5
+ include SimpleFormExtension::FileConcern
6
+
7
+ delegate :content_tag, to: :template
8
+
9
+ def input(wrapper_options = nil)
10
+ input_html_options[:class] << "file-upload"
11
+
12
+ input_markup
13
+ end
14
+
15
+ private
16
+
17
+ def input_markup
18
+ content_tag(:div, class: 'fileinput fileinput-new input-group', data: { provides: 'fileinput' }) do
19
+ content_tag(:div, class: 'form-control uneditable-input', data: { trigger: 'fileinput' }) do
20
+ content_tag(:i, '', class: 'fa fa-file fileinput-exists') +
21
+ content_tag(:span, '', class: 'fileinput-filename')
22
+ end +
23
+
24
+ content_tag(:div, class: 'input-group-btn') do
25
+ content_tag(:div, class: 'btn btn-default btn-file') do
26
+ content_tag(:span, _translate('file.select'), class: 'fileinput-new') +
27
+ content_tag(:span, _translate('file.change'), class: 'fileinput-exists') +
28
+ @builder.file_field(attribute_name, input_html_options)
29
+ end +
30
+
31
+ content_tag(:button, class: 'btn btn-default fileinput-exists', type: 'button', data: { dismiss: 'fileinput' }) do
32
+ content_tag(:i, '', class: 'fa fa-times')
33
+ end
34
+ end
35
+ end +
36
+
37
+ existing_file_tag
38
+ end
39
+ end
40
+ end
41
+ end