decidim-core 0.8.4 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (249) hide show
  1. checksums.yaml +5 -5
  2. data/README.md +1 -1
  3. data/app/assets/images/decidim/decidim-logo.svg +23 -23
  4. data/app/assets/images/decidim/default-avatar.svg +7 -7
  5. data/app/assets/images/decidim/icons.svg +1 -0
  6. data/app/assets/javascripts/decidim.js.es6 +5 -2
  7. data/app/assets/javascripts/decidim/append_redirect_url_to_modals.js.es6 +84 -0
  8. data/app/assets/javascripts/decidim/data_picker.js.es6 +177 -0
  9. data/app/assets/javascripts/decidim/form_filter.component.js.es6 +25 -20
  10. data/app/assets/javascripts/decidim/form_filter.component.test.js +24 -13
  11. data/app/assets/javascripts/decidim/history.js.es6 +3 -3
  12. data/app/assets/stylesheets/decidim/_decidim.scss +1 -4
  13. data/app/assets/stylesheets/decidim/_variables.scss +4 -4
  14. data/app/assets/stylesheets/decidim/editor.scss +13 -0
  15. data/app/assets/stylesheets/decidim/email.css +9 -1
  16. data/app/assets/stylesheets/decidim/extras/_add_comments.scss +3 -3
  17. data/app/assets/stylesheets/decidim/extras/_announcement.scss +1 -1
  18. data/app/assets/stylesheets/decidim/extras/_collection-sort-controls.scss +2 -2
  19. data/app/assets/stylesheets/decidim/extras/_embed.scss +6 -5
  20. data/app/assets/stylesheets/decidim/extras/_impersonation-bar.scss +4 -0
  21. data/app/assets/stylesheets/decidim/extras/_label-required.scss +1 -1
  22. data/app/assets/stylesheets/decidim/extras/_leaflet.scss +6 -4
  23. data/app/assets/stylesheets/decidim/extras/_meeting-registrations.scss +4 -4
  24. data/app/assets/stylesheets/decidim/extras/_process_stats.scss +11 -4
  25. data/app/assets/stylesheets/decidim/extras/_proposal_form.scss +3 -3
  26. data/app/assets/stylesheets/decidim/extras/_quill.scss +1 -1
  27. data/app/assets/stylesheets/decidim/extras/_reference.scss +3 -3
  28. data/app/assets/stylesheets/decidim/extras/_register_form.scss +3 -3
  29. data/app/assets/stylesheets/decidim/extras/_results-per-page.scss +10 -10
  30. data/app/assets/stylesheets/decidim/extras/_social_icons_mini.scss +4 -3
  31. data/app/assets/stylesheets/decidim/layouts/_highlighted_banner.scss +38 -0
  32. data/app/assets/stylesheets/decidim/layouts/_home.scss +33 -3
  33. data/app/assets/stylesheets/decidim/layouts/_user.scss +33 -5
  34. data/app/assets/stylesheets/decidim/layouts/_view.scss +1 -2
  35. data/app/assets/stylesheets/decidim/map.css +5 -3
  36. data/app/assets/stylesheets/decidim/modules/_address.scss +1 -0
  37. data/app/assets/stylesheets/decidim/modules/_author-avatar.scss +24 -9
  38. data/app/assets/stylesheets/decidim/modules/_buttons.scss +24 -10
  39. data/app/assets/stylesheets/decidim/modules/_callout.scss +5 -1
  40. data/app/assets/stylesheets/decidim/modules/_card-grid.scss +1 -1
  41. data/app/assets/stylesheets/decidim/modules/_cards.scss +102 -31
  42. data/app/assets/stylesheets/decidim/modules/_comments.scss +21 -20
  43. data/app/assets/stylesheets/decidim/modules/_cookie-bar.scss +4 -0
  44. data/app/assets/stylesheets/decidim/modules/_data-picker.scss +159 -0
  45. data/app/assets/stylesheets/decidim/modules/_datepicker.scss +36 -36
  46. data/app/assets/stylesheets/decidim/modules/_definition-data.scss +12 -9
  47. data/app/assets/stylesheets/decidim/modules/_extra.scss +4 -1
  48. data/app/assets/stylesheets/decidim/modules/_filter-tags.scss +3 -0
  49. data/app/assets/stylesheets/decidim/modules/_filters.scss +9 -5
  50. data/app/assets/stylesheets/decidim/modules/_flag.scss +1 -0
  51. data/app/assets/stylesheets/decidim/modules/_footer.scss +10 -0
  52. data/app/assets/stylesheets/decidim/modules/_forms.scss +2 -1
  53. data/app/assets/stylesheets/decidim/modules/_help.scss +2 -0
  54. data/app/assets/stylesheets/decidim/modules/_icons.scss +1 -0
  55. data/app/assets/stylesheets/decidim/modules/_layout.scss +4 -0
  56. data/app/assets/stylesheets/decidim/modules/_list-docs.scss +3 -0
  57. data/app/assets/stylesheets/decidim/modules/_main-container.scss +13 -7
  58. data/app/assets/stylesheets/decidim/modules/_map.scss +13 -1
  59. data/app/assets/stylesheets/decidim/modules/_margins.scss +1 -0
  60. data/app/assets/stylesheets/decidim/modules/_messages.scss +2 -1
  61. data/app/assets/stylesheets/decidim/modules/_modules.scss +3 -0
  62. data/app/assets/stylesheets/decidim/modules/_navbar.scss +36 -16
  63. data/app/assets/stylesheets/decidim/modules/_omnipresent_banner.scss +26 -0
  64. data/app/assets/stylesheets/decidim/modules/_opinion-toggle.scss +5 -0
  65. data/app/assets/stylesheets/decidim/modules/_order-by.scss +10 -10
  66. data/app/assets/stylesheets/decidim/modules/_pagination.scss +3 -2
  67. data/app/assets/stylesheets/decidim/modules/_process-header.scss +11 -2
  68. data/app/assets/stylesheets/decidim/modules/_process-info.scss +9 -1
  69. data/app/assets/stylesheets/decidim/modules/_process-nav.scss +20 -3
  70. data/app/assets/stylesheets/decidim/modules/_process-phase.scss +12 -3
  71. data/app/assets/stylesheets/decidim/modules/_progress-bar.scss +69 -0
  72. data/app/assets/stylesheets/decidim/modules/_reference.scss +1 -2
  73. data/app/assets/stylesheets/decidim/modules/_reveal.scss +1 -1
  74. data/app/assets/stylesheets/decidim/modules/_share.scss +2 -0
  75. data/app/assets/stylesheets/decidim/modules/_signup.scss +5 -1
  76. data/app/assets/stylesheets/decidim/modules/_static-pages.scss +6 -0
  77. data/app/assets/stylesheets/decidim/modules/_status-labels.scss +2 -0
  78. data/app/assets/stylesheets/decidim/modules/_tags.scss +3 -1
  79. data/app/assets/stylesheets/decidim/modules/_timeline.scss +41 -30
  80. data/app/assets/stylesheets/decidim/modules/_title-action.scss +2 -1
  81. data/app/assets/stylesheets/decidim/modules/_typography.scss +13 -4
  82. data/app/assets/stylesheets/decidim/modules/_user-form.scss +1 -0
  83. data/app/assets/stylesheets/decidim/modules/_video.scss +2 -2
  84. data/app/assets/stylesheets/decidim/utils/_fontface.scss +22 -20
  85. data/app/assets/stylesheets/decidim/utils/_helpers.scss +6 -6
  86. data/app/assets/stylesheets/decidim/utils/_keyframes.scss +6 -6
  87. data/app/assets/stylesheets/decidim/utils/_mixins.scss +24 -7
  88. data/app/assets/stylesheets/decidim/utils/_settings.scss +50 -52
  89. data/app/assets/stylesheets/decidim/utils/_toggle-expand.scss +1 -0
  90. data/app/commands/decidim/create_omniauth_registration.rb +3 -0
  91. data/app/commands/decidim/create_registration.rb +3 -1
  92. data/app/commands/decidim/destroy_account.rb +1 -0
  93. data/app/commands/decidim/invite_user_again.rb +1 -1
  94. data/app/commands/decidim/messaging/reply_to_conversation.rb +1 -3
  95. data/app/commands/decidim/unsubscribe_settings.rb +29 -0
  96. data/app/commands/decidim/update_account.rb +16 -3
  97. data/app/controllers/concerns/decidim/action_authorization.rb +1 -1
  98. data/app/controllers/concerns/decidim/devise_controllers.rb +10 -0
  99. data/app/controllers/concerns/decidim/form_factory.rb +2 -1
  100. data/app/controllers/concerns/decidim/impersonate_users.rb +13 -8
  101. data/app/controllers/concerns/decidim/participatory_space_context.rb +1 -1
  102. data/app/controllers/decidim/application_controller.rb +16 -0
  103. data/app/controllers/decidim/cookie_policy_controller.rb +2 -0
  104. data/app/controllers/decidim/devise/invitations_controller.rb +9 -1
  105. data/app/controllers/decidim/devise/omniauth_registrations_controller.rb +10 -1
  106. data/app/controllers/decidim/devise/sessions_controller.rb +9 -1
  107. data/app/controllers/decidim/locales_controller.rb +2 -3
  108. data/app/controllers/decidim/messaging/conversations_controller.rb +2 -2
  109. data/app/controllers/decidim/newsletters_controller.rb +60 -0
  110. data/app/controllers/decidim/pages_controller.rb +1 -0
  111. data/app/controllers/decidim/profiles_controller.rb +23 -0
  112. data/app/controllers/decidim/scopes_controller.rb +19 -20
  113. data/app/events/decidim/profile_updated_event.rb +27 -0
  114. data/app/forms/decidim/account_form.rb +34 -0
  115. data/app/forms/decidim/form.rb +1 -0
  116. data/app/forms/decidim/messaging/conversation_form.rb +5 -2
  117. data/app/forms/decidim/omniauth_registration_form.rb +5 -0
  118. data/app/forms/decidim/registration_form.rb +8 -1
  119. data/app/helpers/decidim/action_authorization_helper.rb +2 -2
  120. data/app/helpers/decidim/application_helper.rb +8 -0
  121. data/app/helpers/decidim/feature_path_helper.rb +12 -2
  122. data/app/helpers/decidim/feature_reference_helper.rb +1 -1
  123. data/app/helpers/decidim/messaging/conversation_helper.rb +27 -9
  124. data/app/helpers/decidim/newsletters_helper.rb +49 -0
  125. data/app/helpers/decidim/scopes_helper.rb +43 -2
  126. data/app/helpers/decidim/translations_helper.rb +6 -2
  127. data/app/mailers/decidim/decidim_devise_mailer.rb +1 -3
  128. data/app/mailers/decidim/messaging/conversation_mailer.rb +1 -1
  129. data/app/mailers/decidim/newsletter_mailer.rb +7 -8
  130. data/app/models/decidim/abilities/everyone_ability.rb +1 -0
  131. data/app/models/decidim/authorization.rb +19 -5
  132. data/app/models/decidim/impersonation_log.rb +2 -1
  133. data/app/models/decidim/messaging/conversation.rb +2 -0
  134. data/app/models/decidim/messaging/message.rb +4 -0
  135. data/app/models/decidim/organization.rb +1 -0
  136. data/app/models/decidim/scope.rb +10 -2
  137. data/app/models/decidim/user.rb +10 -2
  138. data/app/presenters/decidim/home_stats_presenter.rb +10 -4
  139. data/app/presenters/decidim/user_group_presenter.rb +28 -0
  140. data/app/presenters/decidim/user_presenter.rb +42 -0
  141. data/app/services/decidim/action_authorizer.rb +32 -68
  142. data/app/services/decidim/notification_generator_for_recipient.rb +8 -3
  143. data/app/uploaders/decidim/avatar_uploader.rb +2 -2
  144. data/app/views/decidim/account/delete.html.erb +1 -1
  145. data/app/views/decidim/account/show.html.erb +4 -1
  146. data/app/views/decidim/devise/invitations/edit.html.erb +2 -0
  147. data/app/views/decidim/devise/omniauth_registrations/new.html.erb +7 -1
  148. data/app/views/decidim/devise/registrations/new.html.erb +7 -1
  149. data/app/views/decidim/messaging/conversations/_message.html.erb +6 -12
  150. data/app/views/decidim/messaging/conversations/_reply.html.erb +1 -1
  151. data/app/views/decidim/messaging/conversations/index.html.erb +1 -1
  152. data/app/views/decidim/messaging/conversations/update.js.erb +1 -0
  153. data/app/views/decidim/newsletter_mailer/newsletter.html.erb +11 -0
  154. data/app/views/decidim/newsletters/show.html.erb +11 -0
  155. data/app/views/decidim/newsletters/unsubscribe.html.erb +4 -0
  156. data/app/views/decidim/notifications/_notification.html.erb +1 -1
  157. data/app/views/decidim/profiles/show.html.erb +64 -0
  158. data/app/views/decidim/scopes/_scopes_picker_input.html.erb +6 -0
  159. data/app/views/decidim/scopes/picker.html.erb +36 -0
  160. data/app/views/decidim/shared/_action_authorization_modal.html.erb +25 -51
  161. data/app/views/decidim/shared/_author.html.erb +21 -0
  162. data/app/views/decidim/shared/_author_reference.html.erb +12 -0
  163. data/app/views/layouts/decidim/_application.html.erb +1 -0
  164. data/app/views/layouts/decidim/_impersonation_warning.html.erb +1 -1
  165. data/app/views/layouts/decidim/_mailer_logo.html.erb +6 -1
  166. data/app/views/layouts/decidim/_omnipresent_banner.html.erb +14 -0
  167. data/app/views/layouts/decidim/_user_menu.html.erb +3 -0
  168. data/app/views/layouts/decidim/mailer.html.erb +16 -4
  169. data/app/views/layouts/decidim/widget.html.erb +14 -9
  170. data/app/views/pages/home.html.erb +2 -0
  171. data/app/views/pages/home/_highlighted_content_banner.html.erb +26 -0
  172. data/config/initializers/devise.rb +1 -3
  173. data/config/locales/ca.yml +67 -9
  174. data/config/locales/en.yml +65 -4
  175. data/config/locales/es.yml +74 -14
  176. data/config/locales/eu.yml +66 -4
  177. data/config/locales/fi.yml +87 -25
  178. data/config/locales/fr.yml +71 -9
  179. data/config/locales/gl.yml +493 -0
  180. data/config/locales/it.yml +79 -17
  181. data/config/locales/nl.yml +71 -9
  182. data/config/locales/pl.yml +66 -4
  183. data/config/locales/pt-BR.yml +493 -0
  184. data/config/locales/pt.yml +99 -37
  185. data/config/locales/ru.yml +85 -13
  186. data/config/locales/sv.yml +493 -0
  187. data/config/locales/uk.yml +78 -16
  188. data/config/routes.rb +11 -1
  189. data/db/migrate/20171212103803_create_unique_nicknames.rb +29 -0
  190. data/db/migrate/20180115090038_extend_user_profile.rb +8 -0
  191. data/db/migrate/20180123125308_add_enable_omnipresent_banner_to_decidim_organizations.rb +7 -0
  192. data/db/migrate/20180123125409_add_omnipresent_banner_title_to_decidim_organizations.rb +7 -0
  193. data/db/migrate/20180123125432_add_omnipresent_banner_short_description_to_decidim_organizations.rb +7 -0
  194. data/db/migrate/20180123125452_add_omnipresent_banner_url_to_decidim_organizations.rb +7 -0
  195. data/db/migrate/20180125063433_add_highlighted_content_banner_to_decidim_organizations.rb +13 -0
  196. data/db/seeds.rb +8 -2
  197. data/lib/decidim/abilities/participatory_process_role_ability.rb +1 -3
  198. data/lib/decidim/content_parsers.rb +8 -0
  199. data/lib/decidim/content_parsers/base_parser.rb +58 -0
  200. data/lib/decidim/content_parsers/user_parser.rb +46 -0
  201. data/lib/decidim/content_processor.rb +84 -0
  202. data/lib/decidim/content_renderers.rb +8 -0
  203. data/lib/decidim/content_renderers/base_renderer.rb +37 -0
  204. data/lib/decidim/content_renderers/user_renderer.rb +32 -0
  205. data/lib/decidim/core.rb +66 -1
  206. data/lib/decidim/core/api/author_interface.rb +3 -3
  207. data/lib/decidim/core/api/user_group_type.rb +10 -8
  208. data/lib/decidim/core/api/user_type.rb +13 -7
  209. data/lib/decidim/core/engine.rb +7 -5
  210. data/lib/decidim/core/test.rb +1 -1
  211. data/lib/decidim/core/test/factories.rb +21 -45
  212. data/lib/decidim/core/test/shared_examples/announcements_examples.rb +3 -2
  213. data/lib/decidim/core/test/shared_examples/comments_examples.rb +5 -2
  214. data/lib/decidim/core/test/shared_examples/scope_helper_examples.rb +40 -3
  215. data/lib/decidim/core/test/shared_examples/simple_event.rb +73 -0
  216. data/lib/decidim/core/version.rb +1 -1
  217. data/lib/decidim/events.rb +2 -0
  218. data/lib/decidim/events/author_event.rb +41 -0
  219. data/lib/decidim/events/base_event.rb +28 -3
  220. data/lib/decidim/events/email_event.rb +1 -1
  221. data/lib/decidim/events/notification_event.rb +1 -1
  222. data/lib/decidim/events/simple_event.rb +79 -0
  223. data/lib/decidim/filter_form_builder.rb +2 -3
  224. data/lib/decidim/form_builder.rb +39 -27
  225. data/lib/decidim/friendly_dates.rb +26 -0
  226. data/lib/decidim/has_feature.rb +1 -0
  227. data/lib/decidim/has_reference.rb +1 -1
  228. data/lib/decidim/i18n_exceptions.rb +1 -3
  229. data/lib/decidim/menu.rb +1 -1
  230. data/lib/decidim/newsletter_encryptor.rb +22 -0
  231. data/lib/decidim/nicknamizable.rb +56 -0
  232. data/lib/decidim/participable.rb +8 -0
  233. data/lib/decidim/participatory_space_manifest.rb +10 -1
  234. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.gl.js +13 -0
  235. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.pt-br.js +14 -0
  236. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.pt.js +5 -1
  237. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.ru.js +4 -1
  238. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.sv.js +14 -0
  239. data/vendor/assets/javascripts/datepicker-locales/foundation-datepicker.uk.js +4 -1
  240. data/vendor/assets/javascripts/form_datepicker.js.es6 +4 -2
  241. data/vendor/assets/javascripts/foundation-datepicker.js +42 -26
  242. metadata +124 -84
  243. data/app/assets/javascripts/decidim/select2.field.js.es6 +0 -47
  244. data/app/assets/javascripts/decidim/select2.js.es6 +0 -11
  245. data/app/assets/stylesheets/decidim/editor.sass +0 -4
  246. data/app/assets/stylesheets/decidim/plugins/_select2.scss +0 -63
  247. data/app/helpers/decidim/datetime_helper.rb +0 -23
  248. data/app/queries/decidim/freetext_scopes.rb +0 -39
  249. data/lib/decidim/core/test/shared_examples/manage_moderations_examples.rb +0 -64
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0ad061f43f8c514c854f0ea29035179e9f9010aa
4
- data.tar.gz: 880adff366f398867619dd379122a0bb2704d153
2
+ SHA256:
3
+ metadata.gz: 805692ed2a7af317223e63403b6d86f95a050669fdef7c4d314b5e4b89c2bd27
4
+ data.tar.gz: c66bfe177feb3f77ee4fe92a1f2968d4e8bccb19fdc426f4115064ead19a3162
5
5
  SHA512:
