ui_bibz 4.0.0.beta16 → 4.0.0.beta17
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/Gemfile.lock +117 -106
- data/app/assets/javascripts/forms/nested-dropdown.js +102 -0
- data/app/assets/javascripts/forms.js +157 -115
- data/app/assets/javascripts/interfaces.js +37 -28
- data/app/assets/stylesheets/sass/_forms.sass +6 -5
- data/app/assets/stylesheets/sass/forms/_dropdown.sass +5 -0
- data/config/importmap.rb +20 -19
- data/lib/ui_bibz/concerns/models/searchable.rb +1 -1
- data/lib/ui_bibz/infos.rb +1 -1
- data/lib/ui_bibz/inputs/ui_bibz_inputs/string_input.rb +1 -1
- data/lib/ui_bibz/ui/core/component.rb +1 -3
- data/lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_dropdown.rb +158 -0
- data/lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb +5 -0
- data/lib/ui_bibz/ui/core/navigations/link.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/components/store.rb +16 -48
- data/lib/ui_bibz/ui/ux/tables/extensions/actionable.rb +2 -2
- data/lib/ui_bibz/ui/ux/tables/extensions/paginable.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/extensions/searchable.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/table_card.rb +1 -3
- metadata +4 -2
@@ -0,0 +1,158 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module UiBibz::Ui::Core::Forms::Dropdowns::Components
|
4
|
+
# Create DropdownDropdown
|
5
|
+
#
|
6
|
+
# This element is an extend of UiBibz::Ui::Core::Forms::Dropdowns::Dropdown.
|
7
|
+
#
|
8
|
+
# ==== Attributes
|
9
|
+
#
|
10
|
+
# * +content+ - Content of element
|
11
|
+
# * +options+ - Options of element
|
12
|
+
# * +html_options+ - Html Options of element
|
13
|
+
#
|
14
|
+
# ==== Options
|
15
|
+
#
|
16
|
+
# You can add HTML attributes using the +html_options+.
|
17
|
+
# You can pass arguments in options attribute:
|
18
|
+
# * +state+ - status of element with symbol value:
|
19
|
+
# (+:active+)
|
20
|
+
# * +url+ - String
|
21
|
+
# * +glyph+ - Add glyph with name or hash options
|
22
|
+
# * +name+ - String
|
23
|
+
# * +size+ - Integer
|
24
|
+
# * +type+ - Symbol
|
25
|
+
# * +link_html_options+ - Hash
|
26
|
+
#
|
27
|
+
# ==== Signatures
|
28
|
+
#
|
29
|
+
# UiBibz::Ui::Core::Forms::DropdownDropdown.new(content, options = nil, html_options = nil)
|
30
|
+
#
|
31
|
+
# UiBibz::Ui::Core::Forms::DropdownDropdown.new(options = nil, html_options = nil) do
|
32
|
+
# content
|
33
|
+
# end
|
34
|
+
#
|
35
|
+
# ==== Examples
|
36
|
+
#
|
37
|
+
# UiBibz::Ui::Core::Forms::DropdownDropdown.new('Home', { glyph: 'home', state: :active, url: '#home', link_html_options: { class: 'link1' }},{ class: 'test' }).render
|
38
|
+
#
|
39
|
+
# UiBibz::Ui::Core::Forms::DropdownDropdown.new({ glyph: { name: 'eye', size: 3 }, url: '#home' }, { class: 'test' }) do
|
40
|
+
# 'Home'
|
41
|
+
# end.render
|
42
|
+
#
|
43
|
+
class DropdownDropdown < UiBibz::Ui::Core::Component
|
44
|
+
include UiBibz::Ui::Concerns::HtmlConcern
|
45
|
+
|
46
|
+
def initialize(...)
|
47
|
+
super
|
48
|
+
@items = []
|
49
|
+
@status = @options.delete(:status)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Render html tag
|
53
|
+
def pre_render
|
54
|
+
content_tag :div, html_options do
|
55
|
+
concat button_html
|
56
|
+
concat ul_html
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
# Add dropdown header
|
61
|
+
# See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownHeader
|
62
|
+
def header(content = nil, options = nil, html_options = nil, &)
|
63
|
+
@items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownHeader.new(content, options, html_options, &).render
|
64
|
+
end
|
65
|
+
|
66
|
+
# Add dropdown Separator
|
67
|
+
# See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownDivider
|
68
|
+
def divider
|
69
|
+
@items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownDivider.new.render
|
70
|
+
end
|
71
|
+
|
72
|
+
# Add dropdown link in list
|
73
|
+
# See UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink
|
74
|
+
def link(content = nil, options = nil, html_options = nil, &)
|
75
|
+
@items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(content, options, html_options, &).render
|
76
|
+
end
|
77
|
+
|
78
|
+
def dropdown(content = nil, options = nil, html_options = nil, &)
|
79
|
+
@items << new(content, options, html_options, &).render
|
80
|
+
end
|
81
|
+
|
82
|
+
def id
|
83
|
+
@id ||= html_options[:id] || generate_id('dropdown')
|
84
|
+
end
|
85
|
+
|
86
|
+
protected
|
87
|
+
|
88
|
+
def component_html_classes
|
89
|
+
['dropdown-item', hover, position, open, inline, without_caret, keep_open]
|
90
|
+
end
|
91
|
+
|
92
|
+
def button_content
|
93
|
+
glyph_and_content_html(@content)
|
94
|
+
end
|
95
|
+
|
96
|
+
def button_html
|
97
|
+
content_tag :a, button_content, { class: join_classes(state, 'dropdown-toggle'), role: 'button', 'data-bs-toggle' => 'dropdown', 'aria-expanded' => false, 'id' => id }
|
98
|
+
end
|
99
|
+
|
100
|
+
def ul_html
|
101
|
+
content_tag :div, @items.join.html_safe, class: join_classes('dropdown-menu', theme, alignment, open), 'arial-labelledby' => id
|
102
|
+
end
|
103
|
+
|
104
|
+
def alignment
|
105
|
+
return nil if @options[:alignment].nil?
|
106
|
+
|
107
|
+
if @options[:alignment].is_a? Hash
|
108
|
+
['dropdown-menu', @options[:alignment][:size], match_direction[@options[:alignment][:direction]]].join('-')
|
109
|
+
else
|
110
|
+
"dropdown-menu-#{match_direction[@options[:alignment]]}"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
def position
|
115
|
+
"drop#{match_direction[@options[:position] || :right]}"
|
116
|
+
end
|
117
|
+
|
118
|
+
def open
|
119
|
+
'show' if @options[:open]
|
120
|
+
end
|
121
|
+
|
122
|
+
def keep_open
|
123
|
+
'keep-open' if @options[:keep_open]
|
124
|
+
end
|
125
|
+
|
126
|
+
def inline
|
127
|
+
'btn-group' if @options[:inline] || @options[:alignment]
|
128
|
+
end
|
129
|
+
|
130
|
+
def without_caret
|
131
|
+
'without-caret' if @options[:caret] == false
|
132
|
+
end
|
133
|
+
|
134
|
+
def outline
|
135
|
+
'outline' if @options[:outline]
|
136
|
+
end
|
137
|
+
|
138
|
+
def hover
|
139
|
+
'dropdown-hover' if @options[:hover]
|
140
|
+
end
|
141
|
+
|
142
|
+
def theme
|
143
|
+
'dropdown-menu-dark' if @options[:theme]
|
144
|
+
end
|
145
|
+
|
146
|
+
# Match end and start directions
|
147
|
+
def match_direction
|
148
|
+
{
|
149
|
+
up: 'up',
|
150
|
+
right: 'end',
|
151
|
+
down: 'down',
|
152
|
+
left: 'start',
|
153
|
+
start: 'start',
|
154
|
+
end: 'end'
|
155
|
+
}.with_indifferent_access
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require 'ui_bibz/ui/core/forms/dropdowns/components/dropdown_header'
|
4
4
|
require 'ui_bibz/ui/core/forms/dropdowns/components/dropdown_divider'
|
5
5
|
require 'ui_bibz/ui/core/forms/dropdowns/components/dropdown_link'
|
6
|
+
require 'ui_bibz/ui/core/forms/dropdowns/components/dropdown_dropdown'
|
6
7
|
module UiBibz::Ui::Core::Forms::Dropdowns
|
7
8
|
# Create a dropdown
|
8
9
|
#
|
@@ -102,6 +103,10 @@ module UiBibz::Ui::Core::Forms::Dropdowns
|
|
102
103
|
@items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownLink.new(content, options, html_options, &).render
|
103
104
|
end
|
104
105
|
|
106
|
+
def dropdown(name = nil, options = nil, html_options = nil, &)
|
107
|
+
@items << UiBibz::Ui::Core::Forms::Dropdowns::Components::DropdownDropdown.new(name, options, html_options).tap(&).render
|
108
|
+
end
|
109
|
+
|
105
110
|
def id
|
106
111
|
@id ||= html_options[:id] || generate_id('dropdown')
|
107
112
|
end
|
@@ -16,45 +16,25 @@ module UiBibz::Ui::Ux::Tables
|
|
16
16
|
@model = store.model
|
17
17
|
end
|
18
18
|
|
19
|
-
|
20
|
-
@records.total_pages
|
21
|
-
end
|
19
|
+
delegate :total_pages, to: :@records
|
22
20
|
|
23
|
-
|
24
|
-
@records.per_page
|
25
|
-
end
|
21
|
+
delegate :per_page, to: :@records
|
26
22
|
|
27
|
-
|
28
|
-
@records.total_entries
|
29
|
-
end
|
23
|
+
delegate :total_entries, to: :@records
|
30
24
|
|
31
|
-
|
32
|
-
@store.id
|
33
|
-
end
|
25
|
+
delegate :id, to: :@store
|
34
26
|
|
35
|
-
|
36
|
-
@store.sort
|
37
|
-
end
|
27
|
+
delegate :sort, to: :@store
|
38
28
|
|
39
|
-
|
40
|
-
@store.column_id
|
41
|
-
end
|
29
|
+
delegate :column_id, to: :@store
|
42
30
|
|
43
|
-
|
44
|
-
@store.direction
|
45
|
-
end
|
31
|
+
delegate :direction, to: :@store
|
46
32
|
|
47
|
-
|
48
|
-
@store.searchable_attributes
|
49
|
-
end
|
33
|
+
delegate :searchable_attributes, to: :@store
|
50
34
|
|
51
|
-
|
52
|
-
@records.current_page
|
53
|
-
end
|
35
|
+
delegate :current_page, to: :@records
|
54
36
|
|
55
|
-
|
56
|
-
@records.limit_value
|
57
|
-
end
|
37
|
+
delegate :limit_value, to: :@records
|
58
38
|
|
59
39
|
def columns
|
60
40
|
@columns ||= Columns.new(model.attribute_names.map { |attribute_name| Column.new(attribute_name, { name: attribute_name.humanize }) })
|
@@ -62,17 +42,11 @@ module UiBibz::Ui::Ux::Tables
|
|
62
42
|
|
63
43
|
attr_reader :model
|
64
44
|
|
65
|
-
|
66
|
-
@store.search
|
67
|
-
end
|
45
|
+
delegate :search, to: :@store
|
68
46
|
|
69
|
-
|
70
|
-
@store.controller
|
71
|
-
end
|
47
|
+
delegate :controller, to: :@store
|
72
48
|
|
73
|
-
|
74
|
-
@store.actions_controller
|
75
|
-
end
|
49
|
+
delegate :actions_controller, to: :@store
|
76
50
|
|
77
51
|
def params
|
78
52
|
@store.params || {}
|
@@ -82,16 +56,10 @@ module UiBibz::Ui::Ux::Tables
|
|
82
56
|
@store.params.to_h
|
83
57
|
end
|
84
58
|
|
85
|
-
|
86
|
-
@store.action
|
87
|
-
end
|
59
|
+
delegate :action, to: :@store
|
88
60
|
|
89
|
-
|
90
|
-
@store.param_id
|
91
|
-
end
|
61
|
+
delegate :param_id, to: :@store
|
92
62
|
|
93
|
-
|
94
|
-
@store.id_key
|
95
|
-
end
|
63
|
+
delegate :id_key, to: :@store
|
96
64
|
end
|
97
65
|
end
|
@@ -9,7 +9,7 @@ module UiBibz::Ui::Ux::Tables
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def actionable?
|
12
|
-
@options[:actionable].nil?
|
12
|
+
@options[:actionable].nil? || @options[:actionable]
|
13
13
|
end
|
14
14
|
|
15
15
|
def header(ths)
|
@@ -25,7 +25,7 @@ module UiBibz::Ui::Ux::Tables
|
|
25
25
|
private
|
26
26
|
|
27
27
|
def default_actions?
|
28
|
-
@options[:default_actions].nil?
|
28
|
+
@options[:default_actions].nil? || @options[:default_actions]
|
29
29
|
end
|
30
30
|
|
31
31
|
def dropdown_action(record)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ui_bibz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0.
|
4
|
+
version: 4.0.0.beta17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thooams [Thomas HUMMEL]
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bootstrap
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- app/assets/javascripts/forms/formula.js
|
109
109
|
- app/assets/javascripts/forms/input-connected.js
|
110
110
|
- app/assets/javascripts/forms/jquery.multi-select-extend.js
|
111
|
+
- app/assets/javascripts/forms/nested-dropdown.js
|
111
112
|
- app/assets/javascripts/interfaces.js
|
112
113
|
- app/assets/javascripts/tables.js
|
113
114
|
- app/assets/javascripts/ui_bibz_js.js
|
@@ -239,6 +240,7 @@ files:
|
|
239
240
|
- lib/ui_bibz/ui/core/forms/choices/switch_field.rb
|
240
241
|
- lib/ui_bibz/ui/core/forms/dates/date_picker_field.rb
|
241
242
|
- lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_divider.rb
|
243
|
+
- lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_dropdown.rb
|
242
244
|
- lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_header.rb
|
243
245
|
- lib/ui_bibz/ui/core/forms/dropdowns/components/dropdown_link.rb
|
244
246
|
- lib/ui_bibz/ui/core/forms/dropdowns/dropdown.rb
|