playbook_ui 14.23.0.pre.alpha.PLAY2121enableexpandedfield9199 → 14.23.0.pre.alpha.PLAY2138advtableselectablerowsindeterminatecheckboxes9287

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.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/app/pb_kits/playbook/pb_advanced_table/advanced_table.html.erb +1 -1
  3. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_header_rails.html.erb +1 -1
  4. data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_selectable_rows_rails.html.erb +1 -1
  5. data/app/pb_kits/playbook/pb_advanced_table/flat_advanced_table.js +4 -11
  6. data/app/pb_kits/playbook/pb_advanced_table/index.js +103 -124
  7. data/app/pb_kits/playbook/pb_advanced_table/table_body.rb +5 -4
  8. data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +10 -4
  9. data/app/pb_kits/playbook/pb_advanced_table/table_row.rb +21 -4
  10. data/app/pb_kits/playbook/pb_checkbox/index.js +220 -30
  11. data/app/pb_kits/playbook/pb_multi_level_select/_helper_functions.tsx +9 -18
  12. data/app/pb_kits/playbook/pb_multi_level_select/_multi_level_select.tsx +1 -3
  13. data/app/pb_kits/playbook/pb_multi_level_select/docs/example.yml +0 -2
  14. data/app/pb_kits/playbook/pb_multi_level_select/docs/index.js +1 -2
  15. data/app/pb_kits/playbook/pb_multi_level_select/multi_level_select.rb +0 -3
  16. data/dist/chunks/{_line_graph-Bz5CsVqz.js → _line_graph-BfCo79KE.js} +1 -1
  17. data/dist/chunks/{_typeahead-DuoHs8Ye.js → _typeahead-Db4YQA5c.js} +1 -1
  18. data/dist/chunks/{_weekday_stacked-0GMpKTN_.js → _weekday_stacked-9aguRqOv.js} +1 -1
  19. data/dist/chunks/vendor.js +1 -1
  20. data/dist/playbook-doc.js +1 -1
  21. data/dist/playbook-rails-react-bindings.js +1 -1
  22. data/dist/playbook-rails.js +1 -1
  23. data/lib/playbook/version.rb +1 -1
  24. metadata +5 -8
  25. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.html.erb +0 -75
  26. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.jsx +0 -94
  27. data/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_show_checked_children.md +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0109bbbee42ce6d9d41eedbb4b8e77c6cf9f62ac3b2abb194494c329850428ec'
4
- data.tar.gz: f7d1de5810791c17ca588b1d894d00ac5e2f8ae73f209557192ae68acbb1ae4f
3
+ metadata.gz: ecb739c3927721ba5492ca57d616722004f821ff322dc6f4fcd476a74c8f8092
4
+ data.tar.gz: 9c4d8012b16f03976e78b07dcceb10547388985a15793f9fff42ffbdcabda46f
5
5
  SHA512:
6
- metadata.gz: 21ca27b9a580c04550d735913b7059e852f34412c3ccedbecde5fd119244237ae45ba52809620c5d295cb592a637b3849b7d34b402588595b8a442b289c3eaf9
7
- data.tar.gz: 9f33624d866c279a343d6f9c569725d6b5a3d240e934a513ad72d56bb38dfdeaeb16359a63c2c0b2f886c57463bb0f680b8d05771416a5f1796d6e6a41d529f5
6
+ metadata.gz: 24bce5d08a093566a2d962b8268e1da89ead48a9deda567b862ad9a1d165a47b89ea3d258743148968812fa643b4eabaf7b014b8a12034e5d6176f3957ab7af4
7
+ data.tar.gz: 43c87889a65d87cd38eecb2b01e2a8d9fb60ca69ace8392f9de4b7a6d5186d3a47b9d2031a862513481e3fab595bfbc2d0a39dcf4d9109cc060d1e2e0899ce87
@@ -11,7 +11,7 @@
11
11
  <% if content.present? %>