6
- metadata.gz: 80b4ae4bfee8d712fcbc8ec4aacbc630e3e294b887cebd70fe716b435cf51904f47c1179a56e4f1a92d50f1944f8bf6947259bb78a416e7651853e637f032a11
7
- data.tar.gz: 607fdd0f547ee9b38348fc2d0a752fcb1be3fbd431931f4e04b22b3447ac07dd03825482d9bf1689a470c3fb51153d069ce6f795b61e833ef95d74006636cc76
6
+ metadata.gz: 6179a494542e34d8662c98ed65bba5960b0641de0f104a1fa1e44576b6ad9c33ba854c8368d53fdb484430d33807c5fa94806c652c729055239e65ae0ce11cdf
7
+ data.tar.gz: db9335b2ed20100ded1417784c281fc627e0805dc3c175ebdd0da91b52655c17c010b82100897037c2dce7f56941850d5bc2f24463071aa2c3263676aef58ebc
data/README.md CHANGED
@@ -4,7 +4,7 @@ Short description and motivation.
4
4
 
5
5
  ## Usage
6
6
 
7
- How to use my plugin.
7
+ How to use my module.
8
8
 
9
9
  ## Installation
10
10
 
@@ -1,7 +1,7 @@
1
1
  <?xml version="1.0" encoding="utf-8"?>
