agilibox 1.0.0 → 1.11.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (135) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +321 -2
  3. data/Rakefile +4 -0
  4. data/app/assets/javascripts/agilibox/autocomplete.coffee +2 -0
  5. data/app/assets/javascripts/agilibox/checkboxes_dropdown.coffee +9 -0
  6. data/app/assets/javascripts/agilibox/modals.coffee +81 -55
  7. data/app/assets/stylesheets/agilibox/actions.sass +2 -0
  8. data/app/assets/stylesheets/agilibox/all.sass +5 -0
  9. data/app/assets/stylesheets/agilibox/buttons.sass +11 -0
  10. data/app/assets/stylesheets/agilibox/filters.sass +13 -3
  11. data/app/assets/stylesheets/agilibox/forms.sass +49 -0
  12. data/app/assets/stylesheets/agilibox/icons.sass +5 -0
  13. data/app/assets/stylesheets/agilibox/modals.sass +15 -7
  14. data/app/assets/stylesheets/agilibox/pagination.sass +7 -0
  15. data/app/assets/stylesheets/agilibox/print.sass +10 -0
  16. data/app/assets/stylesheets/agilibox/tables.sass +26 -0
  17. data/app/controllers/agilibox/application_controller.rb +2 -4
  18. data/app/controllers/agilibox/small_data/filters_controller.rb +8 -6
  19. data/app/controllers/concerns/agilibox/api_controller_concern.rb +69 -0
  20. data/app/controllers/concerns/agilibox/back_url_concern.rb +13 -5
  21. data/app/emails/agilibox/email.rb +113 -0
  22. data/app/filters/agilibox/small_data/filter.rb +19 -1
  23. data/app/filters/agilibox/small_data/filter_strategy.rb +1 -1
  24. data/app/filters/agilibox/small_data/filter_strategy_by_date_begin.rb +3 -2
  25. data/app/filters/agilibox/small_data/filter_strategy_by_date_end.rb +3 -2
  26. data/app/filters/agilibox/small_data/filter_strategy_by_date_or_datetime_period.rb +56 -0
  27. data/app/filters/agilibox/small_data/filter_strategy_by_date_period.rb +5 -0
  28. data/app/filters/agilibox/small_data/filter_strategy_by_datetime_period.rb +5 -0
  29. data/app/filters/agilibox/small_data/filter_strategy_by_key_value.rb +14 -3
  30. data/app/filters/agilibox/small_data/filter_strategy_by_key_values.rb +13 -0
  31. data/app/filters/agilibox/small_data/filter_strategy_by_tags.rb +1 -1
  32. data/app/forms/agilibox/mini_form_object.rb +29 -0
  33. data/app/helpers/agilibox/all_helpers.rb +2 -0
  34. data/app/helpers/agilibox/bootstrap_helper.rb +62 -3
  35. data/app/helpers/agilibox/button_helper.rb +22 -13
  36. data/app/helpers/agilibox/filters_helper.rb +7 -8
  37. data/app/helpers/agilibox/font_awesome_helper.rb +67 -0
  38. data/app/helpers/agilibox/form_helper.rb +37 -14
  39. data/app/helpers/agilibox/i18n_helper.rb +5 -0
  40. data/app/helpers/agilibox/link_helper.rb +1 -1
  41. data/app/helpers/agilibox/pagination_helper.rb +18 -2
  42. data/app/helpers/agilibox/routes_helper.rb +6 -2
  43. data/app/helpers/agilibox/sorting_helper.rb +9 -4
  44. data/app/helpers/agilibox/text_helper.rb +51 -26
  45. data/app/helpers/h.rb +3 -0
  46. data/app/jobs/concerns/agilibox/setup_job_concern.rb +35 -0
  47. data/app/libs/agilibox/collection_update.rb +32 -0
  48. data/app/libs/agilibox/fcm/notifier.rb +28 -0
  49. data/app/libs/agilibox/fcm/request.rb +48 -0
  50. data/app/libs/agilibox/initialize_with.rb +20 -0
  51. data/app/libs/agilibox/mini_model_serializer/serialize.rb +30 -0
  52. data/app/libs/agilibox/mini_model_serializer/serializer.rb +23 -0
  53. data/app/libs/agilibox/monkey.rb +39 -0
  54. data/app/libs/agilibox/phone_number_sanitizer.rb +15 -0
  55. data/app/libs/agilibox/sortable_uuid_generator.rb +1 -1
  56. data/app/libs/agilibox/token_generator.rb +37 -0
  57. data/app/mailers/agilibox/application_mailer.rb +2 -0
  58. data/app/mailers/agilibox/generic_mailer.rb +9 -0
  59. data/app/models/concerns/agilibox/active_record_uuid_concern.rb +4 -2
  60. data/app/models/concerns/agilibox/default_values_concern.rb +4 -3
  61. data/app/models/concerns/agilibox/model_i18n.rb +37 -6
  62. data/app/models/concerns/agilibox/pluck_distinct.rb +13 -0
  63. data/app/models/concerns/agilibox/pluck_to_hash.rb +9 -0
  64. data/app/models/concerns/agilibox/polymorphic_id.rb +5 -2
  65. data/app/models/concerns/agilibox/search.rb +11 -13
  66. data/app/models/concerns/agilibox/timestamp_helpers.rb +17 -0
  67. data/app/serializers/agilibox/serializers/base.rb +47 -1
  68. data/app/serializers/agilibox/serializers/xlsx.rb +25 -23
  69. data/app/services/agilibox/service.rb +17 -0
  70. data/app/sms/agilibox/sms/application_sms.rb +42 -0
  71. data/app/sms/agilibox/sms/message.rb +25 -0
  72. data/app/sms/agilibox/sms/strategies/amazon_sns.rb +48 -0
  73. data/app/sms/agilibox/sms/strategies/base.rb +15 -0
  74. data/app/sms/agilibox/sms/strategies/test.rb +10 -0
  75. data/app/sms/agilibox/sms.rb +35 -0
  76. data/app/sorters/agilibox/sorter.rb +26 -0
  77. data/app/views/agilibox/_flash.html.slim +9 -0
  78. data/app/views/agilibox/forms/_checkboxes_dropdown.html.slim +14 -0
  79. data/app/views/agilibox/search/_form.html.slim +1 -6
  80. data/app/views/agilibox/search/_form_bs3.html.slim +13 -0
  81. data/app/views/agilibox/search/_form_bs4.html.slim +9 -0
  82. data/app/views/agilibox/search/_form_bs5.html.slim +8 -0
  83. data/app/views/kaminari/bootstrap4/_first_page.html.slim +2 -0
  84. data/app/views/kaminari/bootstrap4/_gap.html.slim +2 -0
  85. data/app/views/kaminari/bootstrap4/_last_page.html.slim +2 -0
  86. data/app/views/kaminari/bootstrap4/_next_page.html.slim +2 -0
  87. data/app/views/kaminari/bootstrap4/_page.html.slim +6 -0
  88. data/app/views/kaminari/bootstrap4/_paginator.html.slim +12 -0
  89. data/app/views/kaminari/bootstrap4/_prev_page.html.slim +2 -0
  90. data/config/cucumber.yml +9 -0
  91. data/config/locales/actions.en.yml +76 -0
  92. data/config/locales/actions.fr.yml +76 -0
  93. data/config/locales/attributes.en.yml +108 -0
  94. data/config/locales/attributes.fr.yml +108 -0
  95. data/config/locales/common.en.yml +0 -160
  96. data/config/locales/common.fr.yml +0 -171
  97. data/config/locales/dates.fr.yml +8 -0
  98. data/config/locales/errors.en.yml +5 -0
  99. data/config/locales/errors.fr.yml +5 -0
  100. data/db/migrate/20000101000000_enable_agilibox_extensions.rb +7 -0
  101. data/lib/agilibox/active_model_custom_error_messages.rb +23 -0
  102. data/lib/agilibox/active_model_type_cast.rb +52 -0
  103. data/lib/agilibox/config.rb +19 -0
  104. data/lib/agilibox/core_and_rails_ext.rb +2 -1
  105. data/lib/agilibox/cucumber_config.rb +53 -0
  106. data/lib/agilibox/cucumber_helpers/agilibox.rb +2 -0
  107. data/lib/agilibox/cucumber_helpers/ajax.rb +18 -0
  108. data/lib/agilibox/cucumber_helpers/apparition.rb +18 -0
  109. data/lib/agilibox/cucumber_helpers/capybara.rb +12 -0
  110. data/lib/agilibox/cucumber_helpers/capybara_selectors.rb +7 -0
  111. data/lib/agilibox/cucumber_helpers/chrome_headless.rb +16 -0
  112. data/lib/agilibox/cucumber_helpers/common_steps.rb +139 -0
  113. data/lib/agilibox/cucumber_helpers/cuprite.rb +20 -0
  114. data/lib/agilibox/cucumber_helpers/database_cleaner.rb +8 -0
  115. data/lib/agilibox/cucumber_helpers/factory_bot.rb +1 -0
  116. data/lib/agilibox/cucumber_helpers/rails.rb +1 -0
  117. data/lib/agilibox/cucumber_helpers/rspec.rb +6 -0
  118. data/lib/agilibox/cucumber_helpers/screenshots.rb +3 -0
  119. data/lib/agilibox/cucumber_helpers/select2.rb +23 -0
  120. data/lib/agilibox/cucumber_helpers/sign_in.rb +17 -0
  121. data/lib/agilibox/cucumber_helpers/simplecov.rb +1 -0
  122. data/lib/agilibox/cucumber_helpers/timecop.rb +3 -0
  123. data/lib/agilibox/cucumber_helpers/turbolinks.rb +34 -0
  124. data/lib/agilibox/cucumber_helpers/zonebie.rb +4 -0
  125. data/lib/agilibox/engine.rb +15 -0
  126. data/lib/agilibox/engine_file.rb +10 -0
  127. data/lib/agilibox/errors_middleware.rb +50 -0
  128. data/lib/agilibox/form_back_url.rb +4 -4
  129. data/lib/agilibox/rspec.rb +29 -0
  130. data/lib/agilibox/test_helpers.rb +13 -0
  131. data/lib/agilibox/version.rb +1 -1
  132. data/lib/tasks/cucumber.rake +76 -0
  133. metadata +165 -9
  134. data/app/filters/agilibox/small_data/filter_strategy_by_time_period.rb +0 -37
  135. data/lib/agilibox/active_record_comma_type_cast.rb +0 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 5f40e64e11fd724ef38a9e29fcdceb9679c6c060
