headmin 0.5.3 → 0.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +1 -1
  3. data/app/assets/javascripts/headmin/controllers/media_controller.js +14 -14
  4. data/app/assets/javascripts/headmin/controllers/media_modal_controller.js +5 -5
  5. data/app/assets/javascripts/headmin/controllers/remote_modal_controller.js +1 -2
  6. data/app/assets/javascripts/headmin/controllers/textarea_controller.js +3 -3
  7. data/app/assets/javascripts/headmin.js +11 -11
  8. data/app/assets/stylesheets/headmin/forms/repeater.scss +0 -4
  9. data/app/assets/stylesheets/headmin/forms.scss +0 -6
  10. data/app/assets/stylesheets/headmin/overrides/redactorx.scss +1 -1
  11. data/app/assets/stylesheets/headmin/vendor/{tom-select-bootstrap.css → tom-select-bootstrap.scss} +0 -1
  12. data/app/assets/stylesheets/headmin.css +5 -9
  13. data/app/models/concerns/headmin/field.rb +1 -1
  14. data/app/models/headmin/filter/association.rb +86 -0
  15. data/app/models/headmin/filter/association_view.rb +74 -0
  16. data/app/models/headmin/filter/base.rb +5 -2
  17. data/app/models/headmin/filter/boolean_view.rb +1 -0
  18. data/app/models/headmin/filter/date_view.rb +1 -0
  19. data/app/models/headmin/filter/flatpickr_view.rb +1 -0
  20. data/app/models/headmin/filter/number_view.rb +1 -0
  21. data/app/models/headmin/filter/operator_view.rb +3 -1
  22. data/app/models/headmin/filter/options_view.rb +1 -0
  23. data/app/models/headmin/filter/text_view.rb +1 -0
  24. data/app/models/headmin/form/association_view.rb +102 -0
  25. data/app/models/headmin/form/blocks_view.rb +4 -1
  26. data/app/models/headmin/form/file_view.rb +0 -8
  27. data/app/models/headmin/form/flatpickr_view.rb +2 -1
  28. data/app/models/headmin/form/media_item_view.rb +39 -0
  29. data/app/models/headmin/form/media_view.rb +27 -3
  30. data/app/models/headmin/form/select_view.rb +2 -1
  31. data/app/models/headmin/thumbnail_view.rb +40 -19
  32. data/app/models/view_model.rb +4 -0
  33. data/app/views/headmin/_filters.html.erb +7 -2
  34. data/app/views/headmin/_thumbnail.html.erb +32 -8
  35. data/app/views/headmin/filters/_association.html.erb +24 -0
  36. data/app/views/headmin/filters/_options.html.erb +1 -1
  37. data/app/views/headmin/forms/_association.html.erb +30 -0
  38. data/app/views/headmin/forms/_file.html.erb +4 -5
  39. data/app/views/headmin/forms/_media.html.erb +7 -5
  40. data/app/views/headmin/forms/_repeater.html.erb +10 -8
  41. data/app/views/headmin/forms/_wrapper.html.erb +0 -1
  42. data/app/views/headmin/forms/fields/_list.html.erb +6 -4
  43. data/app/views/headmin/forms/media/_item.html.erb +18 -12
  44. data/app/views/headmin/forms/repeater/_row.html.erb +2 -1
  45. data/app/views/headmin/media/_item.html.erb +1 -2
  46. data/app/views/headmin/media/_media_item_modal.html.erb +2 -2
  47. data/app/views/headmin/table/body/_association.html.erb +17 -3
  48. data/app/views/headmin/views/devise/shared/_links.html.erb +14 -20
  49. data/config/locales/activerecord/en.yml +1 -0
  50. data/config/locales/activerecord/nl.yml +1 -0
  51. data/config/locales/headmin/filters/en.yml +3 -1
  52. data/config/locales/headmin/filters/nl.yml +2 -0
  53. data/config/locales/headmin/media/en.yml +2 -2
  54. data/config/locales/headmin/media/nl.yml +2 -1
  55. data/lib/headmin/version.rb +1 -1
  56. data/package.json +1 -1
  57. metadata +9 -3
@@ -1,26 +1,32 @@
1
1
  <%