2
2
  <!-- Generator: Adobe Illustrator 21.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
3
  <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
4
- viewBox="0 0 255.8 57" style="enable-background:new 0 0 255.8 57;" xml:space="preserve">
4
+ viewBox="0 0 255.8 57" style="enable-background:new 0 0 255.8 57;" xml:space="preserve">
5
5
  <style type="text/css">
6
6
  .center{
7
7
  fill: #dfe3e9;
@@ -29,30 +29,30 @@
29
29
  }
30
30
  </style>
31
31
  <g>
32
- <g>
33
- <path class="text" d="M74.3,42.2v-13c0-13.8,6.6-14.1,9-14.1c3,0,5.2,1.8,6.3,3.4l0,0l-0.2-5.2V2.4h7.5v54.1h-5.9l-0.7-3.8
34
- c-1.3,2.2-3.5,4.3-7.3,4.3C80.4,57,74.3,56.1,74.3,42.2z M89.4,48.2V23.6c-0.7-1.6-2-3-3.8-3c-2.2,0-3.8,1.3-3.8,7.4v15.7
35
- c0,6.1,1.6,7.5,3.8,7.5C87.6,51.1,88.8,49.7,89.4,48.2z"/>
36
- <path class="text" d="M103.6,39.7V32c0-15.7,7.5-16.9,11.8-16.9c5.4,0,10.3,2.9,10.3,12.8c0,3.3-0.4,7-1,9.6h-13.6v4.2
37
- c0,7.1,1,9.6,4.4,9.6c1.8,0,3.6-1.3,3.6-5.7v-1.3h6.3v1.6c0,7.8-3.8,11.2-10.8,11.2C107.5,57,103.6,51.9,103.6,39.7z M118.7,32.4
38
- c0.1-0.9,0.1-3.1,0.1-4.2c0-5.4-1.3-7.6-3.8-7.6c-2.6,0-3.9,2.3-3.9,9.3v2.5H118.7z"/>
39
- <path class="text" d="M131,39.7V32c0-15.7,7.4-16.9,11.5-16.9c5.6,0,9.4,2.9,9.4,9c0,1.9-0.2,3.2-0.5,4.4h-6v-1.4
40
- c0-4.1-0.9-6.6-3.1-6.6c-2.4,0-3.7,2.1-3.7,9.1v11.6c0,7.1,0.9,9.8,3.8,9.8c1.5,0,2.9-1.3,2.9-5.7v-1.3h6.5v1.6
41
- c0,7.8-3.5,11.2-10.3,11.2C134.7,57,131,51.3,131,39.7z"/>
42
- <path class="text" d="M157.5,4.8c0-3.5,1.7-4.8,4.5-4.8c2.9,0,4.6,1.5,4.6,4.8c0,3.1-1.6,4.9-4.6,4.9
43
- C159.3,9.7,157.5,7.9,157.5,4.8z M158.1,15.5h7.5v41h-7.5V15.5z"/>
44
- <path class="text" d="M172.6,42.2v-13c0-13.8,6.6-14.1,9-14.1c3,0,5.2,1.8,6.3,3.4l0,0l-0.2-5.2V2.4h7.5v54.1h-5.9l-0.7-3.8
45
- c-1.3,2.2-3.5,4.3-7.3,4.3C178.6,57,172.6,56.1,172.6,42.2z M187.7,48.2V23.6c-0.7-1.6-2-3-3.8-3c-2.2,0-3.8,1.3-3.8,7.4v15.7
46
- c0,6.1,1.6,7.5,3.8,7.5C185.9,51.1,187,49.7,187.7,48.2z"/>
47
- <path class="text" d="M202.4,4.8c0-3.5,1.7-4.8,4.5-4.8c2.9,0,4.6,1.5,4.6,4.8c0,3.1-1.6,4.9-4.6,4.9
48
- C204.2,9.7,202.4,7.9,202.4,4.8z M203,15.5h7.5v41H203V15.5z"/>
49
- <path class="text" d="M218.4,15.5h5.8l0.7,4.4v0c2.3-3.7,5.5-4.9,8.5-4.9c3.2,0,5.5,1.5,6.6,4.6c2.3-3.5,5.4-4.6,8.4-4.6
50
- c4.7,0,7.5,3.4,7.5,10.1v31.4h-7.5V25.4c0-3.6-1-4.8-3.5-4.8c-1.4,0-2.9,1.1-4,2.9c0,0.4,0,0.7,0,1.1v32h-7.5V25.4
51
- c0-3.6-1-4.8-3.5-4.8c-1.3,0-2.8,1.1-3.9,2.8v33.1h-7.5V15.5z"/>
52
- </g>
32
+ <g>
33
+ <path class="text" d="M74.3,42.2v-13c0-13.8,6.6-14.1,9-14.1c3,0,5.2,1.8,6.3,3.4l0,0l-0.2-5.2V2.4h7.5v54.1h-5.9l-0.7-3.8
34
+ c-1.3,2.2-3.5,4.3-7.3,4.3C80.4,57,74.3,56.1,74.3,42.2z M89.4,48.2V23.6c-0.7-1.6-2-3-3.8-3c-2.2,0-3.8,1.3-3.8,7.4v15.7
35
+ c0,6.1,1.6,7.5,3.8,7.5C87.6,51.1,88.8,49.7,89.4,48.2z"/>
36
+ <path class="text" d="M103.6,39.7V32c0-15.7,7.5-16.9,11.8-16.9c5.4,0,10.3,2.9,10.3,12.8c0,3.3-0.4,7-1,9.6h-13.6v4.2
37
+ c0,7.1,1,9.6,4.4,9.6c1.8,0,3.6-1.3,3.6-5.7v-1.3h6.3v1.6c0,7.8-3.8,11.2-10.8,11.2C107.5,57,103.6,51.9,103.6,39.7z M118.7,32.4
38
+ c0.1-0.9,0.1-3.1,0.1-4.2c0-5.4-1.3-7.6-3.8-7.6c-2.6,0-3.9,2.3-3.9,9.3v2.5H118.7z"/>
39
+ <path class="text" d="M131,39.7V32c0-15.7,7.4-16.9,11.5-16.9c5.6,0,9.4,2.9,9.4,9c0,1.9-0.2,3.2-0.5,4.4h-6v-1.4
40
+ c0-4.1-0.9-6.6-3.1-6.6c-2.4,0-3.7,2.1-3.7,9.1v11.6c0,7.1,0.9,9.8,3.8,9.8c1.5,0,2.9-1.3,2.9-5.7v-1.3h6.5v1.6
41
+ c0,7.8-3.5,11.2-10.3,11.2C134.7,57,131,51.3,131,39.7z"/>
42
+ <path class="text" d="M157.5,4.8c0-3.5,1.7-4.8,4.5-4.8c2.9,0,4.6,1.5,4.6,4.8c0,3.1-1.6,4.9-4.6,4.9
43
+ C159.3,9.7,157.5,7.9,157.5,4.8z M158.1,15.5h7.5v41h-7.5V15.5z"/>
44
+ <path class="text" d="M172.6,42.2v-13c0-13.8,6.6-14.1,9-14.1c3,0,5.2,1.8,6.3,3.4l0,0l-0.2-5.2V2.4h7.5v54.1h-5.9l-0.7-3.8
45
+ c-1.3,2.2-3.5,4.3-7.3,4.3C178.6,57,172.6,56.1,172.6,42.2z M187.7,48.2V23.6c-0.7-1.6-2-3-3.8-3c-2.2,0-3.8,1.3-3.8,7.4v15.7
46
+ c0,6.1,1.6,7.5,3.8,7.5C185.9,51.1,187,49.7,187.7,48.2z"/>
47
+ <path class="text" d="M202.4,4.8c0-3.5,1.7-4.8,4.5-4.8c2.9,0,4.6,1.5,4.6,4.8c0,3.1-1.6,4.9-4.6,4.9
48
+ C204.2,9.7,202.4,7.9,202.4,4.8z M203,15.5h7.5v41H203V15.5z"/>
49
+ <path class="text" d="M218.4,15.5h5.8l0.7,4.4v0c2.3-3.7,5.5-4.9,8.5-4.9c3.2,0,5.5,1.5,6.6,4.6c2.3-3.5,5.4-4.6,8.4-4.6
50
+ c4.7,0,7.5,3.4,7.5,10.1v31.4h-7.5V25.4c0-3.6-1-4.8-3.5-4.8c-1.4,0-2.9,1.1-4,2.9c0,0.4,0,0.7,0,1.1v32h-7.5V25.4
51
+ c0-3.6-1-4.8-3.5-4.8c-1.3,0-2.8,1.1-3.9,2.8v33.1h-7.5V15.5z"/>
52
+ </g>
53
53
  </g>
