fix chat view

This commit is contained in:
amazuecos
2025-04-02 22:24:32 +02:00
parent 69f6d6cbeb
commit 9cbbddcc1c
11 changed files with 62 additions and 54 deletions

View File

@ -151,7 +151,7 @@ class Users extends \App\Controllers\GoBaseController
foreach ($chatDepartments as $chatDepartment) {
$this->chat_department_user_model->insert([
"user_id" => $id,
"chat_department_id" => $this->chat_department_model->where("name", $chatDepartment)->first()["id"]
"chat_department_id" => $this->chat_department_model->where("name", $chatDepartment)->first()->id
]);
}

View File

@ -72,13 +72,15 @@ class ChatService extends BaseService
$cliente_contacto = $this->clienteContactoModel->find($data["client"]);
if ($cliente_contacto) {
$userClienteContacto = $cliente_contacto->cliente()->user();
$cliente_in_department = $this->chatDepartmentUserModel
->where('chat_department_id', $chatDepartmentId)
->where('user_id', $userClienteContacto->id)
->where($this->modelFkMap[$model], $modelId)
->first();
if ($cliente_in_department == null) {
$this->chatDepartmentUserModel->insert(['chat_department_id' => $chatDepartmentId, 'user_id' => $userClienteContacto->id, $this->modelFkMap[$model] => $modelId]);
if ($userClienteContacto) {
$cliente_in_department = $this->chatDepartmentUserModel
->where('chat_department_id', $chatDepartmentId)
->where('user_id', $userClienteContacto->id)
->where($this->modelFkMap[$model], $modelId)
->first();
if ($cliente_in_department == null) {
$this->chatDepartmentUserModel->insert(['chat_department_id' => $chatDepartmentId, 'user_id' => $userClienteContacto->id, $this->modelFkMap[$model] => $modelId]);
}
}
}
}
@ -165,7 +167,7 @@ class ChatService extends BaseService
);
return true;
}
public function getHebras(string $model, int $modelId): array
{
$chats = $this->chatModel->where('chat_department_id', null)

View File

@ -1,6 +1,6 @@
<div class="col-md-12" id="chat-factura" data-id="<?= $modelId ?>">
<div class="container-xxl flex-grow-1 container-p-y" id="chat-factura" data-id="<?= $modelId ?>">
<div class="app-chat card overflow-hidden">
<div class="app-chat card overflow-hidden border">
<div class="row g-0">
<!-- Chat & Contacts -->

View File

@ -13,19 +13,19 @@
<div class="nav-align-top">
<ul class="nav nav-pills mb-4" role="tablist">
<li class="nav-item">
<button type="button" class="nav-link <?=auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta') ? "" : "active" ?>" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false"><?=lang('Chat.messages_client')?></button>
<button type="button" class="nav-link <?=!auth()->user()->inGroup('cliente-editor','cliente') ? "" : "active" ?>" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false"><?=lang('Chat.messages_client')?></button>
</li>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<?php if (!auth()->user()->inGroup('cliente-editor','cliente')) { ?>
<li class="nav-item">
<button type="button" class="nav-link active" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-internal-messages" aria-controls="navs-pills-top-internal-messages" aria-selected="false"><?=lang('Chat.messages_internal')?></button>
</li>
<?php } ?>
</ul>
<div class="tab-content">
<div class="tab-pane fade <?=auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta') ? "" : "show active" ?>" id="navs-pills-top-chat" role="tabpanel">
<div class="tab-pane fade <?=!auth()->user()->inGroup('cliente-editor','cliente') ? "" : "show active" ?>" id="navs-pills-top-chat" role="tabpanel">
<?= view("themes/vuexy/components/chat_factura", data: ["modelId" => $modelId,"type" => "factura"]) ?>
</div>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<?php if (!auth()->user()->inGroup('cliente-editor','cliente')) { ?>
<div class="tab-pane fade show active" id="navs-pills-top-internal-messages" role="tabpanel">
<?= view("themes/vuexy/components/internal_messages", data: ["modelId" => $modelId,"type" => "factura"]) ?>
</div>

View File

@ -13,19 +13,19 @@
<div class="nav-align-top">
<ul class="nav nav-pills mb-4" role="tablist">
<li class="nav-item">
<button type="button" class="nav-link <?=auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta') ? "" : "active" ?>" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false"><?=lang('Chat.messages_client')?></button>
<button type="button" class="nav-link <?=!auth()->user()->inGroup('cliente-editor','cliente') ? "" : "active" ?>" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false"><?=lang('Chat.messages_client')?></button>
</li>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<?php if (!auth()->user()->inGroup('cliente-editor','cliente')) { ?>
<li class="nav-item">
<button type="button" class="nav-link active" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-internal-messages" aria-controls="navs-pills-top-internal-messages" aria-selected="false"><?=lang('Chat.messages_internal')?></button>
</li>
<?php } ?>
</ul>
<div class="tab-content">
<div class="tab-pane fade <?=auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta') ? "" : "show active" ?>" id="navs-pills-top-chat" role="tabpanel">
<div class="tab-pane fade <?=!auth()->user()->inGroup('cliente-editor','cliente') ? "" : "show active" ?>" id="navs-pills-top-chat" role="tabpanel">
<?= view("themes/vuexy/components/chat_pedido", data: ["modelId" => $modelId, "type" => "pedido"]) ?>
</div>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<?php if (!auth()->user()->inGroup('cliente-editor','cliente')) { ?>
<div class="tab-pane fade show active" id="navs-pills-top-internal-messages" role="tabpanel">
<?= view("themes/vuexy/components/internal_messages", data: ["modelId" => $modelId, "type" => "pedido"]) ?>
</div>

View File

@ -13,19 +13,19 @@
<div class="nav-align-top">
<ul class="nav nav-pills mb-4" role="tablist">
<li class="nav-item">
<button type="button" class="nav-link <?=auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta') ? "" : "active" ?>" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false"><?=lang('Chat.messages_client')?></button>
</li>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<li class="nav-item">
<button type="button" class="nav-link active" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-internal-messages" aria-controls="navs-pills-top-internal-messages" aria-selected="false"><?=lang('Chat.messages_internal')?></button>
<button type="button" class="nav-link <?= !auth()->user()->inGroup('cliente-editor','cliente') ? "" : "active" ?>" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-chat" aria-controls="navs-pills-top-internal-chat" aria-selected="false"><?= lang('Chat.messages_client') ?></button>
</li>
<?php if (!auth()->user()->inGroup('cliente-editor','cliente')) { ?>
<li class="nav-item">
<button type="button" class="nav-link active" role="tab" data-bs-toggle="tab" data-bs-target="#navs-pills-top-internal-messages" aria-controls="navs-pills-top-internal-messages" aria-selected="false"><?= lang('Chat.messages_internal') ?></button>
</li>
<?php } ?>
</ul>
<div class="tab-content">
<div class="tab-pane fade <?=auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta') ? "" : "show active" ?>" id="navs-pills-top-chat" role="tabpanel">
<div class="tab-pane fade <?= !auth()->user()->inGroup('cliente-editor','cliente') ? "" : "show active" ?>" id="navs-pills-top-chat" role="tabpanel">
<?= view("themes/vuexy/components/chat_presupuesto", data: ["modelId" => $modelId, "type" => "presupuesto"]) ?>
</div>
<?php if (auth()->user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
<?php if (!auth()->user()->inGroup('cliente-editor','cliente')) { ?>
<div class="tab-pane fade show active" id="navs-pills-top-internal-messages" role="tabpanel">
<?= view("themes/vuexy/components/internal_messages", data: ["modelId" => $modelId, "type" => "presupuesto"]) ?>
</div>

View File

@ -1,6 +1,6 @@
<div class="col-md-12" id="chat-pedido" data-id="<?= $modelId ?>">
<div class="container-xxl flex-grow-1 container-p-y" id="chat-pedido" data-id="<?= $modelId ?>">
<div class="app-chat card overflow-hidden">
<div class="app-chat card overflow-hidden border">
<div class="row g-0">
<!-- Chat & Contacts -->

View File

@ -1,4 +1,4 @@
<div class="col-md-12" id="chat-presupuesto" data-id="<?= $modelId ?>">
<div class="container-xxl flex-grow-1 container-p-y" id="chat-presupuesto" data-id="<?= $modelId ?>">
<div class="app-chat card overflow-hidden border">
<div class="row g-0">
@ -96,7 +96,7 @@
</div>
</div>
</div>
<div class="chat-history-body bg-body ">
<div class="chat-history-body bg-body">
<div class="d-flex justify-content-center chat-loader">
<div class="sk-wave sk-primary ">
<div class="sk-wave-rect"></div>

View File

@ -15,14 +15,16 @@ const chatContactsBody = $('.app-chat-contacts .sidebar-body'),
if (chatContactsBody.length) {
new PerfectScrollbar(chatContactsBody[0], {
wheelPropagation: false,
suppressScrollX: true
suppressScrollX: true,
scrollingThreshold : 200,
});
}
if (chatHistoryBody.length) {
new PerfectScrollbar(chatHistoryBody[0], {
new PerfectScrollbar(document.querySelector('.chat-history-body'), {
wheelPropagation: false,
suppressScrollX: true
suppressScrollX: true,
scrollingThreshold : 200,
});
}