4
- data.tar.gz: f6a811edd6333dae0b8e9823516ff3e118bafca4
2
+ SHA256:
3
+ metadata.gz: 73e2e45e1fed7a2e0cec02d337dc0afa3bf0112e4b26ec3168d8b62e0f64c961
4
+ data.tar.gz: 9a79efe0583a84370cc71d57468e6083b77032053c59ae702c9c557a3cac3dd4
5
5
  SHA512:
6
- metadata.gz: a43f05bc2d8d9dfc8158651e2588b889c808feff3539dae6bf54ccea3c2dc02d41fe85493b34fe16144ba39ea3298f4d43739f46902adf9e80ca9f10d4605db4
7
- data.tar.gz: c31306c47052b96c236dfaf0b26cacd8dcd7da703e694654014177393476ba42a28bde890e3583c8a99fc429696d85a47702f7579118c3ecc92101b024599a12
6
+ metadata.gz: 80764451b386701e1e0033ed885589c1e95bff2bd973cc022dc706ce828fc86f1ac8c947c8bbe5b6f394e395fa5c1e9f933b45fb0173fe03d7ef3c088bc2eed2
7
+ data.tar.gz: 727f23e415b4aa280e2d96bc91d3016636e2e8f76a8a197218b9a8ef93797e638fb9637f880603293476c0ad6960fcd6d1974f74a1669184f20624f4b8169222
data/CHANGELOG.md CHANGED
@@ -2,10 +2,329 @@
2
2
 