54
54
  <path class="center" d="M54.1,29.1C39.4,28.9,27.5,17,27.3,2.3h-0.5C26.6,17,14.7,28.9,0,29.1v0.5c14.7,0.1,26.6,12,26.8,26.8h0.5
55
- c0.1-14.7,12-26.6,26.8-26.8V29.1z"/>
55
+ c0.1-14.7,12-26.6,26.8-26.8V29.1z"/>
56
56
  <path class="top-right-circle" d="M54.1,29.1C53.9,14.4,42,2.5,27.3,2.3C27.5,17,39.4,28.9,54.1,29.1z"/>
57
57
  <path class="bottom-right-circle" d="M54.1,29.6c-14.7,0.1-26.6,12-26.8,26.8C42,56.2,53.9,44.3,54.1,29.6z"/>
58
58
  <path class="square-top-left" d="M0,2.3v26.8h0c14.7-0.1,26.6-12,26.8-26.8H0z"/>
@@ -2,13 +2,13 @@
2
2
  <!-- Generator: Adobe Illustrator 16.0.4, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
3
3
  <!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
4
4
  <svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
5
- width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
5
+ width="200px" height="200px" viewBox="0 0 200 200" enable-background="new 0 0 200 200" xml:space="preserve">
6
6
  <g>
