Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/cant add assignee #4017

Merged
merged 5 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/dispatch/static/dispatch/src/case/DetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
hint="The organization member to which the case is assigned."
clearable
:project="project"
name="Assignee"
:rules="[only_one]"
/>
</v-col>
<v-col cols="12">
Expand All @@ -55,6 +57,8 @@
hint="The organization member who reported the case."
clearable
:project="project"
name="Reporter"
:rules="[only_one]"
/>
</v-col>
<v-col cols="6">
Expand Down Expand Up @@ -160,6 +164,12 @@ export default {
statuses: ["New", "Triage", "Escalated", "Closed"],
visibilities: ["Open", "Restricted"],
resolutionReasons: ["False Positive", "User Acknowledged", "Mitigated", "Escalated"],
only_one: (value) => {
if (value && value.length > 1) {
return "Only one is allowed"
}
return true
},
}
},

Expand Down
80 changes: 54 additions & 26 deletions src/dispatch/static/dispatch/src/case/HandoffDialog.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
<template>
<v-dialog v-model="showHandoffDialog" persistent max-width="800px">
<v-card>
<v-card-title>
<span class="text-h5">Handoff Cases</span>
</v-card-title>
<v-card-text> Select the new assignee for the selected cases. </v-card-text>
<v-card-actions>
<v-container>
<v-row>
<v-col cols="12">
<participant-select v-model="assignee" label="Case Assignee" :project="project" />
</v-col>
<v-btn color="blue en-1" variant="text" @click="closeHandoffDialog()"> Cancel </v-btn>
<v-btn
color="red en-1"
variant="text"
:loading="loading"
@click="saveBulk({ assignee: assignee })"
>
Handoff
</v-btn>
</v-row>
</v-container>
</v-card-actions>
</v-card>
<v-form @submit.prevent v-slot="{ isValid }">
<v-card>
<v-card-title>
<span class="text-h5">Handoff Cases</span>
</v-card-title>
<v-card-text> Select the new assignee for the selected cases. </v-card-text>
<v-card-actions>
<v-container>
<v-row>
<v-col cols="12">
<participant-select
v-model="assignee"
label="Case Assignee"
:project="project"
:rules="[required_and_only_one]"
/>
</v-col>
<v-btn color="blue en-1" variant="text" @click="closeHandoffDialog()"> Cancel </v-btn>
<v-btn
color="red en-1"
variant="text"
:loading="loading"
:disabled="!isValid.value"
@click="saveBulk({ assignee: assignee[0] })"
>
Handoff
</v-btn>
</v-row>
</v-container>
</v-card-actions>
</v-card>
</v-form>
</v-dialog>
</template>

Expand All @@ -38,7 +46,17 @@ export default {

data() {
return {
assignee: { individual: { name: "Assignee Name" } },
assignee: null,
project: null,
required_and_only_one: (value) => {
if (!value || value.length == 0) {
return "This field is required"
}
if (value && value.length > 1) {
return "Only one is allowed"
}
return true
},
}
},

Expand All @@ -50,12 +68,22 @@ export default {
...mapFields("case_management", [
"dialogs.showHandoffDialog",
"selected.loading",
"selected.project",
"table.rows.selected",
]),
},

methods: {
...mapActions("case_management", ["closeHandoffDialog", "saveBulk", "resetSelected"]),
},

watch: {
selected(val) {
this.project = val.map((i) => i.project)
},
},

created: function () {
this.project = this.selected.map((i) => i.project)
},
}
</script>
43 changes: 25 additions & 18 deletions src/dispatch/static/dispatch/src/case/Participant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,24 @@
<div>
<v-menu v-model="menu" origin="overlap">
<template #activator="{ props }">
<v-chip pill size="small" v-bind="props" v-if="participant.individual">
<v-chip pill size="small" v-bind="props" v-if="local_participant.individual">
<v-avatar color="teal" start>
<span class="text-white">{{ initials(participant.individual.name) }}</span>
<span class="text-white">{{ initials(local_participant.individual.name) }}</span>
</v-avatar>
{{ participant.individual.name }}
{{ local_participant.individual.name }}
</v-chip>
</template>
<v-card width="300">
<v-list dark>
<v-list-item v-if="participant.individual">
<v-list-item v-if="local_participant.individual">
<template #prepend>
<v-avatar color="teal">
<span class="text-white">{{ initials(participant.individual.name) }}</span>
<span class="text-white">{{ initials(local_participant.individual.name) }}</span>
</v-avatar>
</template>

<v-list-item-title>{{ participant.individual.name }}</v-list-item-title>
<v-list-item-subtitle>{{ participant.individual.email }}</v-list-item-subtitle>
<v-list-item-title>{{ local_participant.individual.name }}</v-list-item-title>
<v-list-item-subtitle>{{ local_participant.individual.email }}</v-list-item-subtitle>

<template #append>
<v-btn icon variant="text" @click="menu = false">
Expand All @@ -34,39 +34,39 @@
<v-icon>mdi-briefcase</v-icon>
</template>

<v-list-item-subtitle>{{ participant.individual.email }}</v-list-item-subtitle>
<v-list-item-subtitle>{{ local_participant.individual.email }}</v-list-item-subtitle>
</v-list-item>
<v-list-item v-if="participant.individual.company">
<v-list-item v-if="local_participant.individual.company">
<template #prepend>
<v-icon>mdi-domain</v-icon>
</template>

<v-list-item-subtitle>{{ participant.individual.company }}</v-list-item-subtitle>
<v-list-item-subtitle>{{ local_participant.individual.company }}</v-list-item-subtitle>
</v-list-item>
<v-list-item v-if="participant.location">
<v-list-item v-if="local_participant.location">
<template #prepend>
<v-icon>mdi-earth</v-icon>
</template>

