headmin 0.3.2 → 0.3.3
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.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +27 -23
- data/app/assets/images/document.docx +0 -0
- data/app/assets/images/document.pdf +0 -0
- data/app/assets/images/image.jpg +0 -0
- data/app/assets/images/spreadsheet.xls +0 -0
- data/app/assets/images/video.mp4 +0 -0
- data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +2 -2
- data/app/assets/javascripts/headmin/controllers/table_controller.js +28 -13
- data/app/assets/javascripts/headmin/index.js +0 -4
- data/app/assets/javascripts/headmin.js +33 -696
- data/app/assets/stylesheets/headmin/form.scss +4 -4
- data/app/assets/stylesheets/headmin/vendor/tom-select-bootstrap.css +1 -2
- data/app/assets/stylesheets/headmin.css +3 -3
- data/app/controllers/concerns/headmin/authentication.rb +1 -1
- data/app/controllers/concerns/headmin/searchable.rb +1 -1
- data/app/controllers/concerns/headmin/sortable.rb +7 -7
- data/app/helpers/headmin/admin_helper.rb +1 -1
- data/app/helpers/headmin/bootstrap_helper.rb +2 -24
- data/app/helpers/headmin/documentation_helper.rb +1 -1
- data/app/helpers/headmin/filter_helper.rb +1 -1
- data/app/helpers/headmin/form_helper.rb +3 -3
- data/app/helpers/headmin/notification_helper.rb +21 -21
- data/app/helpers/headmin/request_helper.rb +3 -3
- data/app/models/concerns/headmin/block.rb +1 -2
- data/app/models/concerns/headmin/blockable.rb +1 -1
- data/app/models/concerns/headmin/field.rb +1 -1
- data/app/models/concerns/headmin/fieldable.rb +8 -8
- data/app/models/headmin/documentation_renderer.rb +4 -4
- data/app/models/headmin/form/base.rb +1 -2
- data/app/models/headmin/form/text.rb +5 -7
- data/app/models/headmin/thumbnail.rb +61 -0
- data/app/services/block_service.rb +53 -53
- data/app/views/headmin/_thumbnail.html.erb +42 -40
- data/app/views/headmin/dropdown/_item.html.erb +1 -1
- data/app/views/headmin/forms/_checkbox.html.erb +1 -1
- data/app/views/headmin/forms/_file.html.erb +1 -1
- data/app/views/headmin/forms/_repeater.html.erb +1 -1
- data/app/views/headmin/forms/actions/_destroy.html.erb +3 -3
- data/app/views/headmin/forms/fields/_group.html.erb +1 -1
- data/app/views/headmin/nav/item/_devise.html.erb +1 -1
- data/app/views/headmin/table/_actions.html.erb +1 -1
- data/app/views/headmin/views/devise/registrations/_edit.html.erb +2 -2
- data/config/initializers/customize_input_error.rb +4 -4
- data/lib/generators/headmin/blocks_generator.rb +8 -8
- data/lib/generators/headmin/devise_generator.rb +4 -4
- data/lib/generators/headmin/fields_generator.rb +9 -9
- data/lib/generators/templates/controllers/auth/confirmations_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/omniauth_callbacks_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/passwords_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/registrations_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/sessions_controller.rb +1 -1
- data/lib/generators/templates/controllers/auth/unlocks_controller.rb +1 -1
- data/lib/generators/templates/models/block.rb +1 -1
- data/lib/headmin/engine.rb +6 -6
- data/lib/headmin/version.rb +1 -1
- data/package.json +0 -1
- data/yarn.lock +1 -258
- metadata +9 -4
- data/.rubocop.yml +0 -13
@@ -1,45 +1,47 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
1
|
+
<!--
|
2
|
+
<% documentation do %>
|
3
|
+
# Thumbnail
|
4
|
+
Render thumbnails for files. Whenever possible (e.g. images) previews are generated. Icons are used instead for other file types.
|
5
|
+
|
6
|
+
```erbx
|
7
|
+
<%= render 'headmin/thumbnail', src: image_path("image.jpg") %>
|
8
|
+
```
|
9
|
+
|
10
|
+
## Parameters
|
11
|
+
| Name | Required | Type | Description |
|
12
|
+
| ------------ | -------- | ---------------- | ----------- |
|
13
|
+
| src | yes | String | Source of the file. Can be a local or external URL |
|
14
|
+
| width | no | Integer | Width of the thumbnail in px |
|
15
|
+
| height | no | Integer | Height of the thumbnail in px |
|
16
|
+
|
17
|
+
## Examples
|
18
|
+
|
19
|
+
### Sizing
|
20
|
+
```erbx
|
21
|
+
<%= render 'headmin/thumbnail', src: image_path("image.jpg"), width: 300, height: 100 %>
|
22
|
+
```
|
23
|
+
|
24
|
+
### Types
|
25
|
+
```erbx
|
26
|
+
<%= render 'headmin/thumbnail', src: asset_path("document.pdf"), width: 100, height: 100 %>
|
27
|
+
<%= render 'headmin/thumbnail', src: asset_path("document.docx"), width: 100, height: 100 %>
|
28
|
+
<%= render 'headmin/thumbnail', src: asset_path("spreadsheet.xls"), width: 100, height: 100 %>
|
29
|
+
<%= render 'headmin/thumbnail', src: asset_path("video.mp4"), width: 100, height: 100 %>
|
30
|
+
```
|
31
|
+
|
32
|
+
## References
|
33
|
+
- [Bootstrap](https://getbootstrap.com/docs/5.1/content/images/#image-thumbnails)
|
34
|
+
<% end %>
|
35
|
+
-->
|
36
|
+
|
37
|
+
<% thumbnail = Headmin::Thumbnail.new(local_assigns) %>
|
38
|
+
|
39
|
+
<div class="<%= thumbnail.class_names %>" style="width: <%= thumbnail.width %>px; height: <%= thumbnail.height %>px;">
|
40
|
+
<% if thumbnail.image? %>
|
41
|
+
<div class="h-thumbnail-bg" style="background-image: url('<%= thumbnail.src %>');"></div>
|
36
42
|
<% else %>
|
37
43
|
<div class="h-thumbnail-bg">
|
38
|
-
|
39
|
-
<%= bootstrap_icon_for_mime_type(mime_type, class: 'h-thumbnail-icon') %>
|
40
|
-
<% else %>
|
41
|
-
<%= bootstrap_icon('question', class: 'h-thumbnail-icon') %>
|
42
|
-
<% end %>
|
44
|
+
<%= bootstrap_icon(thumbnail.icon_name, class: 'h-thumbnail-icon') %>
|
43
45
|
</div>
|
44
46
|
<% end %>
|
45
47
|
</div>
|
@@ -12,7 +12,7 @@
|
|
12
12
|
<% name = local_assigns.has_key?(:name) ? name : '' %>
|
13
13
|
|
14
14
|
<li>
|
15
|
-
<a class="dropdown-item" href="<%= url %>" <%= "data-method=#{method}" if method %>>
|
15
|
+
<a class="dropdown-item" href="<%= url %>" <%= "data-turbo-method=#{method}" if method %>>
|
16
16
|
<%= name %>
|
17
17
|
</a>
|
18
18
|
</li>
|
@@ -33,7 +33,7 @@
|
|
33
33
|
<div class="<%= ('mb-3 text-start' if show_label) %>">
|
34
34
|
<%= form.check_box(attribute, options) %>
|
35
35
|
<% if show_label %>
|
36
|
-
<%= render 'headmin/forms/label', form: form, attribute: attribute,
|
36
|
+
<%= render 'headmin/forms/label', form: form, attribute: attribute, text: label, required: required %>
|
37
37
|
<% end %>
|
38
38
|
<%= render 'headmin/forms/validation', form: form, attribute: attribute %>
|
39
39
|
</div>
|
@@ -146,7 +146,7 @@
|
|
146
146
|
next unless attachment
|
147
147
|
filename = attachment.blob.filename.to_s
|
148
148
|
size = number_to_human_size(attachment.blob.byte_size)
|
149
|
-
src = attachment.image? ? url_for(attachment.variant(resize_to_fill: [thumbnail_width, thumbnail_height]
|
149
|
+
src = attachment.image? ? url_for(attachment.variant(resize_to_fill: [thumbnail_width, thumbnail_height])) : url_for(attachment)
|
150
150
|
%>
|
151
151
|
<div class="h-form-file-thumbnail" title="<%= "#{filename} (#{size})" %>" data-file-preview-target="thumbnail">
|
152
152
|
<%= ff.hidden_field(:id, disabled: destroy) %>
|
@@ -54,7 +54,7 @@
|
|
54
54
|
|
55
55
|
<!-- Label -->
|
56
56
|
<% if show_label %>
|
57
|
-
<%= render 'headmin/forms/label', form: form, attribute: attribute,
|
57
|
+
<%= render 'headmin/forms/label', form: form, attribute: attribute, text: label, required: required %>
|
58
58
|
<% end %>
|
59
59
|
|
60
60
|
<ul class="list-group <%= 'list-group-flush' if flush %>" data-repeater-target="list">
|
@@ -6,8 +6,8 @@
|
|
6
6
|
%>
|
7
7
|
|
8
8
|
<div class="d-grid">
|
9
|
-
<%= link_to([:admin, form.object], class:
|
10
|
-
<%= bootstrap_icon(
|
11
|
-
<%= t(
|
9
|
+
<%= link_to([:admin, form.object], class: "btn btn-outline-danger", "data-turbo-method": "delete", "data-turbo-confirm": t(".confirm")) do %>
|
10
|
+
<%= bootstrap_icon("trash") %>
|
11
|
+
<%= t(".title") %>
|
12
12
|
<% end %>
|
13
13
|
</div>
|
@@ -29,7 +29,7 @@
|
|
29
29
|
|
30
30
|
<%= render 'headmin/forms/fields/base', form: form, name: name, field_type: :group do |group, field_label| %>
|
31
31
|
<% if show_label %>
|
32
|
-
<%= render 'headmin/forms/label', form: form, attribute: :value,
|
32
|
+
<%= render 'headmin/forms/label', form: form, attribute: :value, text: label || field_label %>
|
33
33
|
<% end %>
|
34
34
|
|
35
35
|
<li class="list-group-item mb-3">
|
@@ -16,6 +16,6 @@
|
|
16
16
|
<%= render 'headmin/dropdown/list', id: 'nav-item-devise' do %>
|
17
17
|
<%= render 'headmin/dropdown/item', name: t('.edit_profile'), url: polymorphic_path([:edit, singular, :registration]) %>
|
18
18
|
<%= render 'headmin/dropdown/divider' %>
|
19
|
-
<%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), method:
|
19
|
+
<%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), data: { "turbo-method": "delete" } %>
|
20
20
|
<% end %>
|
21
21
|
<% end %>
|
@@ -13,7 +13,7 @@
|
|
13
13
|
|
14
14
|
<% content_for :table_actions do %>
|
15
15
|
<th class="h-table-actions d-none" data-controller="table-actions" data-table-actions-target="wrapper" data-table-target="actions">
|
16
|
-
<%= form_with url: '', data: {
|
16
|
+
<%= form_with url: '', data: { "table-actions-target": 'form', "turbo": false } do |form| %>
|
17
17
|
<%= form.hidden_field :authenticity_token, value: form_authenticity_token %>
|
18
18
|
<%= form.hidden_field :_method, value: 'POST', 'data-table-actions-target': 'method' %>
|
19
19
|
<%= query_parameter_fields(form) %>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<div>
|
2
|
-
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {method: :put}) do |f| %>
|
2
|
+
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
3
3
|
<%= render "headmin/views/devise/shared/error_messages", resource: resource %>
|
4
4
|
|
5
5
|
<%= render 'headmin/forms/email', form: f, attribute: :email, required: true, float: true %>
|
@@ -19,6 +19,6 @@
|
|
19
19
|
<h4><%= t('.cancel') %></h4>
|
20
20
|
|
21
21
|
<p><%= t('.unhappy') %></p>
|
22
|
-
<%= button_to t('.cancel'), registration_path(resource_name), class: 'btn btn-lg btn-danger w-100', data
|
22
|
+
<%= button_to t('.cancel'), registration_path(resource_name), class: 'btn btn-lg btn-danger w-100', "data-turbo-confirm": "Are you sure?", "data-turbo-method": "delete" %>
|
23
23
|
</div>
|
24
24
|
</div>
|
@@ -1,9 +1,9 @@
|
|
1
|
-
ActionView::Base.field_error_proc =
|
1
|
+
ActionView::Base.field_error_proc = proc do |html_tag, instance|
|
2
2
|
class_attr_index = html_tag.index 'class="'
|
3
3
|
|
4
4
|
if class_attr_index
|
5
|
-
html_tag.insert class_attr_index+7,
|
5
|
+
html_tag.insert class_attr_index + 7, "error "
|
6
6
|
else
|
7
|
-
html_tag.insert html_tag.index(
|
7
|
+
html_tag.insert html_tag.index(">"), ' class="error"'
|
8
8
|
end
|
9
|
-
end
|
9
|
+
end
|
@@ -2,21 +2,21 @@ module Headmin
|
|
2
2
|
class BlocksGenerator < Rails::Generators::Base
|
3
3
|
include Rails::Generators::Migration
|
4
4
|
|
5
|
-
source_root File.expand_path(
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
6
6
|
|
7
7
|
def copy_models
|
8
|
-
template
|
8
|
+
template "models/block.rb", "app/models/block.rb"
|
9
9
|
end
|
10
10
|
|
11
11
|
def copy_migrations
|
12
|
-
migration_template
|
12
|
+
migration_template "migrations/create_blocks.rb", "db/migrate/create_blocks.rb"
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
class << self
|
16
|
+
def next_migration_number(dirname)
|
17
|
+
next_migration_number = current_migration_number(dirname) + 1
|
18
|
+
ActiveRecord::Migration.next_migration_number(next_migration_number)
|
19
|
+
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -2,15 +2,15 @@ module Headmin
|
|
2
2
|
class DeviseGenerator < Rails::Generators::Base
|
3
3
|
include Rails::Generators::Migration
|
4
4
|
|
5
|
-
source_root File.expand_path(
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
6
6
|
|
7
7
|
def copy_controllers
|
8
|
-
directory
|
8
|
+
directory "controllers/auth", "app/controllers/auth"
|
9
9
|
end
|
10
10
|
|
11
11
|
def copy_views
|
12
|
-
directory
|
13
|
-
copy_file
|
12
|
+
directory "views/auth", "app/views/auth"
|
13
|
+
copy_file "views/layouts/auth.html.erb", "app/views/layouts/auth.html.erb"
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -2,22 +2,22 @@ module Headmin
|
|
2
2
|
class FieldsGenerator < Rails::Generators::Base
|
3
3
|
include Rails::Generators::Migration
|
4
4
|
|
5
|
-
source_root File.expand_path(
|
5
|
+
source_root File.expand_path("../../templates", __FILE__)
|
6
6
|
|
7
7
|
def copy_models
|
8
|
-
template
|
8
|
+
template "models/field.rb", "app/models/field.rb"
|
9
9
|
end
|
10
10
|
|
11
11
|
def copy_migrations
|
12
|
-
migration_template
|
13
|
-
migration_template
|
12
|
+
migration_template "migrations/create_fields.rb", "db/migrate/create_fields.rb"
|
13
|
+
migration_template "migrations/create_field_hierarchies.rb", "db/migrate/create_field_hierarchies.rb"
|
14
14
|
end
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
class << self
|
17
|
+
def next_migration_number(dirname)
|
18
|
+
next_migration_number = current_migration_number(dirname) + 1
|
19
|
+
ActiveRecord::Migration.next_migration_number(next_migration_number)
|
20
|
+
end
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
class Auth::RegistrationsController < Devise::RegistrationsController
|
4
|
-
layout
|
4
|
+
layout "auth"
|
5
5
|
# before_action :configure_sign_up_params, only: [:create]
|
6
6
|
# before_action :configure_account_update_params, only: [:update]
|
7
7
|
|
data/lib/headmin/engine.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Headmin
|
2
2
|
class Engine < Rails::Engine
|
3
|
-
engine_name
|
3
|
+
engine_name "headmin"
|
4
4
|
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
5
|
+
require "closure_tree"
|
6
|
+
require "redcarpet"
|
7
|
+
require "rouge"
|
8
8
|
|
9
9
|
# Add translations to main app
|
10
10
|
config.before_configuration do
|
@@ -14,7 +14,7 @@ module Headmin
|
|
14
14
|
# Add assets to precompilation list
|
15
15
|
initializer "headmin.assets" do |app|
|
16
16
|
next unless app.config.respond_to?(:assets)
|
17
|
-
app.config.assets.precompile += %w
|
17
|
+
app.config.assets.precompile += %w[headmin.js headmin.css headmin.scss]
|
18
18
|
end
|
19
19
|
|
20
20
|
# Add importmap to main app
|
@@ -24,4 +24,4 @@ module Headmin
|
|
24
24
|
app.config.importmap.cache_sweepers << Engine.root.join("app/assets/javascripts")
|
25
25
|
end
|
26
26
|
end
|
27
|
-
end
|
27
|
+
end
|
data/lib/headmin/version.rb
CHANGED