7
- <path fill="#C5C5C5" d="M200-0.5H0v200h26.099c2.885-35.293,24.07-64.381,52.419-74.319C64.372,117.596,54.75,102.674,54.75,85.5
8
- c0-24.853,20.146-45,45-45c24.853,0,45,20.147,45,45c0,17.095-9.533,31.963-23.572,39.58c28.5,9.837,49.828,39.002,52.724,74.42
9
- H200V-0.5z"/>
10
- <path fill="#FFFFFF" d="M121.178,125.08c14.039-7.617,23.572-22.485,23.572-39.58c0-24.853-20.147-45-45-45
11
- c-24.854,0-45,20.147-45,45c0,17.174,9.622,32.096,23.768,39.681c-28.349,9.938-49.534,39.026-52.419,74.319h147.803
12
- C171.006,164.082,149.678,134.917,121.178,125.08z"/>
7
+ <path fill="#C5C5C5" d="M200-0.5H0v200h26.099c2.885-35.293,24.07-64.381,52.419-74.319C64.372,117.596,54.75,102.674,54.75,85.5
8
+ c0-24.853,20.146-45,45-45c24.853,0,45,20.147,45,45c0,17.095-9.533,31.963-23.572,39.58c28.5,9.837,49.828,39.002,52.724,74.42
9
+ H200V-0.5z"/>
10
+ <path fill="#FFFFFF" d="M121.178,125.08c14.039-7.617,23.572-22.485,23.572-39.58c0-24.853-20.147-45-45-45
11
+ c-24.854,0-45,20.147-45,45c0,17.174,9.622,32.096,23.768,39.681c-28.349,9.938-49.534,39.026-52.419,74.319h147.803
12
+ C171.006,164.082,149.678,134.917,121.178,125.08z"/>
13
13
  </g>
14
14
  </svg>