12
12
  <% content.presence %>
13
13
  <% else %>
14
- <%= pb_rails("advanced_table/table_header", props: { column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, show_actions_bar: object.show_actions_bar }) %>
14
+ <%= pb_rails("advanced_table/table_header", props: { id: object.id, column_definitions: object.column_definitions, enable_toggle_expansion: object.enable_toggle_expansion, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, show_actions_bar: object.show_actions_bar }) %>
15
15
  <%= pb_rails("advanced_table/table_body", props: { id: object.id, table_data: object.table_data, column_definitions: object.column_definitions, responsive: object.responsive, loading: object.loading, selectable_rows: object.selectable_rows, enable_toggle_expansion: object.enable_toggle_expansion, row_styling: object.row_styling }) %>
16
16
  <% end %>
17
17
  <% end %>
@@ -31,7 +31,7 @@
31
31
  ] %>
32
32
 
33
33
  <%= pb_rails("advanced_table", props: {
34
- id: "selectable_rows_with_actions",
34
+ id: "selectable_rows_with_header_no_action_bar",
35
35
  table_data: @table_data_no_subrows,
36
36
  column_definitions: column_definitions,
37
37
  selectable_rows: true,
@@ -34,6 +34,6 @@
34
34
  %>
35
35
 
36
36
  <%= pb_rails("advanced_table", props: { id: "selectable_rows", table_data: @table_data_with_id, column_definitions: column_definitions, selectable_rows: true }) do %>
37
- <%= pb_rails("advanced_table/table_header", props: { column_definitions: column_definitions, selectable_rows: true }) %>
37
+ <%= pb_rails("advanced_table/table_header", props: { id: "selectable_rows", column_definitions: column_definitions, selectable_rows: true }) %>
38
38
  <%= pb_rails("advanced_table/table_body", props: { id: "selectable_rows", table_data: @table_data_with_id, column_definitions: column_definitions, subrow_headers: subrow_headers, enable_toggle_expansion: "all", selectable_rows: true }) %>
39
39
  <% end %>
@@ -2,7 +2,6 @@ import PbEnhancedElement from "../pb_enhanced_element";
2
2
  import { updateSelectionActionBar } from "./advanced_table_action_bar";
3
3
 
4
4
  const FLAT_SELECTOR = "[data-flat-advanced-table-select='true']";
5
- const SELECT_ALL_SELECTOR = "#select-all-rows input[type='checkbox']";
6
5
 
7
6
  export default class PbFlatAdvancedTable extends PbEnhancedElement {
8
7
  static get selector() {
@@ -37,9 +36,12 @@ export default class PbFlatAdvancedTable extends PbEnhancedElement {
37
36
  }
38
37
  };
39
38
 
39
+ const selectAllId = this.element.getAttribute('data-pb-checkbox-indeterminate-parent')
40
+ const selectAllSelector = `#${selectAllId} input[type='checkbox']`
41
+
40
42
  table.addEventListener("change", (e) => {
41
43
  const rowCb = e.target.closest(FLAT_SELECTOR + " input[type='checkbox']");
42
- const allCb = e.target.closest(SELECT_ALL_SELECTOR);
44
+ const allCb = e.target.closest(selectAllSelector);
43
45
  if (!rowCb && !allCb) return;
44
46
 
45
47
  if (rowCb) {
@@ -50,15 +52,6 @@ export default class PbFlatAdvancedTable extends PbEnhancedElement {
50
52
  const tr = rowCb.closest("tr");
51
53
  tr?.classList.toggle("bg-row-selection", rowCb.checked);
52
54
  tr?.classList.toggle("bg-white", !rowCb.checked);
53
-
54
- // Sync header checkbox
55
- const header = table.querySelector(SELECT_ALL_SELECTOR);
56
- if (header) {
57
- const all = Array.from(
58
- table.querySelectorAll(FLAT_SELECTOR + " input[type='checkbox']")
59
- ).every((cb) => cb.checked);
60
- header.checked = all;
61
- }
62
55
  }
63
56
 
64
57
  if (allCb) {
@@ -39,6 +39,70 @@ export default class PbAdvancedTable extends PbEnhancedElement {
39
39
  );
40
40
  }
41
41
 
42
+ // Recalculate selected count based on all checked checkboxes
43
+ recalculateSelectedCount() {
44
+ const table = this.element.closest("table");
45
+
46
+ // Get all checkboxes that could be part of the selection
47
+ // This includes row checkboxes and any parent checkboxes that might be programmatically checked
48
+ const rowCheckboxes = table.querySelectorAll(
49
+ 'label[data-row-id] input[type="checkbox"]'
50
+ );
51
+
52
+ // Also get any checkboxes that might be parent checkboxes (those with data-pb-checkbox-indeterminate-main)
53
+ // But exclude the select-all checkbox itself from the count
54
+ const parentCheckboxes = table.querySelectorAll(
55
+ '[data-pb-checkbox-indeterminate-main="true"] input[type="checkbox"]'
56
+ );
57
+
58
+ // Filter out the select-all checkbox from parent checkboxes
59
+ const selectAllCheckbox = table.querySelector('#select-all-rows input[type="checkbox"]');
60
+ const filteredParentCheckboxes = Array.from(parentCheckboxes).filter(checkbox =>
61
+ checkbox !== selectAllCheckbox && !checkbox.id.includes('select-all-rows')
62
+ );
63
+
64
+ // Combine all checkboxes and remove duplicates
65
+ const allCheckboxes = new Set([...rowCheckboxes, ...filteredParentCheckboxes]);
66
+
67
+ // Clear the selectedRows Set and rebuild it from checked checkboxes
68
+ PbAdvancedTable.selectedRows.clear();
69
+
70
+ allCheckboxes.forEach((checkbox) => {
71
+ const rowEl = checkbox.closest("tr");
72
+ const isChecked = checkbox.checked;
73
+
74
+ if (isChecked) {
75
+ PbAdvancedTable.selectedRows.add(checkbox.id);
76
+ // Only apply styling if the checkbox is inside a table row
77
+ if (rowEl) {
78
+ rowEl.classList.add("bg-row-selection");
79
+ rowEl.classList.remove("bg-white", "bg-silver");
80
+ }
81
+ } else {
82
+ // Only apply styling if the checkbox is inside a table row
83
+ if (rowEl) {
84
+ rowEl.classList.remove("bg-row-selection");
85
+
86
+ if (this.isRowExpanded(rowEl)) {
87
+ rowEl.classList.remove("bg-silver");
88
+ rowEl.classList.add("bg-white");
89
+ } else {
90
+ rowEl.classList.remove("bg-white");
91
+ rowEl.classList.add("bg-silver");
92
+ }
93
+ }
94
+ }
95
+ });
96
+
97
+ this.updateTableSelectedRowsAttribute();
98
+ updateSelectionActionBar(table.closest(".pb_advanced_table"), PbAdvancedTable.selectedRows.size);
99
+
100
+ // Sync header select-all state
101
+ if (selectAllCheckbox) {
102
+ selectAllCheckbox.checked = Array.from(rowCheckboxes).every((cb) => cb.checked);
103
+ }
104
+ }
105
+
42
106
  // Check if the row is expanded or collapsed
43
107
  // This is used to determine the background color of the row
44
108
  // when the checkbox is checked or unchecked
@@ -47,75 +111,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
47
111
  return closeIcon?.style.display === "none" || !closeIcon;
48
112
  }
49
113
 
50
- updateParentCheckboxes(checkbox) {
51
- const rowEl = checkbox.closest("tr");
52
- if (!rowEl) return;
53
-
54
- const table = rowEl.closest("table");
55
- if (!table) return;
56
-
57
- const contentTrail = rowEl.dataset.advancedTableContent;
58
- if (!contentTrail) return;
59
-
60
- const ancestorIds = contentTrail.split("-").slice(0, -1);
61
-
62
- ancestorIds.reverse();
63
- ancestorIds.forEach((ancestorId) => {
64
- const parentRowSelector = `[data-advanced-table-content$="${ancestorId}"]`;
65
- const parentRow = table.querySelector(parentRowSelector);
66
- if (!parentRow) return;
67
-
68
- const parentLabel = parentRow.querySelector("label[data-row-id]");
69
- if (!parentLabel) return;
70
-
71
- const parentCheckbox = parentLabel.querySelector(
72
- "input[type='checkbox']"
73
- );
74
- if (!parentCheckbox) return;
75
-
76
- // Find all immediate children of parent linked to ancestor Id, filter our subrow headers
77
- const children = Array.from(
78
- table.querySelectorAll(`tr[data-row-parent$="_${ancestorId}"]`)
79
- ).filter((child) => {
80
- const content = child.dataset.advancedTableContent;
81
- return !(content && content.endsWith("sr"));
82
- });
83
-
84
- const allChildrenChecked = Array.from(children).every((child) => {
85
- const childLabel = child.querySelector("label[data-row-id]");
86
- if (!childLabel) return false;
87
- const childCheckbox = childLabel.querySelector(
88
- "input[type='checkbox']"
89
- );
90
- if (!childCheckbox) return false;
91
- return childCheckbox.checked;
92
- });
93
-
94
- // Update parent checkbox
95
- parentCheckbox.checked = allChildrenChecked;
96
-
97
- const parentCheckboxId = parentCheckbox.id;
98
- if (allChildrenChecked) {
99
- PbAdvancedTable.selectedRows.add(parentCheckboxId);
100
- parentRow.classList.add("bg-row-selection");
101
- parentRow.classList.remove("bg-white", "bg-silver");
102
- } else {
103
- PbAdvancedTable.selectedRows.delete(parentCheckboxId);
104
- }
105
- if (!allChildrenChecked) {
106
- parentRow.classList.remove("bg-row-selection");
107
-
108
- if (this.isRowExpanded(parentRow)) {
109
- parentRow.classList.remove("bg-silver");
110
- parentRow.classList.add("bg-white");
111
- } else {
112
- parentRow.classList.remove("bg-white");
113
- parentRow.classList.add("bg-silver");
114
- }
115
- }
116
- });
117
- }
118
-
119
114
  handleCheckboxClick(event) {
120
115
  const checkbox = event.currentTarget;
121
116
  const rowId = checkbox.id;
@@ -141,49 +136,6 @@ export default class PbAdvancedTable extends PbEnhancedElement {
141
136
  rowEl.classList.add("bg-silver");
142
137
  }
143
138
  }
144
- if (rowEl) {
145
- const table = rowEl.closest("table");
146
- const rowContent = rowEl.dataset.advancedTableContent;
147
-
148
- if (rowContent) {
149
- const childRows = table.querySelectorAll(
150
- `[data-advanced-table-content^="${rowContent}-"]`
151
- );
152
-
153
- childRows.forEach((childRow) => {
154
- const label = childRow.querySelector("label[data-row-id]");
155
- if (!label) return;
156
-
157
- const childCheckbox = label.querySelector("input[type='checkbox']");
158
- if (!childCheckbox) return;
159
-
160
- childCheckbox.checked = isChecked;
161
-
162
- const childRowId = childCheckbox.id;
163
- const childRowEl = childCheckbox.closest("tr");
164
- if (isChecked) {
165
- PbAdvancedTable.selectedRows.add(childRowId);
166
- childRowEl?.classList.add("bg-row-selection");
167
- childRowEl?.classList.remove("bg-white", "bg-silver");
168
- } else {
169
- PbAdvancedTable.selectedRows.delete(childRowId);
170
- }
171
- if (!isChecked) {
172
- childRowEl?.classList.remove("bg-row-selection");
173
-
174
- if (this.isRowExpanded(childRowEl)) {
175
- childRowEl?.classList.remove("bg-silver");
176
- childRowEl?.classList.add("bg-white");
177
- } else {
178
- childRowEl?.classList.remove("bg-white");
179
- childRowEl?.classList.add("bg-silver");
180
- }
181
- }
182
- });
183
- }
184
- }
185
-
186
- this.updateParentCheckboxes(checkbox);
187
139
 
188
140
  this.updateTableSelectedRowsAttribute();
189
141
 
@@ -249,8 +201,11 @@ export default class PbAdvancedTable extends PbEnhancedElement {
249
201
  this.handleCheckboxClick({ currentTarget: cb });
250
202
  }
251
203
  });
252
- this.updateTableSelectedRowsAttribute();
253
- updateSelectionActionBar(table.closest(".pb_advanced_table"), PbAdvancedTable.selectedRows.size);
204
+
205
+ // Recalculate the count to ensure all checkboxes are properly tracked
206
+ setTimeout(() => {
207
+ this.recalculateSelectedCount();
208
+ }, 0);
254
209
  return;
255
210
  }
256
211
 
@@ -258,17 +213,41 @@ export default class PbAdvancedTable extends PbEnhancedElement {
258
213
  const rowLabel = checkbox.closest("label[data-row-id]");
259
214
  if (rowLabel) {
260
215
  this.handleCheckboxClick({ currentTarget: checkbox });
261
- this.updateTableSelectedRowsAttribute();
216
+
217
+ // Recalculate the count to ensure all checkboxes are properly tracked
218
+ setTimeout(() => {
219
+ this.recalculateSelectedCount();
220
+ }, 0);
221
+ }
222
+ });
262
223
 
263
- // Sync header select-all state
264
- const selectAllInput = table.querySelector(
265
- '#select-all-rows input[type="checkbox"]'
266
- );
267
- if (selectAllInput) {
268
- selectAllInput.checked = Array.from(
269
- table.querySelectorAll('label[data-row-id] input[type="checkbox"]')
270
- ).every((cb) => cb.checked);
271
- }
224
+ // If a parent checkbox changed a checkbox, update styling
225
+ // Listen for programmatic checkbox changes from parent-child relationships
226
+ table.addEventListener("checkbox-programmatic-change", (event) => {
227
+ const checkbox = event.target;
228
+ if (!checkbox || checkbox.type !== 'checkbox') return;
229
+
230
+ // Individual row checkbox logic
231
+ const rowLabel = checkbox.closest("label[data-row-id]");
232
+ if (rowLabel) {
233
+ this.handleCheckboxClick({ currentTarget: checkbox });
234
+ }
235
+
236
+ // Recalculate the count to ensure all programmatically changed checkboxes are included
237
+ setTimeout(() => {
238
+ this.recalculateSelectedCount();
239
+ }, 10); // Slightly longer delay to ensure all changes are processed
240
+ });
241
+
242
+
243
+ // Also listen for all checkbox changes to ensure we catch everything
244
+ table.addEventListener("change", (event) => {
245
+ const checkbox = event.target;
246
+ if (checkbox && checkbox.type === 'checkbox') {
247
+ // Force recalculation after a short delay to ensure all changes are processed
248
+ setTimeout(() => {
249
+ this.recalculateSelectedCount();
250
+ }, 50);
272
251
  }
273
252
  });
274
253
 
@@ -40,13 +40,14 @@ module Playbook
40
40
  end.compact
41
41
  end
42
42
 
43
- def render_row_and_children(row, column_definitions, current_depth, first_parent_child, ancestor_ids = [], top_parent_id = nil, additional_classes: "", table_data_attributes: {})
43
+ def render_row_and_children(row, column_definitions, current_depth, first_parent_child, ancestor_ids = [], top_parent_id = nil, additional_classes: "", table_data_attributes: {}, immediate_parent_row_id: nil)
44
44
  top_parent_id ||= row.object_id
45
45
  new_ancestor_ids = ancestor_ids + [row.object_id]
46
46
  leaf_columns = flatten_columns(column_definitions)
47
47
 
48
48
  output = ActiveSupport::SafeBuffer.new
49
49
  is_first_child_of_subrow = current_depth.positive? && first_parent_child && subrow_headers[current_depth - 1].present?
50
+ last_row = subrow_headers.length == current_depth
50
51
 
51
52
  subrow_ancestor_ids = ancestor_ids + ["#{row.object_id}sr"]
52
53
  subrow_data_attributes = {
@@ -55,7 +56,7 @@ module Playbook
55
56
  row_parent: "#{id}_#{ancestor_ids.last}",
56
57
  }
57
58
  # Subrow header if applicable
58
- output << pb_rails("advanced_table/table_subrow_header", props: { row: row, column_definitions: leaf_columns, depth: current_depth, subrow_header: subrow_headers[current_depth - 1], collapsible_trail: collapsible_trail, classname: "toggle-content", responsive: responsive, subrow_data_attributes: subrow_data_attributes }) if is_first_child_of_subrow && enable_toggle_expansion == "all"
59
+ output << pb_rails("advanced_table/table_subrow_header", props: { row: row, column_definitions: leaf_columns, depth: current_depth, subrow_header: subrow_headers[current_depth - 1], collapsible_trail: collapsible_trail, classname: "toggle-content", responsive: responsive, subrow_data_attributes: subrow_data_attributes, last_row: last_row, immediate_parent_row_id: immediate_parent_row_id }) if is_first_child_of_subrow && enable_toggle_expansion == "all"
59
60
 
60
61
  current_data_attributes = if current_depth.zero?
61
62
  {
@@ -68,7 +69,7 @@ module Playbook
68
69
  end
69
70
 
70
71
  # Additional class and data attributes needed for toggle logic
71
- output << pb_rails("advanced_table/table_row", props: { id: id, row: row, column_definitions: leaf_columns, depth: current_depth, collapsible_trail: collapsible_trail, classname: additional_classes, table_data_attributes: current_data_attributes, responsive: responsive, loading: loading, selectable_rows: selectable_rows, row_id: row[:id], enable_toggle_expansion: enable_toggle_expansion, row_styling: row_styling })
72
+ output << pb_rails("advanced_table/table_row", props: { id: id, row: row, column_definitions: leaf_columns, depth: current_depth, collapsible_trail: collapsible_trail, classname: additional_classes, table_data_attributes: current_data_attributes, responsive: responsive, loading: loading, selectable_rows: selectable_rows, row_id: row[:id], enable_toggle_expansion: enable_toggle_expansion, row_styling: row_styling, last_row: last_row, immediate_parent_row_id: immediate_parent_row_id })
72
73
 
73
74
  if row[:children].present?
74
75
  row[:children].each do |child_row|
@@ -83,7 +84,7 @@ module Playbook
83
84
  advanced_table_content: data_content,
84
85
  }
85
86
 
86
- output << render_row_and_children(child_row, column_definitions, current_depth + 1, is_first_child, new_ancestor_ids, top_parent_id, additional_classes: "toggle-content", table_data_attributes: child_data_attributes)
87
+ output << render_row_and_children(child_row, column_definitions, current_depth + 1, is_first_child, new_ancestor_ids, top_parent_id, additional_classes: "toggle-content", table_data_attributes: child_data_attributes, immediate_parent_row_id: row.id)
87
88
  end
88
89
  end
89
90
 
@@ -3,6 +3,8 @@
3
3
  module Playbook
4
4
  module PbAdvancedTable
5
5
  class TableHeader < Playbook::KitBase
6
+ prop :id, type: Playbook::Props::String,
7
+ default: ""
6
8
  prop :column_definitions, type: Playbook::Props::Array,
7
9
  default: []
8
10
  prop :enable_toggle_expansion, type: Playbook::Props::Enum,
@@ -56,8 +58,10 @@ module Playbook
56
58
  classname: additional_classes.join(" "),
57
59
  }) do
