feat: add suggested team
This commit is contained in:
@@ -16,7 +16,7 @@ if (!reportId) {
|
||||
navigateTo('/operator')
|
||||
}
|
||||
|
||||
const { getReportDetail, getMessages, addMessage, flagMessage, flagReport } = useReports()
|
||||
const { getReportDetail, getMessages, addMessage, flagMessage, flagReport, getTeamSuggestions } = useReports()
|
||||
const {
|
||||
takeReport,
|
||||
getInterventionSummary,
|
||||
@@ -31,7 +31,9 @@ const { user } = useAuth()
|
||||
const { data: reportData, refresh: refreshReport } = await useAsyncData(`op-report-${reportId}`, () => getReportDetail(reportId))
|
||||
const { data: messagesData, refresh: refreshMessages } = await useAsyncData(`op-messages-${reportId}`, () => getMessages(reportId))
|
||||
const { data: summaryData, refresh: refreshSummary } = await useAsyncData(`op-summary-${reportId}`, () => getInterventionSummary(reportId))
|
||||
const { data: teamsData } = await useAsyncData('operator-teams', () => getTeams())
|
||||
|
||||
const { data: allTeamsData } = await useAsyncData('operator-teams', () => getTeams())
|
||||
const { data: suggestedTeamsData } = await useAsyncData(`op-team-suggestions-${reportId}`, () => getTeamSuggestions(reportId))
|
||||
|
||||
const report = computed<Report | undefined>(() => (reportData.value as any)?.report)
|
||||
const media = computed(() => (reportData.value as any)?.media || [])
|
||||
@@ -39,7 +41,14 @@ const statusHistory = computed(() => (reportData.value as any)?.history || [])
|
||||
const messages = computed<Message[]>(() => (messagesData.value as any)?.messages || [])
|
||||
const summary = computed(() => (summaryData.value as any)?.summary)
|
||||
const summaryMedia = computed(() => (summaryData.value as any)?.media || [])
|
||||
const teams = computed(() => teamsData.value?.teams || [])
|
||||
|
||||
const allTeams = computed(() => (allTeamsData.value as any)?.teams || [])
|
||||
const suggestedTeams = computed(() => (suggestedTeamsData.value as any)?.suggestions || [])
|
||||
|
||||
const otherTeams = computed(() => {
|
||||
const suggestedIds = new Set(suggestedTeams.value.map((t: any) => Number(t.id)))
|
||||
return allTeams.value.filter((t: any) => !suggestedIds.has(Number(t.id)))
|
||||
})
|
||||
|
||||
const currentUserId = computed(() => user.value?.id ?? null)
|
||||
const isTakenByCurrentOperator = computed(() => report.value?.assigned_operator_id === currentUserId.value)
|
||||
@@ -47,7 +56,7 @@ const isOpenAndUnassigned = computed(() => report.value?.status === 'OPEN' && !r
|
||||
const isReadOnlyPreview = computed(() => !isTakenByCurrentOperator.value)
|
||||
const canTakeReport = computed(() => isOpenAndUnassigned.value && !isTakenByCurrentOperator.value)
|
||||
const isFinalStatus = computed(() => ['REJECTED', 'RESOLVED', 'CLOSED'].includes(report.value?.status || ''))
|
||||
const canAssignTeam = computed(() => !isReadOnlyPreview.value && !isFinalStatus.value && teams.value.length > 0)
|
||||
const canAssignTeam = computed(() => !isReadOnlyPreview.value && !isFinalStatus.value && allTeams.value.length > 0)
|
||||
const canSendMessage = computed(() => !isReadOnlyPreview.value && !isFinalStatus.value)
|
||||
const canChangeStatus = computed(() => !isReadOnlyPreview.value && !isFinalStatus.value && selectableStatuses.value.length > 0)
|
||||
|
||||
@@ -131,6 +140,26 @@ const reportFlagForm = reactive<FlagRequest>({
|
||||
details: ''
|
||||
})
|
||||
|
||||
// === GESTIONE SCROLL SCHERMO CON MODALI ===
|
||||
watch(
|
||||
() => isAssignModalOpen.value || isFlagReportModalOpen.value || isRevokeInterventionModalOpen.value || isFlagMessageModalOpen.value,
|
||||
(isOpen) => {
|
||||
if (import.meta.client) {
|
||||
if (isOpen) {
|
||||
document.body.style.overflow = 'hidden'
|
||||
} else {
|
||||
document.body.style.overflow = ''
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
|
||||
onUnmounted(() => {
|
||||
if (import.meta.client) {
|
||||
document.body.style.overflow = ''
|
||||
}
|
||||
})
|
||||
|
||||
watch(() => report.value?.status, (val) => {
|
||||
if (val) {
|
||||
const allowed = statusTransitions[val] || []
|
||||
@@ -550,8 +579,8 @@ const formattedInterventionLinkExpiry = computed(() =>
|
||||
<strong>{{ summary.assigned_operator_id ? `#${summary.assigned_operator_id}` : 'Nessuno' }}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<span>Team disponibili</span>
|
||||
<strong>{{ teams.length }}</strong>
|
||||
<span>Team suggeriti</span>
|
||||
<strong :class="{'text-primary': suggestedTeams.length > 0}">{{ suggestedTeams.length }}</strong>
|
||||
</li>
|
||||
<li>
|
||||
<span>Allegati</span>
|
||||
@@ -688,48 +717,69 @@ const formattedInterventionLinkExpiry = computed(() =>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isAssignModalOpen" class="modal-backdrop fade show d-block" style="background: rgba(0,0,0,0.5); z-index: 1040;"></div>
|
||||
<div v-if="isAssignModalOpen" class="modal fade show d-block" tabindex="-1" style="z-index: 1050;">
|
||||
<!-- BACKGROUND MODALE COMUNE -->
|
||||
<div v-if="isAssignModalOpen || isFlagReportModalOpen" class="modal-backdrop fade show d-block"
|
||||
style="background: rgba(0,0,0,0.5); z-index: 1040;"></div>
|
||||
|
||||
<!-- MODALE: GESTIONE INTERVENTO -->
|
||||
<div v-if="isAssignModalOpen" class="modal fade show d-block" style="z-index: 1050; overflow-y: auto;"
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Gestione Intervento</h5>
|
||||
<button type="button" class="btn-close" @click="isAssignModalOpen = false"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<form @submit.prevent="handleAssignTeam">
|
||||
<div class="mb-3">
|
||||
<!-- FORM AGGIORNATO CON MODAL-BODY E MODAL-FOOTER -->
|
||||
<form @submit.prevent="handleAssignTeam">
|
||||
<div class="modal-body">
|
||||
<div class="mb-0">
|
||||
<label class="form-label">Team incaricato</label>
|
||||
<select v-model.number="selectedTeamId" class="form-select" required>
|
||||
<option :value="null">Seleziona team</option>
|
||||
<option v-for="team in teams" :key="team.id" :value="team.id">
|
||||
{{ team.name }}<template v-if="team.category_name"> · {{ team.category_name }}</template>
|
||||
<template v-if="team.area_name"> · {{ team.area_name }}</template>
|
||||
</option>
|
||||
|
||||
<optgroup v-if="suggestedTeams.length > 0" label="Team Suggeriti">
|
||||
<option v-for="team in suggestedTeams" :key="'sug-' + team.id" :value="Number(team.id)">
|
||||
{{ team.name }}
|
||||
<template v-if="team.is_recommended"> ★</template>
|
||||
<template v-if="team.category_name"> · {{ team.category_name }}</template>
|
||||
<template v-if="team.area_name"> · {{ team.area_name }}</template>
|
||||
</option>
|
||||
</optgroup>
|
||||
|
||||
<optgroup :label="suggestedTeams.length > 0 ? 'Altri Team' : 'Tutti i Team'">
|
||||
<option v-for="team in otherTeams" :key="'oth-' + team.id" :value="Number(team.id)">
|
||||
{{ team.name }}
|
||||
<template v-if="team.category_name"> · {{ team.category_name }}</template>
|
||||
<template v-if="team.area_name"> · {{ team.area_name }}</template>
|
||||
</option>
|
||||
</optgroup>
|
||||
</select>
|
||||
<small v-if="teams.length === 0" class="form-text text-danger">
|
||||
<small v-if="allTeams.length === 0" class="form-text text-danger mt-1">
|
||||
Nessun team attivo disponibile.
|
||||
</small>
|
||||
</div>
|
||||
<div class="d-flex justify-content-end gap-2 mt-4">
|
||||
<button type="button" class="btn btn-outline-secondary" @click="isAssignModalOpen = false">Annulla</button>
|
||||
<button type="submit" class="btn btn-primary" :disabled="isAssigning || !selectedTeamId">
|
||||
<span v-if="isAssigning" class="spinner-border spinner-border-sm me-2"></span>
|
||||
Salva Assegnazione
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-outline-secondary" type="button" @click="isAssignModalOpen = false">Annulla
|
||||
</button>
|
||||
<button :disabled="isAssigning || !selectedTeamId" class="btn btn-primary" type="submit">
|
||||
<span v-if="isAssigning" class="spinner-border spinner-border-sm me-2"></span>
|
||||
Salva Assegnazione
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="isFlagReportModalOpen" class="modal-backdrop fade show d-block" style="background: rgba(0,0,0,0.5); z-index: 1040;"></div>
|
||||
<div v-if="isFlagReportModalOpen" class="modal fade show d-block" tabindex="-1" style="z-index: 1050;">
|
||||
<!-- MODALE: SEGNALA ALLA MODERAZIONE -->
|
||||
<div v-if="isFlagReportModalOpen" class="modal fade show d-block" style="z-index: 1050; overflow-y: auto;"
|
||||
tabindex="-1">
|
||||
<div class="modal-dialog modal-dialog-centered">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Segnala segnalazione alla moderazione</h5>
|
||||
<h5 class="modal-title">Segnala alla moderazione</h5>
|
||||
<button type="button" class="btn-close" :disabled="isFlaggingReport" @click="isFlagReportModalOpen = false; resetReportFlagForm()"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
@@ -738,7 +788,7 @@ const formattedInterventionLinkExpiry = computed(() =>
|
||||
<label class="form-label">Motivo</label>
|
||||
<input v-model="reportFlagForm.reason" type="text" class="form-control" maxlength="200" />
|
||||
</div>
|
||||
<div>
|
||||
<div class="mb-0">
|
||||
<label class="form-label">Dettagli</label>
|
||||
<textarea v-model="reportFlagForm.details" class="form-control" rows="4" placeholder="Dettagli aggiuntivi opzionali"></textarea>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user