@@ -220,6 +220,7 @@
220
220
  <symbol viewBox="0 0 8 8" id="icon-trash"><title>trash</title> <path d="M3 0c-.55 0-1 .45-1 1h-1c-.55 0-1 .45-1 1h7c0-.55-.45-1-1-1h-1c0-.55-.45-1-1-1h-1zm-2 3v4.81c0 .11.08.19.19.19h4.63c.11 0 .19-.08.19-.19v-4.81h-1v3.5c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-1v3.5c0 .28-.22.5-.5.5s-.5-.22-.5-.5v-3.5h-1z"/> </symbol>
221
221
  <symbol viewBox="0 0 449.956 449.956" id="icon-twitter"><title>twitter</title><path d="M449.956 85.657c-17.702 7.614-35.408 12.37-53.102 14.28 19.985-11.992 33.503-28.932 40.546-50.82-18.28 10.847-37.787 18.268-58.532 22.267-18.274-19.414-40.73-29.125-67.383-29.125-25.502 0-47.246 8.99-65.24 26.98-17.984 17.98-26.977 39.73-26.977 65.23 0 6.85.76 13.892 2.284 21.13-37.688-1.908-73.042-11.37-106.068-28.41-33.024-17.035-61.05-39.73-84.08-68.09-8.376 14.27-12.564 29.785-12.564 46.534 0 15.798 3.71 30.456 11.136 43.97 7.422 13.512 17.417 24.455 29.98 32.83-14.85-.57-28.743-4.474-41.684-11.707v1.14c0 22.27 6.995 41.825 20.983 58.675C53.245 247.395 70.9 258 92.215 262.38c-7.993 2.09-16.084 3.137-24.267 3.137-5.33 0-11.136-.475-17.416-1.42 5.9 18.46 16.75 33.633 32.546 45.535 15.8 11.896 33.69 18.028 53.677 18.418-33.498 26.262-71.66 39.393-114.486 39.393-8.19 0-15.61-.373-22.27-1.14C42.82 393.9 90.03 407.7 141.61 407.7c32.74 0 63.48-5.18 92.21-15.557 28.747-10.368 53.298-24.266 73.666-41.685 20.362-17.415 37.925-37.448 52.674-60.097 14.75-22.65 25.738-46.29 32.977-70.94 7.23-24.65 10.848-49.342 10.848-74.09 0-5.33-.096-9.325-.287-11.99 18.087-13.13 33.504-29.024 46.258-47.673z"/></symbol>
222
222
  <symbol viewBox="0 0 8 8" id="icon-underline"><title>underline</title> <path d="M1 0v4c0 1.1 1.12 2 2.5 2h.5c1.1 0 2-.9 2-2v-4h-1v4c0 .55-.45 1-1 1s-1-.45-1-1v-4h-2zm-1 7v1h7v-1h-7z"/> </symbol>
223
+ <symbol viewBox="0 0 12 12" id="icon-verified-badge"><title>verified-badge</title><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" transform="translate(-10.000000, -10.000000)"><g transform="translate(10.000000, 10.000000)"><circle fill="#EC6A5B" cx="6" cy="6" r="6"></circle><polygon fill="#FFFFFF" points="5.94339623 7.68870417 4.01701324 8.59483494 4.28350974 6.48272604 2.82644308 4.93063676 4.91752996 4.53141244 5.94339623 2.66603774 6.9692625 4.53141244 9.06034938 4.93063676 7.60328272 6.48272604 7.86977921 8.59483494"></polygon></g></g> </symbol>
223
224
  <symbol viewBox="0 0 8 8" id="icon-vertical-align-bottom"><title>vertical-align-bottom</title> <path d="M.09 0c-.06 0-.09.04-.09.09v4.81c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-4.81c0-.06-.04-.09-.09-.09h-1.81zm6 0c-.05 0-.09.04-.09.09v4.81c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-4.81c0-.06-.04-.09-.09-.09h-1.81zm-3 2c-.06 0-.09.04-.09.09v2.81c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-2.81c0-.06-.04-.09-.09-.09h-1.81zm-3.09 4v1h8v-1h-8z"/> </symbol>
224
225
  <symbol viewBox="0 0 8 8" id="icon-vertical-align-center"><title>vertical-align-center</title> <path d="M.09 0c-.06 0-.09.04-.09.09v1.91h2v-1.91c0-.06-.04-.09-.09-.09h-1.81zm6 0c-.05 0-.09.04-.09.09v1.91h2v-1.91c0-.06-.04-.09-.09-.09h-1.81zm-3 1c-.06 0-.09.04-.09.09v.91h2v-.91c0-.05-.04-.09-.09-.09h-1.81zm-3.09 2v1h8v-1h-8zm0 2v1.91c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-1.91h-2zm3 0v.91c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-.91h-2zm3 0v1.91c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-1.91h-2z"/> </symbol>
225
226
  <symbol viewBox="0 0 8 8" id="icon-vertical-align-top"><title>vertical-align-top</title> <path d="M0 0v1h8v-1h-8zm.09 2c-.06 0-.09.04-.09.09v4.81c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-4.81c0-.06-.04-.09-.09-.09h-1.81zm3 0c-.06 0-.09.04-.09.09v2.81c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-2.81c0-.06-.04-.09-.09-.09h-1.81zm3 0c-.05 0-.09.04-.09.09v4.81c0 .05.04.09.09.09h1.81c.05 0 .09-.04.09-.09v-4.81c0-.06-.04-.09-.09-.09h-1.81z"/> </symbol>
@@ -12,14 +12,17 @@
12
12
  // = require decidim/append_elements
13
13
  // = require decidim/user_registrations
14
14
  // = require decidim/account_form
15
- // = require decidim/select2
16
- // = require decidim/select2.field
15
+ // = require decidim/data_picker
16
+ // = require decidim/append_redirect_url_to_modals
17
17
 
18
18
  /* globals svg4everybody */
19
19
 
20
20
  window.Decidim = window.Decidim || {};
21
21
 