58
60
  pb_rails("checkbox", props: {
59
- id: "select-all-rows",
60
- name: "select-all-rows",
61
+ id: "#{id ? "#{id}-" : ''}select-all-rows",
62
+ indeterminate_main: true,
63
+ indeterminate_main_labels: ["", ""],
64
+ name: "#{id ? "#{id}-" : ''}select-all-rows",
61
65
  })
62
66
  end
63
67
  end
@@ -67,8 +71,10 @@ module Playbook
67
71
  def render_select_all_checkbox
68
72
  if selectable_rows
69
73
  pb_rails("checkbox", props: {
70
- id: "select-all-rows",
71
- name: "select-all-rows",
74
+ id: "#{id ? "#{id}-" : ''}select-all-rows",
75
+ indeterminate_main: true,
76
+ indeterminate_main_labels: ["", ""],
77
+ name: "#{id ? "#{id}-" : ''}select-all-rows",
72
78
  data: {
73
79
  action: "click->pb-advanced-table#toggleAllRowSelection",
74
80
  },
@@ -29,6 +29,10 @@ module Playbook
29
29
  default: "header"
30
30
  prop :row_styling, type: Playbook::Props::Array,
31
31
  default: []
32
+ prop :last_row, type: Playbook::Props::Boolean,
33
+ default: false
34
+ prop :immediate_parent_row_id, type: Playbook::Props::String,
35
+ default: ""
32
36
 
33
37
  def data
34
38
  Hash(prop(:data)).merge(table_data_attributes)
@@ -54,12 +58,14 @@ module Playbook
54
58
  # Selectable Rows No Subrows - checkboxes in their own first cell
55
59
  def render_checkbox_cell
56
60
  if selectable_rows
61
+ prefix = id ? "#{id}-" : ""
57
62
  pb_rails("table/table_cell", props: {
58
63
  classname: "checkbox-cell",
59
64
  }) do
60
65
  pb_rails("checkbox", props: {
61
- id: "select-row-#{row_id || row.object_id}",
62
- name: "select-row-#{row_id || row.object_id}",
66
+ id: "#{prefix}select-row-#{row_id || row.object_id}",
67
+ indeterminate_parent: "#{id ? "#{id}-" : ''}select-all-rows",
68
+ name: "#{prefix}select-row-#{row_id || row.object_id}",
63
69
  data: {
64
70
  row_id: row_id || row.object_id.to_s,
65
71
  flat_advanced_table_select: true,
@@ -72,9 +78,20 @@ module Playbook
72
78
  # Selectable Rows w/ Subrows - checkboxes part of toggleable first cell
73
79
  def render_row_checkbox
74
80
  if selectable_rows
81
+ prefix = id ? "#{id}-" : ""
82
+ indeterminate_parent =
83
+ if depth.zero?
84
+ "#{prefix}select-all-rows"
85
+ else
86
+ "#{prefix}select-row-#{immediate_parent_row_id}"
87
+ end
88
+
75
89
  pb_rails("checkbox", props: {
76
- id: "select-row-#{row_id || row.object_id}",
77
- name: "select-row-#{row_id || row.object_id}",
90
+ id: "#{prefix}select-row-#{row_id || row.object_id}",
91
+ indeterminate_main: !last_row,
92
+ indeterminate_main_labels: ["", ""],
93
+ indeterminate_parent: indeterminate_parent,
94
+ name: "#{prefix}select-row-#{row_id || row.object_id}",
78
95
  data: {
79
96
  row_id: row_id || row.object_id.to_s,
80
97
  },