headmin 0.4.2 → 0.5.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.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -1
  3. data/Gemfile.lock +1 -1
  4. data/app/assets/javascripts/headmin/controllers/date_range_controller.js +12 -6
  5. data/app/assets/javascripts/headmin/controllers/filter_controller.js +61 -11
  6. data/app/assets/javascripts/headmin/controllers/filter_row_controller.js +50 -0
  7. data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +2 -6
  8. data/app/assets/javascripts/headmin/controllers/popup_controller.js +3 -1
  9. data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +16 -21
  10. data/app/assets/javascripts/headmin/index.js +2 -0
  11. data/app/assets/javascripts/headmin.js +119 -38
  12. data/app/assets/stylesheets/headmin/filter.scss +74 -0
  13. data/app/assets/stylesheets/headmin/general.scss +0 -1
  14. data/app/assets/stylesheets/headmin/layout/body.scss +5 -0
  15. data/app/assets/stylesheets/headmin/popup.scss +0 -1
  16. data/app/assets/stylesheets/headmin.css +67 -2
  17. data/app/controllers/concerns/headmin/filterable.rb +27 -0
  18. data/app/models/headmin/filter/base.rb +238 -0
  19. data/app/models/headmin/filter/base_view.rb +64 -0
  20. data/app/models/headmin/filter/boolean.rb +15 -0
  21. data/app/models/headmin/filter/boolean_view.rb +61 -0
  22. data/app/models/headmin/filter/button_view.rb +25 -0
  23. data/app/models/headmin/filter/conditional_view.rb +16 -0
  24. data/app/models/headmin/filter/date.rb +19 -0
  25. data/app/models/headmin/filter/date_view.rb +52 -0
  26. data/app/models/headmin/filter/flatpickr_view.rb +54 -0
  27. data/app/models/headmin/filter/menu_item_view.rb +6 -0
  28. data/app/models/headmin/filter/money.rb +13 -0
  29. data/app/models/headmin/filter/number.rb +27 -0
  30. data/app/models/headmin/filter/number_view.rb +54 -0
  31. data/app/models/headmin/filter/operator_view.rb +30 -0
  32. data/app/models/headmin/filter/options_view.rb +61 -0
  33. data/app/models/headmin/filter/row_view.rb +13 -0
  34. data/app/models/headmin/filter/search.rb +18 -0
  35. data/app/models/headmin/filter/search_view.rb +31 -0
  36. data/app/models/headmin/filter/text.rb +25 -0
  37. data/app/models/headmin/filter/text_view.rb +53 -0
  38. data/app/models/headmin/filters.rb +29 -0
  39. data/app/models/headmin/form/datetime_range_view.rb +25 -0
  40. data/app/models/headmin/form/datetime_view.rb +45 -0
  41. data/app/models/headmin/form/flatpickr_range_view.rb +4 -15
  42. data/app/models/headmin/form/flatpickr_view.rb +3 -12
  43. data/app/models/view_model.rb +1 -1
  44. data/app/views/examples/admin.html.erb +13 -13
  45. data/app/views/examples/auth.html.erb +1 -1
  46. data/app/views/headmin/_filters.html.erb +6 -6
  47. data/app/views/headmin/_form.html.erb +2 -2
  48. data/app/views/headmin/_index.html.erb +1 -1
  49. data/app/views/headmin/_pagination.html.erb +1 -1
  50. data/app/views/headmin/_popup.html.erb +2 -2
  51. data/app/views/headmin/_table.html.erb +1 -1
  52. data/app/views/headmin/dropdown/_devise.html.erb +8 -8
  53. data/app/views/headmin/dropdown/_locale.html.erb +4 -4
  54. data/app/views/headmin/filters/_base.html.erb +95 -0
  55. data/app/views/headmin/filters/_boolean.html.erb +23 -0
  56. data/app/views/headmin/filters/_date.html.erb +14 -38
  57. data/app/views/headmin/filters/_flatpickr.html.erb +15 -48
  58. data/app/views/headmin/filters/_number.html.erb +23 -0
  59. data/app/views/headmin/filters/_options.html.erb +24 -0
  60. data/app/views/headmin/filters/_search.html.erb +14 -12
  61. data/app/views/headmin/filters/_text.html.erb +23 -0
  62. data/app/views/headmin/filters/filter/_button.html.erb +9 -10
  63. data/app/views/headmin/filters/filter/_conditional.html.erb +18 -0
  64. data/app/views/headmin/filters/filter/_menu_item.html.erb +5 -2
  65. data/app/views/headmin/filters/filter/_null_select.html.erb +8 -0
  66. data/app/views/headmin/filters/filter/_operator.html.erb +16 -0
  67. data/app/views/headmin/filters/filter/_row.html.erb +11 -0
  68. data/app/views/headmin/forms/_blocks.html.erb +1 -1
  69. data/app/views/headmin/forms/_date_range.html.erb +3 -3
  70. data/app/views/headmin/forms/_datetime.html.erb +41 -0
  71. data/app/views/headmin/forms/_datetime_range.html.erb +40 -0
  72. data/app/views/headmin/forms/_file.html.erb +3 -3
  73. data/app/views/headmin/forms/_flatpickr.html.erb +1 -1
  74. data/app/views/headmin/forms/_flatpickr_range.html.erb +3 -4
  75. data/app/views/headmin/forms/_label.html.erb +1 -1
  76. data/app/views/headmin/forms/_repeater.html.erb +12 -12
  77. data/app/views/headmin/forms/fields/_base.html.erb +1 -1
  78. data/app/views/headmin/forms/fields/_file.html.erb +2 -2
  79. data/app/views/headmin/forms/fields/_files.html.erb +2 -2
  80. data/app/views/headmin/forms/fields/_group.html.erb +5 -5
  81. data/app/views/headmin/forms/fields/_list.html.erb +4 -4
  82. data/app/views/headmin/forms/fields/_text.html.erb +2 -2
  83. data/app/views/headmin/layout/_footer.html.erb +1 -1
  84. data/app/views/headmin/layout/_main.html.erb +1 -1
  85. data/app/views/headmin/nav/_dropdown.html.erb +3 -3
  86. data/app/views/headmin/nav/_item.html.erb +2 -2
  87. data/app/views/headmin/nav/item/_devise.html.erb +8 -8
  88. data/app/views/headmin/nav/item/_locale.html.erb +4 -4
  89. data/app/views/headmin/table/_actions.html.erb +3 -6
  90. data/app/views/headmin/table/actions/_export.html.erb +1 -1
  91. data/app/views/headmin/table/body/_row.html.erb +3 -3
  92. data/app/views/headmin/table/foot/_id.html.erb +1 -1
  93. data/app/views/headmin/views/devise/confirmations/_new.html.erb +1 -1
  94. data/app/views/headmin/views/devise/passwords/_edit.html.erb +2 -2
  95. data/app/views/headmin/views/devise/passwords/_new.html.erb +1 -1
  96. data/app/views/headmin/views/devise/registrations/_edit.html.erb +4 -4
  97. data/app/views/headmin/views/devise/registrations/_new.html.erb +3 -3
  98. data/app/views/headmin/views/devise/sessions/_new.html.erb +3 -3
  99. data/app/views/headmin/views/devise/unlocks/_new.html.erb +1 -1
  100. data/config/locales/en.yml +4 -0
  101. data/config/locales/headmin/dropdown/en.yml +6 -0
  102. data/config/locales/headmin/dropdown/nl.yml +6 -0
  103. data/config/locales/headmin/filters/en.yml +26 -1
  104. data/config/locales/headmin/filters/nl.yml +26 -1
  105. data/config/locales/headmin/layout/en.yml +0 -9
  106. data/config/locales/headmin/layout/nl.yml +0 -9
  107. data/config/locales/headmin/nav/en.yml +7 -0
  108. data/config/locales/headmin/nav/nl.yml +7 -0
  109. data/config/locales/nl.yml +4 -0
  110. data/lib/generators/templates/views/layouts/auth.html.erb +1 -1
  111. data/lib/headmin/version.rb +1 -1
  112. data/package.json +1 -1
  113. metadata +42 -6
  114. data/app/controllers/concerns/headmin/filter.rb +0 -5
  115. data/app/controllers/concerns/headmin/searchable.rb +0 -15
  116. data/app/views/headmin/filters/_select.html.erb +0 -45
  117. data/app/views/headmin/filters/filter/_template.html.erb +0 -13
