headmin 0.1.2 → 0.2.0
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/.gitignore +1 -15
- data/Gemfile +1 -1
- data/Gemfile.lock +24 -2
- data/README.md +5 -34
- data/app/controllers/concerns/headmin/authentication.rb +0 -8
- data/app/controllers/concerns/headmin/pagination.rb +1 -1
- data/app/helpers/headmin/admin_helper.rb +4 -4
- data/app/models/concerns/headmin/block.rb +11 -0
- data/app/models/concerns/headmin/blockable.rb +10 -0
- data/app/models/concerns/headmin/field.rb +17 -0
- data/app/models/concerns/headmin/fieldable.rb +44 -0
- data/app/services/block_service.rb +68 -0
- data/app/views/{layouts → examples}/admin.html.erb +0 -0
- data/app/views/{layouts/admin → examples}/auth.html.erb +0 -0
- data/app/views/headmin/_blocks.html.erb +24 -0
- data/app/views/headmin/_breadcrumbs.html.erb +9 -5
- data/app/views/headmin/_card.html.erb +48 -0
- data/app/views/headmin/_dropdown.html.erb +18 -0
- data/app/views/headmin/_filters.html.erb +56 -34
- data/app/views/headmin/_form.html.erb +60 -6
- data/app/views/headmin/_heading.html.erb +8 -4
- data/app/views/headmin/_index.html.erb +9 -8
- data/app/views/headmin/_notifications.html.erb +8 -0
- data/app/views/headmin/_pagination.html.erb +11 -7
- data/app/views/headmin/_popup.html.erb +26 -0
- data/app/views/headmin/_table.html.erb +11 -4
- data/app/views/headmin/dropdown/_button.html.erb +13 -0
- data/app/views/headmin/dropdown/_devise.html.erb +21 -0
- data/app/views/headmin/{layout/dropdown → dropdown}/_divider.html.erb +1 -1
- data/app/views/headmin/dropdown/_item.html.erb +18 -0
- data/app/views/headmin/dropdown/_list.html.erb +11 -0
- data/app/views/headmin/dropdown/_locale.html.erb +17 -0
- data/app/views/headmin/filters/_date.html.erb +21 -16
- data/app/views/headmin/filters/_search.html.erb +18 -18
- data/app/views/headmin/filters/_select.html.erb +28 -23
- data/app/views/headmin/filters/filter/_button.html.erb +15 -6
- data/app/views/headmin/filters/filter/_menu_item.html.erb +2 -2
- data/app/views/headmin/filters/filter/_template.html.erb +2 -2
- data/app/views/headmin/forms/_actions.html.erb +4 -8
- data/app/views/headmin/forms/_base.html.erb +60 -0
- data/app/views/headmin/forms/_blocks.html.erb +32 -0
- data/app/views/headmin/forms/_checkbox.html.erb +39 -0
- data/app/views/headmin/forms/_ckeditor.html.erb +42 -0
- data/app/views/headmin/forms/_date.html.erb +45 -0
- data/app/views/headmin/forms/_email.html.erb +39 -0
- data/app/views/headmin/forms/_file.html.erb +40 -0
- data/app/views/headmin/forms/_image.html.erb +55 -0
- data/app/views/headmin/forms/_label.html.erb +24 -0
- data/app/views/headmin/forms/_number.html.erb +50 -0
- data/app/views/headmin/forms/_password.html.erb +69 -0
- data/app/views/headmin/forms/_redactorx.html.erb +49 -0
- data/app/views/headmin/forms/_repeater.html.erb +133 -0
- data/app/views/headmin/forms/_select.html.erb +70 -0
- data/app/views/headmin/forms/_text.html.erb +62 -0
- data/app/views/headmin/forms/_textarea.html.erb +39 -0
- data/app/views/headmin/forms/_url.html.erb +39 -0
- data/app/views/headmin/forms/_validation.html.erb +21 -0
- data/app/views/headmin/forms/actions/_destroy.html.erb +13 -0
- data/app/views/headmin/forms/actions/_save.html.erb +12 -0
- data/app/views/headmin/forms/actions/_view.html.erb +15 -0
- data/app/views/headmin/forms/fields/_base.html.erb +25 -0
- data/app/views/headmin/forms/fields/_file.html.erb +15 -22
- data/app/views/headmin/forms/fields/_group.html.erb +38 -0
- data/app/views/headmin/forms/fields/_image.html.erb +15 -35
- data/app/views/headmin/forms/fields/_list.html.erb +26 -0
- data/app/views/headmin/forms/fields/_text.html.erb +15 -37
- data/app/views/headmin/forms/repeater/_row.html.erb +51 -0
- data/app/views/headmin/heading/_title.html.erb +1 -1
- data/app/views/headmin/layout/_body.html.erb +1 -1
- data/app/views/headmin/layout/_content.html.erb +1 -1
- data/app/views/headmin/layout/_footer.html.erb +1 -1
- data/app/views/headmin/layout/_header.html.erb +1 -1
- data/app/views/headmin/layout/_main.html.erb +2 -2
- data/app/views/headmin/layout/_sidebar.html.erb +1 -1
- data/app/views/headmin/layout/sidebar/{_menu.html.erb → _nav.html.erb} +1 -1
- data/app/views/headmin/nav/_item.html.erb +21 -0
- data/app/views/headmin/nav/item/_devise.html.erb +21 -0
- data/app/views/headmin/nav/item/_locale.html.erb +17 -0
- data/app/views/headmin/pagination/_per_page.html.erb +18 -0
- data/app/views/headmin/{kaminari → pagination/kaminari}/_first_page.html.erb +0 -0
- data/app/views/headmin/{kaminari → pagination/kaminari}/_gap.html.erb +0 -0
- data/app/views/headmin/{kaminari → pagination/kaminari}/_last_page.html.erb +0 -0
- data/app/views/headmin/{kaminari → pagination/kaminari}/_next_page.html.erb +0 -0
- data/app/views/headmin/{kaminari → pagination/kaminari}/_page.html.erb +1 -1
- data/app/views/headmin/{kaminari → pagination/kaminari}/_paginator.html.erb +0 -0
- data/app/views/headmin/{kaminari → pagination/kaminari}/_prev_page.html.erb +0 -0
- data/app/views/headmin/table/_actions.html.erb +24 -17
- data/app/views/headmin/table/_body.html.erb +12 -10
- data/app/views/headmin/table/_foot.html.erb +8 -4
- data/app/views/headmin/table/_footer.html.erb +3 -7
- data/app/views/headmin/table/_head.html.erb +3 -1
- data/app/views/headmin/table/_header.html.erb +3 -7
- data/app/views/headmin/table/actions/_action.html.erb +26 -9
- data/app/views/headmin/table/actions/_delete.html.erb +11 -7
- data/app/views/headmin/table/actions/_export.html.erb +11 -7
- data/app/views/headmin/table/body/_association.html.erb +1 -1
- data/app/views/headmin/table/body/_boolean.erb +1 -1
- data/app/views/headmin/table/body/_currency.html.erb +1 -1
- data/app/views/headmin/table/body/_date.html.erb +1 -1
- data/app/views/headmin/table/body/_id.html.erb +2 -2
- data/app/views/headmin/table/body/_row.html.erb +1 -1
- data/app/views/headmin/table/body/_string.html.erb +1 -1
- data/app/views/headmin/table/body/_text.html.erb +1 -1
- data/app/views/headmin/table/foot/_cell.html.erb +1 -1
- data/app/views/headmin/table/foot/_id.html.erb +2 -2
- data/app/views/headmin/table/head/_cell.html.erb +1 -1
- data/app/views/headmin/table/head/_id.html.erb +3 -3
- data/app/views/headmin/views/devise/confirmations/_new.html.erb +9 -0
- data/app/views/headmin/views/devise/passwords/_edit.html.erb +12 -0
- data/app/views/headmin/views/devise/passwords/_new.html.erb +9 -0
- data/app/views/{admin/users/registrations/edit.html.erb → headmin/views/devise/registrations/_edit.html.erb} +5 -5
- data/app/views/headmin/views/devise/registrations/_new.html.erb +11 -0
- data/app/views/headmin/views/devise/sessions/_new.html.erb +13 -0
- data/app/views/{admin/users → headmin/views/devise}/shared/_error_messages.html.erb +0 -0
- data/app/views/{admin/users → headmin/views/devise}/shared/_links.html.erb +0 -0
- data/app/views/headmin/views/devise/unlocks/_new.html.erb +10 -0
- data/config/initializers/customize_input_error.rb +9 -0
- data/config/locales/devise/en.yml +65 -0
- data/config/locales/en.yml +2 -134
- data/config/locales/headmin/filters/en.yml +13 -0
- data/config/locales/headmin/filters/nl.yml +13 -0
- data/config/locales/headmin/forms/en.yml +34 -0
- data/config/locales/headmin/forms/nl.yml +33 -0
- data/config/locales/headmin/heading/en.yml +5 -0
- data/config/locales/headmin/heading/nl.yml +5 -0
- data/config/locales/headmin/layout/en.yml +14 -0
- data/config/locales/headmin/layout/nl.yml +14 -0
- data/config/locales/headmin/pagination/en.yml +21 -0
- data/config/locales/headmin/pagination/nl.yml +21 -0
- data/config/locales/headmin/table/en.yml +23 -0
- data/config/locales/headmin/table/nl.yml +23 -0
- data/config/locales/headmin/views/en.yml +58 -0
- data/config/locales/headmin/views/nl.yml +58 -0
- data/config/locales/nl.yml +2 -135
- data/dist/css/headmin.css +3182 -743
- data/dist/js/headmin.js +729 -33
- data/docs/README.md +2 -1
- data/docs/blocks.md +70 -85
- data/docs/devise.md +1 -60
- data/docs/fields.md +57 -0
- data/lib/generators/headmin/blocks_generator.rb +19 -0
- data/lib/generators/headmin/fields_generator.rb +19 -0
- data/lib/generators/templates/migrations/create_blocks.rb +10 -0
- data/lib/generators/templates/migrations/create_fields.rb +13 -0
- data/lib/generators/templates/models/block.rb +3 -0
- data/lib/generators/templates/models/field.rb +3 -0
- data/lib/headmin/version.rb +1 -1
- data/package.json +6 -6
- data/src/js/headmin/controllers/blocks_controller.js +103 -0
- data/src/js/headmin/controllers/filters_controller.js +23 -12
- data/src/js/headmin/controllers/popup_controller.js +68 -0
- data/src/js/headmin/controllers/repeater_controller.js +117 -11
- data/src/js/headmin/controllers/table_actions_controller.js +16 -5
- data/src/js/headmin/controllers/table_controller.js +84 -1
- data/src/js/headmin/headmin.js +29 -56
- data/src/scss/headmin/filters.scss +0 -14
- data/src/scss/headmin/form.scss +43 -3
- data/src/scss/headmin/popup.scss +17 -0
- data/src/scss/headmin/table.scss +9 -6
- data/src/scss/headmin.scss +7 -4
- data/src/scss/vendor/redactorx/override.css +3 -0
- data/src/scss/vendor/redactorx/redactorx.css +1460 -0
- data/yarn.lock +105 -2210
- metadata +93 -61
- data/app/controllers/admin/users/confirmations_controller.rb +0 -31
- data/app/controllers/admin/users/omniauth_callbacks_controller.rb +0 -31
- data/app/controllers/admin/users/passwords_controller.rb +0 -35
- data/app/controllers/admin/users/registrations_controller.rb +0 -63
- data/app/controllers/admin/users/sessions_controller.rb +0 -28
- data/app/controllers/admin/users/unlocks_controller.rb +0 -31
- data/app/views/admin/users/confirmations/new.html.erb +0 -9
- data/app/views/admin/users/mailer/confirmation_instructions.html.erb +0 -5
- data/app/views/admin/users/mailer/email_changed.html.erb +0 -7
- data/app/views/admin/users/mailer/password_change.html.erb +0 -3
- data/app/views/admin/users/mailer/reset_password_instructions.html.erb +0 -8
- data/app/views/admin/users/mailer/unlock_instructions.html.erb +0 -7
- data/app/views/admin/users/passwords/edit.html.erb +0 -12
- data/app/views/admin/users/passwords/new.html.erb +0 -9
- data/app/views/admin/users/registrations/new.html.erb +0 -11
- data/app/views/admin/users/sessions/new.html.erb +0 -13
- data/app/views/admin/users/unlocks/new.html.erb +0 -10
- data/app/views/headmin/forms/_group.html.erb +0 -36
- data/app/views/headmin/forms/fields/_checkbox.html.erb +0 -23
- data/app/views/headmin/forms/fields/_ckeditor.html.erb +0 -28
- data/app/views/headmin/forms/fields/_currency.html.erb +0 -24
- data/app/views/headmin/forms/fields/_date.html.erb +0 -36
- data/app/views/headmin/forms/fields/_email.html.erb +0 -39
- data/app/views/headmin/forms/fields/_label.html.erb +0 -9
- data/app/views/headmin/forms/fields/_multiple_select.html.erb +0 -37
- data/app/views/headmin/forms/fields/_password.html.erb +0 -39
- data/app/views/headmin/forms/fields/_repeater.html.erb +0 -48
- data/app/views/headmin/forms/fields/_select.html.erb +0 -36
- data/app/views/headmin/forms/fields/_select_tags.html.erb +0 -32
- data/app/views/headmin/forms/fields/_textarea.html.erb +0 -29
- data/app/views/headmin/forms/fields/_url.html.erb +0 -38
- data/app/views/headmin/forms/fields/_validation.html.erb +0 -12
- data/app/views/headmin/forms/fields/repeater/_row.html.erb +0 -16
- data/app/views/headmin/layout/dropdown/_item.html.erb +0 -17
- data/app/views/headmin/layout/header/_account.html.erb +0 -25
- data/app/views/headmin/layout/header/_locale.html.erb +0 -19
- data/app/views/headmin/layout/sidebar/menu/_account.html.erb +0 -25
- data/app/views/headmin/layout/sidebar/menu/_item.html.erb +0 -16
- data/app/views/headmin/layout/sidebar/menu/_locale.html.erb +0 -18
- data/src/js/headmin/controllers/index_controller.js +0 -79
- data/src/js/headmin/controllers/repeater_row_controller.js +0 -54
- data/src/scss/vendor/choices/cross-inverse.svg +0 -6
- data/src/scss/vendor/choices/cross.svg +0 -6
- data/src/scss/vendor/choices/custom.scss +0 -28
- data/src/scss/vendor/choices/variables.scss +0 -16
@@ -1,12 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
<%
|
2
|
+
# headmin/index
|
3
|
+
#
|
4
|
+
# === Examples
|
5
|
+
# Basic version
|
6
|
+
# <%= render 'headmin/index' do %#>
|
7
|
+
# Index content
|
8
|
+
# <% end %#>
|
8
9
|
%>
|
9
10
|
|
10
|
-
<div class="
|
11
|
+
<div class="container-fluid">
|
11
12
|
<%= yield %>
|
12
13
|
</div>
|
@@ -1,3 +1,11 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/notifications
|
3
|
+
#
|
4
|
+
# ==== Examples
|
5
|
+
# Basic version
|
6
|
+
# <%= render "headmin/notifications" %#>
|
7
|
+
%>
|
8
|
+
|
1
9
|
<div class="toast-container position-absolute top-0 end-0 p-3">
|
2
10
|
<% flash.each do |name, message| %>
|
3
11
|
<div class="toast align-items-center text-white show <%= notification_color(name.to_sym)[:background] %>" role="alert" aria-live="assertive" aria-atomic="true">
|
@@ -1,13 +1,17 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<%
|
2
|
+
# headmin/notifications
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>collection</tt> - Kaminari collection that accepts a method .total_count
|
6
|
+
#
|
7
|
+
# ==== Examples
|
8
|
+
# Basic version
|
9
|
+
# <%= render "headmin/pagination, collection: @pages" %#>
|
6
10
|
%>
|
7
11
|
|
8
|
-
<div class="d-flex flex-row-reverse flex-md-row align-items-center
|
12
|
+
<div class="d-flex flex-row-reverse flex-md-row align-items-center justify-content-between justify-content-md-end my-1">
|
9
13
|
<div class="ms-2 me-md-2 text-secondary">
|
10
14
|
<%= t('.items', count: collection.total_count) %>
|
11
15
|
</div>
|
12
|
-
<%= paginate collection, views_prefix: 'headmin' %>
|
16
|
+
<%= paginate collection, views_prefix: 'headmin/pagination' %>
|
13
17
|
</div>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/popup
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>id</tt> - Identifier for this popup
|
6
|
+
#
|
7
|
+
# ==== Examples
|
8
|
+
# To trigger this popup create an element with a data attribute like this
|
9
|
+
#
|
10
|
+
# <button data-popup-id="popupId">open Popup</button>
|
11
|
+
# <%= render 'headmin/popup', id: 'popupId' do %#>
|
12
|
+
# popup Content
|
13
|
+
# <% end %#>
|
14
|
+
#
|
15
|
+
# If you want to pass a click event to an element inside the popup without opening the popup you can use the
|
16
|
+
# "data-popup-pass-thru" attribute.
|
17
|
+
#
|
18
|
+
# <button data-popup-id="popupId" data-popup-pass-thru="#link">open Popup</button>
|
19
|
+
# <%= render 'headmin/popup', id: 'popupId' do %#>
|
20
|
+
# <a href="https://example.com" id="link">
|
21
|
+
# <% end %#>
|
22
|
+
%>
|
23
|
+
|
24
|
+
<div class="h-popup closed" data-popup-target="popup" data-popup-id="<%= id %>">
|
25
|
+
<%= yield if block_given? %>
|
26
|
+
</div>
|
@@ -1,8 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
<%
|
2
|
+
# headmin/table
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>sort_url</tt> - U
|
6
|
+
#
|
7
|
+
# ==== Examples
|
8
|
+
# <%= render 'headmin/table', sort_url: positions_admin_categories_path do %#>
|
9
|
+
# table content here
|
10
|
+
# <% end %#>
|
5
11
|
%>
|
12
|
+
|
6
13
|
<% sort_url = local_assigns.has_key?(:sort_url) ? sort_url : nil %>
|
7
14
|
<div class="h-table card my-2 shadow-sm <%= 'table-drag-sort' if sort_url %>" data-sort-url="<%= sort_url %>">
|
8
15
|
<div class="table-responsive">
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<%#
|
2
|
+
headmin/dropdown/button
|
3
|
+
accepts block: yes
|
4
|
+
parameters:
|
5
|
+
id: unique identifier for the dropdown
|
6
|
+
class: css class names as string
|
7
|
+
%>
|
8
|
+
<% id = local_assigns.has_key?(:id) ? id : 'dropdown-1' %>
|
9
|
+
<% class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : 'btn' %>
|
10
|
+
|
11
|
+
<a class="dropdown-toggle d-flex align-items-center <%= class_names %>" type="button" id="<%= id %>" data-bs-toggle="dropdown" aria-expanded="false">
|
12
|
+
<%= yield %>
|
13
|
+
</a>
|
@@ -0,0 +1,21 @@
|
|
1
|
+
<%#
|
2
|
+
headmin/dropdown/locale
|
3
|
+
accepts block: yes
|
4
|
+
parameters:
|
5
|
+
scope: (symbol) devise scope, i.e. ':users' => current_user
|
6
|
+
%>
|
7
|
+
|
8
|
+
<% scope = local_assigns.has_key?(:scope) ? scope : :users %>
|
9
|
+
<% singular = scope.to_s.singularize.to_sym %>
|
10
|
+
<% user = send("current_#{singular}") %>
|
11
|
+
|
12
|
+
<%= render 'headmin/dropdown' do %>
|
13
|
+
<%= render 'headmin/dropdown/button' do %>
|
14
|
+
<%= user.to_s %>
|
15
|
+
<% end %>
|
16
|
+
<%= render 'headmin/dropdown/list' do %>
|
17
|
+
<%= render 'headmin/dropdown/item', name: t('.edit_profile'), url: polymorphic_path([:edit, singular, :registration]) %>
|
18
|
+
<%= render 'headmin/dropdown/divider' %>
|
19
|
+
<%= render 'headmin/dropdown/item', name: t('.log_out'), url: polymorphic_path([:destroy, singular, :session]), method: :delete %>
|
20
|
+
<% end %>
|
21
|
+
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%#
|
2
|
+
headmin/dropdown/item
|
3
|
+
accepts block: no
|
4
|
+
parameters:
|
5
|
+
name: Name of the link in the dropdown menu
|
6
|
+
url: Url of the link in the dropdown menu
|
7
|
+
method: Sets data-method of url
|
8
|
+
%>
|
9
|
+
|
10
|
+
<% method = local_assigns.has_key?(:method) ? method : nil %>
|
11
|
+
<% url = local_assigns.has_key?(:url) ? url : '' %>
|
12
|
+
<% name = local_assigns.has_key?(:name) ? name : '' %>
|
13
|
+
|
14
|
+
<li>
|
15
|
+
<a class="dropdown-item" href="<%= url %>" <%= "data-method=#{method}" if method %>>
|
16
|
+
<%= name %>
|
17
|
+
</a>
|
18
|
+
</li>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%#
|
2
|
+
headmin/dropdown/locale
|
3
|
+
accepts block: no
|
4
|
+
parameters: none
|
5
|
+
%>
|
6
|
+
|
7
|
+
<%= render 'headmin/dropdown' do %>
|
8
|
+
<%= render 'headmin/dropdown/button', id: 'locale-dropdown' do %>
|
9
|
+
<%= bootstrap_icon('globe', class: 'me-2') %>
|
10
|
+
<%= t('language_name', locale: ::I18n.locale) %>
|
11
|
+
<% end %>
|
12
|
+
<%= render 'headmin/dropdown/list', id: 'locale-dropdown' do %>
|
13
|
+
<% I18n.available_locales.each do |locale| %>
|
14
|
+
<%= render 'headmin/dropdown/item', name: t('language_name', locale: locale), url: url_for({locale: locale.to_s}) %>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
17
|
+
<% end %>
|
@@ -1,20 +1,25 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
1
|
+
<%
|
2
|
+
# headmin/filters/date
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>name</tt> - Name of the filter parameter
|
6
|
+
# * <tt>label</tt> - Display name
|
7
|
+
#
|
8
|
+
# ==== Examples
|
9
|
+
# Basic version
|
10
|
+
# <%= render "headmin/filters/date", name: :created_at, label: 'Created at' %#>
|
11
|
+
|
12
|
+
label = local_assigns.has_key?(:label) ? label : nil
|
13
|
+
name = local_assigns.has_key?(:name) ? name : nil
|
10
14
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
}
|
15
|
+
input_options = {
|
16
|
+
placeholder: 'dd/mm/yyyy',
|
17
|
+
class: "form-control flatpickr",
|
18
|
+
required: true,
|
19
|
+
'data-filters-target': 'input',
|
20
|
+
'data-action': "change->filters#update"
|
21
|
+
}
|
22
|
+
%>
|
18
23
|
|
19
24
|
<%= content_for :filters_menu do %>
|
20
25
|
<%= render 'headmin/filters/filter/menu_item', name: name, label: label %>
|
@@ -1,22 +1,22 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
<%
|
2
|
+
# headmin/filters/search
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>name</tt> - Name of the filter parameter
|
6
|
+
# * <tt>label</tt> - Name of the resource to be used in the placeholder (search in ...)
|
7
|
+
# * <tt>placeholder</tt> - Placeholder in the search field
|
8
|
+
#
|
9
|
+
# ==== Examples
|
10
|
+
# Basic version.
|
11
|
+
# <%= render 'headmin/filters/search', name: :search, label: Poll.model_name.human(count: 2) %#>
|
12
|
+
|
13
|
+
name = local_assigns.has_key?(:name) ? name : :search
|
14
|
+
label = local_assigns.has_key?(:label) ? label : nil
|
15
|
+
placeholder = local_assigns.has_key?(:placeholder) ? placeholder : t('.placeholder', resource: label)
|
12
16
|
|
13
|
-
|
17
|
+
value = filter_param_exists?(name) ? params[name] : nil
|
18
|
+
%>
|
14
19
|
|
15
20
|
<% content_for :filters_search do %>
|
16
|
-
<
|
17
|
-
<input class="form-control me-1" type="search" placeholder="<%= raw placeholder.capitalize %>" aria-label="Search" name="<%= name %>" value="<%= value %>">
|
18
|
-
<button class="btn h-btn-outline-light d-none d-md-block" type="submit">
|
19
|
-
<%= t('.button') %>
|
20
|
-
</button>
|
21
|
-
</div>
|
21
|
+
<input class="form-control" type="search" placeholder="<%= raw placeholder.capitalize %>" aria-label="Search" name="<%= name %>" value="<%= value %>">
|
22
22
|
<% end %>
|
@@ -1,23 +1,28 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
<%
|
2
|
+
# headmin/filters/select
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>name</tt> - Name of the filter parameter
|
6
|
+
# * <tt>label</tt> - Display name
|
7
|
+
# * <tt>options</tt> - List of options to select from
|
8
|
+
#
|
9
|
+
# ==== Examples
|
10
|
+
# Basic version
|
11
|
+
# <%= render "headmin/filters/select", name: :poll_type, label: 'Type', options: [["General", "general", "Fun", "fun"]] %#>
|
12
|
+
|
13
|
+
label = local_assigns.has_key?(:label) ? label : nil
|
14
|
+
name = local_assigns.has_key?(:name) ? name : nil
|
15
|
+
options = local_assigns.has_key?(:options) ? options : []
|
12
16
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
}
|
17
|
+
select_options = {
|
18
|
+
class: "form-select",
|
19
|
+
prompt: t('.blank'),
|
20
|
+
include_blank: false,
|
21
|
+
required: true,
|
22
|
+
'data-filters-target': 'input',
|
23
|
+
'data-action': "change->filters#update"
|
24
|
+
}
|
25
|
+
%>
|
21
26
|
|
22
27
|
<%= content_for :filters_menu do %>
|
23
28
|
<%= render 'headmin/filters/filter/menu_item', name: name, label: label %>
|
@@ -30,10 +35,10 @@
|
|
30
35
|
<% end %>
|
31
36
|
|
32
37
|
<%= content_for :filters_buttons do %>
|
33
|
-
<%
|
34
|
-
<%
|
35
|
-
<%= render 'headmin/filters/filter/button', name: name, label: label, value:
|
36
|
-
<%= select_tag("#{name}[]", options_for_select(options,
|
38
|
+
<% (params[name] || []).each_with_index do |param, index| %>
|
39
|
+
<% value = options.detect { |value, key, config| key == param } %>
|
40
|
+
<%= render 'headmin/filters/filter/button', name: name, label: label, value: value ? value.first : nil, id: "#{name}_#{index}" do %>
|
41
|
+
<%= select_tag("#{name}[]", options_for_select(options, param), select_options) %>
|
37
42
|
<% end %>
|
38
43
|
<% end %>
|
39
44
|
<% end %>
|
@@ -1,22 +1,31 @@
|
|
1
1
|
<%#
|
2
|
-
|
2
|
+
headmin/filters/filter/button
|
3
3
|
accepts block: yes
|
4
4
|
parameters:
|
5
5
|
name: (string) Name of the parameter
|
6
6
|
label: (string) Display name
|
7
7
|
value: (string) Value of the parameter
|
8
8
|
%>
|
9
|
+
<% id = local_assigns.has_key?(:id) ? id : Time.now.utc.to_i %>
|
9
10
|
<% name = local_assigns.has_key?(:name) ? name : nil %>
|
10
11
|
<% label = local_assigns.has_key?(:label) ? label : nil %>
|
11
12
|
<% value = local_assigns.has_key?(:value) ? value : nil %>
|
12
|
-
<% active = local_assigns.has_key?(:active) ? active : false %>
|
13
13
|
|
14
|
-
<div class="h-filter me-1
|
15
|
-
|
14
|
+
<div class="h-filter me-1 my-1" data-filter-name="<%= name %>">
|
15
|
+
|
16
|
+
<button
|
17
|
+
type="button"
|
18
|
+
class="h-filter-button btn h-btn-outline-transparent"
|
19
|
+
data-popup-target="button"
|
20
|
+
data-popup-id="<%= id %>"
|
21
|
+
data-action="click->popup#open"
|
22
|
+
>
|
16
23
|
<%= "#{label}: #{value || t('.all')}" %>
|
17
24
|
<span class="h-filter-remove" data-action="click->filters#remove"><%= bootstrap_icon('x-lg') %></span>
|
18
25
|
</button>
|
19
|
-
|
26
|
+
|
27
|
+
<%= render 'headmin/popup', id: "#{id}" do %>
|
20
28
|
<%= yield if block_given? %>
|
21
|
-
|
29
|
+
<% end %>
|
30
|
+
|
22
31
|
</div>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
<%#
|
2
|
-
|
2
|
+
headmin/filters/filter/menu_item
|
3
3
|
accepts block: no
|
4
4
|
parameters:
|
5
5
|
name: (string) Name of the parameter
|
6
6
|
label: (string) Display name
|
7
7
|
%>
|
8
8
|
<li>
|
9
|
-
<a class="dropdown-item" href="#" data-action="click->filters#add" data-filter-name="<%= name %>">
|
9
|
+
<a class="dropdown-item" href="#" data-filters-target="menuItem" data-action="click->filters#add" data-filter-name="<%= name %>">
|
10
10
|
<%= label %>
|
11
11
|
</a>
|
12
12
|
</li>
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%#
|
2
|
-
|
2
|
+
headmin/filters/filter/template
|
3
3
|
accepts block: yes
|
4
4
|
parameters:
|
5
5
|
name: (string) Name of the parameter
|
@@ -7,7 +7,7 @@
|
|
7
7
|
%>
|
8
8
|
|
9
9
|
<template data-filter-name="<%= name %>" data-filters-target="template">
|
10
|
-
<%= render 'headmin/filters/filter/button', name: name, label: label, value: nil,
|
10
|
+
<%= render 'headmin/filters/filter/button', name: name, label: label, value: nil, id: 'template_id' do %>
|
11
11
|
<%= yield if block_given? %>
|
12
12
|
<% end %>
|
13
13
|
</template>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%#
|
2
|
-
|
2
|
+
headmin/forms/actions
|
3
3
|
accepts block: true
|
4
4
|
parameters:
|
5
|
-
form: (
|
5
|
+
form: (object) Form object
|
6
6
|
%>
|
7
7
|
|
8
8
|
<div class="card forms-actions shadow-sm mb-3">
|
@@ -21,12 +21,8 @@
|
|
21
21
|
|
22
22
|
<%= yield if block_given? %>
|
23
23
|
|
24
|
-
|
25
|
-
<%= link_to(t('.delete.title'),[:admin, form.object], class: 'btn btn-outline-danger', method: :delete, data: {confirm: t('.delete.confirm')}) %>
|
26
|
-
</div>
|
24
|
+
<%= render 'headmin/forms/actions/destroy', form: form %>
|
27
25
|
<hr>
|
28
|
-
|
29
|
-
<%= form.submit "Opslaan", class: 'btn btn-lg btn-primary' %>
|
30
|
-
</div>
|
26
|
+
<%= render 'headmin/forms/actions/save', form: form %>
|
31
27
|
</div>
|
32
28
|
</div>
|
@@ -0,0 +1,60 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/base
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>form<tt> - Form object
|
6
|
+
# * <tt>attribute<tt> - Name of the attribute of the form model
|
7
|
+
# * <tt>options<tt> - Hash with all HTML options to pass to
|
8
|
+
# * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
|
9
|
+
# * <tt>required<tt> - Set to true to mark as required
|
10
|
+
# * <tt>float<tt> - Set to true if you want to show floating labels
|
11
|
+
# * <tt>append<tt> - Text or icon to be shown on the left hand side of the input, Doesn't work with float
|
12
|
+
# * <tt>prepend<tt> - Text or icon to be shown on the right hand side of the input, Doesn't work with float
|
13
|
+
#
|
14
|
+
# ==== Examples
|
15
|
+
# Basic version
|
16
|
+
# <%= render 'headmin/forms/date', form: form, attribute: :title %#>
|
17
|
+
#
|
18
|
+
# With datepicker
|
19
|
+
# <%= render 'headmin/forms/text', form: form, attribute: :title, datepicker: true %#>
|
20
|
+
|
21
|
+
append = local_assigns.has_key?(:append) ? append : nil
|
22
|
+
float = local_assigns.has_key?(:float) ? float : false
|
23
|
+
label = local_assigns.has_key?(:label) ? label : nil
|
24
|
+
prepend = local_assigns.has_key?(:prepend) ? prepend : nil
|
25
|
+
required = local_assigns.has_key?(:required) ? required : false
|
26
|
+
|
27
|
+
show_label = label != false
|
28
|
+
%>
|
29
|
+
|
30
|
+
<div class="<%= 'form-floating' if float %> <%= ('mb-3 text-start' if show_label) %>">
|
31
|
+
<% if show_label && !float %>
|
32
|
+
<%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
<% if float %>
|
36
|
+
<%= yield form %>
|
37
|
+
<%= render 'headmin/forms/validation', form: form, attribute: attribute %>
|
38
|
+
<% else %>
|
39
|
+
<div class="input-group w-100">
|
40
|
+
<% if prepend %>
|
41
|
+
<span class="input-group-text">
|
42
|
+
<%= prepend %>
|
43
|
+
</span>
|
44
|
+
<% end %>
|
45
|
+
|
46
|
+
<%= yield form %>
|
47
|
+
<%= render 'headmin/forms/validation', form: form, attribute: attribute %>
|
48
|
+
|
49
|
+
<% if append %>
|
50
|
+
<span class="input-group-text">
|
51
|
+
<%= append %>
|
52
|
+
</span>
|
53
|
+
<% end %>
|
54
|
+
</div>
|
55
|
+
<% end %>
|
56
|
+
|
57
|
+
<% if show_label && float %>
|
58
|
+
<%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
|
59
|
+
<% end %>
|
60
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/blocks
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>form</tt> - Form object
|
6
|
+
# * <tt>path</tt> - Directory where to look for block templates
|
7
|
+
# * <tt>allow</tt> - Names of block templates that can be added
|
8
|
+
#
|
9
|
+
# ==== Examples
|
10
|
+
# Basic version. This will only look for blocks in 'admin/blocks'
|
11
|
+
# <%= render "headmin/forms/blocks", form: form %#>
|
12
|
+
#
|
13
|
+
# Define the path to look for block templates like this:
|
14
|
+
# <%= render "headmin/forms/blocks", form: form, path: 'admin/pages/blocks' %#>
|
15
|
+
#
|
16
|
+
# Limit the types of blocks
|
17
|
+
# <%= render "headmin/forms/blocks", form: form, allow: ['text', 'text-image'] %#>
|
18
|
+
|
19
|
+
path = local_assigns.has_key?(:path) ? path : nil
|
20
|
+
allowed_block_names = local_assigns.has_key?(:allow) ? allow.map(&:to_s) : BlockService.block_names(path: path)
|
21
|
+
|
22
|
+
templates = allowed_block_names.map { |name| BlockService.form_view(name, path: path) }
|
23
|
+
%>
|
24
|
+
|
25
|
+
<%= render 'headmin/forms/repeater', form: form, attribute: :blocks, templates: templates, label: false do |block| %>
|
26
|
+
<% view_path = BlockService.form_view(block.object.name, path: path).gsub('/_', '/') %>
|
27
|
+
<%= render view_path, form: block, name: block.object.name %>
|
28
|
+
|
29
|
+
<span class="position-absolute top-0 end-0 badge bg-light text-dark">
|
30
|
+
<%= block.object.name.titleize %>
|
31
|
+
</span>
|
32
|
+
<% end %>
|
@@ -0,0 +1,39 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/checkbox
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>form<tt> - Form object
|
6
|
+
# * <tt>attribute<tt> - Name of the attribute of the form model
|
7
|
+
# * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
|
8
|
+
#
|
9
|
+
# ==== Examples
|
10
|
+
# Basic version
|
11
|
+
# <%= render 'headmin/forms/image', form: form, attribute: :image %#>
|
12
|
+
|
13
|
+
class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
|
14
|
+
data = local_assigns.has_key?(:data) ? data : nil
|
15
|
+
disabled = local_assigns.has_key?(:disabled) ? disabled : false
|
16
|
+
label = local_assigns.has_key?(:label) ? label : nil
|
17
|
+
readonly = local_assigns.has_key?(:readonly) ? readonly : false
|
18
|
+
required = local_assigns.has_key?(:required) ? required : false
|
19
|
+
|
20
|
+
options = {
|
21
|
+
'aria-describedby': form_field_validation_id(form, attribute),
|
22
|
+
class: "form-checkbox-input #{form_field_validation_class(form, attribute)} #{class_names}",
|
23
|
+
data: data,
|
24
|
+
disabled: disabled,
|
25
|
+
placeholder: attribute,
|
26
|
+
readonly: readonly,
|
27
|
+
required: required,
|
28
|
+
}
|
29
|
+
|
30
|
+
show_label = label != false
|
31
|
+
%>
|
32
|
+
|
33
|
+
<div class="<%= ('mb-3 text-start' if show_label) %>">
|
34
|
+
<%= form.check_box(attribute, options) %>
|
35
|
+
<% if show_label %>
|
36
|
+
<%= render 'headmin/forms/label', form: form, attribute: attribute, name: label, required: required %>
|
37
|
+
<% end %>
|
38
|
+
<%= render 'headmin/forms/validation', form: form, attribute: attribute %>
|
39
|
+
</div>
|
@@ -0,0 +1,42 @@
|
|
1
|
+
<%
|
2
|
+
# headmin/forms/ckeditor
|
3
|
+
#
|
4
|
+
# ==== Options
|
5
|
+
# * <tt>form<tt> - Form object
|
6
|
+
# * <tt>attribute<tt> - Name of the attribute of the form model
|
7
|
+
# * <tt>label<tt> - Text to show as label. Label will be hidden if value is false
|
8
|
+
# * <tt>toolbar<tt> - Array containing the toolbar items to display
|
9
|
+
# * <tt>upload_path<tt> - URL to upload images to
|
10
|
+
#
|
11
|
+
# ==== Examples
|
12
|
+
# Basic version
|
13
|
+
# <%= render 'headmin/forms/textarea', form: form, attribute: :title %#>
|
14
|
+
|
15
|
+
class_names = local_assigns.has_key?(:class) ? local_assigns[:class] : false
|
16
|
+
data = local_assigns.has_key?(:data) ? data : {}
|
17
|
+
disabled = local_assigns.has_key?(:disabled) ? disabled : false
|
18
|
+
label = local_assigns.has_key?(:label) ? label : nil
|
19
|
+
readonly = local_assigns.has_key?(:readonly) ? readonly : false
|
20
|
+
required = local_assigns.has_key?(:required) ? required : false
|
21
|
+
toolbar = local_assigns.has_key?(:toolbar) ? toolbar : nil
|
22
|
+
upload_path = local_assigns.has_key?(:upload_path) ? upload_path : ''
|
23
|
+
|
24
|
+
data = data.merge(
|
25
|
+
'ckeditor-toolbar': toolbar,
|
26
|
+
'ckeditor-upload-path': upload_path
|
27
|
+
)
|
28
|
+
|
29
|
+
options = {
|
30
|
+
'aria-describedby': form_field_validation_id(form, attribute),
|
31
|
+
class: "ckeditor #{form_field_validation_class(form, attribute)} #{class_names}",
|
32
|
+
data: data,
|
33
|
+
disabled: disabled,
|
34
|
+
placeholder: attribute,
|
35
|
+
readonly: readonly,
|
36
|
+
required: required,
|
37
|
+
}
|
38
|
+
%>
|
39
|
+
|
40
|
+
<%= render 'headmin/forms/base', form: form, attribute: attribute, label: label, required: required do |form| %>
|
41
|
+
<%= form.text_area(attribute, options) %>
|
42
|
+
<% end %>
|