2
- attachment = form.object
3
- filename = attachment.blob&.filename&.to_s
4
- size = number_to_human_size(attachment.blob&.byte_size || 0)
5
- src = nil
6
- if attachment.blob
7
- src = attachment.image? ? url_for(attachment.variant(resize_to_fill: [100, 100])) : url_for(attachment)
8
- end
2
+ # headmin/forms/media/item
3
+ #
4
+ # ==== Required parameters
5
+ # * +form+ - Form object
6
+ # * +url+ - URL for the media modal
7
+ #
8
+ # ==== Optional parameters
9
+ # * +sort+ - Allow sorting by dragging items. `active_storage_attachments` must have a position column.
10
+ # * +width+ - Width of the thumbnail
11
+ # * +height+ - Height of the thumbnail
12
+ #
13
+
14
+ media_item = Headmin::Form::MediaItemView.new(local_assigns)
9
15
  %>
10
16
 
11
- <div class="h-form-file-thumbnail media-drag-sort-handle" title="<%= "#{filename} (#{size})" %>" data-media-target="item">
17
+ <div class="h-form-file-thumbnail media-drag-sort-handle" title="<%= "#{media_item.filename} (#{media_item.size})" %>" data-media-target="item">
12
18
  <%= form.hidden_field(:id) %>
13
19
  <%= form.hidden_field(:blob_id) %>
14
- <%= form.hidden_field(:position, value: attachment.new_record? ? nil : attachment.position) if sort %>
20
+ <%= form.hidden_field(:position, value: media_item.position_value) if media_item.sort %>
15
21
  <%= form.hidden_field(:_destroy) %>
16
22
 
17
- <a href="<%= url %>" data-turbo-frame="remote_modal" data-media-target="modalButton">
18
- <%= render "headmin/thumbnail", src: src, width: 100, height: 100 %>
23
+ <a href="<%= media_item.url %>" data-turbo-frame="remote_modal" data-media-target="modalButton">
24
+ <%= render "headmin/thumbnail", media_item.thumbnail_options %>
19
25
  </a>
20
26
 
21
27
  <div class="h-form-file-thumbnail-actions">
22
28
  <!-- Edit -->
23
- <a href="<%= headmin_media_item_url(id: attachment.blob ? attachment.blob.id : "$1") %>" class="h-form-file-thumbnail-edit" data-turbo-frame="remote_modal" data-media-target="editButton">
29
+ <a href="<%= headmin_media_item_url(id: media_item.id) %>" class="h-form-file-thumbnail-edit" data-turbo-frame="remote_modal" data-media-target="editButton">
24
30
  <%= bootstrap_icon("pencil") %>
25
31
  </a>
26
32
 
@@ -7,9 +7,10 @@
7
7
 
8
8
  draggable = form.object.respond_to?(:position)
9
9
  destroyable = form.object.respond_to?(:destroy)
10
+ class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : "repeater-row list-group-item"
10
11
  %>
11
12
 
12
- <div class="repeater-row list-group-item"
13
+ <div class="<%= class_names %>"
13
14
  data-repeater-target="row"
14
15
  data-row-index="<%= form.options[:child_index] %>"
15
16
  data-new-record="<%= form.object.new_record? %>"
@@ -11,7 +11,6 @@
11
11
 
12
12
  <!-- Label -->
13
13
  <label for="media-item-<%= blob.id %>">
14
- <% src = blob.image? ? url_for(blob.variant(resize_to_fill: [100, 100])) : url_for(blob) %>
15
- <%= render "headmin/thumbnail", src: src, width: 100, height: 100 %>
14
+ <%= render "headmin/thumbnail", file: blob %>
16
15
  </label>
17
16
  </div>
@@ -7,8 +7,8 @@
7
7
  <div class="modal-body">
8
8
  <%= render "headmin/notifications" %>
9
9
  <div class="row">
10
- <div class="col-3">
11
- <%= render "headmin/thumbnail", src: url_for(@blob), width: 100, height: 100 %>
10
+ <div class="col-4">
11
+ <%= render "headmin/thumbnail", file: @blob %>
12
12
  </div>
13
13
  <div class="col-8 d-flex flex-column justify-content-center">
14
14
  <p class="small text-secondary m-0">
@@ -2,10 +2,24 @@
2
2
  headmin/table/body/association
3
3
  accepts block: no
4
4
  parameters:
5
- object: (ActiveRecord::Base) Model resource for which an association needs to be called
6
- attribute: (string) Name of the association
5
+ value: (string) Name of the association
7
6
  %>
8
7
 
9
8
  <td>
