Permisos en progreso
This commit is contained in:
@@ -1,11 +1,11 @@
|
||||
<script lang="ts">
|
||||
import { goto } from '$app/navigation';
|
||||
import { page } from '$app/stores';
|
||||
import IssueModal from '$lib/components/IssueModal.svelte';
|
||||
import ParticipantsModal from '$lib/components/ParticipantsModal.svelte';
|
||||
import { toast } from '$lib/stores/toast';
|
||||
import { api } from '$lib/utils/api';
|
||||
import { onMount } from 'svelte';
|
||||
import ParticipantsModal from '$lib/components/ParticipantsModal.svelte';
|
||||
import IssueModal from '$lib/components/IssueModal.svelte';
|
||||
|
||||
let showParticipants = false;
|
||||
let showIssueModal = false;
|
||||
@@ -47,25 +47,26 @@
|
||||
}
|
||||
|
||||
async function loadData() {
|
||||
isLoading = true;
|
||||
try {
|
||||
const [ticketData, commentsData, attachmentsData, usersData] = await Promise.all([
|
||||
api.get(`/tickets/${ticketId}`),
|
||||
api.get(`/tickets/${ticketId}/comments`),
|
||||
api.get(`/tickets/${ticketId}/attachments`),
|
||||
api.get('/users/')
|
||||
]);
|
||||
ticket = ticketData;
|
||||
comments = commentsData;
|
||||
attachments = attachmentsData;
|
||||
users = usersData;
|
||||
issues = issuesData;
|
||||
} catch (e) {
|
||||
toast.error('Error cargando ticket: ' + (e.message || 'Error desconocido'));
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
isLoading = true;
|
||||
try {
|
||||
const [ticketData, commentsData, attachmentsData, usersData, issuesData] = await Promise.all([
|
||||
api.get(`/tickets/${ticketId}`),
|
||||
api.get(`/tickets/${ticketId}/comments`),
|
||||
api.get(`/tickets/${ticketId}/attachments`),
|
||||
api.get('/users/'),
|
||||
api.get(`/tickets/${ticketId}/issues`)
|
||||
]);
|
||||
ticket = ticketData;
|
||||
comments = commentsData;
|
||||
attachments = attachmentsData;
|
||||
users = usersData;
|
||||
issues = issuesData;
|
||||
} catch (e) {
|
||||
toast.error('Error cargando ticket: ' + (e.message || 'Error desconocido'));
|
||||
} finally {
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleAddComment() {
|
||||
if (!newComment.trim()) return;
|
||||
@@ -294,7 +295,9 @@
|
||||
{formatDate(comment.created_at)}
|
||||
</span>
|
||||
{#if comment.is_internal}
|
||||
<span class="bg-gray-50 text-red-700 text-xs px-2 py-0.5 rounded border border-red-200">
|
||||
<span
|
||||
class="bg-gray-50 text-red-700 text-xs px-2 py-0.5 rounded border border-red-200"
|
||||
>
|
||||
Interno
|
||||
</span>
|
||||
{/if}
|
||||
@@ -381,67 +384,79 @@
|
||||
</div>
|
||||
|
||||
<!-- Participantes -->
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-5 border-b border-gray-200 flex justify-between items-center">
|
||||
<h3 class="text-lg font-semibold text-gray-900">
|
||||
Asuntos {#if issues.length > 0}<span class="text-gray-400 font-normal">({issues.length})</span>{/if}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => showIssueModal = true}
|
||||
class="text-sm text-blue-600 hover:text-blue-700 font-medium"
|
||||
>
|
||||
Crear asunto
|
||||
</button>
|
||||
</div>
|
||||
{#if issues.length > 0}
|
||||
<div class="divide-y divide-gray-100">
|
||||
{#each issues as issue}
|
||||
<div class="px-6 py-4">
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<p class="text-sm text-gray-700 flex-1">{issue.content}</p>
|
||||
<span class="text-xs font-medium px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 shrink-0">
|
||||
{issue.priority}
|
||||
</span>
|
||||
</div>
|
||||
{#if issue.tagged_users?.length > 0}
|
||||
<div class="mt-2 flex flex-wrap gap-1">
|
||||
{#each issue.tagged_users as u}
|
||||
<span class="text-xs bg-blue-50 text-blue-700 px-2 py-0.5 rounded-full">
|
||||
{u.full_name}
|
||||
</span>
|
||||
{/each}
|
||||
<div class="bg-white shadow rounded-lg">
|
||||
<div class="px-6 py-5 border-b border-gray-200 flex justify-between items-center">
|
||||
<h3 class="text-lg font-semibold text-gray-900">
|
||||
Asuntos {#if issues.length > 0}<span class="text-gray-400 font-normal"
|
||||
>({issues.length})</span
|
||||
>{/if}
|
||||
</h3>
|
||||
<button
|
||||
type="button"
|
||||
on:click={() => (showIssueModal = true)}
|
||||
class="text-sm text-blue-600 hover:text-blue-700 font-medium"
|
||||
>
|
||||
Crear asunto
|
||||
</button>
|
||||
</div>
|
||||
{#if issues.length > 0}
|
||||
<div class="divide-y divide-gray-100">
|
||||
{#each issues as issue}
|
||||
<div class="px-6 py-4">
|
||||
<div class="flex items-start justify-between gap-2">
|
||||
<p class="text-sm text-gray-700 flex-1">{issue.content}</p>
|
||||
<span
|
||||
class="text-xs font-medium px-2 py-0.5 rounded-full bg-gray-100 text-gray-600 shrink-0"
|
||||
>
|
||||
{issue.priority}
|
||||
</span>
|
||||
</div>
|
||||
{#if issue.tagged_users?.length > 0}
|
||||
<div class="mt-2 flex flex-wrap gap-1">
|
||||
{#each issue.tagged_users as u}
|
||||
<span class="text-xs bg-blue-50 text-blue-700 px-2 py-0.5 rounded-full">
|
||||
{u.full_name}
|
||||
</span>
|
||||
{/each}
|
||||
</div>
|
||||
{/if}
|
||||
<p class="text-xs text-gray-400 mt-1">{issue.created_by_name}</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<p class="px-6 py-4 text-sm text-gray-500">No hay asuntos creados.</p>
|
||||
{/if}
|
||||
</div>
|
||||
{/if}
|
||||
<p class="text-xs text-gray-400 mt-1">{issue.created_by_name}</p>
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{:else}
|
||||
<p class="px-6 py-4 text-sm text-gray-500">No hay asuntos creados.</p>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
<!-- SLA Information -->
|
||||
{#if ticket.sla_response_due || ticket.sla_resolution_due}
|
||||
<div class="pt-4 border-t border-gray-200">
|
||||
<h4 class="text-sm font-semibold text-gray-900 mb-3">SLA (Acuerdos de Nivel de Servicio)</h4>
|
||||
|
||||
<h4 class="text-sm font-semibold text-gray-900 mb-3">
|
||||
SLA (Acuerdos de Nivel de Servicio)
|
||||
</h4>
|
||||
|
||||
{#if ticket.sla_response_due}
|
||||
<div class="mb-3">
|
||||
<dt class="text-xs font-medium text-gray-500">Tiempo de Respuesta</dt>
|
||||
<dd class="text-sm text-gray-900 mt-1">
|
||||
{formatDate(ticket.sla_response_due)}
|
||||
{#if new Date(ticket.sla_response_due) < new Date() && !ticket.sla_response_met}
|
||||
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-red-700 border border-red-200">
|
||||
<span
|
||||
class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-red-700 border border-red-200"
|
||||
>
|
||||
Vencido
|
||||
</span>
|
||||
{:else if ticket.sla_response_met}
|
||||
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-green-700 border border-green-200">
|
||||
<span
|
||||
class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-green-700 border border-green-200"
|
||||
>
|
||||
Cumplido
|
||||
</span>
|
||||
{:else}
|
||||
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-blue-700 border border-blue-200">
|
||||
<span
|
||||
class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-blue-700 border border-blue-200"
|
||||
>
|
||||
En plazo
|
||||
</span>
|
||||
{/if}
|
||||
@@ -455,15 +470,21 @@
|
||||
<dd class="text-sm text-gray-900 mt-1">
|
||||
{formatDate(ticket.sla_resolution_due)}
|
||||
{#if new Date(ticket.sla_resolution_due) < new Date() && !ticket.sla_resolution_met}
|
||||
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-red-700 border border-red-200">
|
||||
<span
|
||||
class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-red-700 border border-red-200"
|
||||
>
|
||||
Vencido
|
||||
</span>
|
||||
{:else if ticket.sla_resolution_met}
|
||||
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-green-700 border border-green-200">
|
||||
<span
|
||||
class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-green-700 border border-green-200"
|
||||
>
|
||||
Cumplido
|
||||
</span>
|
||||
{:else}
|
||||
<span class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-blue-700 border border-blue-200">
|
||||
<span
|
||||
class="ml-2 inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-50 text-blue-700 border border-blue-200"
|
||||
>
|
||||
En plazo
|
||||
</span>
|
||||
{/if}
|
||||
@@ -478,18 +499,21 @@
|
||||
</div>
|
||||
{/if}
|
||||
{#if showParticipants && ticket}
|
||||
<ParticipantsModal
|
||||
ticketId={ticket.id}
|
||||
createdBy={ticket.created_by}
|
||||
on:close={() => showParticipants = false}
|
||||
/>
|
||||
{/if}
|
||||
{#if showIssueModal && ticket}
|
||||
<IssueModal
|
||||
ticketId={ticket.id}
|
||||
{users}
|
||||
on:close={() => showIssueModal = false}
|
||||
on:created={() => { showIssueModal = false; loadData(); }}
|
||||
/>
|
||||
{/if}
|
||||
<ParticipantsModal
|
||||
ticketId={ticket.id}
|
||||
createdBy={ticket.created_by}
|
||||
on:close={() => (showParticipants = false)}
|
||||
/>
|
||||
{/if}
|
||||
{#if showIssueModal && ticket}
|
||||
<IssueModal
|
||||
ticketId={ticket.id}
|
||||
{users}
|
||||
on:close={() => (showIssueModal = false)}
|
||||
on:created={() => {
|
||||
showIssueModal = false;
|
||||
loadData();
|
||||
}}
|
||||
/>
|
||||
{/if}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user