ui_bibz 4.0.0.beta16 → 4.0.0.beta18
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 +7 -66
- 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.rb +1 -1
- data/lib/ui_bibz/ui/ux/tables/table_card.rb +1 -3
- data/lib/ui_bibz/ui/ux/tables/table_pagination_per_page.rb +1 -1
- 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
|
@@ -5,6 +5,7 @@ require 'ui_bibz/ui/ux/tables/components/column'
|
|
5
5
|
module UiBibz::Ui::Ux::Tables
|
6
6
|
class Store
|
7
7
|
attr_accessor :records
|
8
|
+
attr_reader :model
|
8
9
|
|
9
10
|
# Store Use WillPaginate store methods
|
10
11
|
def initialize(store)
|
@@ -16,62 +17,14 @@ module UiBibz::Ui::Ux::Tables
|
|
16
17
|
@model = store.model
|
17
18
|
end
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
def per_page
|
24
|
-
@records.per_page
|
25
|
-
end
|
26
|
-
|
27
|
-
def total_entries
|
28
|
-
@records.total_entries
|
29
|
-
end
|
30
|
-
|
31
|
-
def id
|
32
|
-
@store.id
|
33
|
-
end
|
34
|
-
|
35
|
-
def sort
|
36
|
-
@store.sort
|
37
|
-
end
|
38
|
-
|
39
|
-
def column_id
|
40
|
-
@store.column_id
|
41
|
-
end
|
42
|
-
|
43
|
-
def direction
|
44
|
-
@store.direction
|
45
|
-
end
|
46
|
-
|
47
|
-
def searchable_attributes
|
48
|
-
@store.searchable_attributes
|
49
|
-
end
|
50
|
-
|
51
|
-
def current_page
|
52
|
-
@records.current_page
|
53
|
-
end
|
54
|
-
|
55
|
-
def limit_value
|
56
|
-
@records.limit_value
|
57
|
-
end
|
20
|
+
delegate :total_pages, :per_page, :total_entries, :current_page, :limit_value, to: :@records
|
21
|
+
delegate :id, :sort, :column_id, :direction, :searchable_attributes,
|
22
|
+
:search, :controller, :actions_controller, :action, :param_id, :id_key, to: :@store
|
58
23
|
|
59
24
|
def columns
|
60
|
-
@columns ||= Columns.new(model.attribute_names.map
|
61
|
-
|
62
|
-
|
63
|
-
attr_reader :model
|
64
|
-
|
65
|
-
def search
|
66
|
-
@store.search
|
67
|
-
end
|
68
|
-
|
69
|
-
def controller
|
70
|
-
@store.controller
|
71
|
-
end
|
72
|
-
|
73
|
-
def actions_controller
|
74
|
-
@store.actions_controller
|
25
|
+
@columns ||= Columns.new(model.attribute_names.map do |attribute_name|
|
26
|
+
Column.new(attribute_name, { name: attribute_name.humanize })
|
27
|
+
end)
|
75
28
|
end
|
76
29
|
|
77
30
|
def params
|
@@ -81,17 +34,5 @@ module UiBibz::Ui::Ux::Tables
|
|
81
34
|
def parameters
|
82
35
|
@store.params.to_h
|
83
36
|
end
|
84
|
-
|
85
|
-
def action
|
86
|
-
@store.action
|
87
|
-
end
|
88
|
-
|
89
|
-
def param_id
|
90
|
-
@store.param_id
|
91
|
-
end
|
92
|
-
|
93
|
-
def id_key
|
94
|
-
@store.id_key
|
95
|
-
end
|
96
37
|
end
|
97
38
|
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)
|
@@ -181,7 +181,7 @@ module UiBibz::Ui::Ux::Tables
|
|
181
181
|
content = content.strftime(col.date_format) unless col.date_format.nil?
|
182
182
|
content = link_to content, action.inject_url(col.link, record) unless col.link.nil?
|
183
183
|
end
|
184
|
-
content = col.format.call(@store.records, record)
|
184
|
+
content = col.format.call(@store.records, record) unless col.format.nil?
|
185
185
|
content = As.new(col, record, content, @options).render unless col.as.nil?
|
186
186
|
content
|
187
187
|
end
|
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.beta18
|
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-15 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
|