10
- <%= t(".items", count: object.send(attribute).count) %>
9
+ <% if defined?(url) && url %>
10
+ <a href="<%= url %>" title="<% t(".open") %>" target=_blank>
11
+ <% if value.respond_to?(:each) %>
12
+ <%= value.map { |i| i.to_s }.join(", ") %>
13
+ <% else %>
14
+ <%= value.to_s %>
15
+ <% end %>
16
+ <%= bootstrap_icon("box-arrow-up-right") %>
17
+ </a>
18
+ <% else %>
19
+ <% if value.respond_to?(:each) %>
20
+ <%= value.map { |i| i.to_s }.join(", ") %>
21
+ <% else %>
22
+ <%= value.to_s %>
23
+ <% end %>
24
+ <% end %>
11
25
  </td>
@@ -1,27 +1,21 @@
1
1
  <div class="bg-light mt-5 text-center">
2
- <%- if controller_name != "sessions" %>
3
- <%= link_to t(".sign_in"), new_session_path(resource_name) %><br />
4
- <% end %>
5
-
6
- <%- if devise_mapping.registerable? && controller_name != "registrations" %>
7
- <%= link_to t(".sign_up"), new_registration_path(resource_name) %><br />
8
- <% end %>
2
+ <%- if controller_name != "sessions" %>
3
+ <%= link_to t(".sign_in"), new_session_path(resource_name) %><br/>
4
+ <% end %>
9
5
 
10
- <%- if devise_mapping.recoverable? && controller_name != "passwords" && controller_name != "registrations" %>
11
- <%= link_to t(".forgot_password"), new_password_path(resource_name) %><br />
12
- <% end %>
6
+ <%- if devise_mapping.registerable? && controller_name != "registrations" %>
7
+ <%= link_to t(".sign_up"), new_registration_path(resource_name) %><br/>
8
+ <% end %>
13
9
 
14
- <%- if devise_mapping.confirmable? && controller_name != "confirmations" %>
15
- <%= link_to t(".confirmation"), new_confirmation_path(resource_name) %><br />
16
- <% end %>
10
+ <%- if devise_mapping.recoverable? && controller_name != "passwords" && controller_name != "registrations" %>
11
+ <%= link_to t(".forgot_password"), new_password_path(resource_name) %><br/>
12
+ <% end %>
17
13
 
18
- <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != "unlocks" %>
19
- <%= link_to t(".unlock"), new_unlock_path(resource_name) %><br />
20
- <% end %>
14
+ <%- if devise_mapping.confirmable? && controller_name != "confirmations" %>
15
+ <%= link_to t(".confirmation"), new_confirmation_path(resource_name) %><br/>
16
+ <% end %>
21
17
 
22
- <%- if devise_mapping.omniauthable? %>
23
- <%- resource_class.omniauth_providers.each do |provider| %>
24
- <%= link_to t(".omniauth", provider: OmniAuth::Utils.camelize(provider)), omniauth_authorize_path(resource_name, provider), method: :post %><br />
18
+ <%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != "unlocks" %>
19
+ <%= link_to t(".unlock"), new_unlock_path(resource_name) %><br/>
25
20
  <% end %>
26
- <% end %>
27
21
  </div>
@@ -2,6 +2,7 @@ en:
2
2
  attributes:
3
3
  created_at: Created at
4
4
  email: Email
5
+ filename: Filename
5
6
  password: Password
6
7
  password_confirmation: Password confirmation
7
8
  remember_me: Stay logged in
@@ -2,6 +2,7 @@ nl:
2
2
  attributes:
3
3
  created_at: Aangemaakt
4
4
  email: E-mailadres
5
+ filename: Bestandsnaam
5
6
  password: Wachtwoord
6
7
  password_confirmation: Wachtwoord bevestiging
7
8
  remember_me: Aangemeld blijven
@@ -31,8 +31,10 @@ en:
31
31
  does_not_match: does not matches with
32
32
  is_not_null: is not null
33
33
  is_null: is null
34
+ in: includes
35
+ not_in: does not include
34
36
  values:
35
37
  "false": "False"
36
38
  "no": "No"
37
- "true": "Hello"
39
+ "true": "True"
38
40
  "yes": "Yes"
@@ -31,6 +31,8 @@ nl:
31
31
  does_not_match: lijkt niet op
32
32
  is_not_null: is ingevuld
33
33
  is_null: is niet ingevuld
34
+ in: bevat
35
+ not_in: bevat niet
34
36
  values:
35
37
  "false": Onwaar
36
38
  "no": Nee
@@ -3,15 +3,15 @@ en:
3
3
  media:
4
4
  modal:
5
5
  close: Close
6
- placeholder: Upload your first file to the media library
7
6
  limits: "minimum: %{min} en maximum: %{max}"
7
+ maximum: " of %{count}"
8
+ placeholder: Upload your first file to the media library
8
9
  select: Select
