card-mod-tabs 0.14.2 → 0.15.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/README.md +0 -0
- data/assets/script/tab.js.coffee +10 -0
- data/data/files/mod_tabs_script_asset_output/file.js +2 -0
- data/lib/card/tab.rb +2 -2
- data/set/abstract/tab_badge.haml +5 -0
- data/set/abstract/tabs.rb +37 -73
- data/set/all/tabs/tab_panel.haml +1 -1
- data/set/all/tabs.rb +53 -2
- metadata +12 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30774695c9b5e4171245c9f4b855d25e3cd20c39f89a234a2e06742e711d63cb
|
4
|
+
data.tar.gz: 9fe40a0aa26794c46de1efcee44e4a92b005143edbd6bea286b1e293b881a12f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a1415f9a6febb005505f1cf192640b6a863b21d71f35dd498847245a659aeb2e368b1b13b37ace53722a65a0812723a91aec73c1dd898222a86bd9b509ef622
|
7
|
+
data.tar.gz: 54c7453f247d7ed6ea0f01193a4f686f98adf6ae77454e1f26ba337deab9e60fc6cb76a0c4171b67e2dad720685c3f5153dec29bba027103134e9383dace9efb
|
data/README.md
ADDED
File without changes
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$(window).ready ->
|
2
|
+
$('body').on 'show.bs.tab', 'a.load[data-bs-toggle="tab"][data-url]', (e) ->
|
3
|
+
tab_id = $(e.target).attr('href')
|
4
|
+
url = $(e.target).data('url')
|
5
|
+
$(e.target).removeClass('load')
|
6
|
+
$.ajax
|
7
|
+
url: url
|
8
|
+
success: (html) ->
|
9
|
+
$(tab_id).append(html)
|
10
|
+
decko.contentLoaded($(tab_id), $(this))
|
@@ -0,0 +1,2 @@
|
|
1
|
+
// tab.js.coffee
|
2
|
+
(function(){$(window).ready(function(){return $("body").on("show.bs.tab",'a.load[data-bs-toggle="tab"][data-url]',function(t){var a,r;return a=$(t.target).attr("href"),r=$(t.target).data("url"),$(t.target).removeClass("load"),$.ajax({url:r,success:function(t){return $(a).append(t),decko.contentLoaded($(a),$(this))}})})})}).call(this);
|
data/lib/card/tab.rb
CHANGED
@@ -68,13 +68,13 @@ class Card
|
|
68
68
|
link_to label, button_attrib.merge(
|
69
69
|
path: "##{tab_id}",
|
70
70
|
role: "tab",
|
71
|
-
"data-toggle" => "tab",
|
71
|
+
"data-bs-toggle" => "tab",
|
72
72
|
"data-tab-name" => name
|
73
73
|
)
|
74
74
|
end
|
75
75
|
|
76
76
|
def tab_id
|
77
|
-
@tab_id ||= "
|
77
|
+
@tab_id ||= "tab-#{unique_id}-#{name.to_name.safe_key}"
|
78
78
|
end
|
79
79
|
|
80
80
|
def active?
|
data/set/abstract/tabs.rb
CHANGED
@@ -3,7 +3,7 @@ include_set Abstract::BsBadge
|
|
3
3
|
format :html do
|
4
4
|
view :tabs, cache: :never do
|
5
5
|
tabs tab_map, default_tab, load: :lazy do
|
6
|
-
_render!
|
6
|
+
_render! tab_map.dig(default_tab, :view)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
@@ -11,16 +11,6 @@ format :html do
|
|
11
11
|
@tab_map ||= generate_tab_map
|
12
12
|
end
|
13
13
|
|
14
|
-
def generate_tab_map
|
15
|
-
options = tab_options
|
16
|
-
tab_list.each_with_object({}) do |codename, hash|
|
17
|
-
hash[codename] = {
|
18
|
-
view: "#{codename}_tab",
|
19
|
-
title: tab_title(codename, options[codename])
|
20
|
-
}
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
14
|
def tab_list
|
25
15
|
[]
|
26
16
|
end
|
@@ -29,95 +19,69 @@ format :html do
|
|
29
19
|
{}
|
30
20
|
end
|
31
21
|
|
32
|
-
def one_line_tab?
|
33
|
-
false
|
34
|
-
end
|
35
|
-
|
36
22
|
def default_tab
|
37
23
|
tab_from_params || tab_map.keys.first
|
38
24
|
end
|
39
25
|
|
40
|
-
def
|
41
|
-
|
42
|
-
Env.params[:tab].to_sym
|
43
|
-
end
|
44
|
-
|
45
|
-
def tab_wrap
|
46
|
-
bs_layout do
|
47
|
-
row 12 do
|
48
|
-
col output(yield), class: "padding-top-10"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def tab_url tab
|
54
|
-
path tab: tab
|
26
|
+
def tab_badge count, label, opts={}
|
27
|
+
haml :tab_badge, badge_haml_opts(count, label, opts)
|
55
28
|
end
|
56
29
|
|
57
|
-
def tab_title
|
30
|
+
def tab_title label, opts
|
58
31
|
opts ||= {}
|
59
|
-
|
60
|
-
|
61
|
-
wrapped_tab_title parts[:label], info
|
32
|
+
label = tab_badge opts[:count], label, opts if opts[:count]
|
33
|
+
wrap_with(:div, class: "tab-title") { label }
|
62
34
|
end
|
63
35
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
36
|
+
private
|
37
|
+
|
38
|
+
def generate_tab_map
|
39
|
+
options = tab_options
|
40
|
+
tab_list.each_with_object({}) do |tab_key, hash|
|
41
|
+
hash[tab_key] = {
|
42
|
+
view: (options.dig(tab_key, :view) || "#{tab_key}_tab"),
|
43
|
+
title: tab_title_from_map(tab_key, options[tab_key])
|
44
|
+
}
|
69
45
|
end
|
70
46
|
end
|
71
47
|
|
72
|
-
def
|
73
|
-
|
48
|
+
def tab_from_params
|
49
|
+
Env.params[:tab]&.to_sym
|
74
50
|
end
|
75
51
|
|
76
|
-
def
|
77
|
-
|
78
|
-
if count.is_a? Card
|
79
|
-
klass = css_classes count.safe_set_keys
|
80
|
-
count = count.try(:cached_count) || count.count
|
81
|
-
end
|
82
|
-
tab_badge count, icon_tag, klass: klass
|
52
|
+
def tab_url tab
|
53
|
+
path tab: tab
|
83
54
|
end
|
84
55
|
|
85
|
-
def
|
86
|
-
|
87
|
-
|
56
|
+
def tab_title_from_map tab_key, opts
|
57
|
+
opts ||= {}
|
58
|
+
if Codename.exists? tab_key
|
59
|
+
tab_title_from_fieldcode tab_key, opts
|
60
|
+
else
|
61
|
+
label = opts[:label] || tab_key
|
62
|
+
tab_title label, opts
|
88
63
|
end
|
89
64
|
end
|
90
65
|
|
91
|
-
def
|
66
|
+
def tab_title_from_fieldcode fieldcode, opts={}
|
92
67
|
field_card = card.fetch fieldcode, new: {}
|
93
|
-
field_card if field_card.respond_to? :count
|
94
|
-
end
|
95
68
|
|
96
|
-
|
97
|
-
|
98
|
-
|
69
|
+
%i[label count klass].each do |part|
|
70
|
+
opts[part] = send("tab_title_#{part}", field_card) unless opts.key? part
|
71
|
+
end
|
99
72
|
|
100
|
-
|
101
|
-
fieldcode.cardname.vary :plural
|
73
|
+
tab_title opts[:label], opts
|
102
74
|
end
|
103
75
|
|
104
|
-
def
|
105
|
-
|
106
|
-
[wrapped_tab_title_info(info),
|
107
|
-
wrap_with(:span, label, class: "count-label")].compact
|
108
|
-
end
|
76
|
+
def tab_title_klass field_card
|
77
|
+
css_classes field_card.safe_set_keys
|
109
78
|
end
|
110
79
|
|
111
|
-
def
|
112
|
-
|
113
|
-
return unless info
|
114
|
-
|
115
|
-
klass = css_classes "count-number", "clearfix"
|
116
|
-
wrap_with :span, info, class: klass
|
80
|
+
def tab_title_count field_card
|
81
|
+
field_card.try(:cached_count) || field_card.try(:count)
|
117
82
|
end
|
118
83
|
|
119
|
-
|
120
|
-
|
121
|
-
try :mapped_icon_tag, key
|
84
|
+
def tab_title_label field_card
|
85
|
+
field_card.name.right_name.vary :plural
|
122
86
|
end
|
123
87
|
end
|
data/set/all/tabs/tab_panel.haml
CHANGED
data/set/all/tabs.rb
CHANGED
@@ -16,13 +16,13 @@ format :html do
|
|
16
16
|
#
|
17
17
|
# @param active_name [String] label of the tab that should be active at the
|
18
18
|
#
|
19
|
-
# @param [Hash]
|
19
|
+
# @param args [Hash] options
|
20
20
|
# @option args [String] :tab_type ('tabs') use pills or tabs
|
21
21
|
# @option args [Hash] :panel_attr html args used for the panel div
|
22
22
|
# @option args [Hash] :pane_attr html args used for the pane div
|
23
23
|
# @option args [Hash] :load. `:lazy` for lazy-loading tabs
|
24
24
|
#
|
25
|
-
# @param [Block]
|
25
|
+
# @param block [Block] content of the active tab (for lazy-loading)
|
26
26
|
# beginning (default is the first)
|
27
27
|
#
|
28
28
|
# @return [HTML] bootstrap tabs element with all content preloaded
|
@@ -37,4 +37,55 @@ format :html do
|
|
37
37
|
)
|
38
38
|
haml :tab_panel, args
|
39
39
|
end
|
40
|
+
|
41
|
+
view :tabs do
|
42
|
+
construct_tabs "tabs"
|
43
|
+
end
|
44
|
+
|
45
|
+
def construct_tabs tab_type
|
46
|
+
tabs = { active: {}, paths: {} }
|
47
|
+
voo.items[:view] ||= :content
|
48
|
+
card.each_item_name_with_options(_render_raw) do |name, options|
|
49
|
+
construct_tab tabs, name, options
|
50
|
+
end
|
51
|
+
tabs tabs[:paths], tabs[:active][:name], tab_type: tab_type, load: :lazy do
|
52
|
+
tabs[:active][:content]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def construct_tab tabs, name, explicit_options
|
57
|
+
tab_options = item_view_options explicit_options
|
58
|
+
tabs[:paths][name] = {
|
59
|
+
title: nest(name, view: :title, title: tab_options[:title]),
|
60
|
+
path: nest_path(name, tab_options).html_safe
|
61
|
+
}
|
62
|
+
return unless tabs[:active].empty?
|
63
|
+
|
64
|
+
tabs[:active] = { name: name, content: nest(name, tab_options) }
|
65
|
+
end
|
66
|
+
|
67
|
+
# def tab_title title, name
|
68
|
+
# return name unless title
|
69
|
+
# name.to_name.title title, @context_names
|
70
|
+
# end
|
71
|
+
|
72
|
+
view :pills do
|
73
|
+
construct_tabs "pills"
|
74
|
+
end
|
75
|
+
|
76
|
+
view :tabs_static do
|
77
|
+
construct_static_tabs "tabs"
|
78
|
+
end
|
79
|
+
|
80
|
+
view :pills_static do
|
81
|
+
construct_static_tabs "pills"
|
82
|
+
end
|
83
|
+
|
84
|
+
def construct_static_tabs tab_type
|
85
|
+
tabs = {}
|
86
|
+
card.item_cards.each do |item|
|
87
|
+
tabs[item.name] = nest item, item_view_options(args)
|
88
|
+
end
|
89
|
+
tabs tabs, nil, tab_type: tab_type
|
90
|
+
end
|
40
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card-mod-tabs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.15.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-01-04 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: card
|
@@ -18,28 +18,28 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.105.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
26
|
- - '='
|
27
27
|
- !ruby/object:Gem::Version
|
28
|
-
version: 1.
|
28
|
+
version: 1.105.0
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: card-mod-bootstrap
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
33
|
- - '='
|
34
34
|
- !ruby/object:Gem::Version
|
35
|
-
version: 0.
|
35
|
+
version: 0.15.0
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
40
|
- - '='
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: 0.
|
42
|
+
version: 0.15.0
|
43
43
|
description: ''
|
44
44
|
email:
|
45
45
|
- info@decko.org
|
@@ -47,8 +47,12 @@ executables: []
|
|
47
47
|
extensions: []
|
48
48
|
extra_rdoc_files: []
|
49
49
|
files:
|
50
|
+
- README.md
|
51
|
+
- assets/script/tab.js.coffee
|
52
|
+
- data/files/mod_tabs_script_asset_output/file.js
|
50
53
|
- lib/card/lazy_tab.rb
|
51
54
|
- lib/card/tab.rb
|
55
|
+
- set/abstract/tab_badge.haml
|
52
56
|
- set/abstract/tabs.rb
|
53
57
|
- set/all/tabs.rb
|
54
58
|
- set/all/tabs/tab_panel.haml
|
@@ -62,6 +66,7 @@ metadata:
|
|
62
66
|
wiki_uri: https://decko.org
|
63
67
|
documentation_url: http://docs.decko.org/
|
64
68
|
card-mod: tabs
|
69
|
+
card-mod-group: gem-defaults
|
65
70
|
post_install_message:
|
66
71
|
rdoc_options: []
|
67
72
|
require_paths:
|
@@ -77,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
82
|
- !ruby/object:Gem::Version
|
78
83
|
version: '0'
|
79
84
|
requirements: []
|
80
|
-
rubygems_version: 3.
|
85
|
+
rubygems_version: 3.3.11
|
81
86
|
signing_key:
|
82
87
|
specification_version: 4
|
83
88
|
summary: tabs
|