playbook_ui 15.6.0.pre.alpha.play266013023 → 15.6.0.pre.alpha.play266913088
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/app/pb_kits/playbook/pb_advanced_table/Components/RegularTableView.tsx +3 -2
- data/app/pb_kits/playbook/pb_advanced_table/Components/TableHeaderCell.tsx +4 -0
- data/app/pb_kits/playbook/pb_advanced_table/advanced_table.test.jsx +95 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_colors_rails.html.erb +43 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_colors_rails.md +1 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.html.erb +11 -5
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_background_control_rails.md +7 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background.jsx +54 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background.md +9 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_multi.jsx +80 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/_advanced_table_column_styling_background_multi.md +3 -0
- data/app/pb_kits/playbook/pb_advanced_table/docs/example.yml +4 -1
- data/app/pb_kits/playbook/pb_advanced_table/docs/index.js +3 -1
- data/app/pb_kits/playbook/pb_advanced_table/table_header.html.erb +2 -2
- data/app/pb_kits/playbook/pb_advanced_table/table_header.rb +57 -0
- data/app/pb_kits/playbook/pb_contact/_contact.tsx +51 -24
- data/app/pb_kits/playbook/pb_contact/contact.html.erb +53 -19
- data/app/pb_kits/playbook/pb_contact/contact.rb +11 -1
- data/app/pb_kits/playbook/pb_contact/contact.test.js +76 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.html.erb +33 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled.jsx +46 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_rails.md +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/_contact_unstyled_react.md +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_contact/docs/index.js +1 -0
- data/app/pb_kits/playbook/pb_date_picker/date_picker_helper.ts +16 -4
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern_rails.html.erb +23 -14
- data/app/pb_kits/playbook/pb_date_picker/docs/_date_picker_range_pattern_rails.md +1 -1
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_overflow_visible.html.erb +71 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_overflow_visible.jsx +57 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_overflow_visible_rails.md +1 -0
- data/app/pb_kits/playbook/pb_dialog/docs/_dialog_overflow_visible_react.md +1 -0
- data/app/pb_kits/playbook/pb_dialog/docs/example.yml +2 -0
- data/app/pb_kits/playbook/pb_dialog/docs/index.js +2 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_default_rails.html.erb +7 -5
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_default_dates.html.erb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_rails.html.erb +12 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_rails.md +26 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end_rails.html.erb +19 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_range_end_rails.md +1 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_default_rails.html.erb +30 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_default_rails.md +3 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_rails.html.erb +29 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_rails.md +13 -0
- data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_with_custom_display_rails.html.erb +3 -1
- data/app/pb_kits/playbook/pb_dropdown/docs/example.yml +5 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.html.erb +4 -0
- data/app/pb_kits/playbook/pb_dropdown/dropdown.rb +39 -5
- data/app/pb_kits/playbook/pb_dropdown/index.js +171 -3
- data/app/pb_kits/playbook/pb_dropdown/quickpick_helper.rb +75 -0
- data/app/pb_kits/playbook/pb_filter/Filter/FilterBackground.tsx +3 -3
- data/app/pb_kits/playbook/pb_table/_table.tsx +187 -33
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.jsx +134 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant.md +34 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.html.erb +101 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_rails.md +33 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.jsx +180 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.html.erb +122 -0
- data/app/pb_kits/playbook/pb_table/docs/_table_with_filter_variant_with_pagination_rails.md +3 -0
- data/app/pb_kits/playbook/pb_table/docs/example.yml +4 -0
- data/app/pb_kits/playbook/pb_table/docs/index.js +2 -0
- data/app/pb_kits/playbook/pb_table/table.html.erb +68 -12
- data/app/pb_kits/playbook/pb_table/table.rb +22 -3
- data/app/pb_kits/playbook/pb_table/table.test.js +143 -0
- data/dist/chunks/_typeahead-CbjBmIDu.js +6 -0
- data/dist/chunks/{lib-DDDLiZuu.js → lib-DxDBrGZX.js} +3 -3
- data/dist/chunks/vendor.js +3 -3
- data/dist/menu.yml +1 -1
- data/dist/playbook-rails-react-bindings.js +1 -1
- data/dist/playbook-rails.js +1 -1
- data/lib/playbook/version.rb +1 -1
- metadata +36 -4
- data/dist/chunks/_typeahead-CYNrKU10.js +0 -6
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
<%= pb_rails("dropdown", props: {
|
|
2
|
+
id: "dropdown-quickpick-with-date-pickers-default",
|
|
3
|
+
label: "Date Range",
|
|
4
|
+
name: "date_range",
|
|
5
|
+
margin_bottom: "sm",
|
|
6
|
+
variant: "quickpick",
|
|
7
|
+
default_value: "This Month",
|
|
8
|
+
controls_start_id: "start-date-picker-default",
|
|
9
|
+
controls_end_id: "end-date-picker-default",
|
|
10
|
+
start_date_id: "quickpick_start_date_default",
|
|
11
|
+
start_date_name: "start_date",
|
|
12
|
+
end_date_id: "quickpick_end_date_default",
|
|
13
|
+
end_date_name: "end_date"
|
|
14
|
+
}) %>
|
|
15
|
+
|
|
16
|
+
<%= pb_rails("date_picker", props: {
|
|
17
|
+
picker_id: "start-date-picker-default",
|
|
18
|
+
label: "Start Date",
|
|
19
|
+
name: "start_date_picker",
|
|
20
|
+
placeholder: "Select Start Date",
|
|
21
|
+
sync_start_with: "dropdown-quickpick-with-date-pickers-default"
|
|
22
|
+
}) %>
|
|
23
|
+
|
|
24
|
+
<%= pb_rails("date_picker", props: {
|
|
25
|
+
picker_id: "end-date-picker-default",
|
|
26
|
+
label: "End Date",
|
|
27
|
+
name: "end_date_picker",
|
|
28
|
+
placeholder: "Select End Date",
|
|
29
|
+
sync_end_with: "dropdown-quickpick-with-date-pickers-default"
|
|
30
|
+
}) %>
|
data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_default_rails.md
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
This example demonstrates the 3-input pattern with a default value. The dropdown is initialized with "This Month" selected, and both DatePickers are automatically populated with the corresponding start and end dates.
|
|
2
|
+
|
|
3
|
+
The default value can be set using the `default_value` prop with any of the quickpick option labels.
|
data/app/pb_kits/playbook/pb_dropdown/docs/_dropdown_quickpick_with_date_pickers_rails.html.erb
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<%= pb_rails("dropdown", props: {
|
|
2
|
+
id: "dropdown-quickpick-with-date-pickers",
|
|
3
|
+
label: "Date Range",
|
|
4
|
+
name: "date_range",
|
|
5
|
+
margin_bottom: "sm",
|
|
6
|
+
variant: "quickpick",
|
|
7
|
+
controls_start_id: "start-date-picker",
|
|
8
|
+
controls_end_id: "end-date-picker",
|
|
9
|
+
start_date_id: "quickpick_start_date",
|
|
10
|
+
start_date_name: "start_date",
|
|
11
|
+
end_date_id: "quickpick_end_date",
|
|
12
|
+
end_date_name: "end_date"
|
|
13
|
+
}) %>
|
|
14
|
+
|
|
15
|
+
<%= pb_rails("date_picker", props: {
|
|
16
|
+
picker_id: "start-date-picker",
|
|
17
|
+
label: "Start Date",
|
|
18
|
+
name: "start_date_picker",
|
|
19
|
+
placeholder: "Select Start Date",
|
|
20
|
+
sync_start_with: "dropdown-quickpick-with-date-pickers"
|
|
21
|
+
}) %>
|
|
22
|
+
|
|
23
|
+
<%= pb_rails("date_picker", props: {
|
|
24
|
+
picker_id: "end-date-picker",
|
|
25
|
+
label: "End Date",
|
|
26
|
+
name: "end_date_picker",
|
|
27
|
+
placeholder: "Select End Date",
|
|
28
|
+
sync_end_with: "dropdown-quickpick-with-date-pickers"
|
|
29
|
+
}) %>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
The quickpick variant can be synced with two DatePickers for a 3-input pattern. When a quickpick option is selected from the dropdown, both DatePickers are automatically populated. When either DatePicker is manually changed, the dropdown is cleared.
|
|
2
|
+
|
|
3
|
+
#### Props for 3-Input Pattern:
|
|
4
|
+
|
|
5
|
+
- `controls_start_id` - ID of the start DatePicker to sync with
|
|
6
|
+
- `controls_end_id` - ID of the end DatePicker to sync with
|
|
7
|
+
|
|
8
|
+
#### DatePicker Props:
|
|
9
|
+
|
|
10
|
+
- `sync_start_with` - ID of the dropdown to clear when start date changes
|
|
11
|
+
- `sync_end_with` - ID of the dropdown to clear when end date changes
|
|
12
|
+
|
|
13
|
+
This pattern allows users to quickly select common date ranges or manually pick specific dates.
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
%>
|
|
48
48
|
|
|
49
49
|
|
|
50
|
-
<%= pb_rails("dropdown", props: {options: options}) do %>
|
|
50
|
+
<%= pb_rails("dropdown", props: {id: "user-dropdown", options: options}) do %>
|
|
51
51
|
<%= pb_rails("dropdown/dropdown_trigger", props: {placeholder: "Select a User", custom_display: custom_display}) %>
|
|
52
52
|
<%= pb_rails("dropdown/dropdown_container") do %>
|
|
53
53
|
<% options.each do |option| %>
|
|
@@ -71,6 +71,8 @@
|
|
|
71
71
|
|
|
72
72
|
<script>
|
|
73
73
|
document.addEventListener("pb:dropdown:selected", (e) => {
|
|
74
|
+
if (e.target.id !== "user-dropdown") return;
|
|
75
|
+
|
|
74
76
|
const option = e.detail;
|
|
75
77
|
const dropdown = e.target;
|
|
76
78
|
|
|
@@ -22,6 +22,11 @@ examples:
|
|
|
22
22
|
- dropdown_multi_select_with_default: Multi Select Default Value
|
|
23
23
|
- dropdown_blank_selection: Blank Selection
|
|
24
24
|
- dropdown_separators_hidden: Separators Hidden
|
|
25
|
+
- dropdown_quickpick_rails: Quick Pick Variant
|
|
26
|
+
- dropdown_quickpick_range_end_rails: Quick Pick Variant (Range Ends Today)
|
|
27
|
+
- dropdown_quickpick_default_dates: Quick Pick Variant (Default Dates)
|
|
28
|
+
- dropdown_quickpick_with_date_pickers_rails: Quick Pick with Date Pickers
|
|
29
|
+
- dropdown_quickpick_with_date_pickers_default_rails: Quick Pick with Date Pickers (Default Value)
|
|
25
30
|
|
|
26
31
|
react:
|
|
27
32
|
- dropdown_default: Default
|
|
@@ -10,6 +10,10 @@
|
|
|
10
10
|
style="display: none"
|
|
11
11
|
<%= object.required ? "required" : ""%>
|
|
12
12
|
/>
|
|
13
|
+
<% if object.variant == "quickpick" %>
|
|
14
|
+
<input id="<%= object.start_date_id %>" name="<%= object.start_date_name %>" style="display: none">
|
|
15
|
+
<input id="<%= object.end_date_id %>" name="<%= object.end_date_name %>" style="display: none">
|
|
16
|
+
<% end %>
|
|
13
17
|
<% if content.present? %>
|
|
14
18
|
<%= content.presence %>
|
|
15
19
|
<%= pb_rails("body", props: { status: "negative", text: object.error }) %>
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require_relative "quickpick_helper"
|
|
4
|
+
|
|
3
5
|
module Playbook
|
|
4
6
|
module PbDropdown
|
|
5
7
|
class Dropdown < Playbook::KitBase
|
|
@@ -14,7 +16,7 @@ module Playbook
|
|
|
14
16
|
prop :blank_selection, type: Playbook::Props::String,
|
|
15
17
|
default: ""
|
|
16
18
|
prop :variant, type: Playbook::Props::Enum,
|
|
17
|
-
values: %w[default subtle],
|
|
19
|
+
values: %w[default subtle quickpick],
|
|
18
20
|
default: "default"
|
|
19
21
|
prop :separators, type: Playbook::Props::Boolean,
|
|
20
22
|
default: true
|
|
@@ -26,13 +28,32 @@ module Playbook
|
|
|
26
28
|
default: false
|
|
27
29
|
prop :form_pill_props, type: Playbook::Props::HashProp,
|
|
28
30
|
default: {}
|
|
31
|
+
prop :range_ends_today, type: Playbook::Props::Boolean,
|
|
32
|
+
default: false
|
|
33
|
+
prop :controls_end_id, type: Playbook::Props::String,
|
|
34
|
+
default: ""
|
|
35
|
+
prop :controls_start_id, type: Playbook::Props::String,
|
|
36
|
+
default: ""
|
|
37
|
+
prop :start_date_id, type: Playbook::Props::String,
|
|
38
|
+
default: "start_date_id"
|
|
39
|
+
prop :start_date_name, type: Playbook::Props::String,
|
|
40
|
+
default: "start_date_name"
|
|
41
|
+
prop :end_date_id, type: Playbook::Props::String,
|
|
42
|
+
default: "end_date_id"
|
|
43
|
+
prop :end_date_name, type: Playbook::Props::String,
|
|
44
|
+
default: "end_date_name"
|
|
29
45
|
|
|
30
46
|
def data
|
|
31
47
|
Hash(prop(:data)).merge(
|
|
32
48
|
pb_dropdown: true,
|
|
33
49
|
pb_dropdown_multi_select: multi_select,
|
|
34
|
-
|
|
35
|
-
|
|
50
|
+
pb_dropdown_variant: variant,
|
|
51
|
+
form_pill_props: form_pill_props.to_json,
|
|
52
|
+
start_date_id: variant == "quickpick" ? start_date_id : nil,
|
|
53
|
+
end_date_id: variant == "quickpick" ? end_date_id : nil,
|
|
54
|
+
controls_start_id: variant == "quickpick" && controls_start_id.present? ? controls_start_id : nil,
|
|
55
|
+
controls_end_id: variant == "quickpick" && controls_end_id.present? ? controls_end_id : nil
|
|
56
|
+
).compact
|
|
36
57
|
end
|
|
37
58
|
|
|
38
59
|
def classname
|
|
@@ -48,7 +69,15 @@ module Playbook
|
|
|
48
69
|
def input_default_value
|
|
49
70
|
return "" unless default_value.present?
|
|
50
71
|
|
|
51
|
-
if
|
|
72
|
+
if variant == "quickpick"
|
|
73
|
+
d = default_value.to_s.downcase
|
|
74
|
+
matched_option = quickpick_options.find do |opt|
|
|
75
|
+
opt[:label].downcase == d
|
|
76
|
+
end
|
|
77
|
+
return matched_option[:id] if matched_option
|
|
78
|
+
|
|
79
|
+
""
|
|
80
|
+
elsif multi_select
|
|
52
81
|
default_value.map { |v| v.transform_keys(&:to_s)["id"] }.join(",")
|
|
53
82
|
else
|
|
54
83
|
default_value.transform_keys(&:to_s)["id"]
|
|
@@ -60,7 +89,12 @@ module Playbook
|
|
|
60
89
|
end
|
|
61
90
|
|
|
62
91
|
def options_with_blank
|
|
63
|
-
|
|
92
|
+
dropdown_options = variant == "quickpick" ? quickpick_options : options
|
|
93
|
+
blank_selection.present? ? [{ id: "", value: "", label: blank_selection }] + dropdown_options : dropdown_options
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
def quickpick_options
|
|
97
|
+
QuickpickHelper.get_quickpick_options(range_ends_today: range_ends_today)
|
|
64
98
|
end
|
|
65
99
|
end
|
|
66
100
|
end
|
|
@@ -28,6 +28,9 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
28
28
|
clearBtn = null;
|
|
29
29
|
|
|
30
30
|
connect() {
|
|
31
|
+
// Store instance on element for DatePicker sync
|
|
32
|
+
this.element._pbDropdownInstance = this;
|
|
33
|
+
|
|
31
34
|
this.keyboardHandler = new PbDropdownKeyboard(this);
|
|
32
35
|
this.isMultiSelect = this.element.dataset.pbDropdownMultiSelect === "true";
|
|
33
36
|
this.formPillProps = this.element.dataset.formPillProps
|
|
@@ -252,6 +255,67 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
252
255
|
const selectedLabel = JSON.parse(value).label;
|
|
253
256
|
triggerElement.textContent = selectedLabel;
|
|
254
257
|
this.emitSelectionChange();
|
|
258
|
+
|
|
259
|
+
// Handle quickpick variant: populate start/end date hidden inputs
|
|
260
|
+
const optionData = JSON.parse(value);
|
|
261
|
+
const startDateId = this.element.dataset.startDateId;
|
|
262
|
+
const endDateId = this.element.dataset.endDateId;
|
|
263
|
+
const controlsStartId = this.element.dataset.controlsStartId;
|
|
264
|
+
const controlsEndId = this.element.dataset.controlsEndId;
|
|
265
|
+
|
|
266
|
+
if (optionData.formatted_start_date && optionData.formatted_end_date) {
|
|
267
|
+
// Populate date inputs when option has date fields
|
|
268
|
+
if (startDateId) {
|
|
269
|
+
const startDateInput = document.getElementById(startDateId);
|
|
270
|
+
if (startDateInput) startDateInput.value = optionData.formatted_start_date;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
if (endDateId) {
|
|
274
|
+
const endDateInput = document.getElementById(endDateId);
|
|
275
|
+
if (endDateInput) endDateInput.value = optionData.formatted_end_date;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
// Sync with DatePickers if controlsStartId/controlsEndId are present
|
|
279
|
+
if (controlsStartId) {
|
|
280
|
+
const startPicker = document.querySelector(`#${controlsStartId}`)?._flatpickr;
|
|
281
|
+
if (startPicker) {
|
|
282
|
+
startPicker.setDate(optionData.formatted_start_date, true, "m/d/Y");
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (controlsEndId) {
|
|
287
|
+
const endPicker = document.querySelector(`#${controlsEndId}`)?._flatpickr;
|
|
288
|
+
if (endPicker) {
|
|
289
|
+
endPicker.setDate(optionData.formatted_end_date, true, "m/d/Y");
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
} else if (startDateId || endDateId) {
|
|
293
|
+
// Clear date inputs when option doesn't have date fields (e.g., blank selection)
|
|
294
|
+
if (startDateId) {
|
|
295
|
+
const startDateInput = document.getElementById(startDateId);
|
|
296
|
+
if (startDateInput) startDateInput.value = "";
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
if (endDateId) {
|
|
300
|
+
const endDateInput = document.getElementById(endDateId);
|
|
301
|
+
if (endDateInput) endDateInput.value = "";
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
// Clear DatePickers as well
|
|
305
|
+
if (controlsStartId) {
|
|
306
|
+
const startPicker = document.querySelector(`#${controlsStartId}`)?._flatpickr;
|
|
307
|
+
if (startPicker) {
|
|
308
|
+
startPicker.clear();
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (controlsEndId) {
|
|
313
|
+
const endPicker = document.querySelector(`#${controlsEndId}`)?._flatpickr;
|
|
314
|
+
if (endPicker) {
|
|
315
|
+
endPicker.clear();
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
255
319
|
}
|
|
256
320
|
if (customDisplayElement) {
|
|
257
321
|
triggerElement.textContent = "";
|
|
@@ -432,9 +496,50 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
432
496
|
if (!selectedOption) return;
|
|
433
497
|
|
|
434
498
|
selectedOption.classList.add("pb_dropdown_option_selected");
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
499
|
+
const optionData = JSON.parse(selectedOption.dataset.dropdownOptionLabel);
|
|
500
|
+
this.setTriggerElementText(optionData.label);
|
|
501
|
+
|
|
502
|
+
// Handle quickpick variant: populate start/end date hidden inputs and sync DatePickers
|
|
503
|
+
if (optionData.formatted_start_date && optionData.formatted_end_date) {
|
|
504
|
+
const startDateId = this.element.dataset.startDateId;
|
|
505
|
+
const endDateId = this.element.dataset.endDateId;
|
|
506
|
+
const controlsStartId = this.element.dataset.controlsStartId;
|
|
507
|
+
const controlsEndId = this.element.dataset.controlsEndId;
|
|
508
|
+
|
|
509
|
+
if (startDateId) {
|
|
510
|
+
const startDateInput = document.getElementById(startDateId);
|
|
511
|
+
if (startDateInput) startDateInput.value = optionData.formatted_start_date;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
if (endDateId) {
|
|
515
|
+
const endDateInput = document.getElementById(endDateId);
|
|
516
|
+
if (endDateInput) endDateInput.value = optionData.formatted_end_date;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
// Sync with DatePickers - retry with delays to ensure DatePickers are initialized
|
|
520
|
+
const syncDatePickers = () => {
|
|
521
|
+
if (controlsStartId) {
|
|
522
|
+
const startPicker = document.querySelector(`#${controlsStartId}`)?._flatpickr;
|
|
523
|
+
if (startPicker) {
|
|
524
|
+
startPicker.setDate(optionData.formatted_start_date, true, "m/d/Y");
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (controlsEndId) {
|
|
529
|
+
const endPicker = document.querySelector(`#${controlsEndId}`)?._flatpickr;
|
|
530
|
+
if (endPicker) {
|
|
531
|
+
endPicker.setDate(optionData.formatted_end_date, true, "m/d/Y");
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
};
|
|
535
|
+
|
|
536
|
+
// Try immediately
|
|
537
|
+
syncDatePickers();
|
|
538
|
+
|
|
539
|
+
// Retry after short delay in case DatePickers aren't ready yet
|
|
540
|
+
setTimeout(syncDatePickers, 100);
|
|
541
|
+
setTimeout(syncDatePickers, 300);
|
|
542
|
+
}
|
|
438
543
|
}
|
|
439
544
|
}
|
|
440
545
|
|
|
@@ -571,6 +676,37 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
571
676
|
if (customDisplay) {
|
|
572
677
|
customDisplay.style.display = "none";
|
|
573
678
|
}
|
|
679
|
+
|
|
680
|
+
// Clear quickpick hidden inputs
|
|
681
|
+
const startDateId = this.element.dataset.startDateId;
|
|
682
|
+
const endDateId = this.element.dataset.endDateId;
|
|
683
|
+
const controlsStartId = this.element.dataset.controlsStartId;
|
|
684
|
+
const controlsEndId = this.element.dataset.controlsEndId;
|
|
685
|
+
|
|
686
|
+
if (startDateId) {
|
|
687
|
+
const startDateInput = document.getElementById(startDateId);
|
|
688
|
+
if (startDateInput) startDateInput.value = "";
|
|
689
|
+
}
|
|
690
|
+
if (endDateId) {
|
|
691
|
+
const endDateInput = document.getElementById(endDateId);
|
|
692
|
+
if (endDateInput) endDateInput.value = "";
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
// Clear linked DatePickers if controlsStartId/controlsEndId are present
|
|
696
|
+
if (controlsStartId) {
|
|
697
|
+
const startPicker = document.querySelector(`#${controlsStartId}`)?._flatpickr;
|
|
698
|
+
if (startPicker) {
|
|
699
|
+
startPicker.clear();
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
if (controlsEndId) {
|
|
704
|
+
const endPicker = document.querySelector(`#${controlsEndId}`)?._flatpickr;
|
|
705
|
+
if (endPicker) {
|
|
706
|
+
endPicker.clear();
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
574
710
|
this.resetDropdownValue();
|
|
575
711
|
this.updatePills();
|
|
576
712
|
this.updateClearButton();
|
|
@@ -578,6 +714,38 @@ export default class PbDropdown extends PbEnhancedElement {
|
|
|
578
714
|
this.emitSelectionChange();
|
|
579
715
|
}
|
|
580
716
|
|
|
717
|
+
// Method for DatePicker sync - only clears the dropdown, not the DatePickers
|
|
718
|
+
clearSelected() {
|
|
719
|
+
// Only clear if this is a single-select quickpick variant
|
|
720
|
+
if (this.element.dataset.pbDropdownVariant !== "quickpick" || this.isMultiSelect) {
|
|
721
|
+
return;
|
|
722
|
+
}
|
|
723
|
+
|
|
724
|
+
const customDisplay = this.element.querySelector(
|
|
725
|
+
"#dropdown_trigger_custom_display"
|
|
726
|
+
);
|
|
727
|
+
if (customDisplay) {
|
|
728
|
+
customDisplay.style.display = "none";
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// Clear quickpick hidden inputs only (not the DatePickers)
|
|
732
|
+
const startDateId = this.element.dataset.startDateId;
|
|
733
|
+
const endDateId = this.element.dataset.endDateId;
|
|
734
|
+
|
|
735
|
+
if (startDateId) {
|
|
736
|
+
const startDateInput = document.getElementById(startDateId);
|
|
737
|
+
if (startDateInput) startDateInput.value = "";
|
|
738
|
+
}
|
|
739
|
+
if (endDateId) {
|
|
740
|
+
const endDateInput = document.getElementById(endDateId);
|
|
741
|
+
if (endDateInput) endDateInput.value = "";
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
this.resetDropdownValue();
|
|
745
|
+
this.updateClearButton();
|
|
746
|
+
this.emitSelectionChange();
|
|
747
|
+
}
|
|
748
|
+
|
|
581
749
|
syncHiddenInputs() {
|
|
582
750
|
if (!this.isMultiSelect) return;
|
|
583
751
|
this.element
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Playbook
|
|
4
|
+
module PbDropdown
|
|
5
|
+
module QuickpickHelper
|
|
6
|
+
class << self
|
|
7
|
+
def get_quickpick_options(range_ends_today: false)
|
|
8
|
+
today = Date.today
|
|
9
|
+
yesterday = today - 1.day
|
|
10
|
+
|
|
11
|
+
this_week_start_date = first_day_of_week(today)
|
|
12
|
+
this_week_end_date = range_ends_today ? today : last_day_of_week(today)
|
|
13
|
+
last_week_start_date = previous_week_start_date(today)
|
|
14
|
+
last_week_end_date = previous_week_end_date(today)
|
|
15
|
+
|
|
16
|
+
this_month_start_date = today.beginning_of_month
|
|
17
|
+
this_month_end_date = range_ends_today ? today : today.end_of_month
|
|
18
|
+
last_month_start_date = (today - 1.month).beginning_of_month
|
|
19
|
+
last_month_end_date = (today - 1.month).end_of_month
|
|
20
|
+
|
|
21
|
+
this_quarter_start_date = today.beginning_of_quarter
|
|
22
|
+
this_quarter_end_date = range_ends_today ? today : today.end_of_quarter
|
|
23
|
+
last_quarter_start_date = (today - 3.months).beginning_of_quarter
|
|
24
|
+
last_quarter_end_date = (today - 3.months).end_of_quarter
|
|
25
|
+
|
|
26
|
+
this_year_start_date = today.beginning_of_year
|
|
27
|
+
this_year_end_date = range_ends_today ? today : today.end_of_year
|
|
28
|
+
last_year_start_date = (today - 1.year).beginning_of_year
|
|
29
|
+
last_year_end_date = (today - 1.year).end_of_year
|
|
30
|
+
|
|
31
|
+
[
|
|
32
|
+
{ id: "quickpick-today", label: "Today", value: [today.to_s, today.to_s], formatted_start_date: format_date(today), formatted_end_date: format_date(today) },
|
|
33
|
+
{ id: "quickpick-yesterday", label: "Yesterday", value: [yesterday.to_s, yesterday.to_s], formatted_start_date: format_date(yesterday), formatted_end_date: format_date(yesterday) },
|
|
34
|
+
{ id: "quickpick-this-week", label: "This Week", value: [this_week_start_date.to_s, this_week_end_date.to_s], formatted_start_date: format_date(this_week_start_date), formatted_end_date: format_date(this_week_end_date) },
|
|
35
|
+
{ id: "quickpick-this-month", label: "This Month", value: [this_month_start_date.to_s, this_month_end_date.to_s], formatted_start_date: format_date(this_month_start_date), formatted_end_date: format_date(this_month_end_date) },
|
|
36
|
+
{ id: "quickpick-this-quarter", label: "This Quarter", value: [this_quarter_start_date.to_s, this_quarter_end_date.to_s], formatted_start_date: format_date(this_quarter_start_date), formatted_end_date: format_date(this_quarter_end_date) },
|
|
37
|
+
{ id: "quickpick-this-year", label: "This Year", value: [this_year_start_date.to_s, this_year_end_date.to_s], formatted_start_date: format_date(this_year_start_date), formatted_end_date: format_date(this_year_end_date) },
|
|
38
|
+
{ id: "quickpick-last-week", label: "Last Week", value: [last_week_start_date.to_s, last_week_end_date.to_s], formatted_start_date: format_date(last_week_start_date), formatted_end_date: format_date(last_week_end_date) },
|
|
39
|
+
{ id: "quickpick-last-month", label: "Last Month", value: [last_month_start_date.to_s, last_month_end_date.to_s], formatted_start_date: format_date(last_month_start_date), formatted_end_date: format_date(last_month_end_date) },
|
|
40
|
+
{ id: "quickpick-last-quarter", label: "Last Quarter", value: [last_quarter_start_date.to_s, last_quarter_end_date.to_s], formatted_start_date: format_date(last_quarter_start_date), formatted_end_date: format_date(last_quarter_end_date) },
|
|
41
|
+
{ id: "quickpick-last-year", label: "Last Year", value: [last_year_start_date.to_s, last_year_end_date.to_s], formatted_start_date: format_date(last_year_start_date), formatted_end_date: format_date(last_year_end_date) },
|
|
42
|
+
]
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
private
|
|
46
|
+
|
|
47
|
+
def format_date(date)
|
|
48
|
+
date.strftime("%m/%d/%Y")
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def format_date_range(start_date, end_date)
|
|
52
|
+
"#{format_date(start_date)} - #{format_date(end_date)}"
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def first_day_of_week(date)
|
|
56
|
+
# Monday as first day of week
|
|
57
|
+
date.beginning_of_week(:monday)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def last_day_of_week(date)
|
|
61
|
+
# Sunday as last day of week
|
|
62
|
+
date.end_of_week(:monday)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def previous_week_start_date(date)
|
|
66
|
+
first_day_of_week(date) - 1.week
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def previous_week_end_date(date)
|
|
70
|
+
last_day_of_week(date) - 1.week
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|
|
@@ -6,10 +6,10 @@ import { GlobalProps, globalProps } from '../../utilities/globalProps'
|
|
|
6
6
|
import Card from '../../pb_card/_card'
|
|
7
7
|
|
|
8
8
|
export type FilterBackgroundProps = {
|
|
9
|
-
background
|
|
10
|
-
className
|
|
9
|
+
background?: boolean,
|
|
10
|
+
className?: string,
|
|
11
11
|
children?: React.ReactChild[] | React.ReactChild,
|
|
12
|
-
dark
|
|
12
|
+
dark?: boolean,
|
|
13
13
|
} & GlobalProps
|
|
14
14
|
|
|
15
15
|
const FilterBackground = (props: FilterBackgroundProps): React.ReactElement => {
|