9
10
  title:
10
11
  one: Select at least 1 file
11
12
  other: Select at least %{count} files
12
13
  unlimited: unlimited
13
14
  upload: Upload new files
14
- maximum: " of %{count}"
15
15
  media_item_modal:
16
16
  close: Close
17
17
  dimensions: Dimensions
@@ -3,8 +3,9 @@ nl:
3
3
  media:
4
4
  modal:
5
5
  close: Sluiten
6
- placeholder: Upload je eerste bestand naar de mediabibliotheek
7
6
  limits: "minimum: %{min} and maximum: %{max}"
7
+ maximum: " van %{count}"
8
+ placeholder: Upload je eerste bestand naar de mediabibliotheek
8
9
  select: Selecteer
9
10
  title:
10
11
  one: Selecteer bestand
@@ -1,3 +1,3 @@
1
1
  module Headmin
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
3
3
  end
data/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "headmin",
3
- "version": "0.5.2",
3
+ "version": "0.5.3",
4
4
  "description": "Admin component library",
5
5
  "module": "app/assets/javascripts/headmin.js",
6
6
  "main": "app/assets/javascripts/headmin.js",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: headmin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.3
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jef Vlamings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-05 00:00:00.000000000 Z
11
+ date: 2022-08-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: closure_tree
@@ -230,7 +230,7 @@ files:
230
230
  - app/assets/stylesheets/headmin/vendor/bootstrap/scss/vendor/_rfs.scss
231
231
  - app/assets/stylesheets/headmin/vendor/flatpickr.css
232
232
  - app/assets/stylesheets/headmin/vendor/redactorx.css
233
- - app/assets/stylesheets/headmin/vendor/tom-select-bootstrap.css
233
+ - app/assets/stylesheets/headmin/vendor/tom-select-bootstrap.scss
234
234
  - app/controllers/concerns/headmin/acts_as_list.rb
235
235
  - app/controllers/concerns/headmin/authentication.rb
236
236
  - app/controllers/concerns/headmin/filterable.rb
@@ -258,6 +258,8 @@ files:
258
258
  - app/models/concerns/headmin/form/wrappable.rb
259
259
  - app/models/headmin/.DS_Store
260
260
  - app/models/headmin/blocks_view.rb
261
+ - app/models/headmin/filter/association.rb
262
+ - app/models/headmin/filter/association_view.rb
261
263
  - app/models/headmin/filter/base.rb
262
264
  - app/models/headmin/filter/base_view.rb
263
265
  - app/models/headmin/filter/boolean.rb
@@ -279,6 +281,7 @@ files:
279
281
  - app/models/headmin/filter/text.rb
280
282
  - app/models/headmin/filter/text_view.rb
281
283
  - app/models/headmin/filters.rb
284
+ - app/models/headmin/form/association_view.rb
282
285
  - app/models/headmin/form/blocks_view.rb
283
286
  - app/models/headmin/form/checkbox_view.rb
284
287
  - app/models/headmin/form/color_view.rb
@@ -294,6 +297,7 @@ files:
294
297
  - app/models/headmin/form/hint_view.rb
295
298
  - app/models/headmin/form/input_group_view.rb
296
299
  - app/models/headmin/form/label_view.rb
300
+ - app/models/headmin/form/media_item_view.rb
297
301
  - app/models/headmin/form/media_view.rb
298
302
  - app/models/headmin/form/number_view.rb
299
303
  - app/models/headmin/form/password_view.rb
@@ -328,6 +332,7 @@ files:
328
332
  - app/views/headmin/dropdown/_item.html.erb
329
333
  - app/views/headmin/dropdown/_list.html.erb
330
334
  - app/views/headmin/dropdown/_locale.html.erb
335
+ - app/views/headmin/filters/_association.html.erb
331
336
  - app/views/headmin/filters/_base.html.erb
332
337
  - app/views/headmin/filters/_boolean.html.erb
333
338
  - app/views/headmin/filters/_date.html.erb
@@ -342,6 +347,7 @@ files:
342
347
  - app/views/headmin/filters/filter/_null_select.html.erb
343
348
  - app/views/headmin/filters/filter/_operator.html.erb
344
349
  - app/views/headmin/filters/filter/_row.html.erb
350
+ - app/views/headmin/forms/_association.html.erb
345
351
  - app/views/headmin/forms/_autocomplete.html.erb
346
352
  - app/views/headmin/forms/_blocks.html.erb
347
353
  - app/views/headmin/forms/_checkbox.html.erb