ajout activity
This commit is contained in:
parent
2a1de6f384
commit
ea2b687533
@ -53,6 +53,7 @@
|
|||||||
@change-tab="activeTab = $event"
|
@change-tab="activeTab = $event"
|
||||||
@updating-client="handleUpdateClient"
|
@updating-client="handleUpdateClient"
|
||||||
@create-contact="handleAddContact"
|
@create-contact="handleAddContact"
|
||||||
|
@updating-contact="handleModifiedContact"
|
||||||
@create-location="handleAddLocation"
|
@create-location="handleAddLocation"
|
||||||
@modify-location="handleModifyLocation"
|
@modify-location="handleModifyLocation"
|
||||||
@remove-location="handleRemoveLocation"
|
@remove-location="handleRemoveLocation"
|
||||||
@ -114,6 +115,7 @@ const emit = defineEmits([
|
|||||||
"updateTheClient",
|
"updateTheClient",
|
||||||
"handleFileInput",
|
"handleFileInput",
|
||||||
"add-new-contact",
|
"add-new-contact",
|
||||||
|
"updating-contact",
|
||||||
"add-new-location",
|
"add-new-location",
|
||||||
"modify-location",
|
"modify-location",
|
||||||
"remove-location",
|
"remove-location",
|
||||||
@ -144,6 +146,10 @@ const handleAddContact = (data) => {
|
|||||||
emit("add-new-contact", data);
|
emit("add-new-contact", data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleModifiedContact = (modifiedContact) => {
|
||||||
|
emit("updating-contact", modifiedContact);
|
||||||
|
};
|
||||||
|
|
||||||
const handleAddLocation = (data) => {
|
const handleAddLocation = (data) => {
|
||||||
emit("add-new-location", data);
|
emit("add-new-location", data);
|
||||||
};
|
};
|
||||||
|
|||||||
@ -16,6 +16,10 @@
|
|||||||
<ClientInfoTab :client="client" @client-updated="updateClient" />
|
<ClientInfoTab :client="client" @client-updated="updateClient" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-show="activeTab === 'activity'">
|
||||||
|
<ClientActivityTab />
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- Contacts Tab -->
|
<!-- Contacts Tab -->
|
||||||
<div v-show="activeTab === 'contacts'">
|
<div v-show="activeTab === 'contacts'">
|
||||||
<ClientContactsTab
|
<ClientContactsTab
|
||||||
@ -23,6 +27,7 @@
|
|||||||
:client-id="client.id"
|
:client-id="client.id"
|
||||||
:is-loading="contactIsLoading"
|
:is-loading="contactIsLoading"
|
||||||
@contact-created="handleCreateContact"
|
@contact-created="handleCreateContact"
|
||||||
|
@contact-modified="handleModifiedContact"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -58,6 +63,7 @@ import ClientAddressTab from "@/components/molecules/client/ClientAddressTab.vue
|
|||||||
import ClientLocationsTab from "@/components/molecules/client/ClientLocationsTab.vue";
|
import ClientLocationsTab from "@/components/molecules/client/ClientLocationsTab.vue";
|
||||||
import ClientNotesTab from "@/components/molecules/client/ClientNotesTab.vue";
|
import ClientNotesTab from "@/components/molecules/client/ClientNotesTab.vue";
|
||||||
import { defineProps, defineEmits } from "vue";
|
import { defineProps, defineEmits } from "vue";
|
||||||
|
import ClientActivityTab from "@/components/molecules/client/ClientActivityTab.vue";
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
activeTab: {
|
activeTab: {
|
||||||
@ -101,6 +107,7 @@ const emit = defineEmits([
|
|||||||
"create-location",
|
"create-location",
|
||||||
"modify-location",
|
"modify-location",
|
||||||
"remove-location",
|
"remove-location",
|
||||||
|
"updating-contact",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
const updateClient = (updatedClient) => {
|
const updateClient = (updatedClient) => {
|
||||||
@ -111,6 +118,10 @@ const handleCreateContact = (newContact) => {
|
|||||||
emit("create-contact", newContact);
|
emit("create-contact", newContact);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const handleModifiedContact = (modifiedContact) => {
|
||||||
|
emit("updating-contact", modifiedContact);
|
||||||
|
};
|
||||||
|
|
||||||
const handleCreateLocation = (newLocation) => {
|
const handleCreateLocation = (newLocation) => {
|
||||||
emit("create-location", 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>
|
<template>
|
||||||
<div class="card">
|
<div class="card contact-list-card">
|
||||||
<div class="card-header pb-0">
|
<div class="card-header pb-0">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<h6 class="mb-0">Liste des contacts</h6>
|
<h6 class="mb-0">Liste des contacts</h6>
|
||||||
<button
|
<SoftButton
|
||||||
class="btn btn-primary btn-sm ms-auto"
|
class="btn btn-primary btn-sm ms-auto"
|
||||||
@click="contactModalIsVisible = true"
|
@click="contactModalIsVisible = true"
|
||||||
>
|
>
|
||||||
<i class="fas fa-plus me-1"></i>Ajouter un contact
|
<i class="fas fa-plus me-1"></i>Ajouter un contact
|
||||||
</button>
|
</SoftButton>
|
||||||
</div>
|
</div>
|
||||||
<contact-modal
|
<contact-modal
|
||||||
:is-visible="contactModalIsVisible"
|
:is-visible="contactModalIsVisible"
|
||||||
:client-id="clientId"
|
:client-id="clientId"
|
||||||
:contact-is-loading="isLoading"
|
:contact-is-loading="isLoading"
|
||||||
@close="contactModalIsVisible = false"
|
:is-modification="isModification"
|
||||||
|
:contact="selectedContact"
|
||||||
|
@close="closeModal"
|
||||||
@contact-created="handleContactCreated"
|
@contact-created="handleContactCreated"
|
||||||
|
@contact-modified="handleContactModified"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body contact-list-body p-0">
|
||||||
<div v-if="contacts.length > 0" class="table-responsive">
|
<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>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th
|
<th
|
||||||
@ -43,7 +46,11 @@
|
|||||||
>
|
>
|
||||||
Poste
|
Poste
|
||||||
</th>
|
</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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -83,10 +90,25 @@
|
|||||||
{{ contact.position || "-" }}
|
{{ contact.position || "-" }}
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle text-center">
|
||||||
<button class="btn btn-link text-secondary mb-0">
|
<div class="d-flex justify-content-center gap-2">
|
||||||
<i class="fa fa-ellipsis-v text-xs"></i>
|
<button
|
||||||
</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>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
@ -103,6 +125,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps, defineEmits, ref } from "vue";
|
import { defineProps, defineEmits, ref } from "vue";
|
||||||
import ContactModal from "../contact/ContactModal.vue";
|
import ContactModal from "../contact/ContactModal.vue";
|
||||||
|
import SoftButton from "@/components/SoftButton.vue";
|
||||||
defineProps({
|
defineProps({
|
||||||
contacts: {
|
contacts: {
|
||||||
type: Array,
|
type: Array,
|
||||||
@ -119,8 +142,10 @@ defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const contactModalIsVisible = ref(false);
|
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) => {
|
const getInitials = (name) => {
|
||||||
if (!name) return "?";
|
if (!name) return "?";
|
||||||
@ -133,16 +158,72 @@ const getInitials = (name) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleContactCreated = (newContact) => {
|
const handleContactCreated = (newContact) => {
|
||||||
contactModalIsVisible.value = false;
|
closeModal();
|
||||||
// Emit an event to notify the parent component about the new contact
|
|
||||||
emit("contact-created", newContact);
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<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 {
|
.avatar-sm .avatar-placeholder {
|
||||||
width: 36px;
|
width: 36px;
|
||||||
height: 36px;
|
height: 36px;
|
||||||
font-size: 0.875rem;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-link:hover {
|
||||||
|
opacity: 0.8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.gap-2 {
|
||||||
|
gap: 0.5rem;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
@ -1,26 +1,29 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="card">
|
<div class="card location-list-card">
|
||||||
<div class="card-header pb-0">
|
<div class="card-header pb-0">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<h6 class="mb-0">Liste des localisations</h6>
|
<h6 class="mb-0">Liste des localisations</h6>
|
||||||
<button
|
<soft-button
|
||||||
class="btn btn-primary btn-sm ms-auto"
|
class="btn btn-primary btn-sm ms-auto"
|
||||||
@click="locationModalIsVisible = true"
|
@click="locationModalIsVisible = true"
|
||||||
>
|
>
|
||||||
<i class="fas fa-plus me-1"></i>Ajouter une localisation
|
<i class="fas fa-plus me-1"></i>Ajouter une localisation
|
||||||
</button>
|
</soft-button>
|
||||||
</div>
|
</div>
|
||||||
<location-modal
|
<location-modal
|
||||||
:is-visible="locationModalIsVisible"
|
:is-visible="locationModalIsVisible"
|
||||||
:client-id="clientId"
|
:client-id="clientId"
|
||||||
:location-is-loading="isLoading"
|
:location-is-loading="isLoading"
|
||||||
|
:is-modification="isModification"
|
||||||
|
:location="selectedLocation"
|
||||||
@close="locationModalIsVisible = false"
|
@close="locationModalIsVisible = false"
|
||||||
@location-created="handleLocationCreated"
|
@location-created="handleLocationCreated"
|
||||||
|
@location-modified="handleLocationModified"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body location-list-body p-0">
|
||||||
<div v-if="locations.length > 0" class="table-responsive">
|
<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>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th
|
<th
|
||||||
@ -43,7 +46,11 @@
|
|||||||
>
|
>
|
||||||
GPS Longitude
|
GPS Longitude
|
||||||
</th>
|
</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>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
@ -77,40 +84,24 @@
|
|||||||
}}
|
}}
|
||||||
</p>
|
</p>
|
||||||
</td>
|
</td>
|
||||||
<td class="align-middle">
|
<td class="align-middle text-center">
|
||||||
<div class="dropdown">
|
<div class="d-flex justify-content-center gap-2">
|
||||||
<button
|
<button
|
||||||
class="btn btn-link text-secondary mb-0"
|
class="btn btn-link text-warning p-0 mb-0"
|
||||||
type="button"
|
type="button"
|
||||||
:id="'dropdownMenuButton' + location.id"
|
title="Modifier"
|
||||||
data-bs-toggle="dropdown"
|
@click="handleModifyLocation(location)"
|
||||||
aria-expanded="false"
|
|
||||||
>
|
>
|
||||||
<i class="fa fa-ellipsis-v text-xs"></i>
|
<i class="fas fa-edit text-sm"></i>
|
||||||
</button>
|
</button>
|
||||||
<ul
|
<button
|
||||||
class="dropdown-menu"
|
class="btn btn-link text-danger p-0 mb-0"
|
||||||
:aria-labelledby="'dropdownMenuButton' + location.id"
|
type="button"
|
||||||
|
title="Supprimer"
|
||||||
|
@click="handleRemoveLocation(location.id)"
|
||||||
>
|
>
|
||||||
<li>
|
<i class="fas fa-trash text-sm"></i>
|
||||||
<a
|
</button>
|
||||||
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>
|
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -130,6 +121,7 @@
|
|||||||
<script setup>
|
<script setup>
|
||||||
import { defineProps, defineEmits, ref } from "vue";
|
import { defineProps, defineEmits, ref } from "vue";
|
||||||
import LocationModal from "../location/LocationModal.vue";
|
import LocationModal from "../location/LocationModal.vue";
|
||||||
|
import SoftButton from "@/components/SoftButton.vue";
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
locations: {
|
locations: {
|
||||||
@ -147,6 +139,8 @@ defineProps({
|
|||||||
});
|
});
|
||||||
|
|
||||||
const locationModalIsVisible = ref(false);
|
const locationModalIsVisible = ref(false);
|
||||||
|
const isModification = ref(false);
|
||||||
|
const selectedLocation = ref(null);
|
||||||
|
|
||||||
const emit = defineEmits([
|
const emit = defineEmits([
|
||||||
"location-created",
|
"location-created",
|
||||||
@ -154,13 +148,20 @@ const emit = defineEmits([
|
|||||||
"location-removed",
|
"location-removed",
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
const handleLocationModified = (modifiedLocation) => {
|
||||||
|
locationModalIsVisible.value = false;
|
||||||
|
emit("location-modified", modifiedLocation);
|
||||||
|
};
|
||||||
|
|
||||||
const handleLocationCreated = (newLocation) => {
|
const handleLocationCreated = (newLocation) => {
|
||||||
locationModalIsVisible.value = false;
|
locationModalIsVisible.value = false;
|
||||||
emit("location-created", newLocation);
|
emit("location-created", newLocation);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleModifyLocation = (location) => {
|
const handleModifyLocation = (location) => {
|
||||||
emit("location-modified", location);
|
selectedLocation.value = location;
|
||||||
|
isModification.value = true;
|
||||||
|
locationModalIsVisible.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveLocation = (locationId) => {
|
const handleRemoveLocation = (locationId) => {
|
||||||
@ -182,15 +183,37 @@ const formatAddress = (location) => {
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.dropdown-menu {
|
.location-list-card {
|
||||||
font-size: 0.875rem;
|
min-height: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-item {
|
.location-list-body {
|
||||||
padding: 0.5rem 1rem;
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-item:hover {
|
.table-flush {
|
||||||
background-color: #f8f9fa;
|
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>
|
</style>
|
||||||
|
|||||||
@ -13,6 +13,12 @@
|
|||||||
:is-active="activeTab === 'info'"
|
:is-active="activeTab === 'info'"
|
||||||
@click="$emit('change-tab', '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
|
<TabNavigationItem
|
||||||
icon="fas fa-users"
|
icon="fas fa-users"
|
||||||
label="Contacts"
|
label="Contacts"
|
||||||
|
|||||||
@ -12,8 +12,8 @@
|
|||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
<div class="modal-header">
|
<div class="modal-header">
|
||||||
<h5 class="modal-title">
|
<h5 class="modal-title">
|
||||||
<i class="fas fa-user-plus me-2"></i>
|
<i :class="isModification ? 'fas fa-edit me-2' : 'fas fa-user-plus me-2'"></i>
|
||||||
Ajouter un contact
|
{{ isModification ? 'Modifier le contact' : 'Ajouter un contact' }}
|
||||||
</h5>
|
</h5>
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
@ -135,7 +135,7 @@
|
|||||||
:disabled="contactIsLoading"
|
:disabled="contactIsLoading"
|
||||||
>
|
>
|
||||||
<i class="fas fa-save me-1"></i>
|
<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>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -168,10 +168,18 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
isModification: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
contact: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// Emits
|
// Emits
|
||||||
const emit = defineEmits(["close", "contact-created"]);
|
const emit = defineEmits(["close", "contact-created", "contact-modified"]);
|
||||||
|
|
||||||
// State
|
// State
|
||||||
const errors = reactive({});
|
const errors = reactive({});
|
||||||
@ -193,6 +201,21 @@ watch(
|
|||||||
{ immediate: true }
|
{ 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
|
// Methods
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
resetForm();
|
resetForm();
|
||||||
@ -296,7 +319,12 @@ const submitForm = async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Emit event - parent will handle the API call and loading state
|
// 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
|
// Close modal and reset form
|
||||||
closeModal();
|
closeModal();
|
||||||
|
|||||||
@ -1,20 +1,30 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<!-- Modal Component -->
|
||||||
<div
|
<div
|
||||||
v-if="isVisible"
|
class="modal fade"
|
||||||
class="modal fade show d-block"
|
:class="{ show: isVisible, 'd-block': isVisible }"
|
||||||
tabindex="-1"
|
tabindex="-1"
|
||||||
role="dialog"
|
role="dialog"
|
||||||
style="background-color: rgba(0, 0, 0, 0.5)"
|
:aria-hidden="!isVisible"
|
||||||
@click="handleBackdropClick"
|
|
||||||
>
|
>
|
||||||
<div
|
<div class="modal-dialog modal-dialog-centered modal-lg" role="document">
|
||||||
class="modal-dialog modal-dialog-centered modal-lg"
|
|
||||||
role="document"
|
|
||||||
@click.stop
|
|
||||||
>
|
|
||||||
<div class="modal-content">
|
<div class="modal-content">
|
||||||
|
<!-- Header -->
|
||||||
<div class="modal-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
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn-close"
|
class="btn-close"
|
||||||
@ -23,10 +33,12 @@
|
|||||||
:disabled="locationIsLoading"
|
:disabled="locationIsLoading"
|
||||||
></button>
|
></button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Body -->
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<!-- Error Alert -->
|
<!-- Error Alert -->
|
||||||
<div v-if="generalError" class="alert alert-danger" role="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 }}
|
{{ generalError }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -51,12 +63,19 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<label class="form-label">Type de localisation</label>
|
<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="office">Bureau</option>
|
||||||
<option value="warehouse">Entrepôt</option>
|
<option value="warehouse">Entrepôt</option>
|
||||||
<option value="store">Magasin</option>
|
<option value="store">Magasin</option>
|
||||||
<option value="other">Autre</option>
|
<option value="other">Autre</option>
|
||||||
</select>
|
</select>
|
||||||
|
<div v-if="errors.location_type" class="invalid-feedback">
|
||||||
|
{{ errors.location_type }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -150,7 +169,7 @@
|
|||||||
class="alert alert-warning"
|
class="alert alert-warning"
|
||||||
role="alert"
|
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
|
Au moins un champ d'adresse (adresse, code postal ou ville) doit
|
||||||
être renseigné.
|
être renseigné.
|
||||||
</div>
|
</div>
|
||||||
@ -162,8 +181,12 @@
|
|||||||
v-model="formData.phone"
|
v-model="formData.phone"
|
||||||
type="tel"
|
type="tel"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
|
:class="{ 'is-invalid': errors.phone }"
|
||||||
placeholder="+33 1 23 45 67 89"
|
placeholder="+33 1 23 45 67 89"
|
||||||
/>
|
/>
|
||||||
|
<div v-if="errors.phone" class="invalid-feedback">
|
||||||
|
{{ errors.phone }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 mb-3">
|
<div class="col-md-6 mb-3">
|
||||||
<label class="form-label">Email</label>
|
<label class="form-label">Email</label>
|
||||||
@ -171,8 +194,12 @@
|
|||||||
v-model="formData.email"
|
v-model="formData.email"
|
||||||
type="email"
|
type="email"
|
||||||
class="form-control"
|
class="form-control"
|
||||||
|
:class="{ 'is-invalid': errors.email }"
|
||||||
placeholder="contact@exemple.fr"
|
placeholder="contact@exemple.fr"
|
||||||
/>
|
/>
|
||||||
|
<div v-if="errors.email" class="invalid-feedback">
|
||||||
|
{{ errors.email }}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -230,13 +257,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
<div class="modal-footer">
|
<div class="modal-footer">
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
class="btn btn-secondary"
|
class="btn btn-outline-secondary"
|
||||||
@click="closeModal"
|
@click="closeModal"
|
||||||
:disabled="locationIsLoading"
|
:disabled="locationIsLoading"
|
||||||
>
|
>
|
||||||
|
<i class="fas fa-times me-1"></i>
|
||||||
Annuler
|
Annuler
|
||||||
</button>
|
</button>
|
||||||
<button
|
<button
|
||||||
@ -245,20 +275,36 @@
|
|||||||
@click="handleSubmit"
|
@click="handleSubmit"
|
||||||
:disabled="locationIsLoading || !isFormValid"
|
:disabled="locationIsLoading || !isFormValid"
|
||||||
>
|
>
|
||||||
|
<i class="fas fa-save me-1"></i>
|
||||||
<span
|
<span
|
||||||
v-if="locationIsLoading"
|
v-if="locationIsLoading"
|
||||||
class="spinner-border spinner-border-sm me-2"
|
class="spinner-border spinner-border-sm me-2"
|
||||||
></span>
|
></span>
|
||||||
{{ locationIsLoading ? "Création..." : "Ajouter" }}
|
{{
|
||||||
|
locationIsLoading
|
||||||
|
? isModification
|
||||||
|
? "Modification..."
|
||||||
|
: "Création..."
|
||||||
|
: isModification
|
||||||
|
? "Modifier"
|
||||||
|
: "Ajouter"
|
||||||
|
}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Backdrop -->
|
||||||
|
<div
|
||||||
|
v-if="isVisible"
|
||||||
|
class="modal-backdrop fade show"
|
||||||
|
@click="closeModal"
|
||||||
|
></div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, watch, computed, nextTick } from "vue";
|
import { ref, reactive, watch, computed, onMounted, onUnmounted } from "vue";
|
||||||
import { defineProps, defineEmits } from "vue";
|
import { defineProps, defineEmits } from "vue";
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
@ -274,15 +320,28 @@ const props = defineProps({
|
|||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
},
|
},
|
||||||
|
isModification: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
|
location: {
|
||||||
|
type: Object,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
errors: {
|
errors: {
|
||||||
type: Object,
|
type: Object,
|
||||||
default: () => ({}),
|
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: "",
|
name: "",
|
||||||
location_type: "office",
|
location_type: "office",
|
||||||
address_line1: "",
|
address_line1: "",
|
||||||
@ -300,11 +359,7 @@ const formData = ref({
|
|||||||
|
|
||||||
// Computed properties
|
// Computed properties
|
||||||
const showAddressWarning = computed(() => {
|
const showAddressWarning = computed(() => {
|
||||||
return (
|
return !formData.address_line1 && !formData.postal_code && !formData.city;
|
||||||
!formData.value.address_line1 &&
|
|
||||||
!formData.value.postal_code &&
|
|
||||||
!formData.value.city
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const generalError = computed(() => {
|
const generalError = computed(() => {
|
||||||
@ -312,7 +367,6 @@ const generalError = computed(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const isFormValid = computed(() => {
|
const isFormValid = computed(() => {
|
||||||
// At least one address field should be filled
|
|
||||||
return !showAddressWarning.value;
|
return !showAddressWarning.value;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -320,23 +374,47 @@ const isFormValid = computed(() => {
|
|||||||
watch(
|
watch(
|
||||||
() => props.clientId,
|
() => props.clientId,
|
||||||
(newVal) => {
|
(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(
|
watch(
|
||||||
() => props.isVisible,
|
() => props.isVisible,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
// Clear errors when modal opens
|
|
||||||
emit("clear-errors");
|
emit("clear-errors");
|
||||||
|
if (!props.isModification) {
|
||||||
|
resetForm();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
// Methods
|
// Methods
|
||||||
const resetForm = () => {
|
const resetForm = () => {
|
||||||
formData.value = {
|
Object.assign(formData, {
|
||||||
name: "",
|
name: "",
|
||||||
location_type: "office",
|
location_type: "office",
|
||||||
address_line1: "",
|
address_line1: "",
|
||||||
@ -350,8 +428,7 @@ const resetForm = () => {
|
|||||||
gps_lng: null,
|
gps_lng: null,
|
||||||
is_default: false,
|
is_default: false,
|
||||||
client_id: props.clientId,
|
client_id: props.clientId,
|
||||||
};
|
});
|
||||||
emit("clear-errors");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const closeModal = () => {
|
const closeModal = () => {
|
||||||
@ -359,34 +436,30 @@ const closeModal = () => {
|
|||||||
emit("close");
|
emit("close");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleBackdropClick = (event) => {
|
|
||||||
if (event.target === event.currentTarget) {
|
|
||||||
closeModal();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!isFormValid.value) {
|
if (!isFormValid.value) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate GPS coordinates if provided
|
// Validate GPS coordinates if provided
|
||||||
if (formData.value.gps_lat !== null) {
|
if (formData.gps_lat !== null) {
|
||||||
const lat = parseFloat(formData.value.gps_lat);
|
const lat = parseFloat(formData.gps_lat);
|
||||||
if (isNaN(lat) || lat < -90 || lat > 90) {
|
if (isNaN(lat) || lat < -90 || lat > 90) {
|
||||||
emit("location-created", {
|
emit("clear-errors");
|
||||||
...formData.value,
|
emit(props.isModification ? "location-modified" : "location-created", {
|
||||||
|
...formData,
|
||||||
errors: { gps_lat: "La latitude doit être comprise entre -90 et 90." },
|
errors: { gps_lat: "La latitude doit être comprise entre -90 et 90." },
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formData.value.gps_lng !== null) {
|
if (formData.gps_lng !== null) {
|
||||||
const lng = parseFloat(formData.value.gps_lng);
|
const lng = parseFloat(formData.gps_lng);
|
||||||
if (isNaN(lng) || lng < -180 || lng > 180) {
|
if (isNaN(lng) || lng < -180 || lng > 180) {
|
||||||
emit("location-created", {
|
emit("clear-errors");
|
||||||
...formData.value,
|
emit(props.isModification ? "location-modified" : "location-created", {
|
||||||
|
...formData,
|
||||||
errors: {
|
errors: {
|
||||||
gps_lng: "La longitude doit être comprise entre -180 et 180.",
|
gps_lng: "La longitude doit être comprise entre -180 et 180.",
|
||||||
},
|
},
|
||||||
@ -396,9 +469,10 @@ const handleSubmit = async () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Validate country code if provided
|
// Validate country code if provided
|
||||||
if (formData.value.country_code && formData.value.country_code.length !== 2) {
|
if (formData.country_code && formData.country_code.length !== 2) {
|
||||||
emit("location-created", {
|
emit("clear-errors");
|
||||||
...formData.value,
|
emit(props.isModification ? "location-modified" : "location-created", {
|
||||||
|
...formData,
|
||||||
errors: {
|
errors: {
|
||||||
country_code: "Le code pays doit contenir exactement 2 caractères.",
|
country_code: "Le code pays doit contenir exactement 2 caractères.",
|
||||||
},
|
},
|
||||||
@ -408,43 +482,127 @@ const handleSubmit = async () => {
|
|||||||
|
|
||||||
// Clean up data before sending
|
// Clean up data before sending
|
||||||
const submitData = {
|
const submitData = {
|
||||||
...formData.value,
|
...formData,
|
||||||
gps_lat: formData.value.gps_lat || null,
|
gps_lat: formData.gps_lat || null,
|
||||||
gps_lng: formData.value.gps_lng || null,
|
gps_lng: formData.gps_lng || null,
|
||||||
name: formData.value.name || null,
|
name: formData.name || null,
|
||||||
address_line1: formData.value.address_line1 || null,
|
address_line1: formData.address_line1 || null,
|
||||||
address_line2: formData.value.address_line2 || null,
|
address_line2: formData.address_line2 || null,
|
||||||
postal_code: formData.value.postal_code || null,
|
postal_code: formData.postal_code || null,
|
||||||
city: formData.value.city || null,
|
city: formData.city || null,
|
||||||
country_code: formData.value.country_code || "FR",
|
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>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.modal.show {
|
.modal {
|
||||||
display: block;
|
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 {
|
.form-label {
|
||||||
font-weight: 600;
|
font-weight: 500;
|
||||||
font-size: 0.875rem;
|
color: #495057;
|
||||||
margin-bottom: 0.5rem;
|
margin-bottom: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form-control,
|
.form-control,
|
||||||
.form-select {
|
.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 {
|
.invalid-feedback {
|
||||||
display: block;
|
font-size: 0.875rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.alert {
|
.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 {
|
.form-text {
|
||||||
@ -455,20 +613,4 @@ const handleSubmit = async () => {
|
|||||||
cursor: not-allowed;
|
cursor: not-allowed;
|
||||||
opacity: 0.6;
|
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>
|
</style>
|
||||||
|
|||||||
@ -328,14 +328,34 @@
|
|||||||
<div class="card-header pb-0">
|
<div class="card-header pb-0">
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
<h6 class="mb-0">Liste des contacts</h6>
|
<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
|
<i class="fas fa-plus me-1"></i>Ajouter un contact
|
||||||
</button>
|
</SoftButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div v-if="contacts_client.length > 0" class="table-responsive">
|
<client-contacts-tab
|
||||||
<table class="table align-items-center mb-0">
|
: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>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="text-uppercase text-secondary text-xxs font-weight-bolder opacity-7">
|
<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 { useRoute } from 'vue-router';
|
||||||
import { useClientStore } from '@/stores/clientStore';
|
import { useClientStore } from '@/stores/clientStore';
|
||||||
import { useContactStore } from '@/stores/contactStore';
|
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 route = useRoute();
|
||||||
const clientStore = useClientStore();
|
const clientStore = useClientStore();
|
||||||
@ -477,6 +500,10 @@ const activeTab = ref('overview');
|
|||||||
const clientAvatar = ref(null);
|
const clientAvatar = ref(null);
|
||||||
const fileInput = ref(null);
|
const fileInput = ref(null);
|
||||||
|
|
||||||
|
const contactModalIsVisible = ref(false);
|
||||||
|
const isModification = ref(false);
|
||||||
|
const selectedContact = ref(null);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (client_id) {
|
if (client_id) {
|
||||||
await clientStore.fetchClient(Number(client_id));
|
await clientStore.fetchClient(Number(client_id));
|
||||||
@ -485,6 +512,43 @@ onMounted(async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Methods
|
// 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) => {
|
const getInitials = (name) => {
|
||||||
if (!name) return '?';
|
if (!name) return '?';
|
||||||
return name
|
return name
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
:location-loading="clientLocationStore.isLoading"
|
:location-loading="clientLocationStore.isLoading"
|
||||||
@update-the-client="updateClient"
|
@update-the-client="updateClient"
|
||||||
@add-new-contact="createNewContact"
|
@add-new-contact="createNewContact"
|
||||||
|
@updating-contact="updateContact"
|
||||||
@add-new-location="createNewLocation"
|
@add-new-location="createNewLocation"
|
||||||
@modify-location="modifyLocation"
|
@modify-location="modifyLocation"
|
||||||
@remove-location="removeLocation"
|
@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) => {
|
const createNewLocation = async (data) => {
|
||||||
try {
|
try {
|
||||||
await clientLocationStore.createClientLocation(data);
|
await clientLocationStore.createClientLocation(data);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user