3
3
  ## Next version
4
4
 
5
- Nothing.
5
+ ## v1.11.0
6
+ - Add ActionDispatch::Http::MimeNegotiation::InvalidType to errors middleware
7
+ - Fix inverted forbidden/unauthorized
6
8
 
7
- ## 1.0.0
9
+ ## v1.10.5
10
+ - Fix hidden_inputs_for_get_form again
11
+
12
+ ## v1.10.4
13
+ - Fix hidden_inputs_for_get_form
14
+
15
+ ## v1.10.3
16
+ - Fix search forms to preserve GET params
17
+
18
+ ## v1.10.2
19
+ - Filters improvements
20
+
21
+ ## v1.10.1
22
+ - Fix date filters
23
+
24
+ ## v1.10.0
25
+ - Add date support to XLSX serializer
26
+ - Remove AXLSX serializer
27
+
28
+ ## v1.9.20
29
+ - Add bootstrap 5 search form
30
+
31
+ ## v1.9.19
32
+ - Add bootstrap 4/5 pagination support
33
+
34
+ ## v1.9.18
35
+ - Rails 6.1 compatibility
36
+
37
+ ## v1.9.17
38
+ - Fix capybara selector
39
+
40
+ ## v1.9.16
41
+ - Fix Rails 6.1 warnings
42
+
43
+ ## v1.9.15
44
+ - Add `modal:before-close` event
45
+
46
+ ## v1.9.14
47
+ - Fix syntax error on Ruby < 2.7
48
+
49
+ ## v1.9.13
50
+ - Add apparition capybara driver
51
+
52
+ ## v1.9.12
53
+ - Fix some Ruby 2.7 warnings
54
+
55
+ ## v1.9.11
56
+ - Fix some Ruby 2.7 warnings
57
+
58
+ ## v1.9.10
59
+ - Fix some Ruby 2.7 warnings
60
+
61
+ ## v1.9.9
62
+ - Add error to ErrorsMiddleware
63
+
64
+ ## v1.9.8
65
+ - Fix `tags` helper
66
+
67
+ ## v1.9.7
68
+ - Change XLSX export
69
+
70
+ ## v1.9.6
71
+ - Fix info helper with false
72
+ - Update Rubocop + fix offences
73
+
74
+ ## 1.9.5
75
+ - Fix warnings on Rails 6
76
+
77
+ ## 1.9.4
78
+ - Cucumber : disable Zonebie
79
+
80
+ ## 1.9.3
81
+ - No change
82
+
83
+ ## 1.9.2
84
+ - ErrorsMiddleware improvements
85
+
86
+ ## 1.9.1
87
+ - Add ErrorsMiddleware
88
+
89
+ ## 1.9.0
90
+ - Remove phantomjs/poltergeist support
91
+ - BackUrlConcern transforms absolute URLs to relative
92
+
93
+ ## 1.8.0
94
+ - SMS improvements
95
+ - Replace TapMethods by Tapenade gem
96
+ - Add nilify_blanks dependency
97
+
98
+ ## 1.7.4
99
+ - Add `tap_update_columns`and `tap_update_column`
100
+
101
+ ## 1.7.3
102
+ - Do not require auth in FiltersController
103
+ - Refactor FiltersController Pundit after_actions
104
+
105
+ ## 1.7.2
106
+ - Fix FontAwesome helper
107
+
108
+ ## 1.7.1
109
+ - Cuprite : improve config + increase timeout
110
+
111
+ ## 1.7.0
112
+ - ActiveRecord/ActiveModel type cast : refactor + add date + add boolean
113
+
114
+ ## 1.6.2
115
+ - Fix cucumber/capybara helpers
116
+
117
+ ## 1.6.1
118
+ - Add `SetupJobConcern`
119
+
120
+ ## 1.6.0
121
+ - Remove `GetHTTP`
122
+ - I18n fixes
123
+ - Add `Agilibox::TapMethods`
124
+ - Filters CSS : add flex-wrap
125
+ - Add `bs_card` helper
126
+ - Add `:br` separator to `info` helper
127
+ - TextHelper refactors
128
+ - Update dummy app to Rails 5.2
129
+ - Replace AXLSX by SpreadsheetArchitect
130
+
131
+ ## 1.5.13
132
+ - Fix `info` helper with nested blank value
133
+
134
+ ## 1.5.12
135
+ - Cuprite config improvements
136
+
137
+ ## 1.5.11
138
+ - Add `nbsp` helper
139
+ - Add `PluckDistinct` model concern
140
+ - Add pagination helpers
141
+
142
+ ## 1.5.10
143
+ - Cucumber Helpers : add cuprite support
144
+
145
+ ## 1.5.9
146
+ - I18n fix
147
+ - Add `bs_progress_bar` helper
148
+
149
+ ## 1.5.8
150
+ - Add GetHTTP#response
8
151
 
