Skip to content

Commit ba3f142

Browse files
committed
adds select all option that is initially checked when editing casa case
1 parent 6f6e544 commit ba3f142

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

app/components/form/multiple_select_component.html.erb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<div class="badge rounded-pill bg-primary active px-3">DATA_LABEL</div>
2020
</template>
2121

22+
<%# not needed, but want to be explicit when including this markup %>
2223
<% if @show_all_option %>
2324
<template data-multiple-select-target="hiddenItem">
2425
<div class="d-none"></div>

app/javascript/controllers/multiple_select_controller.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,7 @@ export default class extends Controller {
5050
orderedOptionVals = [" "].concat(orderedOptionVals)
5151
}
5252

53-
// used to determine initial items selected by tom-select
54-
const initItems = this.selectedItemsValue?.length ? this.selectedItemsValue : orderedOptionVals
53+
const initItems = Array.isArray(this.selectedItemsValue) && this.selectedItemsValue.length ? showAllOptionCheck ? [" "].concat(this.selectedItemsValue) : this.selectedItemsValue : orderedOptionVals
5554

5655
const dropdownOptions = showAllOptionCheck ?
5756
[{ text: "Select/Unseselect all", subtext: "", value: " ", group: ""}].concat(this.optionsValue)

0 commit comments

Comments
 (0)