decidim-decidim_awesome 0.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (138) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE-AGPLv3.txt +661 -0
  3. data/README.md +307 -0
  4. data/Rakefile +51 -0
  5. data/app/assets/config/decidim_admin_decidim_awesome_manifest.css +3 -0
  6. data/app/assets/config/decidim_admin_decidim_awesome_manifest.js +1 -0
  7. data/app/assets/config/decidim_decidim_awesome_manifest.css +5 -0
  8. data/app/assets/config/decidim_decidim_awesome_manifest.js +2 -0
  9. data/app/assets/images/decidim/decidim_awesome/loading.gif +0 -0
  10. data/app/assets/images/decidim/decidim_awesome/platoniq-logo.png +0 -0
  11. data/app/assets/javascripts/decidim/decidim_awesome/admin.js +2 -0
  12. data/app/assets/javascripts/decidim/decidim_awesome/admin/constraints.js.es6 +54 -0
  13. data/app/assets/javascripts/decidim/decidim_awesome/application.js +4 -0
  14. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/api_fetcher.js.es6 +38 -0
  15. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/categories.js.es6 +25 -0
  16. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/map.js.es6 +215 -0
  17. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/meetings.js.es6 +129 -0
  18. data/app/assets/javascripts/decidim/decidim_awesome/awesome_map/proposals.js.es6 +78 -0
  19. data/app/assets/javascripts/decidim/decidim_awesome/editors/markdown_view.js.es6 +12 -0
  20. data/app/assets/javascripts/decidim/decidim_awesome/editors/quill_editor.js.es6 +162 -0
  21. data/app/assets/javascripts/decidim/decidim_awesome/forms/autosave.js.es6 +90 -0
  22. data/app/assets/javascripts/decidim/decidim_awesome/proposals/images.js.es6 +25 -0
  23. data/app/assets/stylesheets/decidim/decidim_awesome/admin.scss +45 -0
  24. data/app/assets/stylesheets/decidim/decidim_awesome/admin/constraints.scss +37 -0
  25. data/app/assets/stylesheets/decidim/decidim_awesome/application.scss +8 -0
  26. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_iframe/iframe.scss +10 -0
  27. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/leaflet.scss.erb +9 -0
  28. data/app/assets/stylesheets/decidim/decidim_awesome/awesome_map/map.scss +66 -0
  29. data/app/assets/stylesheets/decidim/decidim_awesome/editors/markdown_editor.scss +17 -0
  30. data/app/assets/stylesheets/decidim/decidim_awesome/editors/markdown_view.scss +27 -0
  31. data/app/assets/stylesheets/decidim/decidim_awesome/editors/quill_editor.scss +7 -0
  32. data/app/assets/stylesheets/decidim/decidim_awesome/forms/autosave.scss +17 -0
  33. data/app/awesome_overrides/presenters/decidim/proposals/proposal_presenter_override.rb +31 -0
  34. data/app/commands/decidim/decidim_awesome/admin/create_constraint.rb +47 -0
  35. data/app/commands/decidim/decidim_awesome/admin/destroy_constraint.rb +31 -0
  36. data/app/commands/decidim/decidim_awesome/admin/update_config.rb +44 -0
  37. data/app/commands/decidim/decidim_awesome/admin/update_constraint.rb +44 -0
  38. data/app/commands/decidim/decidim_awesome/create_editor_image.rb +34 -0
  39. data/app/controllers/concerns/decidim/decidim_awesome/needs_awesome_config.rb +17 -0
  40. data/app/controllers/decidim/decidim_awesome/admin/application_controller.rb +21 -0
  41. data/app/controllers/decidim/decidim_awesome/admin/checks_controller.rb +37 -0
  42. data/app/controllers/decidim/decidim_awesome/admin/config_controller.rb +44 -0
  43. data/app/controllers/decidim/decidim_awesome/admin/constraints_controller.rb +126 -0
  44. data/app/controllers/decidim/decidim_awesome/application_controller.rb +14 -0
  45. data/app/controllers/decidim/decidim_awesome/editor_images_controller.rb +50 -0
  46. data/app/controllers/decidim/decidim_awesome/iframe_component/application_controller.rb +15 -0
  47. data/app/controllers/decidim/decidim_awesome/iframe_component/iframe_controller.rb +33 -0
  48. data/app/controllers/decidim/decidim_awesome/map_component/application_controller.rb +15 -0
  49. data/app/controllers/decidim/decidim_awesome/map_component/map_controller.rb +31 -0
  50. data/app/forms/decidim/decidim_awesome/admin/config_form.rb +22 -0
  51. data/app/forms/decidim/decidim_awesome/admin/constraint_form.rb +20 -0
  52. data/app/forms/decidim/decidim_awesome/admin/intergram_form.rb +21 -0
  53. data/app/forms/decidim/decidim_awesome/editor_image_form.rb +16 -0
  54. data/app/helpers/decidim/decidim_awesome/admin/config_constraints_helpers.rb +90 -0
  55. data/app/helpers/decidim/decidim_awesome/application_helper.rb +10 -0
  56. data/app/helpers/decidim/decidim_awesome/map_helper.rb +121 -0
  57. data/app/models/decidim/decidim_awesome/application_record.rb +10 -0
  58. data/app/models/decidim/decidim_awesome/awesome_config.rb +23 -0
  59. data/app/models/decidim/decidim_awesome/config_constraint.rb +13 -0
  60. data/app/models/decidim/decidim_awesome/editor_image.rb +24 -0
  61. data/app/permissions/decidim/decidim_awesome/permissions.rb +29 -0
  62. data/app/uploaders/decidim/decidim_awesome/image_uploader.rb +22 -0
  63. data/app/views/decidim/decidim_awesome/admin/checks/index.html.erb +35 -0
  64. data/app/views/decidim/decidim_awesome/admin/config/_constraints.html.erb +27 -0
  65. data/app/views/decidim/decidim_awesome/admin/config/_form_editors.html.erb +20 -0
  66. data/app/views/decidim/decidim_awesome/admin/config/_form_livechat.html.erb +44 -0
  67. data/app/views/decidim/decidim_awesome/admin/config/_form_proposals.html.erb +12 -0
  68. data/app/views/decidim/decidim_awesome/admin/config/_form_surveys.html.erb +9 -0
  69. data/app/views/decidim/decidim_awesome/admin/config/_modal.html.erb +11 -0
  70. data/app/views/decidim/decidim_awesome/admin/config/show.html.erb +15 -0
  71. data/app/views/decidim/decidim_awesome/admin/constraints/_form.html.erb +56 -0
  72. data/app/views/decidim/decidim_awesome/admin/constraints/new.html.erb +14 -0
  73. data/app/views/decidim/decidim_awesome/admin/constraints/show.html.erb +14 -0
  74. data/app/views/decidim/decidim_awesome/iframe_component/iframe/show.html.erb +9 -0
  75. data/app/views/decidim/decidim_awesome/map_component/map/error.erb +7 -0
  76. data/app/views/decidim/decidim_awesome/map_component/map/show.html.erb +74 -0
  77. data/app/views/layouts/decidim/_head.html.erb +5 -0
  78. data/app/views/layouts/decidim/admin/_header.html.erb +5 -0
  79. data/app/views/layouts/decidim/admin/decidim_awesome.html.erb +47 -0
  80. data/app/views/layouts/decidim/decidim_awesome/_awesome_config.html.erb +20 -0
  81. data/app/views/layouts/decidim/decidim_awesome/_intergram_widget.html.erb +16 -0
  82. data/app/views/v0.21/layouts/decidim/_head.html.erb +34 -0
  83. data/app/views/v0.21/layouts/decidim/admin/_header.html.erb +9 -0
  84. data/app/views/v0.22/layouts/decidim/_head.html.erb +36 -0
  85. data/app/views/v0.22/layouts/decidim/admin/_header.html.erb +11 -0
  86. data/config/i18n-tasks.yml +10 -0
  87. data/config/locales/ca.yml +125 -0
  88. data/config/locales/cs.yml +125 -0
  89. data/config/locales/en.yml +176 -0
  90. data/config/locales/es.yml +125 -0
  91. data/config/locales/fr.yml +125 -0
  92. data/config/locales/sv.yml +125 -0
  93. data/db/migrate/20200324170000_create_decidim_awesome_config.rb +16 -0
  94. data/db/migrate/20200324230936_create_awesome_editor_images.rb +14 -0
  95. data/db/migrate/20200403142257_create_decidim_awesome_config_constraints.rb +13 -0
  96. data/db/seeds.rb +27 -0
  97. data/lib/decidim/decidim_awesome.rb +110 -0
  98. data/lib/decidim/decidim_awesome/admin.rb +10 -0
  99. data/lib/decidim/decidim_awesome/admin_engine.rb +45 -0
  100. data/lib/decidim/decidim_awesome/awesome_helpers.rb +55 -0
  101. data/lib/decidim/decidim_awesome/checksums.yml +15 -0
  102. data/lib/decidim/decidim_awesome/config.rb +129 -0
  103. data/lib/decidim/decidim_awesome/content_renderers.rb +9 -0
  104. data/lib/decidim/decidim_awesome/content_renderers/markdown_renderer.rb +18 -0
  105. data/lib/decidim/decidim_awesome/context_analyzers.rb +11 -0
  106. data/lib/decidim/decidim_awesome/context_analyzers/component_analyzer.rb +38 -0
  107. data/lib/decidim/decidim_awesome/context_analyzers/participatory_space_analyzer.rb +31 -0
  108. data/lib/decidim/decidim_awesome/context_analyzers/request_analyzer.rb +97 -0
  109. data/lib/decidim/decidim_awesome/engine.rb +38 -0
  110. data/lib/decidim/decidim_awesome/iframe_component/component.rb +59 -0
  111. data/lib/decidim/decidim_awesome/iframe_component/engine.rb +23 -0
  112. data/lib/decidim/decidim_awesome/map_component/component.rb +74 -0
  113. data/lib/decidim/decidim_awesome/map_component/engine.rb +23 -0
  114. data/lib/decidim/decidim_awesome/system_checker.rb +63 -0
  115. data/lib/decidim/decidim_awesome/test/factories.rb +36 -0
  116. data/lib/decidim/decidim_awesome/test/shared_examples/config_examples.rb +25 -0
  117. data/lib/decidim/decidim_awesome/test/themes/css.lvh.me.css +3 -0
  118. data/lib/decidim/decidim_awesome/test/themes/erb.lvh.me.scss.erb +2 -0
  119. data/lib/decidim/decidim_awesome/test/themes/scss.lvh.me.scss +1 -0
  120. data/lib/decidim/decidim_awesome/test/themes/test-theme/body.scss +4 -0
  121. data/lib/decidim/decidim_awesome/version.rb +10 -0
  122. data/vendor/assets/images/layers-2x.png +0 -0
  123. data/vendor/assets/images/layers.png +0 -0
  124. data/vendor/assets/images/marker-icon.png +0 -0
  125. data/vendor/assets/javascripts/codemirror-4.inline-attachment.js +89 -0
  126. data/vendor/assets/javascripts/form-storage.js +824 -0
  127. data/vendor/assets/javascripts/highlight.min.js +44 -0
  128. data/vendor/assets/javascripts/image-resize.min.js +1 -0
  129. data/vendor/assets/javascripts/image-upload.min.js +6 -0
  130. data/vendor/assets/javascripts/inline-attachment.js +399 -0
  131. data/vendor/assets/javascripts/inscrybmde.min.js +7 -0
  132. data/vendor/assets/javascripts/jquery.inline-attachment.js +66 -0
  133. data/vendor/assets/javascripts/leaflet.featuregroup.subgroup.js +6 -0
  134. data/vendor/assets/stylesheets/default.min.css +1 -0
  135. data/vendor/assets/stylesheets/foundation.min.css +1 -0
  136. data/vendor/assets/stylesheets/github.min.css +2 -0
  137. data/vendor/assets/stylesheets/inscrybmde.min.css +8 -0
  138. metadata +267 -0