@@ -0,0 +1,13 @@
1
+ module Headmin
2
+ module Filter
3
+ class Money < Headmin::Filter::Number
4
+ def cast_value(value)
5
+ super(value) * 100
6
+ end
7
+
8
+ def attribute
9
+ "#{@attribute}_cents"
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ module Headmin
2
+ module Filter
3
+ class Number < Headmin::Filter::Base
4
+ OPERATORS = %w[eq not_eq gt gteq lt lteq between not_between in not_in is_null is_not_null]
5
+
6
+ def cast_value(value)
7
+ is_i?(value) ? value.to_i : 0
8
+ end
9
+
10
+ def to_s
11
+ string
12
+ end
13
+
14
+ private
15
+
16
+ def is_i?(value)
17
+ # Regex: this selects signed digits (\d) only, it is then checked to the value, e.g.:
18
+ # is_i?("3") = true
19
+ # is_i?("-3") = true
20
+ # is_i?("3a") = false
21
+ # is_i?("3.2") = false
22
+
23
+ /\A[-+]?\d+\z/.match(value)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,54 @@
1
+ module Headmin
2
+ module Filter
3
+ class NumberView < ViewModel
4
+ def base_options
5
+ keys = %i[name label form]
6
+ options = to_h.slice(*keys)
7
+ default_base_options.merge(options)
8
+ end
9
+
10
+ def input_options
11
+ keys = %i[form]
12
+ options = to_h.slice(*keys)
13
+ default_input_options.merge(options)
14
+ end
15
+
16
+ private
17
+
18
+ def id
19
+ "#{name}_value"
20
+ end
21
+
22
+ def name
23
+ @name || attribute
24
+ end
25
+
26
+ def label
27
+ @label || I18n.t("attributes.#{attribute}", default: name.to_s)
28
+ end
29
+
30
+ def default_base_options
31
+ {
32
+ label: label,
33
+ name: attribute,
34
+ filter: Headmin::Filter::Number.new(name, @params),
35
+ allowed_operators: Headmin::Filter::Number::OPERATORS - %w[in not_in between not_between]
36
+ }
37
+ end
38
+
39
+ def default_input_options
40
+ {
41
+ label: false,
42
+ wrapper: false,
43
+ id: id,
44
+ data: {
45
+ action: "change->filter#updateHiddenValue",
46
+ filter_target: "value",
47
+ filter_row_target: "original"
48
+ },
49
+ class: "form-control"
50
+ }
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,30 @@
1
+ module Headmin
2
+ module Filter
3
+ class OperatorView < ViewModel
4
+ def allowed_operators
5
+ @allowed_operators || []
6
+ end
7
+
8
+ def selected
9
+ @selected || nil
10
+ end
11
+
12
+ def operator_symbol
13
+ {
14
+ eq: "&equals; #{I18n.t("headmin.filters.operators.eq")}",
15
+ not_eq: "&ne; #{I18n.t("headmin.filters.operators.not_eq")}",
16
+ gt: "&gt; #{I18n.t("headmin.filters.operators.gt")}",
17
+ gteq: "&ge; #{I18n.t("headmin.filters.operators.gteq")}",
18
+ lt: "&lt; #{I18n.t("headmin.filters.operators.lt")}",
19
+ lteq: "&le; #{I18n.t("headmin.filters.operators.lteq")}",
20
+ starts_with: "&sqsub; #{I18n.t("headmin.filters.operators.starts_with")}",
21
+ ends_with: "&sqsup; #{I18n.t("headmin.filters.operators.ends_with")}",
22
+ matches: "&approx; #{I18n.t("headmin.filters.operators.matches")}",
23
+ does_not_match: "&napprox; #{I18n.t("headmin.filters.operators.does_not_match")}",
24
+ is_null: "&#9675; #{I18n.t("headmin.filters.operators.is_null")}",
25
+ is_not_null: "&#9679; #{I18n.t("headmin.filters.operators.is_not_null")}"
26
+ }
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,61 @@
1
+ module Headmin
2
+ module Filter
3
+ class OptionsView < ViewModel
4
+ def base_options
5
+ keys = %i[name label form]
6
+ options = to_h.slice(*keys)
7
+ default_base_options.merge(options)
8
+ end
9
+
10
+ def input_options
11
+ keys = %i[form]
12
+ options = to_h.slice(*keys)
13
+ default_input_options.merge(options)
14
+ end
15
+
16
+ def collection
17
+ @collection || []
18
+ end
19
+
20
+ private
21
+
22
+ def id
23
+ "#{name}_value"
24
+ end
25
+
26
+ def name
27
+ @name || attribute
28
+ end
29
+
30
+ def label
31
+ @label || I18n.t("attributes.#{attribute}", default: name.to_s)
32
+ end
33
+
34
+ def default_base_options
35
+ {
36
+ label: label,
37
+ name: attribute,
38
+ display_values: collection,
39
+ filter: Headmin::Filter::Text.new(name, @params),
40
+ allowed_operators: Headmin::Filter::Text::OPERATORS - %w[starts_with ends_with in not_in]
41
+ }
42
+ end
43
+
44
+ def default_input_options
45
+ {
46
+ label: false,
47
+ wrapper: false,
48
+ id: id,
49
+ data: {
50
+ action: "change->filter#updateHiddenValue",
51
+ filter_target: "value",
52
+ filter_row_target: "original"
53
+ },
54
+ collection: collection,
55
+ selected: selected,
56
+ class: "form-select"
57
+ }
58
+ end
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,13 @@
1
+ module Headmin
2
+ module Filter
3
+ class RowView < ViewModel
4
+ def operator
5
+ @operator || nil
6
+ end
7
+
8
+ def value
9
+ @value || nil
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,18 @@
1
+ module Headmin
2
+ module Filter
3
+ class Search < Headmin::Filter::Base
4
+ def query(collection)
5
+ return collection unless @instructions.any?
6
+ collection.search(raw_value)
7
+ end
8
+
9
+ def cast_value(value)
10
+ value
11
+ end
12
+
13
+ def display_value(value)
14
+ value.downcase
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,31 @@
1
+ module Headmin
2
+ module Filter
3
+ class SearchView < ViewModel
4
+ def input_options
5
+ keys = attributes - %i[params]
6
+ options = to_h.slice(*keys)
7
+ options = default_input_options.merge(options)
8
+ options.merge(label: false)
9
+ end
10
+
11
+ private
12
+
13
+ def default_input_options
14
+ {
15
+ name: name,
16
+ value: params[name],
17
+ wrapper: false,
18
+ placeholder: placeholder
19
+ }
20
+ end
21
+
22
+ def name
23
+ @name || attribute || :search
24
+ end
25
+
26
+ def placeholder
27
+ @placeholder || I18n.t("headmin.filters.search.placeholder", resource: label)
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,25 @@
1
+ module Headmin
2
+ module Filter
3
+ class Text < Headmin::Filter::Base
4
+ OPERATORS = %w[eq not_eq in not_in matches does_not_match starts_with ends_with is_null is_not_null starts_with ends_with]
5
+
6
+ def cast_value(value)
7
+ value
8
+ end
9
+
10
+ def display_value(value)
11
+ value.downcase
12
+ end
13
+
14
+ private
15
+
16
+ def convert_to_ends(value)
17
+ "%#{value}"
18
+ end
19
+
20
+ def convert_to_starts(value)
21
+ "#{value}%"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,53 @@
1
+ module Headmin
2
+ module Filter
3
+ class TextView < ViewModel
4
+ def base_options
5
+ keys = %i[name label form]
6
+ options = to_h.slice(*keys)
7
+ default_base_options.merge(options)
8
+ end
9
+
10
+ def input_options
11
+ keys = %i[form]
12
+ options = to_h.slice(*keys)
13
+ default_input_options.merge(options)
14
+ end
15
+
16
+ private
17
+
18
+ def id
19
+ "#{name}_value"
20
+ end
21
+
22
+ def name
23
+ @name || attribute
24
+ end
25
+
26
+ def label
27
+ @label || I18n.t("attributes.#{attribute}", default: name.to_s)
28
+ end
29
+
30
+ def default_base_options
31
+ {
32
+ label: label,
33
+ name: attribute,
34
+ filter: Headmin::Filter::Text.new(name, @params),
35
+ allowed_operators: Headmin::Filter::Text::OPERATORS - %w[in not_in]
36
+ }
37
+ end
38
+
39
+ def default_input_options
40
+ {
41
+ label: false,
42
+ wrapper: false,
43
+ id: id,
44
+ data: {
45
+ action: "change->filter#updateHiddenValue",
46
+ filter_target: "value",
47
+ filter_row_target: "original"
48
+ }
49
+ }
50
+ end
51
+ end
52
+ end
53
+ end
@@ -0,0 +1,29 @@
1
+ module Headmin
2
+ class Filters
3
+ # Example:
4
+ #
5
+ # @orders = Headmin::Filters.new(params, {
6
+ # status: :text,
7
+ # price: :number,
8
+ # in_stock: :boolean
9
+ # }).query(Order)
10
+
11
+ def initialize(params, param_types)
12
+ @params = params
13
+ @param_types = param_types
14
+ end
15
+
16
+ def parse(attribute, type)
17
+ class_name = "Headmin::Filter::#{type.to_s.classify}".constantize
18
+ class_name.new(attribute, @params)
19
+ end
20
+
21
+ def query(collection)
22
+ @param_types.each do |attribute, type|
23
+ filter = parse(attribute, type)
24
+ collection = filter.query(collection)
25
+ end
26
+ collection
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,25 @@
1
+ module Headmin
2
+ module Form
3
+ class DatetimeRangeView < ViewModel
4
+ def start_options
5
+ default_start_options.deep_merge(@start || {})
6
+ end
7
+
8
+ def end_options
9
+ default_end_options.deep_merge(@end || {})
10
+ end
11
+
12
+ private
13
+
14
+ def default_start_options
15
+ keys = attributes - %i[start]
16
+ to_h.slice(*keys)
17
+ end
18
+
19
+ def default_end_options
20
+ keys = attributes - %i[end]
21
+ to_h.slice(*keys)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,45 @@
1
+ module Headmin
2
+ module Form
3
+ class DatetimeView < ViewModel
4
+ include Headmin::Form::Hintable
5
+ include Headmin::Form::InputGroupable
6
+ include Headmin::Form::Labelable
7
+ include Headmin::Form::Listable
8
+ include Headmin::Form::Placeholderable
9
+ include Headmin::Form::Validatable
10
+ include Headmin::Form::Wrappable
11
+
12
+ def input_options
13
+ keys = attributes - %i[append attribute float form input_group input_group label prepend validate wrapper]
14
+ options = to_h.slice(*keys)
15
+ default_input_options.deep_merge(options)
16
+ end
17
+
18
+ def input_group_options
19
+ default_input_group_options
20
+ .deep_merge(label_input_group_options)
21
+ .deep_merge(@input_group || {})
22
+ end
23
+
24
+ def wrapper_options
25
+ default_wrapper_options.deep_merge({
26
+ class: ["mb-3", ("form-floating" if float)]
27
+ }).deep_merge(@wrapper || {})
28
+ end
29
+
30
+ private
31
+
32
+ def default_input_options
33
+ {
34
+ aria: {describedby: validation_id},
35
+ class: [form_control_class, validation_class],
36
+ placeholder: placeholder
37
+ }
38
+ end
39
+
40
+ def form_control_class
41
+ plaintext ? "form-control-plaintext" : "form-control"
42
+ end
43
+ end
44
+ end
45
+ end
@@ -43,10 +43,7 @@ module Headmin
43
43
 
