-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PBNTR-606] Add Reset Functionality to Rails side of MultiLevelSelect (…
…#3792) [Runway Story](https://runway.powerhrg.com/backlog_items/PBNTR-606) This PR: - ✅ Adds reset functionality to rails side of kit so it can be used within nitro_search_playbook_filter in Nitro - ✅ Unblocks [this work](https://runway.powerhrg.com/backlog_items/FIRST-1537) for First Contact - ✅ Creates reset doc example on rails side to showcase how to use exposed function
- Loading branch information
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
93 changes: 93 additions & 0 deletions
93
playbook/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_reset.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
<% treeData = [{ | ||
label: "Power Home Remodeling", | ||
value: "Power Home Remodeling", | ||
id: "100", | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: "People", | ||
value: "People", | ||
id: "101", | ||
expanded: true, | ||
children: [ | ||
{ | ||
label: "Talent Acquisition", | ||
value: "Talent Acquisition", | ||
id: "102", | ||
}, | ||
{ | ||
label: "Business Affairs", | ||
value: "Business Affairs", | ||
id: "103", | ||
children: [ | ||
{ | ||
label: "Initiatives", | ||
value: "Initiatives", | ||
id: "104", | ||
}, | ||
{ | ||
label: "Learning & Development", | ||
value: "Learning & Development", | ||
id: "105", | ||
}, | ||
], | ||
}, | ||
{ | ||
label: "People Experience", | ||
value: "People Experience", | ||
id: "106", | ||
}, | ||
], | ||
}, | ||
{ | ||
label: "Contact Center", | ||
value: "Contact Center", | ||
id: "107", | ||
children: [ | ||
{ | ||
label: "Appointment Management", | ||
value: "Appointment Management", | ||
id: "108", | ||
}, | ||
{ | ||
label: "Customer Service", | ||
value: "Customer Service", | ||
id: "109", | ||
}, | ||
{ | ||
label: "Energy", | ||
value: "Energy", | ||
id: "110", | ||
}, | ||
], | ||
}, | ||
], | ||
}] %> | ||
|
||
<%= pb_rails("multi_level_select", props: { | ||
id: "multi-level-select-reset-example", | ||
name: "my_array", | ||
tree_data: treeData, | ||
return_all_selected: true | ||
}) %> | ||
|
||
<%= pb_rails("button", props: { text: "Reset", margin_top: "lg", id:"multilevelselect-reset-button" }) %> | ||
|
||
|
||
<script> | ||
window.addEventListener('DOMContentLoaded', () => { | ||
const exampleResetButton = document.querySelector("#multilevelselect-reset-button"); | ||
|
||
exampleResetButton.addEventListener("click", () => { | ||
clearMultiLevelSelectById('multi-level-select-reset-example'); | ||
}); | ||
function clearMultiLevelSelectById(id) { | ||
const clearFunction = window[`clearMultiLevelSelect_${id}`]; | ||
if (clearFunction) { | ||
clearFunction(); | ||
} else { | ||
console.warn(`No clear function found for MultiLevelSelect with id: ${id}`); | ||
} | ||
} | ||
}) | ||
</script> |
1 change: 1 addition & 0 deletions
1
...ok/app/pb_kits/playbook/pb_multi_level_select/docs/_multi_level_select_reset.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
In order to clear the multilevelselect selection using an external trigger (like a reset button), the `clearMultiLevelSelect` function can be used. See the code snippet below to see this in action. The function is scoped by id so an id MUST be used on the multilevelselect kit and passed to the function as shown for it to work. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters