Skip to content

Commit

Permalink
Added searchable multiselect
Browse files Browse the repository at this point in the history
  • Loading branch information
midhunmanoj2024 committed Sep 3, 2024
1 parent ff6ee73 commit 1826a31
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 66 deletions.
52 changes: 19 additions & 33 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
"postinstall-postinstall": "^2.1.0",
"process": "^0.11.10",
"rrule": "^2.6.8",
"select2": "^4.1.0-rc.0",
"semantic-ui-css": "git+https://github.com/Semantic-Org/Semantic-UI-CSS.git",
"socket.io-client": "^4.0.0",
"stream-browserify": "^3.0.0",
Expand All @@ -61,6 +62,7 @@
"vue-bootstrap-typeahead": "^0.2.6",
"vue-class-component": "^7.2.3",
"vue-fragment": "^1.5.2",
"vue-multiselect": "^2.1.9",
"vue-property-decorator": "^9.1.2",
"vue-router": "3.5.1",
"vue-search-select": "^2.9.6",
Expand Down
14 changes: 8 additions & 6 deletions frontend/src/assets/css/q.css
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,13 @@ input#app_timepicker_id {
left: unset;
}

.custom-dropdown > a {
padding: 0 !important;

.multiselect__option--highlight {
background-color: #ffffff;
}

.custom-multiselect .multiselect__option {
padding: 0;
text-wrap: wrap;
}

.dropdown-scrollable .dropdown-menu {
max-height: 300px;
overflow-y: auto;
}
67 changes: 40 additions & 27 deletions frontend/src/components/exams/add-exam-form-components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import OfficeDrop from './office-drop.vue'
import moment from 'moment'
import { ModelListSelect } from "vue-search-select"
import { throws } from 'assert'
import Multiselect from 'vue-multiselect'
import 'vue-multiselect/dist/vue-multiselect.min.css'

// Checkmark
@Component({
Expand Down Expand Up @@ -185,7 +187,8 @@ export class DateQuestion extends Vue {
@Component({
components: {
Checkmark,
ModelListSelect
ModelListSelect,
Multiselect
},
computed: {
...mapState({
Expand All @@ -196,30 +199,39 @@ export class DateQuestion extends Vue {
},
template: `
<b-row no-gutters>
<b-row>
<b-col class="dropdown">
<h5 v-if="addExamModal.setup === 'group'">Add Group Exam</h5>
<h5 v-if="addExamModal.setup === 'individual'">Add Individual SkilledTradesBC Exam</h5>
<h5 v-if="addExamModal.setup === 'other'">Add Non-SkilledTradesBC Exam</h5>
<h5 v-if="addExamModal.setup === 'pesticide'">Add Environment Exam</h5>
</b-col>
<b-col>
<label>Exam Type</label><br>
<b-dropdown size="sm" split split-variant="primary" :text="displayText" class="m-md-2 dropdown-scrollable" variant="info">
<b-dropdown-item
v-for="type in dropItems"
:key="type.exam_type_id"
@click="preHandleInput(type)"
class="custom-dropdown"
<b-row>
<b-col class="dropdown">
<h5 v-if="addExamModal.setup === 'group'">Add Group Exam</h5>
<h5 v-if="addExamModal.setup === 'individual'">Add Individual SkilledTradesBC Exam</h5>
<h5 v-if="addExamModal.setup === 'other'">Add Non-SkilledTradesBC Exam</h5>
<h5 v-if="addExamModal.setup === 'pesticide'">Add Environment Exam</h5>
</b-col>
<b-col>
<label>Exam Type</label><br>
<multiselect
v-model="selectedExam"
:options="dropItems"
:track-by="'exam_type_id'"
:label="'exam_type_name'"
class="custom-multiselect"
:show-labels="false"
@input="preHandleInput"
:placeholder="displayText"
>
<p
:style="{backgroundColor: type.exam_color, padding: '5px 10px'}"
>{{ type.exam_type_name }}</p>
</b-dropdown-item>
</b-dropdown>
</b-col>
<template #singleLabel="{ selectedOptions }">
<span class="multiselect__single">
<span >{{ displayText }}</span>
</span>
</template>
<template #option="{ option }">
<p :style="{ backgroundColor: option.exam_color, padding: '10px' }">
{{ option.exam_type_name }}
</p>
</template>
</multiselect>
</b-col>
</b-row>
</b-row>
</b-row>
`
})
export class DropdownQuestion extends Vue {
Expand Down Expand Up @@ -253,6 +265,7 @@ export class DropdownQuestion extends Vue {
@State('capturedExam') private capturedExam!: any
@State('nonITAExam') private nonITAExam!: any
private objectItem:any = {};
private selectedExam:any = []
private displayText : string = 'Select An Exam Type'

@Mutation('setAddExamModalSetting') public setAddExamModalSetting: any
Expand Down Expand Up @@ -302,10 +315,6 @@ export class DropdownQuestion extends Vue {
}
}

get selectedExam () {
return this.capturedExam.exam_type_id ?? 0;
}

get inputText () {
if (this.exam_object && this.exam_object.exam_type_name) {
return this.exam_object.exam_type_name
Expand All @@ -330,6 +339,10 @@ export class DropdownQuestion extends Vue {
this.setAddExamModalSetting({ step1MenuOpen: false })
}

customLabel(option) {
return option.exam_type_name
}

preHandleInput (item) {
this.handleInput({
target: {
Expand Down

0 comments on commit 1826a31

Please sign in to comment.