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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -1
- data/Gemfile.lock +1 -1
- data/app/assets/javascripts/headmin/controllers/date_range_controller.js +12 -6
- data/app/assets/javascripts/headmin/controllers/filter_controller.js +61 -11
- data/app/assets/javascripts/headmin/controllers/filter_row_controller.js +50 -0
- data/app/assets/javascripts/headmin/controllers/flatpickr_controller.js +2 -6
- data/app/assets/javascripts/headmin/controllers/popup_controller.js +3 -1
- data/app/assets/javascripts/headmin/controllers/table_actions_controller.js +16 -21
- data/app/assets/javascripts/headmin/index.js +2 -0
- data/app/assets/javascripts/headmin.js +119 -38
- data/app/assets/stylesheets/headmin/filter.scss +74 -0
- data/app/assets/stylesheets/headmin/general.scss +0 -1
- data/app/assets/stylesheets/headmin/layout/body.scss +5 -0
- data/app/assets/stylesheets/headmin/popup.scss +0 -1
- data/app/assets/stylesheets/headmin.css +67 -2
- data/app/controllers/concerns/headmin/filterable.rb +27 -0
- data/app/models/headmin/filter/base.rb +238 -0
- data/app/models/headmin/filter/base_view.rb +64 -0
- data/app/models/headmin/filter/boolean.rb +15 -0
- data/app/models/headmin/filter/boolean_view.rb +61 -0
- data/app/models/headmin/filter/button_view.rb +25 -0
- data/app/models/headmin/filter/conditional_view.rb +16 -0
- data/app/models/headmin/filter/date.rb +19 -0
- data/app/models/headmin/filter/date_view.rb +52 -0
- data/app/models/headmin/filter/flatpickr_view.rb +54 -0
- data/app/models/headmin/filter/menu_item_view.rb +6 -0
- data/app/models/headmin/filter/money.rb +13 -0
- data/app/models/headmin/filter/number.rb +27 -0
- data/app/models/headmin/filter/number_view.rb +54 -0
- data/app/models/headmin/filter/operator_view.rb +30 -0
- data/app/models/headmin/filter/options_view.rb +61 -0
- data/app/models/headmin/filter/row_view.rb +13 -0
- data/app/models/headmin/filter/search.rb +18 -0
- data/app/models/headmin/filter/search_view.rb +31 -0
- data/app/models/headmin/filter/text.rb +25 -0
- data/app/models/headmin/filter/text_view.rb +53 -0
- data/app/models/headmin/filters.rb +29 -0
- data/app/models/headmin/form/datetime_range_view.rb +25 -0
- data/app/models/headmin/form/datetime_view.rb +45 -0
- data/app/models/headmin/form/flatpickr_range_view.rb +4 -15
- data/app/models/headmin/form/flatpickr_view.rb +3 -12
- data/app/models/view_model.rb +1 -1
- data/app/views/examples/admin.html.erb +13 -13
- data/app/views/examples/auth.html.erb +1 -1
- data/app/views/headmin/_filters.html.erb +6 -6
- data/app/views/headmin/_form.html.erb +2 -2
- data/app/views/headmin/_index.html.erb +1 -1
- data/app/views/headmin/_pagination.html.erb +1 -1
- data/app/views/headmin/_popup.html.erb +2 -2
- data/app/views/headmin/_table.html.erb +1 -1
- data/app/views/headmin/dropdown/_devise.html.erb +8 -8
- data/app/views/headmin/dropdown/_locale.html.erb +4 -4
- data/app/views/headmin/filters/_base.html.erb +95 -0
- data/app/views/headmin/filters/_boolean.html.erb +23 -0
- data/app/views/headmin/filters/_date.html.erb +14 -38
- data/app/views/headmin/filters/_flatpickr.html.erb +15 -48
- data/app/views/headmin/filters/_number.html.erb +23 -0
- data/app/views/headmin/filters/_options.html.erb +24 -0
- data/app/views/headmin/filters/_search.html.erb +14 -12
- data/app/views/headmin/filters/_text.html.erb +23 -0
- data/app/views/headmin/filters/filter/_button.html.erb +9 -10
- data/app/views/headmin/filters/filter/_conditional.html.erb +18 -0
- data/app/views/headmin/filters/filter/_menu_item.html.erb +5 -2
- data/app/views/headmin/filters/filter/_null_select.html.erb +8 -0
- data/app/views/headmin/filters/filter/_operator.html.erb +16 -0
- data/app/views/headmin/filters/filter/_row.html.erb +11 -0
- data/app/views/headmin/forms/_blocks.html.erb +1 -1
- data/app/views/headmin/forms/_date_range.html.erb +3 -3
- data/app/views/headmin/forms/_datetime.html.erb +41 -0
- data/app/views/headmin/forms/_datetime_range.html.erb +40 -0
- data/app/views/headmin/forms/_file.html.erb +3 -3
- data/app/views/headmin/forms/_flatpickr.html.erb +1 -1
- data/app/views/headmin/forms/_flatpickr_range.html.erb +3 -4
- data/app/views/headmin/forms/_label.html.erb +1 -1
- data/app/views/headmin/forms/_repeater.html.erb +12 -12
- data/app/views/headmin/forms/fields/_base.html.erb +1 -1
- data/app/views/headmin/forms/fields/_file.html.erb +2 -2
- data/app/views/headmin/forms/fields/_files.html.erb +2 -2
- data/app/views/headmin/forms/fields/_group.html.erb +5 -5
- data/app/views/headmin/forms/fields/_list.html.erb +4 -4
- data/app/views/headmin/forms/fields/_text.html.erb +2 -2
- data/app/views/headmin/layout/_footer.html.erb +1 -1
- data/app/views/headmin/layout/_main.html.erb +1 -1
- data/app/views/headmin/nav/_dropdown.html.erb +3 -3
- data/app/views/headmin/nav/_item.html.erb +2 -2
- data/app/views/headmin/nav/item/_devise.html.erb +8 -8
- data/app/views/headmin/nav/item/_locale.html.erb +4 -4
- data/app/views/headmin/table/_actions.html.erb +3 -6
- data/app/views/headmin/table/actions/_export.html.erb +1 -1
- data/app/views/headmin/table/body/_row.html.erb +3 -3
- data/app/views/headmin/table/foot/_id.html.erb +1 -1
- data/app/views/headmin/views/devise/confirmations/_new.html.erb +1 -1
- data/app/views/headmin/views/devise/passwords/_edit.html.erb +2 -2
- data/app/views/headmin/views/devise/passwords/_new.html.erb +1 -1
- data/app/views/headmin/views/devise/registrations/_edit.html.erb +4 -4
- data/app/views/headmin/views/devise/registrations/_new.html.erb +3 -3
- data/app/views/headmin/views/devise/sessions/_new.html.erb +3 -3
- data/app/views/headmin/views/devise/unlocks/_new.html.erb +1 -1
- data/config/locales/en.yml +4 -0
- data/config/locales/headmin/dropdown/en.yml +6 -0
- data/config/locales/headmin/dropdown/nl.yml +6 -0
- data/config/locales/headmin/filters/en.yml +26 -1
- data/config/locales/headmin/filters/nl.yml +26 -1
- data/config/locales/headmin/layout/en.yml +0 -9
- data/config/locales/headmin/layout/nl.yml +0 -9
- data/config/locales/headmin/nav/en.yml +7 -0
- data/config/locales/headmin/nav/nl.yml +7 -0
- data/config/locales/nl.yml +4 -0
- data/lib/generators/templates/views/layouts/auth.html.erb +1 -1
- data/lib/headmin/version.rb +1 -1
- data/package.json +1 -1
- metadata +42 -6
- data/app/controllers/concerns/headmin/filter.rb +0 -5
- data/app/controllers/concerns/headmin/searchable.rb +0 -15
- data/app/views/headmin/filters/_select.html.erb +0 -45
- data/app/views/headmin/filters/filter/_template.html.erb +0 -13
@@ -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: "= #{I18n.t("headmin.filters.operators.eq")}",
|
15
|
+
not_eq: "≠ #{I18n.t("headmin.filters.operators.not_eq")}",
|
16
|
+
gt: "> #{I18n.t("headmin.filters.operators.gt")}",
|
17
|
+
gteq: "≥ #{I18n.t("headmin.filters.operators.gteq")}",
|
18
|
+
lt: "< #{I18n.t("headmin.filters.operators.lt")}",
|
19
|
+
lteq: "≤ #{I18n.t("headmin.filters.operators.lteq")}",
|
20
|
+
starts_with: "⊏ #{I18n.t("headmin.filters.operators.starts_with")}",
|
21
|
+
ends_with: "⊐ #{I18n.t("headmin.filters.operators.ends_with")}",
|
22
|
+
matches: "≈ #{I18n.t("headmin.filters.operators.matches")}",
|
23
|
+
does_not_match: "≉ #{I18n.t("headmin.filters.operators.does_not_match")}",
|
24
|
+
is_null: "○ #{I18n.t("headmin.filters.operators.is_null")}",
|
25
|
+
is_not_null: "● #{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,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-
|
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
|
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
|
-
|
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
|
data/app/models/view_model.rb
CHANGED
@@ -11,26 +11,26 @@
|
|
11
11
|
</head>
|
12
12
|
|
13
13
|
<body>
|
14
|
-
<%= render
|
15
|
-
<%= render
|
16
|
-
<%= render
|
17
|
-
<%= render
|
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
|
20
|
-
<%= render
|
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
|
25
|
-
<%= render
|
26
|
-
<%= render
|
27
|
-
<%= render
|
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
|
30
|
-
<%= render
|
29
|
+
<%= render "headmin/layout/content" do %>
|
30
|
+
<%= render "headmin/notifications" %>
|
31
31
|
<%= yield %>
|
32
32
|
<% end %>
|
33
|
-
<%= render
|
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') %>
|
@@ -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
|
-
|
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
|
-
<%=
|
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
|
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
|
27
|
+
# <%= render "headmin/form", model: @product, url: admin_products_path do |form| %#>
|
28
28
|
# Form content
|
29
29
|
# <% end %#>
|
30
30
|
|
@@ -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
|
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
|
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
|
8
|
+
# <%= render "headmin/table", sort_url: positions_admin_categories_path do %#>
|
9
9
|
# table content here
|
10
10
|
# <% end %#>
|
11
11
|
|