22
22
  $(() => {
23
+ if (window.Decidim.DataPicker) {
24
+ window.theDataPicker = new window.Decidim.DataPicker($(".data-picker"));
25
+ }
23
26
  $(document).foundation();
24
27
  svg4everybody();
25
28
  if (window.Decidim.formDatePicker) {
@@ -0,0 +1,84 @@
1
+ /* eslint-disable multiline-ternary, no-ternary */
2
+ // require self
3
+
4
+ /*
5
+ *
6
+ * This is used to make sure users are redirected to
7
+ * the expected URL after sign in.
8
+ *
9
+ * When a button or link trigger a login modal we capture
10
+ * the event and inject the URL where the user should
11
+ * be redirected after sign in (the redirect_url param).
12
+ *
13
+ * The code is injected to any form or link in the modal
14
+ * and when the modal is closed we remove the injected
15
+ * code.
16
+ *
17
+ * In order for this to work the button or link must have
18
+ * a data-open attribute with the ID of the modal to open
19
+ * and a data-redirect-url attribute with the URL to redirect
20
+ * the user. If any of this is missing no code will be
21
+ * injected.
22
+ *
23
+ */
24
+ $(() => {
25
+ const removeUrlParameter = (url, parameter) => {
26
+ const urlParts = url.split('?');
27
+
28
+ if (urlParts.length >= 2) {
29
+ // Get first part, and remove from array
30
+ const urlBase = urlParts.shift();
31
+
32
+ // Join it back up
33
+ const queryString = urlParts.join('?');
34
+
35
+ const prefix = `${encodeURIComponent(parameter)}=`;
36
+ const parts = queryString.split(/[&;]/g);
37
+
38
+ // Reverse iteration as may be destructive
39
+ for (let index = parts.length; index > 0; index -= 1) {
40
+ // Idiom for string.startsWith
41
+ if (parts[index].lastIndexOf(prefix, 0) !== -1) {
42
+ parts.splice(index, 1);
43
+ }
44
+ }
45
+
46
+ if (parts.length === 0) {
47
+ return urlBase;
48
+ }
49
+
50
+ return `${urlBase}?${parts.join('&')}`;
51
+ }
52
+
53
+ return url;
54
+ }
55
+
56
+ $(document).on("click.zf.trigger", (event) => {
57
+ const target = `#${$(event.target).data("open")}`;
58
+ const redirectUrl = $(event.target).data("redirectUrl");
59
+
60
+ if (target && redirectUrl) {
61
+ $("<input type='hidden' />").
62
+ attr("id", "redirect_url").
63
+ attr("name", "redirect_url").
64
+ attr("value", redirectUrl).
65
+ appendTo(`${target} form`);
66
+
67
+ $(`${target} a`).attr("href", (index, href) => {
68
+ const querystring = jQuery.param({"redirect_url": redirectUrl});
69
+ return href + (href.match(/\?/) ? '&' : '?') + querystring;
70
+ });
71
+ }
72
+ });
73
+
74
+ $(document).on('closed.zf.reveal', (event) => {
75
+ $("#redirect_url", event.target).remove();
76
+ $("a", event.target).attr("href", (index, href) => {
77
+ if (href && href.indexOf("redirect_url") !== -1) {
78
+ return removeUrlParameter(href, "redirect_url");
79
+ }
80
+
81
+ return href;
82
+ });
83
+ });
84
+ });
@@ -0,0 +1,177 @@
1
+ /**
2
+ * DataPicker component.
3
+ */
4
+ ((exports) => {
5
+ class DataPicker {
6
+ constructor(elements) {
7
+ this.modal = this._createModalContainer();
8
+ this.modal.appendTo($("body"));
9
+ this.current = null;
10
+
11
+ elements.each((_index, element) => {
12
+ let $element = $(element);
13
+ let input = "hidden",
14
+ name = $element.data('picker-name'),
15
+ values = $(".picker-values", $element);
16
+
17
+ if ($element.hasClass("picker-multiple")) {
18
+ input = "checkbox";
19
+ name += "[]";
20
+ }
21
+
22
+ $("div", values).each((_index2, div) => {
23
+ let value = $("a", div).data("picker-value");
24
+ $(div).prepend($(`<input type="${input}" checked name="${name}" value="${value}"/>`));
25
+ });
26
+
27
+ $element.on("click", "a", (event) => {
28
+ event.preventDefault();
29
+ if ($element.hasClass('disabled')) {
30
+ return;
31
+ }
32
+ this._openPicker($element, event.target.parentNode);
33
+ });
34
+
35
+ $element.on("click", "input", (event) => {
36
+ this._removeValue($element, event.target.parentNode);
37
+ });
38
+ });
39
+ }
40
+
41
+ enabled(picker, value) {
42
+ $(picker).toggleClass("disabled", !value);
43
+ $("input", picker).attr("disabled", !value);
44
+ }
45
+
46
+ clear(picker) {
47
+ $(".picker-values", picker).html("");
48
+ }
49
+
50
+ save(picker) {
51
+ return $(".picker-values div:has(input:checked)", picker).map((_index, div) => {
52
+ let $link = $("a", div);
53
+ return {
54
+ value: $("input", div).val(),
55
+ text: $link.text(),
56
+ url: $link.attr("href")
57
+ };
58
+ }).get();
59
+ }
60
+
61
+ load(picker, savedData) {
62
+ this._setCurrentPicker($(picker), null);
63
+ $.each(savedData, (_index, data) => {
64
+ this._choose(data, false);
65
+ });
66
+ }
67
+
68
+ _createModalContainer() {
69
+ return $(`<div class="small reveal" id="data_picker-modal" aria-hidden="true" role="dialog" aria-labelledby="data_picker-title" data-reveal data-multiple-opened="true">
70
+ <div class="data_picker-modal-content"></div>
71
+ <button class="close-button" data-close type="button" data-reveal-id="data_picker-modal"><span aria-hidden="true">&times;</span></button>
72
+ </div>`);
73
+ }
74
+
75
+ _openPicker($picker, div) {
76
+ this._setCurrentPicker($picker, div);
77
+ this._load($("a", div).attr('href'));
78
+ }
79
+
80
+ _setCurrentPicker($picker, div) {
81
+ let currentDiv = false;
82
+ if (div && !$(div).hasClass("picker-prompt")) {
83
+ currentDiv = $(div);
84
+ }
85
+
86
+ this.current = {
87
+ multiple: $picker.hasClass("picker-multiple"),
88
+ picker: $picker,
89
+ name: $picker.data('picker-name'),
90
+ values: $picker.find(".picker-values"),
91
+ div: currentDiv
92
+ };
93
+ }
94
+
95
+ _load(url) {
96
+ $.ajax(url).done((resp) => {
97
+ let modalContent = $(".data_picker-modal-content", this.modal);
98
+ modalContent.html(resp);
99
+ this._handleLinks(modalContent);
100
+ this.modal.foundation('open');
101
+ });
102
+ }
103
+
104
+ _handleLinks(content) {
105
+ $("a", content).each((_index, link) => {
106
+ let $link = $(link);
107
+ $link.click((event) => {
108
+ event.preventDefault();
109
+ if ($link.data('data-close')) {
110
+ return;
111
+ }
112
+
113
+ let chooseUrl = $link.attr('href');
114
+ if (chooseUrl) {
115
+ if (typeof $link.data('picker-choose') === 'undefined') {
116
+ this._load(chooseUrl);
117
+ } else {
118
+ this._choose({url: chooseUrl, value: $link.data('picker-value') || "", text: $link.data('picker-text') || ""});
119
+ }
120
+ }
121
+ });
122
+ });
123
+ }
124
+
125
+ _choose(data, user = true) {
126
+ // Add or update value appearance
127
+ if (this.current.div) {
128
+ let link = $("a", this.current.div);
129
+ link.data("picker-value", data.value);
130
+ link.attr("href", data.url);
131
+ link.text(data.text);
132
+ } else {
133
+ let input = "hidden",
134
+ name = this.current.name;
135
+
136
+ if (this.current.multiple) {
137
+ input = "checkbox";
138
+ name += "[]";
139
+ }
140
+ this.current.div = $(`<div><input type="${input}" checked name="${name}"/><a href="${data.url}" data-picker-value="${data.value}">${data.text}</a></div>`);
141
+ this.current.div.appendTo(this.current.values);
142
+ }
143
+
144
+ // Set input value
145
+ let $input = $("input", this.current.div);
146
+ $input.attr("value", data.value);
147
+
148
+ // Raise changed event
149
+ if (user) {
150
+ $input.trigger("change");
151
+ this._removeErrors();
152
+ this.modal.foundation('close');
153
+ }
154
+
155
+ // Unselect updated value and close modal
156
+ this.current.div = null;
157
+ }
158
+
159
+ _removeValue($picker, div) {
160
+ this._setCurrentPicker($picker, div);
161
+ this.current.div.fadeOut(500, () => {
162
+ this.current.div.remove();
163
+ this.current.div = null;
164
+ });
165
+ }
166
+
167
+ _removeErrors() {
168
+ let parent = this.current.picker.parent();
169
+ $(".is-invalid-input", parent).removeClass("is-invalid-input");
170
+ $(".is-invalid-label", parent).removeClass("is-invalid-label");
171
+ $(".form-error.is-visible", parent).removeClass("is-visible");
172
+ }
173
+ }
174
+
175
+ exports.Decidim = exports.Decidim || {};
176
+ exports.Decidim.DataPicker = DataPicker;
177
+ })(window);
@@ -11,7 +11,6 @@
11
11
  this.$form = $form;
12
12
  this.id = this.$form.attr('id') || this._getUID();
13
13
  this.mounted = false;
14
- this.select2Filters = [];
15
14
 
16
15
  this._onFormChange = this._onFormChange.bind(this);
17
16
  this._onPopState = this._onPopState.bind(this);
@@ -32,10 +31,7 @@
32
31
  unmountComponent() {
33
32
  if (this.mounted) {
34
33
  this.mounted = false;
35
- this.$form.off('change', 'input:not(.select2-search__field), select', this._onFormChange);
36
- this.select2Filters.forEach((select) => {
37
- select.destroy();
38
- });
34
+ this.$form.off('change', 'input, select', this._onFormChange);
39
35
 
40
36
  exports.Decidim.History.unregisterCallback(`filters-${this.id}`)
41
37
  }
@@ -49,14 +45,10 @@
49
45
  mountComponent() {
50
46
  if (this.$form.length > 0 && !this.mounted) {
51
47
  this.mounted = true;
52
- let select2Filters = this.select2Filters;
53
- this.$form.find('select.select2').each(function(index, select) {
54
- select2Filters.push(new window.Decidim.Select2Field(select));
55
- });
56
- this.$form.on('change', 'input:not(.select2-search__field), select', this._onFormChange);
48
+ this.$form.on('change', 'input, select', this._onFormChange);
57
49
 
58
- exports.Decidim.History.registerCallback(`filters-${this.id}`, () => {
59
- this._onPopState();
50
+ exports.Decidim.History.registerCallback(`filters-${this.id}`, (state) => {
51
+ this._onPopState(state);
60
52
  });
61
53
  }
62
54
  }
@@ -142,7 +134,9 @@
142
134
  _clearForm() {
143
135
  this.$form.find('input[type=checkbox]').attr('checked', false);
144
136
  this.$form.find('input[type=radio]').attr('checked', false);
145
- this.$form.find('select.select2').val(null).trigger('change.select2');
137
+ this.$form.find('.data-picker').each((_index, picker) => {
138
+ exports.theDataPicker.clear(picker);
139
+ });
146
140
 
147
141
  // This ensure the form is reset in a valid state where a fieldset of
148
142
  // radio buttons has the first selected.
@@ -155,9 +149,10 @@
155
149
  /**
156
150
  * Handles the logic when going back to a previous state in the filter form.
157
151
  * @private
152
+ * @param {Object} state - state stored along with location URL
158
153
  * @returns {Void} - Returns nothing.
159
154
  */
160
- _onPopState() {
155
+ _onPopState(state) {
161
156
  this._clearForm();
162
157
 
163
158
  const filterParams = this._parseLocationFilterValues();
@@ -184,16 +179,20 @@
184
179
  field = this.$form.find(`input#filter_${fieldId},select#filter_${fieldId}`);
185
180
 
186
181
  if (field.length > 0) {
187
- if (field.hasClass("select2")) {
188
- field.val(filterParams[fieldId]).trigger('change.select2');
189
- } else {
190
- field.val(filterParams[fieldId]);
191
- }
182
+ field.val(filterParams[fieldId]);
192
183
  }
193
184
  }
194
185
  });
195
186
  }
196
187
 
188
+ // Retrieves picker information for selected values (value, text and link) from the state object
189
+ $(".data-picker", this.$form).each((_index, picker) => {
190
+ let pickerState = state[picker.id];
191
+ if (pickerState) {
192
+ exports.theDataPicker.load(picker, pickerState);
193
+ }
194
+ })
195
+
197
196
  // Only one instance should submit the form on browser history navigation
198
197
  if (this.popStateSubmiter) {
199
198
  exports.Rails.fire(this.$form[0], 'submit');
@@ -210,6 +209,7 @@
210
209
  const params = this.$form.serialize();
211
210
 
212
211
  let newUrl = '';
212
+ let newState = {};
213
213
 
214
214
  exports.Rails.fire(this.$form[0], 'submit');
215
215
 
@@ -219,7 +219,12 @@
219
219
  newUrl = `${formAction}&${params}`;
220
220
  }
221
221
 
222
- exports.Decidim.History.pushState(newUrl);
222
+ // Stores picker information for selected values (value, text and link) in the state object
223
+ $(".data-picker", this.$form).each((_index, picker) => {
224
+ newState[picker.id] = exports.theDataPicker.save(picker);
225
+ })
226
+
227
+ exports.Decidim.History.pushState(newUrl, newState);
223
228
  }
224
229
 
225
230
  /**