152
+ ## 1.5.7
153
+ - `download_button` and `export_button` fixes
154
+ - checkboxes-dropdown CSS improvements
155
+ - Change searchbar CSS
156
+
157
+ ## 1.5.6
158
+ - Various fixes on filters
159
+
160
+ ## 1.5.5
161
+ - Add ModelI18n::raise_on_missing_translations option
162
+
163
+ ## 1.5.4
164
+ - Cucumber "click on" steps improvement
165
+
166
+ ## 1.5.3
167
+ - Fix FontAwesome >=5.6
168
+
169
+ ## 1.5.2
170
+ - GetHTTP service improvements
171
+ - New common steps + improvements
172
+
173
+ ## 1.5.1
174
+ - Add CSS helpers
175
+ - Add Cucumber common steps
176
+ - Add Cucumber select2 helper
177
+
178
+ ## 1.5.0
179
+ - Add `GetHTTP`
180
+ - Add BS4 search form
181
+
182
+ ## 1.4.4
183
+ - Fix i18n error on `info` helper
184
+
185
+ ## 1.4.3
186
+ - `form_buttons` helper fixes and improvements
187
+
188
+ ## 1.4.2
189
+ - Fix FontAwesome helper
190
+
191
+ ## 1.4.1
192
+ - FCM request handle JSON errors
193
+
194
+ ## 1.4.0
195
+ - Add `Agilibox::Email`
196
+ - Add `Agilibox.parent_controller` config
197
+ - Add `Agilibox.parent_mailer` config
198
+ - Filters improvements
199
+
200
+ ## 1.3.6
201
+ - Remove deprecated `Agilibox::SortableUUIDGenerator::generate`
202
+ - `Agilibox::ActiveRecordUUIDConcern` improvements
203
+ - `Agilibox::DefaultValuesConcern` improvements
204
+ - Fix FontAwesome version error
205
+
206
+ ## 1.3.5
207
+ - Add `Agilibox::Monkey`
208
+
209
+ ## 1.3.4
210
+ - Support FontAwesome v4
211
+
212
+ ## 1.3.3
213
+ - Fix error messages
214
+
215
+ ## 1.3.2
216
+ - Add `Agilibox::ActiveModelCustomErrorMessages`
217
+
218
+ ## 1.3.1
219
+ - `ApiControllerConcern` refactor + helpers
220
+
221
+ ## 1.3.0
222
+ - ApiControllerConcern : add `model_errors` in json response
223
+ - `json_response` is now a `HashWithIndifferentAccess`
224
+
225
+ ## 1.2.3
226
+ - Add FCM
227
+
228
+ ## 1.2.2
229
+ - Add CollectionUpdate
230
+ - Rename Agilibox::SortableUUIDGenerator::generate to ::call
231
+
232
+ ## 1.2.1
233
+ - Fix flash partial
234
+ - Filter by date/datetime period now allows custom periods
235
+ - Sorter class improvements
236
+
237
+ ## 1.2.0
238
+ - Add `Agilibox::MiniFormObject`
239
+ - Replace time period filter by date+datetime period filters
240
+ - JS Modal improvements
241
+ - Change Cucumber config :
242
+ - add Chrome Headless support
243
+ - rename `phantomjs_window_size` to `window_size`
244
+ - refactoring
245
+ - you now need to add `Agilibox::CucumberConfig.require_poltergeist!` or `Agilibox::CucumberConfig.require_chrome_headless!` to your `env.rb`
246
+
247
+ ## 1.1.0
248
+ - Search concern improvements
249
+ - Date helper improvements
250
+ - Add `boolean_icon` helper
251
+ - Add i18n attributes
252
+ - Add `Agilibox::PluckToHash`
253
+ - Switch to FontAwesome 5 + `icon` helper improvements
254
+
255
+ ## 1.0.15
256
+ - `ApiControllerConcern#render_json_error` improvements
257
+ - Add Agilibox::Service object
258
+ - Fix SMS AmazonSNS strategy bug
259
+ - Fix time period filter
260
+
261
+ ## 1.0.14
262
+ - Sorting helper improvements
263
+ - FormBackUrl fixes
264
+ - FiltersHelper fixes
265
+
266
+ ## 1.0.13
267
+ - Modal JS fix
268
+
269
+ ## 1.0.12
270
+ - `.checkboxes-dropdown` CSS fix
271
+ - Fix sorting helper
272
+
273
+ ## 1.0.11
274
+ - Add Agilibox::SMS
275
+ - Test helpers improvements
276
+
277
+ ## 1.0.10
278
+ - Add TokenGenerator
279
+ - Add PhoneNumberSanitizer
280
+ - Add engine_file helper to Kernel
281
+ - Syntax improvements and refactors
282
+ - Add H alias of Agilibox::AllHelpers
283
+ - Add TimestampHelpers
284
+ - Add MiniModelSerializer
285
+ - Add ApiControllerConcern
286
+
287
+ ## 1.0.9
288
+ - Fix Model#tv
289
+ - Add cucumber helpers
290
+
291
+ ## 1.0.8
292
+ - Serializers improvements
293
+
294
+ ## 1.0.7
295
+ - Search form add reset button
296
+ - Filter form fix default submit button
297
+
298
+ ## 1.0.6
299
+ - Add checkboxes_dropdown helper
300
+ - Add FilterStrategyByKeyValues
301
+ - bs_button improvements
302
+ - Add Filter#any? and Filter#empty?
303
+ - Add i18n actions
304
+ - Add ModelI18n#tv
305
+ - Split i18n files
306
+
307
+ ## 1.0.5
308
+ - Fix `import_button` helper
309
+ - Add mime types
310
+
311
+ ## 1.0.4
312
+ - Search now ignore accents
313
+ - Add Sorter class
314
+
315
+ ## 1.0.3
316
+ - Add `ta` (translate action) helper
317
+ - Add `blank` css class to `info` helper
318
+ - Add autocomplete.coffee
319
+
320
+ ## 1.0.2
321
+ - Button helper changes
322
+ - Modals use event delegation
323
+
324
+ ## 1.0.1
325
+ - Remove AXLSX dependency
326
+
327
+ ## 1.0.0
9
328
  - First version imported from agilidee/dorsale