44
44
  def wrapper_options
45
45
  default_wrapper_options.deep_merge({
46
- class: ["mb-3", ("form-floating" if float)],
47
- data: {
48
- controller: "flatpickr date-range"
49
- }
46
+ class: ["mb-3", ("form-floating" if float)]
50
47
  }).deep_merge(@wrapper || {})
51
48
  end
52
49
 
@@ -59,19 +56,11 @@ module Headmin
59
56
  end
60
57
 
61
58
  def default_start_options
62
- {
63
- data: {
64
- 'date-range-target': "startDateInput"
65
- }
66
- }
59
+ {}
67
60
  end
68
61
 
69
62
  def default_end_options
70
- {
71
- data: {
72
- 'date-range-target': "endDateInput"
73
- }
74
- }
63
+ {}
75
64
  end
76
65
 
77
66
  def default_input_options
@@ -81,7 +70,7 @@ module Headmin
81
70
  placeholder: placeholder,
82
71
  name: nil,
83
72
  data: {
84
- "flatpickr-target": "input",
73
+ controller: "flatpickr date-range",
85
74
  action: "change->date-range#update",
86
75
  flatpickr: {
87
76
  mode: "range",
@@ -2,7 +2,7 @@ module Headmin
2
2
  module Form
3
3
  class FlatpickrView < ViewModel
4
4
  def options
5
- keys = attributes - %i[data wrapper]
5
+ keys = attributes - %i[data]
6
6
  options = to_h.slice(*keys)
7
7
  default_options.deep_merge(options)
8
8
  end
@@ -11,27 +11,18 @@ module Headmin
11
11
 
12
12
  def default_options
13
13
  {
14
- data: default_data.deep_merge(data || {}),
15
- wrapper: default_wrapper_options.deep_merge(wrapper || {})
14
+ data: default_data.deep_merge(data || {})
16
15
  }
17
16
  end
18
17
 
19
18
  def default_data
20
19
  {
21
- "flatpickr-target": "input",
20
+ controller: "flatpickr",
22
21
  flatpickr: {
23
22
  defaultDate: form.object&.send(attribute)&.strftime("%d/%m/%Y")
24
23
  }
25
24
  }
26
25
  end
27
-
28
- def default_wrapper_options
29
- {
30
- data: {
31
- controller: "flatpickr"
32
- }
33
- }
34
- end
35
26
  end
36
27
  end
37
28
  end
@@ -33,7 +33,7 @@ class ViewModel
33
33
  end
34
34
 
35
35
  def to_hash
36
- attributes.map { |attribute| {attribute => value_for(attribute)} }.inject(:merge)
36
+ attributes.map { |attribute| {attribute => value_for(attribute)} }.inject(:merge) || {}
37
37
  end
38
38
 
39
39
  alias_method :to_h, :to_hash
@@ -11,26 +11,26 @@
11
11
  </head>
12
12
 
13
13
  <body>
14
- <%= render 'headmin/layout/main' do %>
15
- <%= render 'headmin/layout/sidebar', logo: inline_svg_tag('logo.svg') do %>
16
- <%= render 'headmin/layout/sidebar/menu' do %>
17
- <%= render 'headmin/layout/sidebar/menu/item', name: t('.dashboard'), link: admin_root_path, icon: 'speedometer' %>
14
+ <%= render "headmin/layout/main" do %>
15
+ <%= render "headmin/layout/sidebar", logo: inline_svg_tag('logo.svg') do %>
16
+ <%= render "headmin/layout/sidebar/menu" do %>
17
+ <%= render "headmin/layout/sidebar/menu/item", name: t('.dashboard'), link: admin_root_path, icon: 'speedometer' %>
18
18
  <div class="d-block d-md-none">
19
- <%= render 'headmin/layout/sidebar/menu/locale' do end %>
20
- <%= render 'headmin/layout/sidebar/menu/account' do end %>
19
+ <%= render "headmin/layout/sidebar/menu/locale" do end %>
20
+ <%= render "headmin/layout/sidebar/menu/account" do end %>
21
21
  </div>
22
22
  <% end %>
23
23
  <% end %>
24
- <%= render 'headmin/layout/body' do %>
25
- <%= render 'headmin/layout/header' do %>
26
- <%= render 'headmin/layout/header/locale' do end %>
27
- <%= render 'headmin/layout/header/account' do end %>
24
+ <%= render "headmin/layout/body" do %>
25
+ <%= render "headmin/layout/header" do %>
26
+ <%= render "headmin/layout/header/locale" do end %>
27
+ <%= render "headmin/layout/header/account" do end %>
28
28
  <% end %>
29
- <%= render 'headmin/layout/content' do %>
30
- <%= render 'headmin/notifications' %>
29
+ <%= render "headmin/layout/content" do %>
30
+ <%= render "headmin/notifications" %>
31
31
  <%= yield %>
32
32
  <% end %>
33
- <%= render 'headmin/layout/footer', class: 'text-secondary' do %>
33
+ <%= render "headmin/layout/footer", class: 'text-secondary' do %>
34
34
  <%= bootstrap_icon('question-circle') %>
35
35
  <a class="text-secondary" href="mailto:info@insiting.com" title="<%= t('.help') %>">
36
36
  <%= t('.help') %>
@@ -10,7 +10,7 @@
10
10
  </head>
11
11
  <body class="bg-light w-100 vh-100">
12
12
 
13
- <%= render 'headmin/notifications' %>
13
+ <%= render "headmin/notifications" %>
14
14
 
15
15
  <main class="d-flex justify-content-center align-items-center w-100 vh-100 p-3">
16
16
  <%= yield %>
@@ -14,16 +14,16 @@
14
14
  # <%= render "headmin/filters", url: admin_polls_path %#>
15
15
 
16
16
  action = local_assigns.has_key?(:url) ? url : request.path
17
-
18
- # Perform yield in order to capture content blocks
19
- yield
20
17
  %>
21
18
 
22
- <form action="<%= action %>" data-controller="filters" data-filters-target="form">
19
+ <%= form_with url: action, method: :get, data: {controller: "filters", filters_target: "form"} do |form| %>
20
+
21
+ <%# Perform yield in order to capture content blocks, pass form so we can use headmin form inputs %>
22
+ <%= yield(form) %>
23
23
 
24
24
  <!-- Default parameters (e.g. sorting, pagination) -->
25
25
  <% default_params.except('page').each do |name, value| %>
26
- <%= hidden_field_tag(name.to_sym, value) %>
26
+ <%= form.hidden_field name.to_sym, value: value %>
27
27
  <% end %>
28
28
 
29
29
  <div class="d-flex flex-column flex-md-row align-content-start align-items-md-start">
@@ -69,8 +69,8 @@
69
69
 
70
70
  <!-- Filter templates -->
71
71
  <%= yield :filters_templates %>
72
- </form>
73
72
 
73
+ <% end %>
74
74
 
75
75
  <%
76
76
  # Clears content blocks to make this view reusable
@@ -19,12 +19,12 @@
19
19
  #
20
20
  # === Examples
21
21
  # Basic version
22
- # <%= render 'headmin/form', model: @product do |form| %#>
22
+ # <%= render "headmin/form", model: @product do |form| %#>
23
23
  # Form content
24
24
  # <% end %#>
25
25
  #
26
26
  # Specify URL to post to
27
- # <%= render 'headmin/form', model: @product, url: admin_products_path do |form| %#>
27
+ # <%= render "headmin/form", model: @product, url: admin_products_path do |form| %#>
28
28
  # Form content
29
29
  # <% end %#>
30
30
 
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # === Examples
5
5
  # Basic version
6
- # <%= render 'headmin/index' do %#>
6
+ # <%= render "headmin/index" do %#>
7
7
  # Index content
8
8
  # <% end %#>
9
9
  %>
@@ -11,7 +11,7 @@
11
11
 
12
12
  <div class="d-flex flex-row-reverse flex-md-row align-items-center justify-content-between justify-content-md-end my-1">
13
13
  <% content_for :collection_total_count, collection.total_count.to_s unless content_for?(:collection_total_count) %>
14
- <div class="ms-2 me-md-2 text-secondary">
14
+ <div class="ms-2 me-md-2 text-secondary flex-grow-1 flex-shrink-0">
15
15
  <%= t('.items', count: content_for(:collection_total_count).to_i) %>
16
16
  </div>
17
17
  <%= paginate collection, views_prefix: 'headmin/pagination' %>
@@ -8,7 +8,7 @@
8
8
  # To trigger this popup create an element with a data attribute like this
9
9
  #
10
10
  # <button data-popup-id="popupId">open Popup</button>
11
- # <%= render 'headmin/popup', id: 'popupId' do %#>
11
+ # <%= render "headmin/popup", id: 'popupId' do %#>
12
12
  # popup Content
13
13
  # <% end %#>
14
14
  #
@@ -16,7 +16,7 @@
16
16
  # "data-popup-pass-thru" attribute.
17
17
  #
18
18
  # <button data-popup-id="popupId" data-popup-pass-thru="#link">open Popup</button>
19
- # <%= render 'headmin/popup', id: 'popupId' do %#>
19
+ # <%= render "headmin/popup", id: 'popupId' do %#>
20
20
  # <a href="https://example.com" id="link">
21
21
  # <% end %#>
22
22
  data = local_assigns.has_key?(:data) ? data : {}
@@ -5,7 +5,7 @@
5
5
  # * +sort_url</tt> - Url to post object ids to in the order of positions
6
6
  #
7
7
  # ==== Examples
8
- # <%= render 'headmin/table', sort_url: positions_admin_categories_path do %#>
8
+ # <%= render "headmin/table", sort_url: positions_admin_categories_path do %#>
9
9
  # table content here
10
10
  # <% end %#>
11
11