ajout activity
This commit is contained in:
parent
2a1de6f384
commit
ea2b687533
@ -53,6 +53,7 @@
|
||||
@change-tab="activeTab = $event"
|
||||
@updating-client="handleUpdateClient"
|
||||
@create-contact="handleAddContact"
|
||||
@updating-contact="handleModifiedContact"
|
||||
@create-location="handleAddLocation"
|
||||
@modify-location="handleModifyLocation"
|
||||
@remove-location="handleRemoveLocation"
|
||||
@ -114,6 +115,7 @@ const emit = defineEmits([
|
||||
"updateTheClient",
|
||||
"handleFileInput",
|
||||
"add-new-contact",
|
||||
"updating-contact",
|
||||
"add-new-location",
|
||||
"modify-location",
|
||||
"remove-location",
|
||||
@ -144,6 +146,10 @@ const handleAddContact = (data) => {
|
||||
emit("add-new-contact", data);
|
||||
};
|
||||
|
||||
const handleModifiedContact = (modifiedContact) => {
|
||||
emit("updating-contact", modifiedContact);
|
||||
};
|
||||
|
||||
const handleAddLocation = (data) => {
|
||||
emit("add-new-location", data);
|
||||
};
|
||||
|
||||
@ -16,6 +16,10 @@
|
||||
<ClientInfoTab :client="client" @client-updated="updateClient" />
|
||||
</div>
|
||||
|
||||
<div v-show="activeTab === 'activity'">
|
||||
<ClientActivityTab />
|
||||
</div>
|
||||
|
||||
<!-- Contacts Tab -->
|
||||
<div v-show="activeTab === 'contacts'">
|
||||
<ClientContactsTab
|
||||
@ -23,6 +27,7 @@
|
||||
:client-id="client.id"
|
||||
:is-loading="contactIsLoading"
|
||||
@contact-created="handleCreateContact"
|
||||
@contact-modified="handleModifiedContact"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@ -58,6 +63,7 @@ import ClientAddressTab from "@/components/molecules/client/ClientAddressTab.vue
|
||||
import ClientLocationsTab from "@/components/molecules/client/ClientLocationsTab.vue";
|
||||
import ClientNotesTab from "@/components/molecules/client/ClientNotesTab.vue";
|
||||
import { defineProps, defineEmits } from "vue";
|
||||
import ClientActivityTab from "@/components/molecules/client/ClientActivityTab.vue";
|
||||
|
||||
defineProps({
|
||||
activeTab: {
|
||||
@ -101,6 +107,7 @@ const emit = defineEmits([
|
||||
"create-location",
|
||||
"modify-location",
|
||||
"remove-location",
|
||||
"updating-contact",
|
||||
]);
|
||||
|
||||
const updateClient = (updatedClient) => {
|
||||
@ -111,6 +118,10 @@ const handleCreateContact = (newContact) => {
|
||||
emit("create-contact", newContact);
|
||||
};
|
||||
|
||||
const handleModifiedContact = (modifiedContact) => {
|
||||
emit("updating-contact", modifiedContact);
|
||||
};
|
||||
|
||||
const handleCreateLocation = (newLocation) => {
|
||||
emit("create-location", newLocation);
|
||||
};
|
||||
|
||||
@ -0,0 +1,451 @@
|
||||
<template>
|
||||
<div class="card activity-list-card">
|
||||
<div class="card-header pb-0">
|
||||
<div class="d-flex align-items-center">
|
||||
<h6 class="mb-0">Activités du client</h6>
|
||||
<div class="ms-auto">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
:class="{ active: activeFilter === 'all' }"
|
||||
@click="activeFilter = 'all'"
|
||||
>
|
||||
Toutes
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
:class="{ active: activeFilter === 'calls' }"
|
||||
@click="activeFilter = 'calls'"
|
||||
>
|
||||
Appels
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
:class="{ active: activeFilter === 'emails' }"
|
||||
@click="activeFilter = 'emails'"
|
||||
>
|
||||
Emails
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
:class="{ active: activeFilter === 'invoices' }"
|
||||
@click="activeFilter = 'invoices'"
|
||||
>
|
||||
Factures
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-outline-primary"
|
||||
:class="{ active: activeFilter === 'files' }"
|
||||
@click="activeFilter = 'files'"
|
||||
>
|
||||
Fichiers
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body activity-list-body p-0">
|
||||
<!-- Activity Timeline -->
|
||||
<div class="timeline-container">
|
||||
<!-- Call Activity -->
|
||||
<div class="timeline-item" data-type="call">
|
||||
<div class="timeline-badge bg-info">
|
||||
<i class="fas fa-phone"></i>
|
||||
</div>
|
||||
<div class="timeline-content">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h6 class="mb-1">Appel téléphonique</h6>
|
||||
<p class="text-sm text-muted mb-1">
|
||||
<i class="fas fa-clock me-1"></i>
|
||||
Il y a 2 heures • Durée: 15min
|
||||
</p>
|
||||
<p class="text-sm mb-0">
|
||||
Discussion concernant le nouveau projet. Le client est
|
||||
satisfait de la proposition.
|
||||
</p>
|
||||
</div>
|
||||
<div class="dropdown">
|
||||
<button
|
||||
class="btn btn-link text-secondary p-0"
|
||||
type="button"
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#"
|
||||
><i class="fas fa-edit me-2"></i>Modifier</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item text-danger" href="#"
|
||||
><i class="fas fa-trash me-2"></i>Supprimer</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Email Activity -->
|
||||
<div class="timeline-item" data-type="email">
|
||||
<div class="timeline-badge bg-success">
|
||||
<i class="fas fa-envelope"></i>
|
||||
</div>
|
||||
<div class="timeline-content">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h6 class="mb-1">Email envoyé</h6>
|
||||
<p class="text-sm text-muted mb-1">
|
||||
<i class="fas fa-clock me-1"></i>
|
||||
Il y a 4 heures • Sujet: Devis projet X
|
||||
</p>
|
||||
<p class="text-sm mb-0">
|
||||
Envoi du devis signé et de la documentation technique.
|
||||
</p>
|
||||
<div class="mt-2">
|
||||
<span class="badge bg-light text-dark me-2">
|
||||
<i class="fas fa-paperclip me-1"></i>devis.pdf
|
||||
</span>
|
||||
<span class="badge bg-light text-dark">
|
||||
<i class="fas fa-paperclip me-1"></i>specifications.docx
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown">
|
||||
<button
|
||||
class="btn btn-link text-secondary p-0"
|
||||
type="button"
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#"
|
||||
><i class="fas fa-reply me-2"></i>Répondre</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" href="#"
|
||||
><i class="fas fa-edit me-2"></i>Modifier</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Invoice Activity -->
|
||||
<div class="timeline-item" data-type="invoice">
|
||||
<div class="timeline-badge bg-warning">
|
||||
<i class="fas fa-file-invoice-dollar"></i>
|
||||
</div>
|
||||
<div class="timeline-content">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h6 class="mb-1">Nouvelle facture créée</h6>
|
||||
<p class="text-sm text-muted mb-1">
|
||||
<i class="fas fa-clock me-1"></i>
|
||||
Il y a 1 jour • Facture #FACT-2024-001
|
||||
</p>
|
||||
<p class="text-sm mb-0">
|
||||
Montant: <strong>1 250,00 €</strong> • Échéance: 30/01/2024
|
||||
</p>
|
||||
<div class="mt-2">
|
||||
<span class="badge bg-success me-2">Payée</span>
|
||||
<span class="badge bg-light text-dark">
|
||||
<i class="fas fa-download me-1"></i>Télécharger
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown">
|
||||
<button
|
||||
class="btn btn-link text-secondary p-0"
|
||||
type="button"
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#"
|
||||
><i class="fas fa-edit me-2"></i>Modifier</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" href="#"
|
||||
><i class="fas fa-envelope me-2"></i>Envoyer</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item text-danger" href="#"
|
||||
><i class="fas fa-trash me-2"></i>Supprimer</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- File Upload Activity -->
|
||||
<div class="timeline-item" data-type="file">
|
||||
<div class="timeline-badge bg-primary">
|
||||
<i class="fas fa-file-upload"></i>
|
||||
</div>
|
||||
<div class="timeline-content">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h6 class="mb-1">Fichier ajouté</h6>
|
||||
<p class="text-sm text-muted mb-1">
|
||||
<i class="fas fa-clock me-1"></i>
|
||||
Il y a 2 jours • Contrat signé
|
||||
</p>
|
||||
<p class="text-sm mb-0">
|
||||
Le client a uploadé le contrat signé pour le projet en cours.
|
||||
</p>
|
||||
<div class="mt-2">
|
||||
<span class="badge bg-light text-dark me-2">
|
||||
<i class="fas fa-file-pdf me-1 text-danger"></i
|
||||
>contrat_signé.pdf
|
||||
</span>
|
||||
<span class="badge bg-secondary">2.4 MB</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown">
|
||||
<button
|
||||
class="btn btn-link text-secondary p-0"
|
||||
type="button"
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#"
|
||||
><i class="fas fa-download me-2"></i>Télécharger</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item" href="#"
|
||||
><i class="fas fa-share me-2"></i>Partager</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item text-danger" href="#"
|
||||
><i class="fas fa-trash me-2"></i>Supprimer</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Meeting Activity -->
|
||||
<div class="timeline-item" data-type="meeting">
|
||||
<div class="timeline-badge bg-purple">
|
||||
<i class="fas fa-video"></i>
|
||||
</div>
|
||||
<div class="timeline-content">
|
||||
<div class="d-flex justify-content-between align-items-start">
|
||||
<div>
|
||||
<h6 class="mb-1">Réunion planifiée</h6>
|
||||
<p class="text-sm text-muted mb-1">
|
||||
<i class="fas fa-clock me-1"></i>
|
||||
Il y a 3 jours • 15 Janvier 2024, 14:00
|
||||
</p>
|
||||
<p class="text-sm mb-0">
|
||||
Révision du projet avec l'équipe technique.
|
||||
</p>
|
||||
<div class="mt-2">
|
||||
<span class="badge bg-info me-2">Teams</span>
|
||||
<span class="badge bg-light text-dark">
|
||||
<i class="fas fa-calendar me-1"></i>Ajouter au calendrier
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="dropdown">
|
||||
<button
|
||||
class="btn btn-link text-secondary p-0"
|
||||
type="button"
|
||||
data-bs-toggle="dropdown"
|
||||
>
|
||||
<i class="fas fa-ellipsis-v"></i>
|
||||
</button>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a class="dropdown-item" href="#"
|
||||
><i class="fas fa-edit me-2"></i>Modifier</a
|
||||
>
|
||||
</li>
|
||||
<li>
|
||||
<a class="dropdown-item text-danger" href="#"
|
||||
><i class="fas fa-trash me-2"></i>Annuler</a
|
||||
>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Empty State -->
|
||||
<div v-if="false" class="text-center py-5">
|
||||
<i class="fas fa-stream fa-3x text-secondary opacity-5 mb-3"></i>
|
||||
<p class="text-sm text-secondary">Aucune activité pour ce client</p>
|
||||
<button class="btn btn-primary btn-sm mt-2">
|
||||
<i class="fas fa-plus me-1"></i>Ajouter une activité
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Quick Actions Footer -->
|
||||
<div class="card-footer">
|
||||
<div class="d-flex gap-2 justify-content-center">
|
||||
<button class="btn btn-outline-primary btn-sm">
|
||||
<i class="fas fa-phone me-1"></i>Appel
|
||||
</button>
|
||||
<button class="btn btn-outline-success btn-sm">
|
||||
<i class="fas fa-envelope me-1"></i>Email
|
||||
</button>
|
||||
<button class="btn btn-outline-warning btn-sm">
|
||||
<i class="fas fa-file-invoice me-1"></i>Facture
|
||||
</button>
|
||||
<button class="btn btn-outline-info btn-sm">
|
||||
<i class="fas fa-file-upload me-1"></i>Fichier
|
||||
</button>
|
||||
<button class="btn btn-outline-secondary btn-sm">
|
||||
<i class="fas fa-plus me-1"></i>Note
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from "vue";
|
||||
|
||||
const activeFilter = ref("all");
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.activity-list-card {
|
||||
min-height: 600px;
|
||||
}
|
||||
|
||||
.activity-list-body {
|
||||
overflow-y: auto;
|
||||
max-height: 500px;
|
||||
}
|
||||
|
||||
/* Timeline Styles */
|
||||
.timeline-container {
|
||||
position: relative;
|
||||
padding: 1rem 0;
|
||||
}
|
||||
|
||||
.timeline-container::before {
|
||||
content: "";
|
||||
position: absolute;
|
||||
left: 2rem;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
width: 2px;
|
||||
background-color: #e9ecef;
|
||||
}
|
||||
|
||||
.timeline-item {
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
margin-bottom: 2rem;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.timeline-badge {
|
||||
width: 3rem;
|
||||
height: 3rem;
|
||||
border-radius: 50%;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
color: white;
|
||||
margin-right: 1rem;
|
||||
flex-shrink: 0;
|
||||
z-index: 2;
|
||||
}
|
||||
|
||||
.timeline-content {
|
||||
flex: 1;
|
||||
background: white;
|
||||
padding: 1rem;
|
||||
border-radius: 0.5rem;
|
||||
border: 1px solid #e9ecef;
|
||||
box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.timeline-content h6 {
|
||||
color: #344767;
|
||||
}
|
||||
|
||||
.bg-purple {
|
||||
background-color: #6f42c1 !important;
|
||||
}
|
||||
|
||||
/* Filter buttons active state */
|
||||
.btn-group .btn.active {
|
||||
background-color: #cb0c9f;
|
||||
border-color: #cb0c9f;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* Badge styles */
|
||||
.badge {
|
||||
font-size: 0.75rem;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
/* Dropdown styles */
|
||||
.dropdown-menu {
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
/* Quick actions */
|
||||
.card-footer {
|
||||
background-color: #f8f9fa;
|
||||
border-top: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.btn-sm {
|
||||
font-size: 0.75rem;
|
||||
padding: 0.375rem 0.75rem;
|
||||
}
|
||||
|
||||
/* Responsive */
|
||||
@media (max-width: 768px) {
|
||||
.timeline-container::before {
|
||||
left: 1.5rem;
|
||||
}
|
||||
|
||||
.timeline-badge {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
margin-right: 0.75rem;
|
||||
}
|
||||
|
||||
.btn-group {
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@ -1,26 +1,29 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<div class="card contact-list-card">
|
||||
<div class="card-header pb-0">
|
||||
<div class="d-flex align-items-center">
|
||||
<h6 class="mb-0">Liste des contacts</h6>
|
||||
<button
|
||||
<SoftButton
|
||||
class="btn btn-primary btn-sm ms-auto"
|
||||
@click="contactModalIsVisible = true"
|
||||
>
|
||||
<i class="fas fa-plus me-1"></i>Ajouter un contact
|
||||
</button>
|
||||
</SoftButton>
|
||||
</div>
|
||||
<contact-modal
|
||||
:is-visible="contactModalIsVisible"
|
||||
:client-id="clientId"
|
||||
:contact-is-loading="isLoading"
|
||||
@close="contactModalIsVisible = false"
|
||||
:is-modification="isModification"
|
||||
:contact="selectedContact"
|
||||
@close="closeModal"
|
||||
@contact-created="handleContactCreated"
|
||||
@contact-modified="handleContactModified"
|
||||
/>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body contact-list-body p-0">
|
||||
<div v-if="contacts.length > 0" class="table-responsive">
|
||||
<table class="table align-items-center mb-0">
|
||||
<table class="table align-items-center table-flush mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
@ -43,7 +46,11 @@
|
||||
>
|
||||
Poste
|
||||
</th>
|
||||
<th class="text-secondary opacity-7"></th>
|
||||
<th
|
||||
class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 text-center"
|
||||
>
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -83,10 +90,25 @@
|
||||
{{ contact.position || "-" }}
|
||||
</p>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<button class="btn btn-link text-secondary mb-0">
|
||||
<i class="fa fa-ellipsis-v text-xs"></i>
|
||||
</button>
|
||||
<td class="align-middle text-center">
|
||||
<div class="d-flex justify-content-center gap-2">
|
||||
<button
|
||||
class="btn btn-link text-warning p-0 mb-0"
|
||||
type="button"
|
||||
title="Modifier"
|
||||
@click="handleModifyContact(contact)"
|
||||
>
|
||||
<i class="fas fa-edit text-sm"></i>
|
||||
</button>
|
||||
<button
|
||||
class="btn btn-link text-danger p-0 mb-0"
|
||||
type="button"
|
||||
title="Supprimer"
|
||||
@click="handleRemoveContact(contact.id)"
|
||||
>
|
||||
<i class="fas fa-trash text-sm"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
@ -103,6 +125,7 @@
|
||||
<script setup>
|
||||
import { defineProps, defineEmits, ref } from "vue";
|
||||
import ContactModal from "../contact/ContactModal.vue";
|
||||
import SoftButton from "@/components/SoftButton.vue";
|
||||
defineProps({
|
||||
contacts: {
|
||||
type: Array,
|
||||
@ -119,8 +142,10 @@ defineProps({
|
||||
});
|
||||
|
||||
const contactModalIsVisible = ref(false);
|
||||
const isModification = ref(false);
|
||||
const selectedContact = ref(null);
|
||||
|
||||
const emit = defineEmits(["add-contact", "contact-created"]);
|
||||
const emit = defineEmits(["add-contact", "contact-created", "contact-modified"]);
|
||||
|
||||
const getInitials = (name) => {
|
||||
if (!name) return "?";
|
||||
@ -133,16 +158,72 @@ const getInitials = (name) => {
|
||||
};
|
||||
|
||||
const handleContactCreated = (newContact) => {
|
||||
contactModalIsVisible.value = false;
|
||||
// Emit an event to notify the parent component about the new contact
|
||||
closeModal();
|
||||
emit("contact-created", newContact);
|
||||
};
|
||||
|
||||
const handleContactModified = (modifiedContact) => {
|
||||
closeModal();
|
||||
emit("contact-modified", modifiedContact);
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
contactModalIsVisible.value = false;
|
||||
isModification.value = false;
|
||||
selectedContact.value = null;
|
||||
};
|
||||
|
||||
const handleModifyContact = (contact) => {
|
||||
selectedContact.value = contact;
|
||||
isModification.value = true;
|
||||
contactModalIsVisible.value = true;
|
||||
};
|
||||
|
||||
const handleRemoveContact = (contactId) => {
|
||||
if (confirm("Êtes-vous sûr de vouloir supprimer cette contact ?")) {
|
||||
emit("contact-removed", contactId);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.contact-list-card {
|
||||
min-height: 500px;
|
||||
}
|
||||
|
||||
.contact-list-body {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.table-flush {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table-flush thead th {
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.table-flush tbody tr {
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.table-flush tbody td {
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.avatar-sm .avatar-placeholder {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.btn-link:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.gap-2 {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -1,26 +1,29 @@
|
||||
<template>
|
||||
<div class="card">
|
||||
<div class="card location-list-card">
|
||||
<div class="card-header pb-0">
|
||||
<div class="d-flex align-items-center">
|
||||
<h6 class="mb-0">Liste des localisations</h6>
|
||||
<button
|
||||
<soft-button
|
||||
class="btn btn-primary btn-sm ms-auto"
|
||||
@click="locationModalIsVisible = true"
|
||||
>
|
||||
<i class="fas fa-plus me-1"></i>Ajouter une localisation
|
||||
</button>
|
||||
</soft-button>
|
||||
</div>
|
||||
<location-modal
|
||||
:is-visible="locationModalIsVisible"
|
||||
:client-id="clientId"
|
||||
:location-is-loading="isLoading"
|
||||
:is-modification="isModification"
|
||||
:location="selectedLocation"
|
||||
@close="locationModalIsVisible = false"
|
||||
@location-created="handleLocationCreated"
|
||||
@location-modified="handleLocationModified"
|
||||
/>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="card-body location-list-body p-0">
|
||||
<div v-if="locations.length > 0" class="table-responsive">
|
||||
<table class="table align-items-center mb-0">
|
||||
<table class="table align-items-center table-flush mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th
|
||||
@ -43,7 +46,11 @@
|
||||
>
|
||||
GPS Longitude
|
||||
</th>
|
||||
<th class="text-secondary opacity-7">Actions</th>
|
||||
<th
|
||||
class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7 text-center"
|
||||
>
|
||||
Actions
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@ -77,40 +84,24 @@
|
||||
}}
|
||||
</p>
|
||||
</td>
|
||||
<td class="align-middle">
|
||||
<div class="dropdown">
|
||||
<td class="align-middle text-center">
|
||||
<div class="d-flex justify-content-center gap-2">
|
||||
<button
|
||||
class="btn btn-link text-secondary mb-0"
|
||||
class="btn btn-link text-warning p-0 mb-0"
|
||||
type="button"
|
||||
:id="'dropdownMenuButton' + location.id"
|
||||
data-bs-toggle="dropdown"
|
||||
aria-expanded="false"
|
||||
title="Modifier"
|
||||
@click="handleModifyLocation(location)"
|
||||
>
|
||||
<i class="fa fa-ellipsis-v text-xs"></i>
|
||||
<i class="fas fa-edit text-sm"></i>
|
||||
</button>
|
||||
<ul
|
||||
class="dropdown-menu"
|
||||
:aria-labelledby="'dropdownMenuButton' + location.id"
|
||||
<button
|
||||
class="btn btn-link text-danger p-0 mb-0"
|
||||
type="button"
|
||||
title="Supprimer"
|
||||
@click="handleRemoveLocation(location.id)"
|
||||
>
|
||||
<li>
|
||||
<a
|
||||
class="dropdown-item"
|
||||
href="#"
|
||||
@click.prevent="handleModifyLocation(location)"
|
||||
>
|
||||
<i class="fas fa-edit me-2"></i>Modifier
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a
|
||||
class="dropdown-item text-danger"
|
||||
href="#"
|
||||
@click.prevent="handleRemoveLocation(location.id)"
|
||||
>
|
||||
<i class="fas fa-trash me-2"></i>Supprimer
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
<i class="fas fa-trash text-sm"></i>
|
||||
</button>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@ -130,6 +121,7 @@
|
||||
<script setup>
|
||||
import { defineProps, defineEmits, ref } from "vue";
|
||||
import LocationModal from "../location/LocationModal.vue";
|
||||
import SoftButton from "@/components/SoftButton.vue";
|
||||
|
||||
defineProps({
|
||||
locations: {
|
||||
@ -147,6 +139,8 @@ defineProps({
|
||||
});
|
||||
|
||||
const locationModalIsVisible = ref(false);
|
||||
const isModification = ref(false);
|
||||
const selectedLocation = ref(null);
|
||||
|
||||
const emit = defineEmits([
|
||||
"location-created",
|
||||
@ -154,13 +148,20 @@ const emit = defineEmits([
|
||||
"location-removed",
|
||||
]);
|
||||
|
||||
const handleLocationModified = (modifiedLocation) => {
|
||||
locationModalIsVisible.value = false;
|
||||
emit("location-modified", modifiedLocation);
|
||||
};
|
||||
|
||||
const handleLocationCreated = (newLocation) => {
|
||||
locationModalIsVisible.value = false;
|
||||
emit("location-created", newLocation);
|
||||
};
|
||||
|
||||
const handleModifyLocation = (location) => {
|
||||
emit("location-modified", location);
|
||||
selectedLocation.value = location;
|
||||
isModification.value = true;
|
||||
locationModalIsVisible.value = true;
|
||||
};
|
||||
|
||||
const handleRemoveLocation = (locationId) => {
|
||||
@ -182,15 +183,37 @@ const formatAddress = (location) => {
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.dropdown-menu {
|
||||
font-size: 0.875rem;
|
||||
.location-list-card {
|
||||
min-height: 500px;
|
||||
}
|
||||
|
||||
.dropdown-item {
|
||||
padding: 0.5rem 1rem;
|
||||
.location-list-body {
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.dropdown-item:hover {
|
||||
background-color: #f8f9fa;
|
||||
.table-flush {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
.table-flush thead th {
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.table-flush tbody tr {
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
}
|
||||
|
||||
.table-flush tbody td {
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.btn-link:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.gap-2 {
|
||||
gap: 0.5rem;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -13,6 +13,12 @@
|
||||
:is-active="activeTab === 'info'"
|
||||
@click="$emit('change-tab', 'info')"
|
||||
/>
|
||||
<TabNavigationItem
|
||||
icon="fas fa-info-circle"
|
||||
label="Activités recentes"
|
||||
:is-active="activeTab === 'activity'"
|
||||
@click="$emit('change-tab', 'activity')"
|
||||
/>
|
||||
<TabNavigationItem
|
||||
icon="fas fa-users"
|
||||
label="Contacts"
|
||||
|
||||
@ -12,8 +12,8 @@
|
||||
<!-- Header -->
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">
|
||||
<i class="fas fa-user-plus me-2"></i>
|
||||
Ajouter un contact
|
||||
<i :class="isModification ? 'fas fa-edit me-2' : 'fas fa-user-plus me-2'"></i>
|
||||
{{ isModification ? 'Modifier le contact' : 'Ajouter un contact' }}
|
||||
</h5>
|
||||
<button
|
||||
type="button"
|
||||
@ -135,7 +135,7 @@
|
||||
:disabled="contactIsLoading"
|
||||
>
|
||||
<i class="fas fa-save me-1"></i>
|
||||
{{ contactIsLoading ? "Création..." : "Créer le contact" }}
|
||||
{{ contactIsLoading ? (isModification ? "Modification..." : "Création...") : (isModification ? "Modifier le contact" : "Créer le contact") }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
@ -168,10 +168,18 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isModification: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
contact: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
});
|
||||
|
||||
// Emits
|
||||
const emit = defineEmits(["close", "contact-created"]);
|
||||
const emit = defineEmits(["close", "contact-created", "contact-modified"]);
|
||||
|
||||
// State
|
||||
const errors = reactive({});
|
||||
@ -193,6 +201,21 @@ watch(
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// Watch for contact changes (for modification mode)
|
||||
watch(
|
||||
() => props.contact,
|
||||
(newContact) => {
|
||||
if (newContact && props.isModification) {
|
||||
formData.first_name = newContact.first_name || "";
|
||||
formData.last_name = newContact.last_name || "";
|
||||
formData.email = newContact.email || "";
|
||||
formData.phone = newContact.phone || "";
|
||||
formData.role = newContact.position || "";
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
// Methods
|
||||
const closeModal = () => {
|
||||
resetForm();
|
||||
@ -296,7 +319,12 @@ const submitForm = async () => {
|
||||
});
|
||||
|
||||
// Emit event - parent will handle the API call and loading state
|
||||
emit("contact-created", submitData);
|
||||
if (props.isModification) {
|
||||
submitData.id = props.contact.id;
|
||||
emit("contact-modified", submitData);
|
||||
} else {
|
||||
emit("contact-created", submitData);
|
||||
}
|
||||
|
||||
// Close modal and reset form
|
||||
closeModal();
|
||||
|
||||
@ -1,20 +1,30 @@
|
||||
<template>
|
||||
<!-- Modal Component -->
|
||||
<div
|
||||
v-if="isVisible"
|
||||
class="modal fade show d-block"
|
||||
class="modal fade"
|
||||
:class="{ show: isVisible, 'd-block': isVisible }"
|
||||
tabindex="-1"
|
||||
role="dialog"
|
||||
style="background-color: rgba(0, 0, 0, 0.5)"
|
||||
@click="handleBackdropClick"
|
||||
:aria-hidden="!isVisible"
|
||||
>
|
||||
<div
|
||||
class="modal-dialog modal-dialog-centered modal-lg"
|
||||
role="document"
|
||||
@click.stop
|
||||
>
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<!-- Header -->
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Ajouter une localisation</h5>
|
||||
<h5 class="modal-title">
|
||||
<i
|
||||
:class="
|
||||
isModification
|
||||
? 'fas fa-edit me-2'
|
||||
: 'fas fa-map-marker-alt me-2'
|
||||
"
|
||||
></i>
|
||||
{{
|
||||
isModification
|
||||
? "Modifier la localisation"
|
||||
: "Ajouter une localisation"
|
||||
}}
|
||||
</h5>
|
||||
<button
|
||||
type="button"
|
||||
class="btn-close"
|
||||
@ -23,10 +33,12 @@
|
||||
:disabled="locationIsLoading"
|
||||
></button>
|
||||
</div>
|
||||
|
||||
<!-- Body -->
|
||||
<div class="modal-body">
|
||||
<!-- Error Alert -->
|
||||
<div v-if="generalError" class="alert alert-danger" role="alert">
|
||||
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
||||
<i class="fas fa-exclamation-triangle me-2"></i>
|
||||
{{ generalError }}
|
||||
</div>
|
||||
|
||||
@ -51,12 +63,19 @@
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">Type de localisation</label>
|
||||
<select v-model="formData.location_type" class="form-select">
|
||||
<select
|
||||
v-model="formData.location_type"
|
||||
class="form-select"
|
||||
:class="{ 'is-invalid': errors.location_type }"
|
||||
>
|
||||
<option value="office">Bureau</option>
|
||||
<option value="warehouse">Entrepôt</option>
|
||||
<option value="store">Magasin</option>
|
||||
<option value="other">Autre</option>
|
||||
</select>
|
||||
<div v-if="errors.location_type" class="invalid-feedback">
|
||||
{{ errors.location_type }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -150,7 +169,7 @@
|
||||
class="alert alert-warning"
|
||||
role="alert"
|
||||
>
|
||||
<i class="bi bi-info-circle me-2"></i>
|
||||
<i class="fas fa-info-circle me-2"></i>
|
||||
Au moins un champ d'adresse (adresse, code postal ou ville) doit
|
||||
être renseigné.
|
||||
</div>
|
||||
@ -162,8 +181,12 @@
|
||||
v-model="formData.phone"
|
||||
type="tel"
|
||||
class="form-control"
|
||||
:class="{ 'is-invalid': errors.phone }"
|
||||
placeholder="+33 1 23 45 67 89"
|
||||
/>
|
||||
<div v-if="errors.phone" class="invalid-feedback">
|
||||
{{ errors.phone }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6 mb-3">
|
||||
<label class="form-label">Email</label>
|
||||
@ -171,8 +194,12 @@
|
||||
v-model="formData.email"
|
||||
type="email"
|
||||
class="form-control"
|
||||
:class="{ 'is-invalid': errors.email }"
|
||||
placeholder="contact@exemple.fr"
|
||||
/>
|
||||
<div v-if="errors.email" class="invalid-feedback">
|
||||
{{ errors.email }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -230,13 +257,16 @@
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Footer -->
|
||||
<div class="modal-footer">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-secondary"
|
||||
class="btn btn-outline-secondary"
|
||||
@click="closeModal"
|
||||
:disabled="locationIsLoading"
|
||||
>
|
||||
<i class="fas fa-times me-1"></i>
|
||||
Annuler
|
||||
</button>
|
||||
<button
|
||||
@ -245,20 +275,36 @@
|
||||
@click="handleSubmit"
|
||||
:disabled="locationIsLoading || !isFormValid"
|
||||
>
|
||||
<i class="fas fa-save me-1"></i>
|
||||
<span
|
||||
v-if="locationIsLoading"
|
||||
class="spinner-border spinner-border-sm me-2"
|
||||
></span>
|
||||
{{ locationIsLoading ? "Création..." : "Ajouter" }}
|
||||
{{
|
||||
locationIsLoading
|
||||
? isModification
|
||||
? "Modification..."
|
||||
: "Création..."
|
||||
: isModification
|
||||
? "Modifier"
|
||||
: "Ajouter"
|
||||
}}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Backdrop -->
|
||||
<div
|
||||
v-if="isVisible"
|
||||
class="modal-backdrop fade show"
|
||||
@click="closeModal"
|
||||
></div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, watch, computed, nextTick } from "vue";
|
||||
import { ref, reactive, watch, computed, onMounted, onUnmounted } from "vue";
|
||||
import { defineProps, defineEmits } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
@ -274,15 +320,28 @@ const props = defineProps({
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
isModification: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
location: {
|
||||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
errors: {
|
||||
type: Object,
|
||||
default: () => ({}),
|
||||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(["close", "location-created", "clear-errors"]);
|
||||
const emit = defineEmits([
|
||||
"close",
|
||||
"location-created",
|
||||
"location-modified",
|
||||
"clear-errors",
|
||||
]);
|
||||
|
||||
const formData = ref({
|
||||
const formData = reactive({
|
||||
name: "",
|
||||
location_type: "office",
|
||||
address_line1: "",
|
||||
@ -300,11 +359,7 @@ const formData = ref({
|
||||
|
||||
// Computed properties
|
||||
const showAddressWarning = computed(() => {
|
||||
return (
|
||||
!formData.value.address_line1 &&
|
||||
!formData.value.postal_code &&
|
||||
!formData.value.city
|
||||
);
|
||||
return !formData.address_line1 && !formData.postal_code && !formData.city;
|
||||
});
|
||||
|
||||
const generalError = computed(() => {
|
||||
@ -312,7 +367,6 @@ const generalError = computed(() => {
|
||||
});
|
||||
|
||||
const isFormValid = computed(() => {
|
||||
// At least one address field should be filled
|
||||
return !showAddressWarning.value;
|
||||
});
|
||||
|
||||
@ -320,23 +374,47 @@ const isFormValid = computed(() => {
|
||||
watch(
|
||||
() => props.clientId,
|
||||
(newVal) => {
|
||||
formData.value.client_id = newVal;
|
||||
formData.client_id = newVal;
|
||||
}
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.location,
|
||||
(newLocation) => {
|
||||
if (newLocation && props.isModification) {
|
||||
// Populate form with location data for modification
|
||||
formData.name = newLocation.name || "";
|
||||
formData.location_type = newLocation.location_type || "office";
|
||||
formData.address_line1 = newLocation.address?.line1 || "";
|
||||
formData.address_line2 = newLocation.address?.line2 || "";
|
||||
formData.postal_code = newLocation.address?.postal_code || "";
|
||||
formData.city = newLocation.address?.city || "";
|
||||
formData.country_code = newLocation.address?.country_code || "FR";
|
||||
formData.phone = newLocation.phone || "";
|
||||
formData.email = newLocation.email || "";
|
||||
formData.gps_lat = newLocation.gps_lat || null;
|
||||
formData.gps_lng = newLocation.gps_lng || null;
|
||||
formData.is_default = newLocation.is_default || false;
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
);
|
||||
|
||||
watch(
|
||||
() => props.isVisible,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
// Clear errors when modal opens
|
||||
emit("clear-errors");
|
||||
if (!props.isModification) {
|
||||
resetForm();
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
// Methods
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
Object.assign(formData, {
|
||||
name: "",
|
||||
location_type: "office",
|
||||
address_line1: "",
|
||||
@ -350,8 +428,7 @@ const resetForm = () => {
|
||||
gps_lng: null,
|
||||
is_default: false,
|
||||
client_id: props.clientId,
|
||||
};
|
||||
emit("clear-errors");
|
||||
});
|
||||
};
|
||||
|
||||
const closeModal = () => {
|
||||
@ -359,34 +436,30 @@ const closeModal = () => {
|
||||
emit("close");
|
||||
};
|
||||
|
||||
const handleBackdropClick = (event) => {
|
||||
if (event.target === event.currentTarget) {
|
||||
closeModal();
|
||||
}
|
||||
};
|
||||
|
||||
const handleSubmit = async () => {
|
||||
if (!isFormValid.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate GPS coordinates if provided
|
||||
if (formData.value.gps_lat !== null) {
|
||||
const lat = parseFloat(formData.value.gps_lat);
|
||||
if (formData.gps_lat !== null) {
|
||||
const lat = parseFloat(formData.gps_lat);
|
||||
if (isNaN(lat) || lat < -90 || lat > 90) {
|
||||
emit("location-created", {
|
||||
...formData.value,
|
||||
emit("clear-errors");
|
||||
emit(props.isModification ? "location-modified" : "location-created", {
|
||||
...formData,
|
||||
errors: { gps_lat: "La latitude doit être comprise entre -90 et 90." },
|
||||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (formData.value.gps_lng !== null) {
|
||||
const lng = parseFloat(formData.value.gps_lng);
|
||||
if (formData.gps_lng !== null) {
|
||||
const lng = parseFloat(formData.gps_lng);
|
||||
if (isNaN(lng) || lng < -180 || lng > 180) {
|
||||
emit("location-created", {
|
||||
...formData.value,
|
||||
emit("clear-errors");
|
||||
emit(props.isModification ? "location-modified" : "location-created", {
|
||||
...formData,
|
||||
errors: {
|
||||
gps_lng: "La longitude doit être comprise entre -180 et 180.",
|
||||
},
|
||||
@ -396,9 +469,10 @@ const handleSubmit = async () => {
|
||||
}
|
||||
|
||||
// Validate country code if provided
|
||||
if (formData.value.country_code && formData.value.country_code.length !== 2) {
|
||||
emit("location-created", {
|
||||
...formData.value,
|
||||
if (formData.country_code && formData.country_code.length !== 2) {
|
||||
emit("clear-errors");
|
||||
emit(props.isModification ? "location-modified" : "location-created", {
|
||||
...formData,
|
||||
errors: {
|
||||
country_code: "Le code pays doit contenir exactement 2 caractères.",
|
||||
},
|
||||
@ -408,43 +482,127 @@ const handleSubmit = async () => {
|
||||
|
||||
// Clean up data before sending
|
||||
const submitData = {
|
||||
...formData.value,
|
||||
gps_lat: formData.value.gps_lat || null,
|
||||
gps_lng: formData.value.gps_lng || null,
|
||||
name: formData.value.name || null,
|
||||
address_line1: formData.value.address_line1 || null,
|
||||
address_line2: formData.value.address_line2 || null,
|
||||
postal_code: formData.value.postal_code || null,
|
||||
city: formData.value.city || null,
|
||||
country_code: formData.value.country_code || "FR",
|
||||
...formData,
|
||||
gps_lat: formData.gps_lat || null,
|
||||
gps_lng: formData.gps_lng || null,
|
||||
name: formData.name || null,
|
||||
address_line1: formData.address_line1 || null,
|
||||
address_line2: formData.address_line2 || null,
|
||||
postal_code: formData.postal_code || null,
|
||||
city: formData.city || null,
|
||||
country_code: formData.country_code || "FR",
|
||||
};
|
||||
|
||||
emit("location-created", submitData);
|
||||
if (props.isModification && props.location) {
|
||||
submitData.id = props.location.id;
|
||||
emit("location-modified", submitData);
|
||||
} else {
|
||||
emit("location-created", submitData);
|
||||
}
|
||||
};
|
||||
|
||||
// Keyboard event listener for ESC key
|
||||
const handleKeydown = (event) => {
|
||||
if (event.key === "Escape" && props.isVisible) {
|
||||
closeModal();
|
||||
}
|
||||
};
|
||||
|
||||
// Add event listener when component is mounted
|
||||
onMounted(() => {
|
||||
document.addEventListener("keydown", handleKeydown);
|
||||
});
|
||||
onUnmounted(() => {
|
||||
document.removeEventListener("keydown", handleKeydown);
|
||||
});
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.modal.show {
|
||||
display: block;
|
||||
.modal {
|
||||
background-color: rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
.modal-content {
|
||||
border: none;
|
||||
border-radius: 0.5rem;
|
||||
box-shadow: 0 10px 25px rgba(0, 0, 0, 0.2);
|
||||
}
|
||||
|
||||
.modal-header {
|
||||
background-color: #f8f9fa;
|
||||
border-bottom: 1px solid #e9ecef;
|
||||
border-top-left-radius: 0.5rem;
|
||||
border-top-right-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.modal-title {
|
||||
color: #495057;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.modal-body {
|
||||
padding: 1.5rem;
|
||||
}
|
||||
|
||||
.modal-footer {
|
||||
border-top: 1px solid #e9ecef;
|
||||
background-color: #f8f9fa;
|
||||
border-bottom-left-radius: 0.5rem;
|
||||
border-bottom-right-radius: 0.5rem;
|
||||
}
|
||||
|
||||
.form-label {
|
||||
font-weight: 600;
|
||||
font-size: 0.875rem;
|
||||
font-weight: 500;
|
||||
color: #495057;
|
||||
margin-bottom: 0.5rem;
|
||||
}
|
||||
|
||||
.form-control,
|
||||
.form-select {
|
||||
font-size: 0.875rem;
|
||||
border: 1px solid #dce1e6;
|
||||
border-radius: 0.375rem;
|
||||
padding: 0.5rem 0.75rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.form-control:focus,
|
||||
.form-select:focus {
|
||||
border-color: #cb0c9f;
|
||||
box-shadow: 0 0 0 0.2rem rgba(203, 12, 159, 0.25);
|
||||
}
|
||||
|
||||
.btn-primary {
|
||||
background-color: #cb0c9f;
|
||||
border-color: #cb0c9f;
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
.btn-primary:hover:not(:disabled) {
|
||||
background-color: #a90982;
|
||||
border-color: #a90982;
|
||||
transform: translateY(-1px);
|
||||
}
|
||||
|
||||
.btn-outline-secondary {
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
.invalid-feedback {
|
||||
display: block;
|
||||
font-size: 0.875rem;
|
||||
}
|
||||
|
||||
.alert {
|
||||
font-size: 0.875rem;
|
||||
border: none;
|
||||
border-radius: 0.375rem;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.fade {
|
||||
transition: opacity 0.15s linear;
|
||||
}
|
||||
|
||||
.modal-backdrop {
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.form-text {
|
||||
@ -455,20 +613,4 @@ const handleSubmit = async () => {
|
||||
cursor: not-allowed;
|
||||
opacity: 0.6;
|
||||
}
|
||||
|
||||
/* Smooth transitions for modal */
|
||||
.modal-content {
|
||||
animation: modalSlideIn 0.3s ease-out;
|
||||
}
|
||||
|
||||
@keyframes modalSlideIn {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(-50px);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -328,14 +328,34 @@
|
||||
<div class="card-header pb-0">
|
||||
<div class="d-flex align-items-center">
|
||||
<h6 class="mb-0">Liste des contacts</h6>
|
||||
<button class="btn btn-primary btn-sm ms-auto">
|
||||
<SoftButton
|
||||
class="btn btn-primary btn-sm ms-auto"
|
||||
@click="openCreateContactModal"
|
||||
>
|
||||
<i class="fas fa-plus me-1"></i>Ajouter un contact
|
||||
</button>
|
||||
</SoftButton>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div v-if="contacts_client.length > 0" class="table-responsive">
|
||||
<table class="table align-items-center mb-0">
|
||||
<client-contacts-tab
|
||||
:contacts="contacts_client"
|
||||
:client-id="Number(client_id)"
|
||||
:is-loading="contactStore.isLoading"
|
||||
@contact-created="onContactCreated"
|
||||
@contact-modified="onContactModified"
|
||||
@contact-removed="onContactRemoved"
|
||||
/>
|
||||
|
||||
<contact-modal
|
||||
:is-visible="contactModalIsVisible"
|
||||
:client-id="Number(client_id)"
|
||||
:contact-is-loading="contactStore.isLoading"
|
||||
:is-modification="isModification"
|
||||
:contact="selectedContact"
|
||||
@close="closeContactModal"
|
||||
@contact-created="handleModalCreated"
|
||||
@contact-modified="handleModalModified"
|
||||
/>
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">
|
||||
@ -466,6 +486,9 @@ import { ref, onMounted } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useClientStore } from '@/stores/clientStore';
|
||||
import { useContactStore } from '@/stores/contactStore';
|
||||
import ClientContactsTab from '@/components/molecules/client/ClientContactsTab.vue';
|
||||
import ContactModal from '@/components/molecules/contact/ContactModal.vue';
|
||||
import SoftButton from '@/components/SoftButton.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const clientStore = useClientStore();
|
||||
@ -477,6 +500,10 @@ const activeTab = ref('overview');
|
||||
const clientAvatar = ref(null);
|
||||
const fileInput = ref(null);
|
||||
|
||||
const contactModalIsVisible = ref(false);
|
||||
const isModification = ref(false);
|
||||
const selectedContact = ref(null);
|
||||
|
||||
onMounted(async () => {
|
||||
if (client_id) {
|
||||
await clientStore.fetchClient(Number(client_id));
|
||||
@ -485,6 +512,43 @@ onMounted(async () => {
|
||||
});
|
||||
|
||||
// Methods
|
||||
const openCreateContactModal = () => {
|
||||
isModification.value = false;
|
||||
selectedContact.value = null;
|
||||
contactModalIsVisible.value = true;
|
||||
};
|
||||
|
||||
const closeContactModal = () => {
|
||||
contactModalIsVisible.value = false;
|
||||
isModification.value = false;
|
||||
selectedContact.value = null;
|
||||
};
|
||||
|
||||
const handleModalCreated = async (payload) => {
|
||||
await contactStore.createContact(payload);
|
||||
contacts_client.value = await contactStore.getClientListContact(Number(client_id));
|
||||
};
|
||||
|
||||
const handleModalModified = async (payload) => {
|
||||
await contactStore.updateContact(payload);
|
||||
contacts_client.value = await contactStore.getClientListContact(Number(client_id));
|
||||
};
|
||||
|
||||
const onContactCreated = async (payload) => {
|
||||
// From child tab create
|
||||
await contactStore.createContact(payload);
|
||||
contacts_client.value = await contactStore.getClientListContact(Number(client_id));
|
||||
};
|
||||
|
||||
const onContactModified = async (payload) => {
|
||||
await contactStore.updateContact(payload);
|
||||
contacts_client.value = await contactStore.getClientListContact(Number(client_id));
|
||||
};
|
||||
|
||||
const onContactRemoved = async (id) => {
|
||||
await contactStore.deleteContact(Number(id));
|
||||
contacts_client.value = await contactStore.getClientListContact(Number(client_id));
|
||||
};
|
||||
const getInitials = (name) => {
|
||||
if (!name) return '?';
|
||||
return name
|
||||
|
||||
@ -12,6 +12,7 @@
|
||||
:location-loading="clientLocationStore.isLoading"
|
||||
@update-the-client="updateClient"
|
||||
@add-new-contact="createNewContact"
|
||||
@updating-contact="updateContact"
|
||||
@add-new-location="createNewLocation"
|
||||
@modify-location="modifyLocation"
|
||||
@remove-location="removeLocation"
|
||||
@ -75,6 +76,15 @@ const createNewContact = async (data) => {
|
||||
}
|
||||
};
|
||||
|
||||
const updateContact = async (modifiedContact) => {
|
||||
try {
|
||||
await contactStore.updateContact(modifiedContact);
|
||||
contacts_client.value = await contactStore.getClientListContact(client_id);
|
||||
} catch (error) {
|
||||
console.error("Error updating contact:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const createNewLocation = async (data) => {
|
||||
try {
|
||||
await clientLocationStore.createClientLocation(data);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user