-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into bugfix/format-timeline-fixes
- Loading branch information
Showing
14 changed files
with
173 additions
and
279 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
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
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
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
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
127 changes: 0 additions & 127 deletions
127
src/dispatch/static/dispatch/src/case/ParticipantSelect.vue
This file was deleted.
Oops, something went wrong.
139 changes: 139 additions & 0 deletions
139
src/dispatch/static/dispatch/src/components/ParticipantSelect.vue
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,139 @@ | ||
<template> | ||
<v-autocomplete | ||
:items="items" | ||
:label="labelProp" | ||
:loading="loading" | ||
v-model:search="search" | ||
clearable | ||
hide-selected | ||
item-title="individual.name" | ||
item-value="individual.id" | ||
return-object | ||
chips | ||
:hide-no-data="false" | ||
v-model="participant" | ||
@update:modelValue="handleClear" | ||
Check warning on line 15 in src/dispatch/static/dispatch/src/components/ParticipantSelect.vue GitHub Actions / build
|
||
> | ||
<template #no-data> | ||
<v-list-item v-if="!loading"> | ||
<v-list-item-title> | ||
No individuals matching <strong>"{{ search }}".</strong> | ||
</v-list-item-title> | ||
</v-list-item> | ||
</template> | ||
<template #item="{ props, item }"> | ||
<v-list-item v-bind="props" :subtitle="item.raw.individual.email" /> | ||
</template> | ||
<template #append-item v-if="items.length < total.value"> | ||
<v-list-item @click="loadMore()"> | ||
<v-list-item-subtitle> Load More </v-list-item-subtitle> | ||
</v-list-item> | ||
</template> | ||
<template #chip="data"> | ||
<v-chip v-bind="data.props" pill> | ||
<template #prepend> | ||
<v-avatar color="teal" start> {{ initials(data.item.title) }} </v-avatar> | ||
</template> | ||
{{ data.item.title }} | ||
</v-chip> | ||
</template> | ||
</v-autocomplete> | ||
</template> | ||
|
||
<script> | ||
import { ref, watch, toRefs, onMounted } from "vue" | ||
import { initials } from "@/filters" | ||
import { debounce } from "lodash" | ||
import IndividualApi from "@/individual/api" | ||
export default { | ||
name: "ParticipantSelect", | ||
props: { | ||
labelProp: { | ||
// Define the labelProp | ||
type: String, | ||
default: "Participant", | ||
}, | ||
initialValue: { | ||
type: Object, | ||
default: () => ({}), | ||
}, | ||
}, | ||
setup(props) { | ||
const { labelProp } = toRefs(props) // toRefs make props reactive | ||
let loading = ref(false) | ||
let items = ref([]) | ||
console.log(items) | ||
let numItems = ref(10) | ||
let participant = ref({ ...props.initialValue }) | ||
let currentPage = ref(1) | ||
let total = ref(0) | ||
const search = ref(props.initialValue.name) | ||
let debouncedGetIndividualData = null | ||
const getIndividualData = async (searchVal, page = currentPage.value) => { | ||
loading.value = true | ||
let filterOptions = { | ||
q: searchVal, | ||
sortBy: ["name"], | ||
descending: [false], | ||
itemsPerPage: numItems.value * page, | ||
} | ||
await IndividualApi.getAll(filterOptions).then((response) => { | ||
console.log(response.data.items) | ||
items.value = response.data.items.map(function (x) { | ||
return { individual: x } | ||
}) | ||
total.value = response.data.total | ||
}) | ||
loading.value = false | ||
} | ||
onMounted(() => { | ||
debouncedGetIndividualData = debounce(getIndividualData, 300) | ||
debouncedGetIndividualData(search.value) | ||
}) | ||
const loadMore = async () => { | ||
currentPage.value++ | ||
numItems.value += 10 | ||
await debouncedGetIndividualData(search.value) | ||
} | ||
const handleClear = (newValue) => { | ||
if (!newValue) { | ||
items.value = [] | ||
search.value = null | ||
participant.value = null | ||
numItems.value = 10 | ||
currentPage.value = 1 | ||
} | ||
} | ||
watch(search, async (newVal, oldVal) => { | ||
if (oldVal !== newVal) { | ||
numItems.value = 10 | ||
await debouncedGetIndividualData(newVal) | ||
} | ||
}) | ||
return { | ||
getIndividualData, | ||
handleClear, | ||
initials, | ||
items, | ||
labelProp, | ||
loading, | ||
loadMore, | ||
participant, | ||
search, | ||
total, | ||
} | ||
}, | ||
} | ||
</script> |
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
Oops, something went wrong.