<v-list-item-subtitle>{{ participant.location }}</v-list-item-subtitle>
<v-list-item-subtitle>{{ local_participant.location }}</v-list-item-subtitle>
</v-list-item>
<v-list-item v-if="participant.department">
<v-list-item v-if="local_participant.department">
<template #prepend>
<v-icon>mdi-account-group-outline</v-icon>
</template>

<v-list-item-subtitle>{{ participant.department }}</v-list-item-subtitle>
<v-list-item-subtitle>{{ local_participant.department }}</v-list-item-subtitle>
</v-list-item>
<v-list-item v-if="participant.team">
<v-list-item v-if="local_participant.team">
<template #prepend>
<v-icon>mdi-account-multiple-outline</v-icon>
</template>

<v-list-item-subtitle>{{ participant.team }}</v-list-item-subtitle>
<v-list-item-subtitle>{{ local_participant.team }}</v-list-item-subtitle>
</v-list-item>
<v-list-item
v-if="participant.individual.weblink"
:href="participant.individual.weblink"
v-if="local_participant.individual.weblink"
:href="local_participant.individual.weblink"
target="_blank"
>
<template #prepend>
Expand All @@ -89,6 +89,7 @@ export default {

data: () => ({
menu: false,
local_participant: { individual: {} },
}),

setup() {
Expand All @@ -103,5 +104,11 @@ export default {
},
},
},

created: function () {
if (this.participant?.individual) {
this.local_participant = this.participant
}
},
}
</script>
6 changes: 6 additions & 0 deletions src/dispatch/static/dispatch/src/case/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,12 @@ const actions = {
})
},
save({ commit, dispatch }) {
if (Array.isArray(state.selected.reporter)) {
state.selected.reporter = state.selected.reporter[0]
}
if (Array.isArray(state.selected.assignee)) {
state.selected.assignee = state.selected.assignee[0]
}
commit("SET_SELECTED_LOADING", true)
if (!state.selected.id) {
return CaseApi.create(state.selected)
Expand Down
42 changes: 36 additions & 6 deletions src/dispatch/static/dispatch/src/components/ParticipantSelect.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
:label="label"
:loading="loading"
v-model:search="search"
clearable
closable-chips
hide-selected
item-title="individual.name"
item-value="individual.id"
return-object
chips
:hide-no-data="false"
v-model="participant"
chips
multiple
@update:model-value="handleClear"
:menu-props="{ closeOnContentClick: true }"
>
<template #no-data>
<v-list-item v-if="!loading">
Expand All @@ -32,9 +33,9 @@
<template #chip="data">
<v-chip v-bind="data.props" pill>
<template #prepend>
<v-avatar color="teal" start> {{ initials(data.item.title) }} </v-avatar>
<v-avatar color="teal" start> {{ initials(data.item.raw.individual.name) }} </v-avatar>
</template>
{{ data.item.title }}
{{ data.item.raw.individual.name }}
</v-chip>
</template>
</v-autocomplete>
Expand All @@ -44,7 +45,7 @@
import { ref, watch, onMounted } from "vue"
import { initials } from "@/filters"
import { debounce } from "lodash"

import SearchUtils from "@/search/utils"
import IndividualApi from "@/individual/api"

export default {
Expand All @@ -58,6 +59,10 @@
type: Object,
default: () => ({}),
},
project: {
type: [Object],
default: null,
},
},
setup(props) {
let loading = ref(false)
Expand All @@ -79,6 +84,25 @@
itemsPerPage: numItems.value * page,
}

if (props.project) {
if (Array.isArray(props.project) && props.project.length > 0) {
filterOptions = {
filters: {
project: props.project,
},
...filterOptions,
}
} else {
filterOptions = {
filters: {
project: [props.project],
},
...filterOptions,
}
}
}
filterOptions = SearchUtils.createParametersFromTableOptions({ ...filterOptions })

await IndividualApi.getAll(filterOptions).then((response) => {
items.value = response.data.items.map(function (x) {
return { individual: x }
Expand All @@ -101,6 +125,7 @@
}

const handleClear = (newValue) => {
search.value = null
if (!newValue) {
items.value = []
search.value = null
Expand Down Expand Up @@ -129,5 +154,10 @@
total,
}
},
watch: {
project(val) {

Check failure on line 158 in src/dispatch/static/dispatch/src/components/ParticipantSelect.vue

View workflow job for this annotation

GitHub Actions / build

'val' is defined but never used
this.getIndividualData()
},
},
}
</script>
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ export default {
methods: {
applyFilters() {
if (this.local_participant) {
if (Array.isArray(this.local_participant)) {
this.local_participant = this.local_participant[0]
}
if (this.local_participant_is_commander) {
this.filters.commander = this.local_participant
this.filters.participant = null
Expand Down
13 changes: 11 additions & 2 deletions src/dispatch/static/dispatch/src/incident/DetailsTab.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
required
:project="project"
name="Reporter"
:rules="[rules.required]"
:rules="[required_and_only_one]"
/>
</v-col>
<v-col cols="6">
Expand All @@ -52,7 +52,7 @@
required
:project="project"
name="Incident Commander"
:rules="[rules.required]"
:rules="[required_and_only_one]"
/>
</v-col>
<v-col cols="6">
Expand Down Expand Up @@ -153,6 +153,15 @@ export default {
return {
statuses: ["Active", "Stable", "Closed"],
visibilities: ["Open", "Restricted"],
required_and_only_one: (value) => {
if (!value || value.length == 0) {
return "This field is required"
}
if (value && value.length > 1) {
return "Only one is allowed"
}
return true
},
}
},

Expand Down
Loading
Loading