playbook_ui 14.10.0.pre.alpha.play1465attempt25272 → 14.10.0.pre.alpha.play1662cssbargraph5193
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/pb_kits/playbook/pb_advanced_table/_advanced_table.scss +16 -11
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.rb +1 -8
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_beta_sort.html.erb +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +1 -4
- data/app/pb_kits/playbook/pb_advanced_table/index.js +95 -143
- data/app/pb_kits/playbook/pb_advanced_table/table_body.html.erb +1 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +8 -50
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +14 -17
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +0 -78
- data/app/pb_kits/playbook/pb_advanced_table/table_row.html.erb +3 -4
- data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +2 -7
- data/app/pb_kits/playbook/pb_advanced_table/table_subrow_header.html.erb +6 -2
- data/app/pb_kits/playbook/pb_card/_card.scss +3 -21
- data/app/pb_kits/playbook/pb_card/docs/_card_header.html.erb +0 -18
- data/app/pb_kits/playbook/pb_card/docs/_card_header.jsx +0 -40
- data/app/pb_kits/playbook/pb_dashboard/BarGraphStyles.scss +53 -0
- data/app/pb_kits/playbook/pb_icon_circle/_icon_circle.scss +13 -1
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.scss +1 -64
- data/app/pb_kits/playbook/pb_section_separator/_section_separator.tsx +1 -3
- data/app/pb_kits/playbook/pb_section_separator/docs/example.yml +0 -2
- data/app/pb_kits/playbook/pb_section_separator/docs/index.js +0 -1
- data/app/pb_kits/playbook/pb_section_separator/section_separator.rb +1 -4
- data/app/pb_kits/playbook/pb_skeleton_loading/_skeleton_loading.scss +2 -2
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_default.html.erb +1 -1
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_filter.jsx +2 -10
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.jsx +2 -6
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_user.jsx +3 -11
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/example.yml +2 -7
- data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.html.erb +12 -8
- data/app/pb_kits/playbook/pb_skeleton_loading/skeleton_loading.rb +1 -48
- data/app/pb_kits/playbook/pb_table/_table.tsx +18 -67
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns.jsx +1 -1
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_rails.md +0 -2
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_left_columns_react.md +1 -4
- data/app/pb_kits/playbook/pb_table/index.ts +17 -17
- data/app/pb_kits/playbook/pb_table/styles/_scroll.scss +2 -38
- data/app/pb_kits/playbook/pb_table/styles/_sticky_columns.scss +3 -17
- data/app/pb_kits/playbook/pb_typeahead/_typeahead.tsx +2 -3
- data/app/pb_kits/playbook/pb_typeahead/components/ClearIndicator.tsx +4 -12
- data/app/pb_kits/playbook/pb_typeahead/components/Control.tsx +1 -5
- data/app/pb_kits/playbook/pb_typeahead/components/IndicatorsContainer.tsx +3 -8
- data/app/pb_kits/playbook/pb_typeahead/components/MenuList.tsx +1 -6
- data/app/pb_kits/playbook/pb_typeahead/components/Option.tsx +6 -21
- data/app/pb_kits/playbook/pb_typeahead/components/Placeholder.tsx +6 -13
- data/app/pb_kits/playbook/pb_typeahead/components/ValueContainer.tsx +3 -7
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_custom_menu_list.jsx +0 -2
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async.jsx +2 -4
- data/app/pb_kits/playbook/pb_typeahead/docs/_typeahead_with_pills_async_custom_options.jsx +5 -5
- data/dist/chunks/{_typeahead-BhT5aXCY.js → _typeahead-BXXEtXbz.js} +3 -3
- data/dist/chunks/_weekday_stacked-D0yBvHBb.js +45 -0
- data/dist/chunks/{lib-B7sgJtGS.js → lib-sMFo2JZy.js} +1 -1
- data/dist/chunks/{pb_form_validation-C5Cc0-1v.js → pb_form_validation-CgvjWbOK.js} +1 -1
- data/dist/chunks/vendor.js +1 -1
- data/dist/menu.yml +1 -1
- data/dist/playbook-doc.js +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/dist/playbook.css +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +9 -26
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers.html.erb +0 -43
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_headers_multiple.html.erb +0 -58
- data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_color.html.erb +0 -10
- data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_color.jsx +0 -42
- data/app/pb_kits/playbook/pb_section_separator/docs/_section_separator_color.md +0 -3
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_description.md +0 -3
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius.html.erb +0 -9
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_border_radius_rails.md +0 -1
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_color.html.erb +0 -7
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_filter.html.erb +0 -119
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width.html.erb +0 -15
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_height_width_rails.md +0 -3
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_layout.html.erb +0 -3
- data/app/pb_kits/playbook/pb_skeleton_loading/docs/_skeleton_loading_user.html.erb +0 -63
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns.jsx +0 -88
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_columns_react.md +0 -3
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns.jsx +0 -87
- data/app/pb_kits/playbook/pb_table/docs/_table_sticky_right_columns_react.md +0 -5
- data/dist/chunks/_weekday_stacked-DJOTNDSY.js +0 -45
- /data/app/pb_kits/playbook/pb_skeleton_loading/docs/{_skeleton_loading_border_radius_react.md → _skeleton_loading_border_radius.md} +0 -0
- /data/app/pb_kits/playbook/pb_skeleton_loading/docs/{_skeleton_loading_height_width_react.md → _skeleton_loading_height_width.md} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2e1aaf2cadccd158fb55ca05342e3dfefd6e2614dc37d220086b342e5df4340
|
4
|
+
data.tar.gz: fc03a93a9cc11765508190229426d34d507306ebf46aff0efe5ec23bb65ddb32
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88632df2e8dd9a501cd6d97a0bc60213d11a1a4f3e3b063c9318a83267177403c02adb69e60c69344c07c91e7a1915f8a3954069c8682839d8787879b3208219
|
7
|
+
data.tar.gz: 03f3eec3ebd3da933b162a985c72fde36109c4f2e01ad4d732f73cf27a1eae8fb633823af6859f659470d0dca062b8f1dba1777e172a05be30af19b19cc063a4
|
@@ -36,29 +36,35 @@
|
|
36
36
|
.last-header-cell {
|
37
37
|
border-right: 1px solid $border_light !important;
|
38
38
|
}
|
39
|
+
|
39
40
|
th {
|
40
41
|
border-radius: 0px !important;
|
41
42
|
border-width: 0 0 1px 0 !important;
|
42
43
|
}
|
43
44
|
th:first-child {
|
44
45
|
border-left-width: 1px !important;
|
46
|
+
@media only screen and (max-width: $screen-xl-min) {
|
47
|
+
border-left-width: 0 !important;
|
48
|
+
}
|
49
|
+
}
|
50
|
+
th:last-child {
|
51
|
+
border-right-width: 1px !important;
|
52
|
+
@media only screen and (max-width: $screen-xl-min) {
|
53
|
+
border-right-width: 0 !important;
|
54
|
+
}
|
45
55
|
}
|
46
56
|
}
|
47
57
|
th[colspan]:not([colspan="1"]) {
|
48
|
-
border-right: 1px solid $border_light
|
58
|
+
border-right: 1px solid $border_light;
|
49
59
|
}
|
60
|
+
|
61
|
+
|
50
62
|
}
|
51
63
|
|
52
64
|
.pb_advanced_table_body {
|
53
65
|
.last-cell {
|
54
66
|
border-right: 1px solid $border_light !important;
|
55
67
|
}
|
56
|
-
tr td:first-child {
|
57
|
-
padding-left: 8px !important;
|
58
|
-
}
|
59
|
-
tr .pb_table_td:last-child {
|
60
|
-
padding-right: 8px !important;
|
61
|
-
}
|
62
68
|
}
|
63
69
|
|
64
70
|
|
@@ -128,7 +134,7 @@
|
|
128
134
|
}
|
129
135
|
|
130
136
|
.toggle-content {
|
131
|
-
display: none
|
137
|
+
display: none;
|
132
138
|
height: 0;
|
133
139
|
padding-bottom: 0 !important;
|
134
140
|
padding-top: 0 !important;
|
@@ -137,7 +143,7 @@
|
|
137
143
|
}
|
138
144
|
|
139
145
|
.toggle-content.is-visible {
|
140
|
-
display:
|
146
|
+
display: contents;
|
141
147
|
height: auto;
|
142
148
|
}
|
143
149
|
|
@@ -160,7 +166,7 @@
|
|
160
166
|
width: 100%;
|
161
167
|
[class^=pb_table].table-sm.table-card thead tr th:first-child,
|
162
168
|
[class^=pb_table].table-sm:not(.no-hover).table-card tbody tr td:first-child {
|
163
|
-
border-left-width: 0px
|
169
|
+
border-left-width: 0px;
|
164
170
|
}
|
165
171
|
[class^=pb_table].table-sm.table-card thead tr th:last-child,
|
166
172
|
[class^=pb_table].table-sm:not(.no-hover).table-card tbody tr td:last-child {
|
@@ -186,7 +192,6 @@
|
|
186
192
|
.bg-white td:first-child {
|
187
193
|
background-color: $white;
|
188
194
|
}
|
189
|
-
|
190
195
|
}
|
191
196
|
}
|
192
197
|
@media only screen and (min-width: $screen-xl-min) {
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= pb_content_tag do %>
|
2
|
-
<%= pb_rails("table", props: { size: "sm", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark }) do %>
|
2
|
+
<%= pb_rails("table", props: { size: "sm", tag:"div", data_table: true, number_spacing:"tabular", responsive:"none", dark: dark }) do %>
|
3
3
|
<% if content.present? %>
|
4
4
|
<% content.presence %>
|
5
5
|
<% else %>
|
@@ -10,16 +10,9 @@ module Playbook
|
|
10
10
|
prop :enable_toggle_expansion, type: Playbook::Props::Enum,
|
11
11
|
values: %w[all header none],
|
12
12
|
default: "header"
|
13
|
-
prop :responsive, type: Playbook::Props::Enum,
|
14
|
-
values: %w[none scroll],
|
15
|
-
default: "none"
|
16
13
|
|
17
14
|
def classname
|
18
|
-
generate_classname("pb_advanced_table"
|
19
|
-
end
|
20
|
-
|
21
|
-
def responsive_classname
|
22
|
-
responsive == "scroll" ? "advanced-table-responsive-scroll" : "advanced-table-responsive-none"
|
15
|
+
generate_classname("pb_advanced_table")
|
23
16
|
end
|
24
17
|
end
|
25
18
|
end
|
@@ -49,9 +49,11 @@
|
|
49
49
|
label: "Graduated Students",
|
50
50
|
}
|
51
51
|
]
|
52
|
+
|
53
|
+
subrow_headers = ["Quarter", "Month", "Day"]
|
52
54
|
%>
|
53
55
|
|
54
56
|
<%= pb_rails("advanced_table", props: { table_data: @table_data, column_definitions: column_definitions }) do %>
|
55
57
|
<%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions }) %>
|
56
|
-
<%= pb_rails("advanced_table/table_body", props: { id: "beta_sort", table_data: @table_data, column_definitions: column_definitions, enable_toggle_expansion: "all" }) %>
|
58
|
+
<%= pb_rails("advanced_table/table_body", props: { id: "beta_sort", table_data: @table_data, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all" }) %>
|
57
59
|
<% end %>
|
@@ -1,13 +1,10 @@
|
|
1
1
|
examples:
|
2
2
|
rails:
|
3
3
|
- advanced_table_beta: Default (Required Props)
|
4
|
-
|
4
|
+
- advanced_table_beta_subrow_headers: SubRow Headers
|
5
5
|
- advanced_table_collapsible_trail_rails: Collapsible Trail
|
6
6
|
- advanced_table_beta_sort: Enable Sorting
|
7
7
|
- advanced_table_custom_cell_rails: Custom Components for Cells
|
8
|
-
- advanced_table_column_headers: Multi-Header Columns
|
9
|
-
- advanced_table_column_headers_multiple: Multi-Header Columns (Multiple Levels)
|
10
|
-
|
11
8
|
|
12
9
|
react:
|
13
10
|
- advanced_table_default: Default (Required Props)
|
@@ -1,186 +1,138 @@
|
|
1
|
-
import PbEnhancedElement from
|
1
|
+
import PbEnhancedElement from '../pb_enhanced_element'
|
2
2
|
|
3
|
-
const ADVANCED_TABLE_SELECTOR =
|
4
|
-
const
|
5
|
-
const
|
3
|
+
const ADVANCED_TABLE_SELECTOR = '[data-advanced-table]'
|
4
|
+
const CONTENT_SELECTOR = '[data-advanced-table-content="id"]'
|
5
|
+
const DOWN_ARROW_SELECTOR = '#advanced-table_open_icon'
|
6
|
+
const UP_ARROW_SELECTOR = '#advanced-table_close_icon'
|
6
7
|
|
7
8
|
export default class PbAdvancedTable extends PbEnhancedElement {
|
8
9
|
static get selector() {
|
9
|
-
return ADVANCED_TABLE_SELECTOR
|
10
|
+
return ADVANCED_TABLE_SELECTOR
|
10
11
|
}
|
11
12
|
|
12
13
|
get target() {
|
13
|
-
|
14
|
-
return table.querySelectorAll(`[data-row-parent="${this.element.id}"]`);
|
14
|
+
return document.querySelector(CONTENT_SELECTOR.replace("id", this.element.id))
|
15
15
|
}
|
16
|
-
|
17
|
-
static expandedRows = new Set()
|
18
|
-
static isCollapsing = false
|
16
|
+
|
17
|
+
static expandedRows = new Set()
|
18
|
+
static isCollapsing = false
|
19
19
|
|
20
20
|
connect() {
|
21
|
-
this.element.addEventListener(
|
21
|
+
this.element.addEventListener('click', () => {
|
22
22
|
if (!PbAdvancedTable.isCollapsing) {
|
23
|
-
const isExpanded =
|
24
|
-
this.element.querySelector(UP_ARROW_SELECTOR).style.display ===
|
25
|
-
"inline-block";
|
23
|
+
const isExpanded = this.element.querySelector(UP_ARROW_SELECTOR).style.display === 'inline-block'
|
26
24
|
if (!isExpanded) {
|
27
|
-
PbAdvancedTable.expandedRows.add(this.element.id)
|
25
|
+
PbAdvancedTable.expandedRows.add(this.element.id)
|
28
26
|
} else {
|
29
|
-
PbAdvancedTable.expandedRows.delete(this.element.id)
|
27
|
+
PbAdvancedTable.expandedRows.delete(this.element.id)
|
30
28
|
}
|
31
|
-
this.toggleElement(this.target);
|
32
29
|
}
|
33
|
-
|
34
|
-
|
35
|
-
const nestedButtons = this.element
|
36
|
-
.closest("table")
|
37
|
-
.querySelectorAll("[data-advanced-table]");
|
38
|
-
nestedButtons.forEach((button) => {
|
39
|
-
button.addEventListener("click", () => {
|
40
|
-
const isExpanded =
|
41
|
-
button.querySelector(UP_ARROW_SELECTOR).style.display ===
|
42
|
-
"inline-block";
|
43
|
-
if (isExpanded) {
|
44
|
-
PbAdvancedTable.expandedRows.add(button.id);
|
45
|
-
} else {
|
46
|
-
PbAdvancedTable.expandedRows.delete(button.id);
|
47
|
-
}
|
48
|
-
});
|
49
|
-
});
|
30
|
+
this.toggleElement(this.target)
|
31
|
+
})
|
50
32
|
}
|
51
33
|
|
52
|
-
showElement(
|
53
|
-
|
54
|
-
elem.style.display =
|
55
|
-
elem.
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
`[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`
|
60
|
-
);
|
61
|
-
|
62
|
-
childRowsAll.forEach((childRow) => {
|
63
|
-
const dataContent = childRow.dataset.advancedTableContent;
|
64
|
-
|
65
|
-
if (!dataContent) {
|
66
|
-
return;
|
67
|
-
}
|
68
|
-
|
69
|
-
// Split the dataContent to get all ancestor IDs, check against simpleExpandedRows
|
70
|
-
const ancestorIds = dataContent.split("-").slice(0, -1);
|
34
|
+
showElement(elem) {
|
35
|
+
const getHeight = () => {
|
36
|
+
elem.style.display = 'block'
|
37
|
+
const height = elem.scrollHeight + 'px'
|
38
|
+
elem.style.display = ''
|
39
|
+
return height
|
40
|
+
}
|
71
41
|
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
PbAdvancedTable.expandedRows.has(id)
|
77
|
-
);
|
42
|
+
const height = getHeight()
|
43
|
+
elem.classList.add('is-visible')
|
44
|
+
elem.style.height = height
|
45
|
+
elem.style.overflow = "hidden"
|
78
46
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
childRow.style.display = "none";
|
84
|
-
childRow.classList.remove("is-visible");
|
85
|
-
}
|
86
|
-
});
|
87
|
-
});
|
47
|
+
window.setTimeout(() => {
|
48
|
+
elem.style.height = ''
|
49
|
+
elem.style.overflow = "visible"
|
50
|
+
}, 250)
|
88
51
|
}
|
89
52
|
|
90
|
-
hideElement(
|
91
|
-
|
92
|
-
elem.style.display = "none";
|
93
|
-
elem.classList.remove("is-visible");
|
53
|
+
hideElement(elem) {
|
54
|
+
elem.style.height = elem.scrollHeight + 'px'
|
94
55
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
56
|
+
window.setTimeout(() => {
|
57
|
+
elem.style.height = '0'
|
58
|
+
elem.style.paddingTop = '0'
|
59
|
+
elem.style.paddingBottom = '0'
|
60
|
+
elem.style.overflow = "hidden"
|
61
|
+
}, 1)
|
99
62
|
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
const childRows = this.element
|
105
|
-
.closest("table")
|
106
|
-
.querySelectorAll(
|
107
|
-
`[data-advanced-table-content^="${elem.dataset.advancedTableContent}-"]`
|
108
|
-
);
|
109
|
-
|
110
|
-
childRows.forEach((childRow) => {
|
111
|
-
childRow.style.display = "none";
|
112
|
-
childRow.classList.remove("is-visible");
|
113
|
-
});
|
114
|
-
}
|
115
|
-
});
|
63
|
+
window.setTimeout(() => {
|
64
|
+
elem.classList.remove('is-visible')
|
65
|
+
elem.style.overflow = ""
|
66
|
+
}, 200)
|
116
67
|
}
|
117
68
|
|
118
|
-
toggleElement(
|
119
|
-
if (
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
this.hideElement(elements);
|
124
|
-
this.displayDownArrow();
|
125
|
-
} else {
|
126
|
-
this.showElement(elements);
|
127
|
-
this.displayUpArrow();
|
69
|
+
toggleElement(elem) {
|
70
|
+
if (elem.classList.contains('is-visible')) {
|
71
|
+
this.hideElement(elem)
|
72
|
+
this.displayDownArrow()
|
73
|
+
return
|
128
74
|
}
|
75
|
+
|
76
|
+
this.showElement(elem)
|
77
|
+
this.displayUpArrow()
|
129
78
|
}
|
130
79
|
|
131
80
|
displayDownArrow() {
|
132
|
-
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display =
|
133
|
-
|
134
|
-
this.element.querySelector(UP_ARROW_SELECTOR).style.display = "none";
|
81
|
+
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'inline-block'
|
82
|
+
this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'none'
|
135
83
|
}
|
136
84
|
|
137
85
|
displayUpArrow() {
|
138
|
-
this.element.querySelector(UP_ARROW_SELECTOR).style.display =
|
139
|
-
|
140
|
-
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = "none";
|
86
|
+
this.element.querySelector(UP_ARROW_SELECTOR).style.display = 'inline-block'
|
87
|
+
this.element.querySelector(DOWN_ARROW_SELECTOR).style.display = 'none'
|
141
88
|
}
|
142
89
|
|
143
90
|
static handleToggleAllHeaders(element) {
|
144
|
-
const table = element.closest(
|
145
|
-
const firstLevelButtons = table.querySelectorAll(
|
146
|
-
|
147
|
-
)
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
button.click();
|
157
|
-
PbAdvancedTable.expandedRows.delete(button.id);
|
158
|
-
});
|
91
|
+
const table = element.closest('.pb_table')
|
92
|
+
const firstLevelButtons = table.querySelectorAll('.pb_advanced_table_body > .pb_table_tr [data-advanced-table]')
|
93
|
+
|
94
|
+
const expandedRows = Array.from(firstLevelButtons).filter(button =>
|
95
|
+
button.querySelector(UP_ARROW_SELECTOR).style.display === 'inline-block'
|
96
|
+
)
|
97
|
+
|
98
|
+
if (expandedRows.length === firstLevelButtons.length) {
|
99
|
+
expandedRows.forEach(button => {
|
100
|
+
button.click()
|
101
|
+
})
|
102
|
+
this.expandedRows.clear()
|
159
103
|
} else {
|
160
|
-
firstLevelButtons.forEach(
|
161
|
-
if (!
|
162
|
-
button.click()
|
163
|
-
PbAdvancedTable.expandedRows.add(button.id);
|
104
|
+
firstLevelButtons.forEach(button => {
|
105
|
+
if (!this.expandedRows.has(button.id)) {
|
106
|
+
button.click()
|
164
107
|
}
|
165
|
-
})
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
108
|
+
})
|
109
|
+
}
|
110
|
+
}
|
111
|
+
static handleToggleAllSubRows(element, rowDepth) {
|
112
|
+
const parentElement = element.closest(".toggle-content")
|
113
|
+
const subrowButtons = parentElement.querySelectorAll('.depth-sub-row-' + rowDepth + ' [data-advanced-table]')
|
114
|
+
|
115
|
+
const expandedSubRows = Array.from(subrowButtons).filter(button =>
|
116
|
+
button.querySelector(UP_ARROW_SELECTOR).style.display === 'inline-block'
|
117
|
+
)
|
118
|
+
|
119
|
+
if (expandedSubRows.length === subrowButtons.length) {
|
120
|
+
expandedSubRows.forEach(button => {
|
121
|
+
button.click()
|
122
|
+
})
|
123
|
+
} else {
|
124
|
+
subrowButtons.forEach(button => {
|
125
|
+
if (!this.expandedRows.has(button.id)) {
|
126
|
+
button.click()
|
173
127
|
}
|
174
|
-
})
|
128
|
+
})
|
175
129
|
}
|
176
130
|
}
|
177
|
-
|
178
|
-
// static handleToggleAllSubRows(element, rowDepth) {}
|
179
131
|
}
|
180
132
|
|
181
133
|
window.expandAllRows = (element) => {
|
182
|
-
PbAdvancedTable.handleToggleAllHeaders(element)
|
183
|
-
}
|
184
|
-
|
185
|
-
|
186
|
-
|
134
|
+
PbAdvancedTable.handleToggleAllHeaders(element)
|
135
|
+
}
|
136
|
+
window.expandAllSubRows = (element, rowDepth) => {
|
137
|
+
PbAdvancedTable.handleToggleAllSubRows(element, rowDepth)
|
138
|
+
}
|
@@ -17,69 +17,27 @@ module Playbook
|
|
17
17
|
prop :collapsible_trail, type: Playbook::Props::Boolean,
|
18
18
|
default: true
|
19
19
|
|
20
|
-
def
|
21
|
-
columns.flat_map do |col|
|
22
|
-
if col[:columns]
|
23
|
-
flatten_columns(col[:columns])
|
24
|
-
elsif col[:accessor].present?
|
25
|
-
if has_grouped_headers?
|
26
|
-
col.merge(is_last_in_group: last_in_group?(columns, col))
|
27
|
-
else
|
28
|
-
col
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end.compact
|
32
|
-
end
|
33
|
-
|
34
|
-
def render_row_and_children(row, column_definitions, current_depth, first_parent_child, ancestor_ids = [], top_parent_id = nil)
|
35
|
-
top_parent_id ||= row.object_id
|
36
|
-
new_ancestor_ids = ancestor_ids + [row.object_id]
|
37
|
-
leaf_columns = flatten_columns(column_definitions)
|
38
|
-
|
20
|
+
def render_row_and_children(row, column_definitions, current_depth, first_parent_child)
|
39
21
|
output = ActiveSupport::SafeBuffer.new
|
40
22
|
is_first_child_of_subrow = current_depth.positive? && first_parent_child && subrow_headers[current_depth - 1].present?
|
41
23
|
|
42
24
|
output << pb_rails("advanced_table/table_subrow_header", props: { row: row, column_definitions: column_definitions, depth: current_depth, subrow_header: subrow_headers[current_depth - 1], collapsible_trail: collapsible_trail }) if is_first_child_of_subrow && enable_toggle_expansion == "all"
|
43
25
|
|
44
|
-
|
45
|
-
output << pb_rails("advanced_table/table_row", props: {
|
46
|
-
id: id,
|
47
|
-
row: row,
|
48
|
-
column_definitions: leaf_columns,
|
49
|
-
depth: current_depth,
|
50
|
-
collapsible_trail: collapsible_trail,
|
51
|
-
})
|
26
|
+
output << pb_rails("advanced_table/table_row", props: { id: id, row: row, column_definitions: column_definitions, depth: current_depth, collapsible_trail: collapsible_trail })
|
52
27
|
|
53
28
|
if row[:children].present?
|
54
|
-
output << row
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
immediate_parent_id = row.object_id
|
60
|
-
top_parent = top_parent_id
|
61
|
-
# Combine ancestor_ids to build the content id
|
62
|
-
data_content = new_ancestor_ids.join("-") + "-#{child_row.object_id}"
|
63
|
-
|
64
|
-
child_output.to_str.sub("<tr", %(<tr class="toggle-content" data-top-parent="#{id}_#{top_parent}" data-row-depth="#{current_depth}" data-row-parent="#{id}_#{immediate_parent_id}" data-advanced-table-content="#{data_content}"))
|
65
|
-
end.join.html_safe
|
29
|
+
output << content_tag(:div, class: "toggle-content", data: { advanced_table_content: row.object_id.to_s + id }) do
|
30
|
+
row[:children].map do |child_row|
|
31
|
+
render_row_and_children(child_row, column_definitions, current_depth + 1, row.children.first == child_row)
|
32
|
+
end.join.html_safe
|
33
|
+
end
|
66
34
|
end
|
67
35
|
|
68
36
|
output
|
69
37
|
end
|
70
38
|
|
71
39
|
def classname
|
72
|
-
generate_classname("pb_advanced_table_body", separator: " ")
|
73
|
-
end
|
74
|
-
|
75
|
-
private
|
76
|
-
|
77
|
-
def has_grouped_headers?
|
78
|
-
column_definitions.any? { |col| col.key?(:columns) }
|
79
|
-
end
|
80
|
-
|
81
|
-
def last_in_group?(columns, current_col)
|
82
|
-
columns.last[:accessor] == current_col[:accessor]
|
40
|
+
generate_classname("pb_advanced_table_body", "pb_table_tbody", separator: " ")
|
83
41
|
end
|
84
42
|
end
|
85
43
|
end
|
@@ -1,21 +1,18 @@
|
|
1
|
-
<%= pb_content_tag
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
<%= pb_content_tag do %>
|
2
|
+
<%= pb_rails("table/table_row", props: { tag: "div" }) do %>
|
3
|
+
<% object.column_definitions.each_with_index do |item, index| %>
|
4
|
+
<%= pb_rails("table/table_header", props: { tag: "div", id: item[:accessor], classname: object.th_classname, sort_menu: item[:sort_menu] }) do %>
|
5
|
+
<%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end", text_align: "end" }) do %>
|
6
|
+
<% if index.zero? && (object.enable_toggle_expansion == "header" || object.enable_toggle_expansion == "all") %>
|
7
|
+
<button
|
8
|
+
class="gray-icon toggle-all-icon"
|
9
|
+
onclick="expandAllRows(this); event.preventDefault();">
|
10
|
+
<%= pb_rails("icon", props: { icon: "arrows-from-line", cursor: "pointer", fixed_width: true, padding_right: "xs" }) %>
|
11
|
+
</button>
|
12
|
+
<% end %>
|
13
|
+
<%= item[:label] %>
|
14
14
|
<% end %>
|
15
|
-
<%= cell[:label] %>
|
16
15
|
<% end %>
|
16
|
+
<% end %>
|
17
17
|
<% end %>
|
18
|
-
<% end %>
|
19
|
-
<% end %>
|
20
|
-
<% end %>
|
21
18
|
<% end %>
|
@@ -16,84 +16,6 @@ module Playbook
|
|
16
16
|
def th_classname
|
17
17
|
generate_classname("table-header-cells", separator: " ")
|
18
18
|
end
|
19
|
-
|
20
|
-
def header_rows
|
21
|
-
wrapped_columns = wrap_leaf_columns(column_definitions)
|
22
|
-
|
23
|
-
rows = []
|
24
|
-
max_depth = compute_max_depth(wrapped_columns)
|
25
|
-
max_depth.times { rows << [] }
|
26
|
-
process_columns(wrapped_columns, rows, 0, max_depth)
|
27
|
-
rows
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
|
32
|
-
def compute_max_depth(columns)
|
33
|
-
columns.map do |col|
|
34
|
-
col[:columns] ? 1 + compute_max_depth(col[:columns]) : 1
|
35
|
-
end.max || 1
|
36
|
-
end
|
37
|
-
|
38
|
-
def process_columns(columns, rows, current_depth, max_depth)
|
39
|
-
total_columns = columns.size
|
40
|
-
columns.each_with_index do |col, index|
|
41
|
-
is_last = index == total_columns - 1
|
42
|
-
if col[:columns]
|
43
|
-
colspan = compute_leaf_columns(col[:columns])
|
44
|
-
rows[current_depth] << {
|
45
|
-
label: col[:label],
|
46
|
-
colspan: colspan,
|
47
|
-
is_last_in_group: is_last && current_depth.positive?,
|
48
|
-
}
|
49
|
-
|
50
|
-
process_columns(col[:columns], rows, current_depth + 1, max_depth)
|
51
|
-
else
|
52
|
-
colspan = 1
|
53
|
-
rows[current_depth] << {
|
54
|
-
label: col[:label],
|
55
|
-
colspan: colspan,
|
56
|
-
accessor: col[:accessor],
|
57
|
-
sort_menu: col[:sort_menu],
|
58
|
-
is_last_in_group: is_last && current_depth.positive?,
|
59
|
-
}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def compute_leaf_columns(columns)
|
65
|
-
columns.reduce(0) do |sum, col|
|
66
|
-
col[:columns] ? sum + compute_leaf_columns(col[:columns]) : sum + 1
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def wrap_leaf_columns(column_definitions)
|
71
|
-
max_depth = compute_max_depth(column_definitions)
|
72
|
-
|
73
|
-
column_definitions.map do |col|
|
74
|
-
if col.key?(:columns)
|
75
|
-
{
|
76
|
-
label: col[:label],
|
77
|
-
columns: wrap_leaf_columns(col[:columns]),
|
78
|
-
}
|
79
|
-
else
|
80
|
-
# For leaf columns, wrap with empty labels up to max depth to get proper structure
|
81
|
-
wrap_leaf_column(col, max_depth)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
def wrap_leaf_column(col, max_depth)
|
87
|
-
wrapped = {
|
88
|
-
accessor: col[:accessor],
|
89
|
-
label: col[:label] || "",
|
90
|
-
sort_menu: col[:sort_menu] || nil,
|
91
|
-
}
|
92
|
-
(max_depth - 1).times do
|
93
|
-
wrapped = { label: "", columns: [wrapped] }
|
94
|
-
end
|
95
|
-
wrapped
|
96
|
-
end
|
97
19
|
end
|
98
20
|
end
|
99
21
|
end
|
@@ -1,7 +1,6 @@
|
|
1
|
-
<%= pb_content_tag
|
1
|
+
<%= pb_content_tag do %>
|
2
2
|
<% object.column_definitions.each_with_index do |column, index| %>
|
3
|
-
|
4
|
-
<%= pb_rails("table/table_cell", props: { classname:object.td_classname(column)}) do %>
|
3
|
+
<%= pb_rails("table/table_cell", props: { tag:"div", classname:object.td_classname}) do %>
|
5
4
|
<%= pb_rails("flex", props:{ align: "center", justify: index.zero? ? "start" : "end" }) do %>
|
6
5
|
<% if collapsible_trail && index.zero? %>
|
7
6
|
<% (1..depth).each do |i| %>
|
@@ -14,7 +13,7 @@
|
|
14
13
|
<div style="padding-left: <%= depth * 1.25 %>em">
|
15
14
|
<%= pb_rails("flex", props:{align: "center", column_gap: "xs"}) do %>
|
16
15
|
<% if index.zero? && object.row[:children].present? %>
|
17
|
-
<button id="<%=
|
16
|
+
<button id="<%= object.row.object_id.to_s + object.id %>" class="gray-icon expand-toggle-icon" data-advanced-table="true" >
|
18
17
|
<%= pb_rails("icon", props: { id: "advanced-table_open_icon", icon: "circle-play", cursor: "pointer" }) %>
|
19
18
|
<%= pb_rails("icon", props: { id: "advanced-table_close_icon", display: "none", icon: "circle-play", cursor: "pointer", rotation: 90 }) %>
|
20
19
|
</button>
|