@@ -0,0 +1,307 @@
1
+ # Decidim::DecidimAwesome
2
+
3
+ [![Build](https://github.com/Platoniq/decidim-module-decidim_awesome/workflows/Build/badge.svg)](https://github.com/Platoniq/decidim-module-decidim_awesome/actions)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/2dada53525dd5a944089/maintainability)](https://codeclimate.com/github/Platoniq/decidim-module-decidim_awesome/maintainability)
5
+ [![Test Coverage](https://codecov.io/gh/Platoniq/decidim-module-decidim_awesome/branch/master/graph/badge.svg?token=TFBMCLLZJG)](undefined)
6
+
7
+ Usability and UX tweaks for Decidim.
8
+
9
+ This plugin allows the administrators to expand the possibilities of Decidim beyond some existing limitations.
10
+ All tweaks are provided in a optional fashion with granular permissions that let the administrator to choose exactly where to apply those mods. Some tweaks can be applied to any assembly, other in an specific participatory process or even in type of component only.
11
+
12
+ **This in beta status, we do not accept any responsibility for breaking anything. Feedback is appreciated though.**
13
+
14
+ ## Why this plugin?
15
+
16
+ At Platoniq, we like to explore and combine open tools for enriching democracy in many levels. And also for organizations or companies, not only governments.
17
+ Currently we are working very closely with the team behind [Decidim](https://decidim.org) because we believe that it is a great software.
18
+
19
+ However in Platoniq we have this slogan: "Democracy is fun if you take it seriously" (feel free to ask for T-shirts 😉).
20
+ And, let's face it, sometimes we feel that Decidim lacks a bit of the "fun" part so we created this.
21
+ Because Decidim is awesome and so is this!
22
+
23
+ ## Usage
24
+
25
+ Read the [CHANGELOG](CHANGELOG.md) for Decidim compatibility.
26
+
27
+ DecidimAwesome is a module that hacks Decidim in order to provide more features or improve some aspects of it.
28
+
29
+ It generates and admin module that allows to choose what hacks to apply.
30
+ Each hack can be scoped to one or more specific participatory spaces or components.
31
+
32
+ ### Tweaks:
33
+
34
+ #### 1. Image support for the Quill editor
35
+
36
+ Modifies the WYSIWYG editor in Decidim by adding the possibility to insert images. When uploading images, Drag & Drop is supported. Images will be uploaded to the server and inserted as external resources (it doesn't use base64 inline encoding).
37
+
38
+ This feature allows you use images in newsletters as well.
39
+
40
+ ![Images in Quill Editor](examples/quill-images.png)
41
+
42
+ #### 2. Auto-save for surveys and forms
43
+
44
+ With this feature admins can activate (globally or scoped) an auto-save feature for any form in Decidim.
45
+
46
+ It works purely in the client side by using LocalStorage capabilities of the browser. Data is store every time any field changes and retrieved automatically if the same user with the same browser returns to it in the future.
47
+
48
+ Saving the form removes the stored data.
49
+
50
+ ![Auto save in forms](examples/auto-save.png)
51
+
52
+ #### 3. Images in proposals
53
+
54
+ Event if you haven't activated the WYSIWYG editor (Quill) in public views (eg: proposals use a simple textarea if rich text editor has not been activated for users). You can allow users to upload images in them by drag & drop over the text area.
55
+
56
+ ![Proposal images](examples/proposal-images.png)
57
+
58
+ #### 4. Markdown editor for proposals
59
+
60
+ Allows to use markdown when creating proposals instead of a bare textarea.
61
+
62
+ #### 5. Admin scope configuration
63
+
64
+ All tweaks can be configured and scoped to a specific participatory space, a type of participatory space, a type of component or a specific component.
65
+
66
+ Many scopes can be defined for every tweak.
67
+
68
+ ![Admin tweaks for editors](examples/admin-editors.png)
69
+
70
+ #### 6. Awesome map component
71
+
72
+ This is a component you can add in any participatory space. It retrieves all the geolocated content in that participatory space (meetings or proposals) and displays it in a big map.
73
+
74
+ It also provides a simple search by category, each category is assignated to a different color.
75
+
76
+ ![Awesome map](examples/awesome-map.png)
77
+
78
+ #### 7. Allow Decidim to use custom CSS themes for every tenant
79
+
80
+ When customizind CSS for a Decidim installation, each change affects all the organizations (tenant).
81
+
82
+ This feature allows to customize each organization css without affecting the others in the same Decidim installation.
83
+
84
+ ##### To create a theme
85
+
86
+ 1. Get your hostname for the organization, theme search will be based on this (e.g: `myorganization.com`)
87
+ 2. Create in you Decidim application this folder: `app/assets/themes/`
88
+ 3. Create a file in that folder with the same name as the host and suffixed `.css` or `.scss` (e.g: `app/assets/themes/myorganization.com.scss`)
89
+ 4. Modify that file as you like, you can use any SASS function available (such as `@import`)
90
+ 5. Restart your server, enjoy!
91
+
92
+ See an example here:
93
+ https://github.com/Platoniq/decidim-demo/tree/master/app/assets/themes
94
+
95
+ NOTE: Files presents in the `app/assets/themes` folder are added automatically into the precompile list of Rails by this plugin.
96
+
97
+ #### 8. Fullscreen Iframe component
98
+
99
+ Another simple component that can be used to embed and Iframe with any external content in it that fills all the viewport.
100
+
101
+ ![Fullscreen iframe](examples/fullscreen-iframe.png)
102
+
103
+ #### 9. Live support chat
104
+
105
+ With this feature you can have a support chat in Decidim. It is linked to a [Telegram](https://telegram.org/) group or a single user chat using the [[IntergramBot](https://web.telegram.org/#/im?p=@IntergramBot). Just invite the bot to a group or chat with it directly, grab your ID, put it on the Awesome settings and have fun!. For more info or for hosting your own version of the bot check the [Intergram project](https://github.com/idoco/intergram).
106
+
107
+ ![Intergram screenshot](examples/intergram.png)
108
+
109
+
110
+ #### To be continued...
111
+
112
+ Some things in the road-map:
113
+
114
+ 1. Improve the conversation in comments by allowing images
115
+ 1. Direct export of surveys in PDF
116
+ 1. Allow to create surveys where the responding user is known
117
+ 1. Propose something! or even better send a PR!
118
+
119
+ ## Installation
120
+
121
+ Add this line to your application's Gemfile:
122
+
123
+ ```ruby
124
+ gem "decidim-decidim_awesome", "~> 0.5.1"
125
+ ```
126
+
127
+ And then execute:
128
+
129
+ ```bash
130
+ bundle
131
+ bundle exec rails decidim_decidim_awesome:install:migrations
132
+ bundle exec rails db:migrate
133
+ ```
134
+
135
+ Depending on your Decidim version, choose the corresponding Awesome version to ensure compatibility:
136
+
137
+ | Awesome version | Compatible Decidim versions |
138
+ |---|---|---|---|---|
139
+ | 0.5.x | 0.21.x, 0.22.x |
140
+
141
+
142
+ ## Configuration
143
+
144
+ Each tweak can be enabled or disabled by default. It also can be deactivated so
145
+ admins do not even see it.
146
+
147
+ In order to personalize default values, create an initializer such as:
148
+
149
+ ```ruby
150
+ # config/initializers/awesome_defaults.rb
151
+
152
+ # Change some variables defaults
153
+ Decidim::DecidimAwesome.configure do |config|
154
+ # Enabled by default to all scopes, admins can still limit it's scope
155
+ config.allow_images_in_full_editor = true
156
+
157
+ # Disabled by default to all scopes, admins can enable it and limit it's scope
158
+ config.allow_images_in_small_editor = false
159
+
160
+ # De-activated, admins don't even see it as an option
161
+ config.use_markdown_editor = :disabled
162
+ end
163
+ ```
164
+
165
+ For a complete list of options take a look at the [module defaults](lib/decidim/decidim_awesome.rb).
166
+
167
+ ## Missing something?
168
+
169
+ We add new features and maintain them, however we do it according our needs as this is mostly voluntary work.
170
+ So if you feel that you can contribute feel free to create a pull request with your idea. We are open to incorporate anything reasonable.
171
+
172
+ We do ask some things:
173
+ - Each feature has to come with and activation option, same as the already existing (unless is something that do not modify predefined Decidim behavior)
174
+ - Try to avoid views or assets overrides. Many times it is just enough to add additional css or scripts that alter existing objects.
175
+
176
+ You can also ask for new feature by creating and issue and, if you are ready to provide funds for its development just contact us!
177
+
178
+ Thanks!
179
+
180
+ ## Developing
181
+
182
+ To start contributing to this project, first:
183
+
184
+ - Install the basic dependencies (such as Ruby and PostgreSQL)
185
+ - Clone this repository
186
+
187
+ Decidim's main repository also provides a Docker configuration file if you
188
+ prefer to use Docker instead of installing the dependencies locally on your
189
+ machine.
190
+
191
+ You can create the development app by running the following commands after
192
+ cloning this project:
193
+
194
+ ```bash
195
+ bundle
196
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake development_app
197
+ ```
198
+
199
+ Note that the database user has to have rights to create and drop a database in
200
+ order to create the dummy test app database.
201
+
202
+ Then to test how the module works in Decidim, start the development server:
203
+
204
+ ```bash
205
+ cd development_app
206
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rails s
207
+ ```
208
+
209
+ In case you are using [rbenv](https://github.com/rbenv/rbenv) and have the
210
+ [rbenv-vars](https://github.com/rbenv/rbenv-vars) plugin installed for it, you
211
+ can add the environment variables to the root directory of the project in a file
212
+ named `.rbenv-vars`. If these are defined for the environment, you can omit
213
+ defining these in the commands shown above.
214
+
215
+ ### Code Styling
216
+
217
+ Please follow the code styling defined by the different linters that ensure we
218
+ are all talking with the same language collaborating on the same project. This
219
+ project is set to follow the same rules that Decidim itself follows.
220
+
221
+ [Rubocop](https://rubocop.readthedocs.io/) linter is used for the Ruby language.
222
+
223
+ You can run the code styling checks by running the following commands from the
224
+ console:
225
+
226
+ ```
227
+ bundle exec rubocop
228
+ ```
229
+
230
+ To ease up following the style guide, you should install the plugin to your
231
+ favorite editor, such as:
232
+
233
+ - Atom - [linter-rubocop](https://atom.io/packages/linter-rubocop)
234
+ - Sublime Text - [Sublime RuboCop](https://github.com/pderichs/sublime_rubocop)
235
+ - Visual Studio Code - [Rubocop for Visual Studio Code](https://github.com/misogi/vscode-ruby-rubocop)
236
+
237
+ ### Testing
238
+
239
+ To run the tests run the following in the gem development path:
240
+
241
+ ```bash
242
+ bundle
243
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_app
244
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rspec
245
+ ```
246
+
247
+ However, this project also make use of the gem [Appraisals](https://github.com/thoughtbot/appraisal) in order to test againts several versions of Decidim. The idea is to suport same supported versions of Decidim.
248
+
249
+ You can run run all tests againts all Decidim versions by using:
250
+ ```bash
251
+ bundle exec appraisal install
252
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec rake test_app
253
+ DATABASE_USERNAME=<username> DATABASE_PASSWORD=<password> bundle exec appraisal rspec
254
+ ```
255
+
256
+ Note that the database user has to have rights to create and drop a database in
257
+ order to create the dummy test app database.
258
+
259
+ In case you are using [rbenv](https://github.com/rbenv/rbenv) and have the
260
+ [rbenv-vars](https://github.com/rbenv/rbenv-vars) plugin installed for it, you
261
+ can add these environment variables to the root directory of the project in a
262
+ file named `.rbenv-vars`. In this case, you can omit defining these in the
263
+ commands shown above.
264
+
265
+ ### Test code coverage
266
+
267
+ If you want to generate the code coverage report for the tests, you can use
268
+ the `SIMPLECOV=1` environment variable in the rspec command as follows:
269
+
270
+ ```bash
271
+ SIMPLECOV=1 bundle exec rspec
272
+ ```
273
+
274
+ This will generate a folder named `coverage` in the project root which contains
275
+ the code coverage report.
276
+
277
+ ### Appraisals commands
278
+
279
+ Appraisal uses custom gems for testing in the folder `gemfiles`, these gemfiles are generated from the file `Appraisals`. To update definitions do:
280
+
281
+ ```
282
+ bundle exec appraisal install
283
+ ```
284
+
285
+ To update the Appraisal definitions maually do the following:
286
+
287
+ ```
288
+ cd gemfiles
289
+ BUNDLE_GEMFILE=./decidim_0.XX.gemfile bundle update
290
+ ```
291
+
292
+ Where 0.XX is the supported version that needs to be updated.
293
+
294
+ ### Localization
295
+
296
+ If you would like to see this module in your own language, you can help with its
297
+ translation at Crowdin:
298
+
299
+ https://crowdin.com/translate/decidim-awesome
300
+
301
+ ## License
302
+
303
+ This engine is distributed under the GNU AFFERO GENERAL PUBLIC LICENSE.
304
+
305
+ ## Credits
306
+
307
+ This plugin has been developed by ![Platoniq](app/assets/images/decidim/decidim_awesome/platoniq-logo.png)
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "decidim/dev/common_rake"
4
+ require "fileutils"
5
+
6
+ def install_module(path)
7
+ Dir.chdir(path) do
8
+ system("bundle exec rake decidim_decidim_awesome:install:migrations")
9
+ system("bundle exec rake db:migrate")
10
+ end
11
+ end
12
+
13
+ def seed_db(path)
14
+ Dir.chdir(path) do
15
+ system("bundle exec rake db:seed")
16
+ end
17
+ end
18
+
19
+ def copy_themes
20
+ FileUtils.cp_r "lib/decidim/decidim_awesome/test/themes", "spec/decidim_dummy_app/app/assets/themes", verbose: true
21
+ end
22
+
23
+ desc "copy test theme files"
24
+ task :copy_themes do
25
+ copy_themes
26
+ end
27
+
28
+ desc "Generates a dummy app for testing"
29
+ task test_app: "decidim:generate_external_test_app" do
30
+ ENV["RAILS_ENV"] = "test"
31
+ install_module("spec/decidim_dummy_app")
32
+ copy_themes
33
+ end
34
+
35
+ desc "Generates a development app."
36
+ task :development_app do
37
+ Bundler.with_original_env do
38
+ generate_decidim_app(
39
+ "development_app",
40
+ "--app_name",
41
+ "#{base_app_name}_development_app",
42
+ "--path",
43
+ "..",
44
+ "--recreate_db",
45
+ "--demo"
46
+ )
47
+ end
48
+
49
+ install_module("development_app")
50
+ seed_db("development_app")
51
+ end
@@ -0,0 +1,3 @@
1
+ /*
2
+ *= link decidim/decidim_awesome/admin.css
3
+ */
@@ -0,0 +1 @@
1
+ // = link decidim/decidim_awesome/admin.js
@@ -0,0 +1,5 @@
1
+ /*
2
+ *= link decidim/decidim_awesome/application.css
3
+ *= link decidim/decidim_awesome/awesome_map/map.css
4
+ *= link decidim/decidim_awesome/awesome_iframe/iframe.css
5
+ */
@@ -0,0 +1,2 @@
1
+ // = link decidim/decidim_awesome/application.js
2
+ // = link decidim/decidim_awesome/awesome_map/map.js
@@ -0,0 +1,2 @@
1
+ // = require decidim/decidim_awesome/admin/constraints
2
+ // = require decidim/decidim_awesome/editors/quill_editor
@@ -0,0 +1,54 @@
1
+ // = require_self
2
+
3
+ $(() => {
4
+ const $modal = $('#constraintsModal');
5
+ if(!$modal.length) return;
6
+
7
+ $(".decidim_awesome-form").on("click", ".constraints-editor .add-condition,.constraints-editor .edit-condition", (e) => {
8
+ e.preventDefault();
9
+ const $this = $(e.target)
10
+ const url = $this.attr("href");
11
+ const $callout = $this.closest(".constraints-editor").find(".callout");
12
+ $callout.hide();
13
+ $callout.removeClass('alert success');
14
+ $modal.find('.modal-content').html('');
15
+ $modal.addClass('loading').foundation('open');
16
+ $modal.data("url", url);
17
+ $modal.find('.modal-content').load(url, () => {
18
+ $modal.removeClass('loading');
19
+ });
20
+ });
21
+
22
+ // Custom event listener to reload the modal if needed
23
+ document.body.addEventListener("constraint:change", (e) => {
24
+ const vars = e.detail.map((setting) => `${setting.key}=${setting.value}`);
25
+ const url = $modal.data("url") + "&" + vars.join("&")
26
+ $modal.addClass('loading');
27
+ $modal.find('.modal-content').load(url, () => {
28
+ $modal.removeClass('loading');
29
+ });
30
+ });
31
+
32
+ // Rails AJAX events
33
+ document.body.addEventListener('ajax:error', (responseText) => {
34
+ const $container = $(`.constraints-editor[data-key="${responseText.detail[0].key}"]`)
35
+ const $callout = $container.find(".callout");
36
+ $callout.show();
37
+ $callout.contents('p').html(responseText.detail[0].message + ": <strong>" + responseText.detail[0].error + "</strong>");
38
+ $callout.addClass('alert');
39
+ });
40
+
41
+ document.body.addEventListener('ajax:success', (responseText) => {
42
+ const $container = $(`.constraints-editor[data-key="${responseText.detail[0].key}"]`)
43
+ const $callout = $container.find(".callout");
44
+ $callout.show();
45
+ $callout.contents('p').html(responseText.detail[0].message);
46
+ $callout.addClass('success');
47
+ // reconstruct list
48
+ $container.replaceWith(responseText.detail[0].html);
49
+ });
50
+
51
+ document.body.addEventListener('ajax:complete', () => {
52
+ $modal.foundation('close');
53
+ })
54
+ });
@@ -0,0 +1,4 @@
1
+ // = require decidim/decidim_awesome/proposals/images
2
+ // = require decidim/decidim_awesome/editors/quill_editor
3
+ // = require decidim/decidim_awesome/editors/markdown_view
4
+ // = require decidim/decidim_awesome/forms/autosave
@@ -0,0 +1,38 @@
1
+ class ApiFetcher { // eslint-disable-line no-unused-vars
2
+
3
+ constructor(query, variables) {
4
+ this.query = query;
5
+ this.variables = variables;
6
+ }
7
+
8
+ fetch(callback) {
9
+ $.ajax({
10
+ method: "POST",
11
+ url: "/api",
12
+ contentType: "application/json",
13
+ data: JSON.stringify({
14
+ query: this.query,
15
+ variables: this.variables
16
+ })
17
+ }).done(function(data) {
18
+ callback(data.data);
19
+ });
20
+ }
21
+
22
+ fetchAll (callback) {
23
+ this.fetch(callback);
24
+ }
25
+
26
+ static findTranslation(translations) {
27
+ let text, lang = document.querySelector('html').getAttribute('lang');
28
+
29
+ translations.forEach((t) => {
30
+ if(t.text) {
31
+ if(!text || t.locale == lang) {
32
+ text = t.text
33
+ }
34
+ }
35
+ });
36
+ return text;
37
+ }
38
+ }