10
329
  - `sortable_column_order` now returns symbols
11
330
  - modal fixes + allow upload
data/Rakefile CHANGED
@@ -35,3 +35,7 @@ end
35
35
 
36
36
 
37
37
  task default: :test
38
+
39
+ task "assets:precompile" do
40
+ Rake::Task["app:assets:precompile"].invoke
41
+ end
@@ -0,0 +1,2 @@
1
+ $(document).on "turbolinks:load", ->
2
+ $("select.select2").map -> $(this).select2()
@@ -0,0 +1,9 @@
1
+ $(document).on "click", ".checkboxes-dropdown .dropdown-menu", (e) ->
2
+ e.stopPropagation()
3
+
4
+ $(document).on "change", ".checkboxes-dropdown [type=checkbox]", ->
5
+ $dropdown = $(this).parents(".checkboxes-dropdown")
6
+ $dropdown.find(".number").html $dropdown.find(":checked").length
7
+
8
+ $(document).on "turbolinks:load", ->
9
+ $(".checkboxes-dropdown [type=checkbox]").change()
@@ -4,12 +4,12 @@ window.modal =
4
4
  error: "Error."
5
5
 
6
6
  template: """
7
- <div id='modal' class='closable'>
8
- <div id='modal-overlay'></div>
7
+ <div id="modal" class="closable">
8
+ <div id="modal-overlay"></div>
9
9
 
10
- <button id='modal-close'>×</button>
10
+ <button id="modal-close">&times;</button>
11
11
 
12
- <div id='modal-body'>
12
+ <div id="modal-body">
13
13
  {{content}}
14
14
  </div>
15
15
  </div>
@@ -19,7 +19,7 @@ window.modal =
19
19
  $(modal.template.replace("{{content}}", content))
20
20
 
21
21
  open: (content) ->
22
- if modal.is_opened()
22
+ if modal.isOpened()
23
23
  modal._update(content)
24
24
  else
25
25
  modal._create(content)
@@ -32,34 +32,45 @@ window.modal =
32
32
  _update: (content) ->
33
33
  $("#modal-body").html(content)
34
34
 
35
- close: ->
35
+ close: (event) ->
36
+ event.preventDefault() if event
37
+ $(document).trigger("modal:before-close")
36
38
  $("body").removeClass("modal-open")
37
39
  $("#modal").remove()
38
40
  $(document).trigger("modal:close")
39
- return false
41
+ return true
40
42
 
41
- is_opened: ->
42
- return $("#modal").length > 0
43
+ isOpened: -> return $("#modal").length > 0
43
44
 
44
- is_closed: ->
45
- return $("#modal").length == 0
45
+ isClosed: -> return $("#modal").length == 0
46
46
 
47
- is_closable: ->
48
- return $("#modal").hasClass("closable")
47
+ isClosable: -> return $("#modal").hasClass("closable")
49
48
 
50
- autoclose: ->
51
- modal.close() if modal.is_closable()
52
- return false
49
+ autoclose: (event) ->
50
+ event.preventDefault() if event
51
+ modal.close() if modal.isClosable()
52
+ return true
53
53
 
54
- set_closable: ->
55
- $("#modal").addClass("closable")
54
+ # Modes : normal, nested, off, unknown
55
+ setModalMode: (mode) ->
56
+ mode = modal.parseModalMode(mode)
57
+ if mode != "unknown"
58
+ try document.querySelector("#modal").dataset.modal = mode
59
+ return true
56
60
 
57
- set_unclosable: ->
58
- $("#modal").removeClass("closable")
61
+ parseModalMode: (mode) ->
62
+ if String(mode) == "1"
63
+ console.log("[data-modal=1] if deprecated, please use [data-modal=nested] or [data-modal=normal]")
64
+ return "nested"
59
65
 
60
- _set_closable_for_element: (element) ->
61
- return modal.set_closable() if $(element).is("[data-modal-closable=1]")
62
- return modal.set_unclosable() if $(element).is("[data-modal-closable=0]")
66
+ if String(mode) == "0"
67
+ console.log("[data-modal=0] if deprecated, please use [data-modal=off]")
68
+ return "off"
69
+
70
+ if mode == "off" || mode == "normal" || mode == "nested"
71
+ return mode
72
+ else
73
+ return "unknown"
63
74
 
64
75
  openUrl: (url, type = "GET", data = {}) ->
65
76
  modal.open(modal.i18n.loading)
@@ -85,45 +96,60 @@ window.modal =
85
96
 
86
97
  error: ->
87
98
  modal.open(modal.i18n.error)
88
- modal.set_closable()
89
99
 
90
100
  _callbacks:
91
- links: ->
101
+ links: (event) ->
102
+ return unless modal.shouldOpenInModalForElement(this)
103
+
104
+ event.preventDefault()
92
105
  modal.openUrl(this.href)
93
- modal._set_closable_for_element(this)
94
- return false
106
+ modal.setModalMode(this.dataset.modal)
107
+
108
+ forms: (event) ->
109
+ return unless modal.shouldOpenInModalForElement(this)
110
+
111
+ event.preventDefault()
95
112
 
96
- forms: ->
97
- modal.openUrl(this.action, this.method, new FormData(this))
98
- modal._set_closable_for_element(this)
99
- return false
113
+ if String(this.method).toLowerCase() == "get"
114
+ data = $(this).serialize()
115
+ else
116
+ data = new FormData(this)
117
+
118
+ modal.openUrl(this.action, this.method, data)
119
+ modal.setModalMode(this.dataset.modal)
100
120
 
101
121
  escape: (event) ->
102
122
  modal.autoclose() if event.keyCode == 27
123
+
124
+ shouldOpenInModalForElement: (element) ->
125
+ # ALWAYS ignore
126
+ return false if String(element.href).indexOf("javascript:") == 0
127
+ return false if String(element.href).indexOf("mailto:") == 0
128
+ return false if String(element.href).indexOf("tel:") == 0
129
+ return false if String(element.href).indexOf("sms:") == 0
130
+ return false if String(element.target).indexOf("_") == 0
131
+ return false if String(element.dataset.remote || "") != ""
132
+ return false if String(element.dataset.method || "") != ""
133
+ return false if modal.parseModalMode(element.dataset.modal) == "off"
134
+
135
+ # True if element mode is NORMAL or NESTED
136
+ elementMode = modal.parseModalMode(element.dataset.modal)
137
+ return true if elementMode == "normal" || elementMode == "nested"
138
+
139
+ # True if element is inside a NESTED modal
140
+ if $(element).parents("#modal[data-modal=nested]").length
141
+ return true
142
+
143
+ # Hidden forms created by jquery_ujs for remote links inside a NESTED modal
144
+ if $(element).parent().is("body.modal-open") && $("#modal[data-modal=nested]").length
103
145
  return true
104
146
 
147
+ return false
148
+
105
149
  setup: ->
106
- $(document)
107
- .off("keyup", modal._callbacks.escape)
108
- .on("keyup", modal._callbacks.escape)
109
-
110
- $("#modal-overlay, #modal-close")
111
- .off("click", modal.autoclose)
112
- .on("click", modal.autoclose)
113
-
114
- $("a[href][data-modal=1], #modal-body a[href]")
115
- .not("[data-modal=0]")
116
- .not("[data-method]")
117
- .not("[data-remote]")
118
- .off("click", modal._callbacks.links)
119
- .on("click", modal._callbacks.links)
120
-
121
- $("form[data-modal=1], #modal-body form")
122
- .not("[data-modal=0]")
123
- .not("[data-remote]")
124
- .off("submit", modal._callbacks.forms)
125
- .on("submit", modal._callbacks.forms)
126
-
127
-
128
- $(document).on "turbolinks:load modal:open", ->
129
- modal.setup()
150
+ $(document).on("keyup", modal._callbacks.escape)
151
+ $(document).on("click", "#modal-overlay, #modal-close, .modal-autoclose", modal.autoclose)
152
+ $(document).on("click", "a", modal._callbacks.links)
153
+ $(document).on("submit", "form", modal._callbacks.forms)
154
+
155
+ modal.setup()
@@ -0,0 +1,2 @@
1
+ .actions.top
2
+ text-align: right
@@ -1,5 +1,10 @@
1
+ @import agilibox/actions
2
+ @import agilibox/buttons
1
3
  @import agilibox/filters
2
4
  @import agilibox/flash
5
+ @import agilibox/forms
6
+ @import agilibox/icons
3
7
  @import agilibox/modals
4
8
  @import agilibox/pagination
5
9
  @import agilibox/print
10
+ @import agilibox/tables
@@ -0,0 +1,11 @@
1
+ // .btn-xs has been removed in Bootstrap 4
2
+ .btn-xs
3
+ padding: 1px 5px
4
+ font-size: 12px
5
+
6
+ // .btn-default has been removed in Bootstrap 4
7
+ .btn-default
8
+ @extend .btn-outline-primary !optional
9
+
10
+ .btn + .btn
11
+ margin-left: 0.5em
@@ -1,8 +1,14 @@
1
1
  .filters
2
- @extend .well
2
+ // Bootstrap 3
3
+ @extend .well !optional
4
+ // Bootstrap 4
5
+ @extend .card !optional
3
6
  padding: 8px
4
7
  box-shadow: none
5
8
  display: flex
9
+ flex-wrap: wrap
10
+ flex-direction: initial
11
+ background: #F0F0F0
6
12
 
7
13
  select,
8
14
  button,
@@ -20,14 +26,18 @@
20
26
  margin: 0
21
27
 
22
28
  .form-control,
23
- @extend .input-sm
29
+ // Bootstrap 3
30
+ @extend .input-sm !optional
31
+ // Bootstrap 4
32
+ @extend .form-control-sm !optional
24
33
  display: inline-block
25
34
  width: auto
26
35
 
27
36
  .btn
28
37
  @extend .btn-sm
29
38
 
30
- input[id*=date]
39
+ input[type=date],
40
+ input[type=text][id*=date],
31
41
  width: 8em
32
42
 
33
43
  .select2-container
@@ -0,0 +1,49 @@
1
+ .checkboxes-dropdown
2
+ .checkbox
3
+ display: block
4
+
5
+ label
6
+ position: static
7
+ margin: 0
8
+ padding: 0
9
+
10
+ input[type=checkbox]
11
+ position: static
12
+ margin: 0 0.5em 0 0
13
+ width: auto
14
+
15
+ .dropdown-menu
16
+ width: 350px
17
+ max-height: 400px
18
+ max-height: calc(100vh - 300px)
19
+ overflow: auto
20
+
21
+ @media (min-height: 700px)
22
+ max-height: 400px
23
+
24
+ // Chrome and Safari does not trigger display:none submit buttons on <enter> key press
25
+ .hidden-submit
26
+ position: absolute
27
+ top: -9999px
28
+ left: -9999px
29
+ opacity: 0
30
+ height: 0
31
+ width: 0
32
+ visibility: hidden
33
+
34
+ form.search
35
+ max-width: 25em
36
+
37
+ .search-middle form.search,
38
+ .search-right form.search,
39
+ margin-left: auto
40
+
41
+ .search-left form.search,
42
+ .search-middle form.search,
43
+ margin-right: auto
44
+
45
+ .form-actions
46
+ text-align: center
47
+ margin-top: 45px
48
+ padding-top: 15px
49
+ border-top: 1px solid #ccc
@@ -0,0 +1,5 @@
1
+ .fa,
2
+ .fab,
3
+ .far,
4
+ .fas,
5
+ @extend .fa-fw