+
@@ -101,19 +118,23 @@
diff --git a/ci4/app/Views/themes/vuexy/components/chat_pedido.php b/ci4/app/Views/themes/vuexy/components/chat_pedido.php
index d6a5d1db..b629f638 100644
--- a/ci4/app/Views/themes/vuexy/components/chat_pedido.php
+++ b/ci4/app/Views/themes/vuexy/components/chat_pedido.php
@@ -1,9 +1,5 @@
+ placeholder="= lang('Chat.write_message_placeholder') ?>" />
-
-
- Enviar
-
-
-
- Enviar
-
+ user()->inGroup('admin')): ?>
+
+
+
+
+
-user()->inGroup('admin')) { ?>
-
-
-
-
+
@@ -30,13 +26,20 @@
+
+ user()->inGroup('admin')): ?>
+
+
+
+
+ Departamentos
-
-
-
+
+
+ user()->inGroup('admin')): ?>
+
+
+
+
+
+
+
+
-
@@ -79,7 +97,7 @@
-
+
@@ -98,19 +116,21 @@
diff --git a/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php b/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php
index 20877108..92b10484 100644
--- a/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php
+++ b/ci4/app/Views/themes/vuexy/components/chat_presupuesto.php
@@ -1,9 +1,5 @@
+ placeholder="= lang('Chat.write_message_placeholder') ?>" />
-
-
-
- Enviar
-
-
-
- Enviar
-
+ user()->inGroup('admin')): ?>
+
+
+
+
- user()->inGroup('admin')) { ?>
-
+
+
+
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/components/tables/chat_departments_table.php b/ci4/app/Views/themes/vuexy/components/tables/chat_departments_table.php
new file mode 100644
index 00000000..e5696838
--- /dev/null
+++ b/ci4/app/Views/themes/vuexy/components/tables/chat_departments_table.php
@@ -0,0 +1,13 @@
+
+
+
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/components/tables/messages_table.php b/ci4/app/Views/themes/vuexy/components/tables/messages_table.php
index 22456941..17316fda 100644
--- a/ci4/app/Views/themes/vuexy/components/tables/messages_table.php
+++ b/ci4/app/Views/themes/vuexy/components/tables/messages_table.php
@@ -4,10 +4,20 @@
= lang('Chat.datatable_messages.created_at') ?>
= lang('Chat.datatable_messages.updated_at') ?>
= lang('Chat.datatable_messages.title') ?>
+ = lang('Chat.datatable_messages.message') ?>
= lang('Chat.datatable_messages.creator') ?>
= lang('Chat.datatable_messages.viewed') ?>
= lang('Basic.global.Action') ?>
+
+
+
+
+
+
+
+
+
diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/messages/configView.php b/ci4/app/Views/themes/vuexy/form/configuracion/messages/configView.php
new file mode 100644
index 00000000..20c7e3a0
--- /dev/null
+++ b/ci4/app/Views/themes/vuexy/form/configuracion/messages/configView.php
@@ -0,0 +1,54 @@
+= $this->include('themes/_commonPartialsBs/select2bs5') ?>
+= $this->include('themes/_commonPartialsBs/datatables') ?>
+= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
+= $this->extend('themes/vuexy/main/defaultlayout') ?>
+
+
+= $this->section('content'); ?>
+
+
-
-
-
+
@@ -29,6 +25,14 @@
+
@@ -63,15 +67,29 @@
+ user()->inGroup('admin')): ?>
+
+
+
+
+
+ Departamentos
+ user()->inGroup('admin')): ?>
+
+
diff --git a/ci4/app/Views/themes/vuexy/components/forms/chat_department.php b/ci4/app/Views/themes/vuexy/components/forms/chat_department.php
new file mode 100644
index 00000000..07ff5bee
--- /dev/null
+++ b/ci4/app/Views/themes/vuexy/components/forms/chat_department.php
@@ -0,0 +1,46 @@
+
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/components/tables/chat_department_users_table.php b/ci4/app/Views/themes/vuexy/components/tables/chat_department_users_table.php
new file mode 100644
index 00000000..1a636804
--- /dev/null
+++ b/ci4/app/Views/themes/vuexy/components/tables/chat_department_users_table.php
@@ -0,0 +1,12 @@
+
+
+
+
+
+
+
-
@@ -97,19 +115,22 @@
-
-
+ placeholder="= lang('Chat.write_message_placeholder') ?>" />
+ user()->inGroup('admin')): ?>
+
+
+
+
-
-
- Enviar
-
-
-
- Enviar
-
| = lang('Chat.datatable_department_users.name') ?> | += lang('Chat.datatable_department_users.user') ?> | += lang('Basic.global.Action') ?> | +
|---|
| # | += lang('Chat.datatable_departments.name') ?> | += lang('Chat.datatable_departments.description') ?> | += lang('Basic.global.Action') ?> | +
|---|
+
+
+= $this->endSection() ?>
+
+= $this->section('css') ?>
+
+
+
+= $this->endSection() ?>
+= $this->section("additionalExternalJs") ?>
+
+
+
+
+
+
+
+= $this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/configuracion/messages/editChatDepartmentForm.php b/ci4/app/Views/themes/vuexy/form/configuracion/messages/editChatDepartmentForm.php
new file mode 100644
index 00000000..1e7d0b05
--- /dev/null
+++ b/ci4/app/Views/themes/vuexy/form/configuracion/messages/editChatDepartmentForm.php
@@ -0,0 +1,38 @@
+= $this->include('themes/_commonPartialsBs/select2bs5') ?>
+= $this->include('themes/_commonPartialsBs/datatables') ?>
+= $this->include('themes/_commonPartialsBs/_confirm2delete') ?>
+= $this->extend('themes/vuexy/main/defaultlayout') ?>
+
+
+= $this->section('content'); ?>
+
+
+
+
+
+
+
+
+
+
+ = lang('Chat.message_configuration') ?>
+
+ = view('themes/_commonPartialsBs/_alertBoxes'); ?>
+
+ = lang('Chat.store_department') ?>
+
+
+ = view("themes/vuexy/components/tables/chat_departments_table", ["id" => "tableChatDepartments"]) ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = $this->endSection() ?>
+
+ = $this->section('css') ?>
+
+
+
+ = $this->endSection() ?>
+ = $this->section("additionalExternalJs") ?>
+
+
+
+
+
+
+ = $this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/mensajesView.php b/ci4/app/Views/themes/vuexy/form/mensajes/mensajesView.php
index 07428fcb..3ef4954e 100644
--- a/ci4/app/Views/themes/vuexy/form/mensajes/mensajesView.php
+++ b/ci4/app/Views/themes/vuexy/form/mensajes/mensajesView.php
@@ -10,11 +10,11 @@
+
+
+
+
+ = $chat_department->display ?>
+
+ = view("themes/vuexy/components/forms/chat_department", ["id" => "chatDepartmentForm", "entity" => $chat_department]) ?>
+
+
+ -
-
- +
- - +
- @@ -25,18 +25,8 @@
-
- user()->inGroup('admin')) { ?>
-
-
-
-
- = view("themes/vuexy/components/tables/messages_table", ["id" => "tableMessages"]) ?>
-
-
-
-
+
= view("themes/vuexy/components/tables/messages_table", ["id" => "tablePresupuestoMessages"]) ?>
@@ -60,8 +50,7 @@
= $this->section('css') ?>
-
-
+
= $this->endSection() ?>
= $this->section("additionalExternalJs") ?>
@@ -70,5 +59,7 @@
+
= $this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php
index 4b6df88a..cb4e3a1f 100644
--- a/ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php
+++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChat.php
@@ -23,5 +23,7 @@
+
+
= $this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatFactura.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatFactura.php
index ff05265c..ac6cd19a 100644
--- a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatFactura.php
+++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatFactura.php
@@ -18,6 +18,8 @@
= $this->section('css') ?>
+
+
@@ -26,5 +28,7 @@
+
+
= $this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatInternal.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatInternal.php
index 0152bb79..a25ee198 100644
--- a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatInternal.php
+++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatInternal.php
@@ -15,6 +15,8 @@
= $this->section('css') ?>
+
+
@@ -24,5 +26,5 @@
-
+
= $this->endSection() ?>
diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPedido.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPedido.php
index db0e52d1..110ea521 100644
--- a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPedido.php
+++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPedido.php
@@ -15,13 +15,12 @@
= $this->section('css') ?>
-
-
+
= $this->endSection() ?>
= $this->section("additionalExternalJs") ?>
-
-
+
+
= $this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPresupuesto.php b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPresupuesto.php
index 8eda11d4..90a632f1 100644
--- a/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPresupuesto.php
+++ b/ci4/app/Views/themes/vuexy/form/mensajes/messageChatPresupuesto.php
@@ -15,13 +15,12 @@
= $this->section('css') ?>
-
-
+
= $this->endSection() ?>
= $this->section("additionalExternalJs") ?>
-
-
+
+
= $this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/mail/mail_layout.php b/ci4/app/Views/themes/vuexy/mail/mail_layout.php
new file mode 100644
index 00000000..b4654e4b
--- /dev/null
+++ b/ci4/app/Views/themes/vuexy/mail/mail_layout.php
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = $this->renderSection('css') ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/mail/messageNotification.php b/ci4/app/Views/themes/vuexy/mail/messageNotification.php
new file mode 100644
index 00000000..7c6557c2
--- /dev/null
+++ b/ci4/app/Views/themes/vuexy/mail/messageNotification.php
@@ -0,0 +1,30 @@
+= $this->extend('themes/vuexy/mail/mail_layout') ?>
+
+= $this->section('content'); ?>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ = $header ?>
+ +
+
+
+ = $this->renderSection('content') ?>
+
+
+
+= $this->endSection() ?>
\ No newline at end of file
diff --git a/ci4/app/Views/themes/vuexy/main/defaultlayout.php b/ci4/app/Views/themes/vuexy/main/defaultlayout.php
index adc7e9e1..63230311 100644
--- a/ci4/app/Views/themes/vuexy/main/defaultlayout.php
+++ b/ci4/app/Views/themes/vuexy/main/defaultlayout.php
@@ -250,7 +250,7 @@ $picture = "/assets/img/default-user.png";
+
+ = $data->chat()->title ?>
+
+
+
+
+
+
+
+ = $data->user->first_name . " " . $data->user->last_name ?>
+ +
+
+ = $data->created_at ?>
+
+
+
+
+
+
+ = $data->message ?>
+
-
+
-
@@ -259,7 +259,7 @@ $picture = "/assets/img/default-user.png";
- + + = lang("App.menu_config_messages") ?> + + + \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js b/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js index 320a8126..d9c3cec7 100644 --- a/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js +++ b/httpdocs/assets/js/safekat/components/alerts/sweetAlert.js @@ -34,18 +34,19 @@ export const alertConfirmAction = (title, type = "primary") => { buttonsStyling: false }) } -export const alertSuccessMessage = (title, type = "primary") => { +export const alertSuccessMessage = (title, type = "primary", options = {}) => { return Swal.fire({ showCancelButton: false, showConfirmButton: false, title: title, text: title, icon: "success", - timer: 2000 + timer: 2000, + ...options, }) } -export const alertWarningMessage = (title, message, type = "primary") => { +export const alertWarningMessage = (title, message, type = "primary",options = {}) => { return Swal.fire({ title: title, text: message, @@ -70,8 +71,8 @@ export const toastPresupuestoSummary = (value, target = 'body') => { popup: 'bg-primary text-white', }, target: target, - width : "200px", - padding : '1px', + width: "200px", + padding: '1px', allowEscapeKey: false, showConfirmButton: false, timer: 0, @@ -79,7 +80,7 @@ export const toastPresupuestoSummary = (value, target = 'body') => { stopKeydownPropagation: false, }) } -export const alertSuccess = (value, target = 'body') => { +export const alertSuccess = (value, target = 'body',options = {}) => { return Swal.mixin({ toast: true, position: 'bottom-end', @@ -87,15 +88,16 @@ export const alertSuccess = (value, target = 'body') => { customClass: { popup: 'bg-success text-white', }, - icon : 'success', + icon: 'success', iconColor: 'white', target: target, showConfirmButton: false, - timer: 2000, + timer: 6000, timerProgressBar: true, + ...options, }) } -export const alertError = (value, target = 'body') => { +export const alertError = (value, target = 'body',options = {}) => { return Swal.mixin({ toast: true, position: 'bottom-end', @@ -103,15 +105,16 @@ export const alertError = (value, target = 'body') => { customClass: { popup: 'bg-danger text-white', }, - icon : 'error', + icon: 'error', iconColor: 'white', target: target, showConfirmButton: false, - timer: 2000, + timer: 6000, timerProgressBar: true, + ...options }) } -export const alertWarning = (value, target = 'body') => { +export const alertWarning = (value, target = 'body',options = {}) => { return Swal.mixin({ toast: true, position: 'bottom-end', @@ -119,11 +122,12 @@ export const alertWarning = (value, target = 'body') => { customClass: { popup: 'bg-warning text-white', }, - icon : 'warning', + icon: 'warning', iconColor: 'white', target: target, showConfirmButton: false, - timer: 2000, + timer: 6000, timerProgressBar: true, + ...options }) } \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/chat.js b/httpdocs/assets/js/safekat/components/chat.js index e572b1fc..6f941544 100644 --- a/httpdocs/assets/js/safekat/components/chat.js +++ b/httpdocs/assets/js/safekat/components/chat.js @@ -1,7 +1,7 @@ import Ajax from '../components/ajax.js' import Modal from './modal.js' import ClassSelect from './select2.js' - +import { alertConfirmAction, alertConfirmationDelete, alertError, alertSuccess } from "./alerts/sweetAlert.js" class Chat { @@ -12,14 +12,18 @@ class Chat { this.modelId = this.domItem.data("id") this.chatHistoryBody = this.domItem.find(".chat-history-body") this.sendBtnMessageDepartment = this.domItem.find("#send-msg-btn-deparment") + this.sendBtnMessageDepartmentClient = this.domItem.find("#send-msg-btn-deparment-client") this.sendBtnMessageInternal = this.domItem.find("#send-msg-btn-internal") this.chatSidebarLeftUserAbout = this.domItem.find('.chat-sidebar-left-user-about'), - this.messageInput = this.domItem.find(".message-input") + this.messageInput = this.domItem.find(".message-input") this.sideBar = this.domItem.find(".sidebar-body") + this.selectItem = this.domItem.find(".chat-search-client") + this.btnExitChat = this.domItem.find(".exit-chat") + this.btnSubscribeChat = this.domItem.find(".subscribe-chat") + this.chatDeparmentId = undefined this.searchInput = this.domItem.find(".chat-search-input") this.headers = {} - this.chatContactsBody = this.domItem.find('.app-chat-contacts .sidebar-body') this.chatContactListItems = [].slice.call( document.querySelectorAll('.chat-contact-list-item:not(.chat-contact-list-item-title)') @@ -52,6 +56,9 @@ class Chat { } this.sendBtnMessageDepartment.addClass("d-none") + this.btnExitChat.on('click', this._handleExitChatDepartment.bind(this)) + this.btnSubscribeChat.on('click', this._handleSubscribeChatDepartment.bind(this)) + this.sendBtnMessageInternal.addClass("d-none") if (this.chatContactsBody[0]) { this.scrollbarContacts = new PerfectScrollbar(this.chatContactsBody[0], { @@ -69,6 +76,7 @@ class Chat { } } initDirectMessage() { + this.chatType = "direct" this.modalNewParticipant = new Modal(this.domItem.find("#modalAddNewChatParticipant")) this.selectPlaceholder = { @@ -91,7 +99,7 @@ class Chat { this.selectParticipants.init() this.modalNewParticipant.toggle() }) - + this.selectParticipants.item.on("change", () => { if (this.selectParticipants.getVal().length > 0) { this.btnAddParticipantSubmit.removeClass("d-none") @@ -99,20 +107,39 @@ class Chat { this.btnAddParticipantSubmit.addClass("d-none") } }) - this.btnUpdateMessagesUnviewed.on("click",this._handleUpdateChatMessagesUnread.bind(this)) + this.btnUpdateMessagesUnviewed.on("click", this._handleUpdateChatMessagesUnread.bind(this)) this._handleGetChatDirect() - setInterval(this._handleReloadChatDirectMessages.bind(this),10000) + setInterval(this._handleReloadChatDirectMessages.bind(this), 10000) + } + initSelectClient() { + this.selectClientUser = new ClassSelect(this.selectItem, `/chat/direct/client/users/select/${this.chatType}/${this.modelId}`, "Seleccione contacto", true) + this.selectClientUser.init() + this.selectItem.on('change', () => { + if (this.selectClientUser.getVal()) { + this.sendBtnMessageDepartment.attr('disabled', null) + } else { + this.sendBtnMessageDepartment.attr('disabled', 'disabled') + } + }) + } initGeneral() { this.chatType = "general" this._handleGetChatList() this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this)) + this.sendBtnMessageDepartmentClient.on("click", this._sendMessage.bind(this)) + } initPresupuesto() { this.chatType = "presupuesto" this._handleGetChatList() this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this)) + this.sendBtnMessageDepartmentClient.on("click", this._sendMessage.bind(this)) + this.messageInput.on("keypress", this._sendMessagePressKey.bind(this)) + this.initSelectClient() + // setInterval(this._getChatMessage.bind(this), 10000) + } @@ -120,15 +147,22 @@ class Chat { this.chatType = "pedido" this._handleGetChatList() this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this)) + this.sendBtnMessageDepartmentClient.on("click", this._sendMessage.bind(this)) this.messageInput.on("keypress", this._sendMessagePressKey.bind(this)) + this.initSelectClient() + // setInterval(this._getChatMessage.bind(this), 10000) + + } initFactura() { this.chatType = "factura" this._handleGetChatList() this.sendBtnMessageDepartment.on("click", this._sendMessage.bind(this)) + this.sendBtnMessageDepartmentClient.on("click", this._sendMessage.bind(this)) this.messageInput.on("keypress", this._sendMessagePressKey.bind(this)) - + this.initSelectClient() + // setInterval(this._getChatMessage.bind(this), 10000) } initContacts() { this.chatType = "internal" @@ -166,7 +200,7 @@ class Chat { _handleGetChatList(event) { this.domItem.find(".chat-loader").removeClass("d-none") let ajax = new Ajax( - "/chat/departments", + `/chat/departments/${this.chatType}/${this.modelId}`, null, null, this._handleGetChatListSuccess.bind(this), @@ -179,7 +213,6 @@ class Chat { Object.values(data).map(row => { this.chatList.append(this._getContact(row)) this.chatDeparmentId = row.id - this._getChatTotalMessages(row.name) this.chatList.find(`#chat_${row.name}`).on("click", (event) => { $(".chat-contact-list-item").removeClass("active") $(event.currentTarget).parent().addClass("active") @@ -188,12 +221,15 @@ class Chat { this.domItem.find(".chat-history-header div.chat-contact-info h6").text(row.display) this.domItem.find(".chat-history-header div.chat-contact-info small.user-status").text(row.display) this._getChatMessage() - this._getChatTotalMessages(row.name) this._getChatDeparmentUsers() + }) }) - this.chatList.find(`#chat__produccion`).trigger("click"); + if (Object.values(data)) { + const firstDepartment = Object.values(data)[0] + this.chatList.find(`#chat_${firstDepartment.name}`).trigger("click"); + } } _handleGetChatListError(error) { console.error(error) @@ -202,7 +238,7 @@ class Chat { this.domItem.find("#chat-header-users").empty() this.domItem.find("#chat-header-dropdown-users").removeClass("d-none") let ajax = new Ajax( - `/chat/department/${this.chatDeparmentId}/users`, + `/chat/department/users/${this.chatType}/${this.chatDeparmentId}/${this.modelId}`, null, null, this._getChatDeparmentUsersSuccess.bind(this), @@ -212,31 +248,32 @@ class Chat { ajax.get() } _getChatDeparmentUsersSuccess(deparmentUsers) { - deparmentUsers.map((user) => { - this.domItem.find("#chat-header-users").append( - ` -
-
-
- - - ${user?.first_name?.charAt(0) ?? "?" - + user?.last_name?.charAt(0) ?? "?"} - ---- -
${user?.first_name ?? "" + " " + - user?.last_name ?? ""}
-- ${user.username} -
-
+ deparmentUsers.adminUsers.map(user => this.appendChatDepartmentUser(user))
+ deparmentUsers.externalUsers.map(user => this.appendChatDepartmentUser(user, 'warning', 'user'))
+ }
+ appendChatDepartmentUser(user, color = "primary", icon = "user") {
+ this.domItem.find("#chat-header-users").append(
`
- )
- })
+ -
+ + ++++
+
++${user?.first_name ?? "" + " " + + user?.last_name ?? ""}
++ ${user.username} +
+
+
+ `
+ )
}
_getChatDeparmentUsersError(err) { }
@@ -253,7 +290,7 @@ class Chat {
${row.display}
-
+
+ + ${e.avatar} ++++ ${numberOfMessages} + +
[${e.title}] ${e.chatDisplay}
+
+ `
+ )
+ }
+}
+const addDepartmentNotification = (e) => {
+ let numberOfMessages = e.unreadMessages
+ if (numberOfMessages > 0) {
+ $("#chat-notification-list").append(
+ `
+ -
+
+ + ${e.avatar} ++++ ${numberOfMessages} + +
[${e.title}] ${e.chatDisplay}
+
+ `
+ )
+ }
+}
-export const showNotificationMessages = (dom) => {
+const addNotificationsToDom = (data) =>
+{
+ $("#chat-notification-list").empty()
+ if (data.totalMessages > 0) {
+ $("#chat-message-notification-title").addClass("d-none")
+ $("#chat-notification-number").removeClass("d-none")
+ $("#chat-notification-number").text(data.totalMessages ?? 0)
+ } else {
+ $("#chat-message-notification-title").removeClass("d-none")
+ $("#chat-notification-number").addClass("d-none")
+ $("#chat-notification-number").text(0)
+ }
+ data.departmentNotifications?.map( e => {
+ addDepartmentNotification(e)}
+ )
+ data.internalNotifications?.map(e => {
+ addInternalNotification(e)}
+ )
+
+}
+export const showNotificationMessages = () => {
let ajax = new Ajax(
'/chat/notifications',
null,
null,
- (data) => {
- dom.empty()
- $("#chat-notification-number")
- if (data.totalMessages > 0) {
- $("#chat-message-notification-title").addClass("d-none")
- $("#chat-notification-number").removeClass("d-none")
- $("#chat-notification-number").text(data.totalMessages ?? 0)
- } else {
- $("#chat-message-notification-title").removeClass("d-none")
- $("#chat-notification-number").addClass("d-none")
- $("#chat-notification-number").text(0)
- }
- data?.internals?.map((e) => {
- let numberOfMessages = e.unreadMessages
- if (numberOfMessages > 0) {
- dom.append(
- `
- -
-
- - ${e.avatar} ---- ${numberOfMessages} - -
[${e.title}] ${e.chatDisplay}
-
- `
- )
- }
- })
- data?.chatPresupuestos?.map((e) => {
- let numberOfMessages = e.unreadMessages
- if (numberOfMessages > 0) {
- dom.append(
- `
- -
-
- - ${e.presupuestoId} ---- ${numberOfMessages} - -
[${e.title}] ${e.chatDisplay}
-
- `
- )
- }
- })
- data?.chatFacturas?.map((e) => {
- let numberOfMessages = e.unreadMessages
- if (numberOfMessages > 0) {
- dom.append(
- `
- -
-
- - ${e.facturaId} ---- ${numberOfMessages} - -
[${e.title}] ${e.chatDisplay}
-
- `
- )
- }
- })
- data?.chatPedidos?.map((e) => {
- let numberOfMessages = e.unreadMessages
- if (numberOfMessages > 0) {
- dom.append(
- `
- -
-
- - ${e.pedidoId} ---- ${numberOfMessages} - -
[${e.title}] ${e.chatDisplay}
-
- `
- )
- }
- })
-
- },
+ addNotificationsToDom,
(err) => { }
)
ajax.get()
@@ -829,104 +895,3 @@ export const showNotificationMessages = (dom) => {
export default Chat
-// // Seleccionar elementos del DOM
-// const chatContactsBody = document.querySelector('.app-chat-contacts .sidebar-body'),
-// chatContactListItems = [].slice.call(
-// document.querySelectorAll('.chat-contact-list-item:not(.chat-contact-list-item-title)')
-// ),
-// chatHistoryBody = document.querySelector('.chat-history-body'),
-// chatSidebarLeftUserAbout = document.querySelector('.chat-sidebar-left-user-about'),
-// messageInput = document.querySelector('.message-input'),
-// searchInput = document.querySelector('.chat-search-input'),
-// sendMsgBtn = document.querySelector('.send-msg-btn'); // Seleccionar el botón de envío de mensaje
-
-// // Inicializar PerfectScrollbar
-// if (chatContactsBody) {
-// new PerfectScrollbar(chatContactsBody, {
-// wheelPropagation: false,
-// suppressScrollX: true
-// });
-// }
-
-// if (chatHistoryBody) {
-// new PerfectScrollbar(chatHistoryBody, {
-// wheelPropagation: false,
-// suppressScrollX: true
-// });
-// }
-
-// // Función para desplazar el scroll al final
-// function scrollToBottom() {
-// if (chatHistoryBody) {
-// chatHistoryBody.scrollTo(0, chatHistoryBody.scrollHeight);
-// }
-// }
-// scrollToBottom();
-
-// // Seleccionar chat o contacto
-
-
-// // Filtrar chats
-// if (searchInput) {
-// searchInput.addEventListener('keyup', e => {
-// const searchValue = e.currentTarget.value.toLowerCase(),
-// chatListItem0 = document.querySelector('.chat-list-item-0'),
-// contactListItem0 = document.querySelector('.contact-list-item-0'),
-// searchChatListItems = [].slice.call(
-// document.querySelectorAll('#chat-list li:not(.chat-contact-list-item-title)')
-// ),
-// searchContactListItems = [].slice.call(
-// document.querySelectorAll('#contact-list li:not(.chat-contact-list-item-title)')
-// );
-
-// // Buscar en chats
-// const chatListItemsCount = searchChatContacts(searchChatListItems, searchValue);
-// // Mostrar u ocultar mensaje de "No se encontraron resultados" en chats
-// if (chatListItem0) {
-// chatListItem0.classList.toggle('d-none', chatListItemsCount !== 0);
-// }
-
-// // Buscar en contactos
-// const contactListItemsCount = searchChatContacts(searchContactListItems, searchValue);
-// // Mostrar u ocultar mensaje de "No se encontraron resultados" en contactos
-// if (contactListItem0) {
-// contactListItem0.classList.toggle('d-none', contactListItemsCount !== 0);
-// }
-// });
-// }
-
-// // Función para buscar en chats y contactos
-// function searchChatContacts(searchListItems, searchValue) {
-// let searchListItemsCount = 0;
-// searchListItems.forEach(searchListItem => {
-// const searchListItemText = searchListItem.textContent.toLowerCase();
-// const matchesSearch = searchListItemText.indexOf(searchValue) !== -1;
-
-// searchListItem.classList.toggle('d-flex', matchesSearch);
-// searchListItem.classList.toggle('d-none', !matchesSearch);
-
-// if (matchesSearch) {
-// searchListItemsCount++;
-// }
-// });
-
-// return searchListItemsCount;
-// }
-
-// // // Enviar mensaje
-// // if (sendMsgBtn) {
-// // sendMsgBtn.addEventListener('click', e => {
-// // e.preventDefault();
-// // if (messageInput.value) {
-// // const renderMsg = document.createElement('div');
-// // renderMsg.className = 'chat-message-text mt-2';
-// // renderMsg.innerHTML = ` - - - ${user.userFullName ?? user.userName} - - - - - - `) + $(`#dropdown-viewed-${chat_message_id}`) + .append(this.addDropUpItem(user)) } }); - } else { - $(`#dropdown-viewed-${chatId}`).append(`
- Visto `) } + // if (viewedNotifications.length > 0) { + + // viewedNotifications.forEach(user => { + // if (user.userFullName || user.userName) { + + // $(`#dropdown-viewed-${chat_message_id}`) + // .append(this.addDropUpItem(user)) + // } + + // }); + // } } handleDropUpError() { } - + addDropUpItem(user) + { + return ` +
- + + ${user.userFullName ?? user.userName} + + + + + `; + } } diff --git a/httpdocs/assets/js/safekat/components/forms/chatDepartmentForm.js b/httpdocs/assets/js/safekat/components/forms/chatDepartmentForm.js new file mode 100644 index 00000000..16d66d30 --- /dev/null +++ b/httpdocs/assets/js/safekat/components/forms/chatDepartmentForm.js @@ -0,0 +1,91 @@ +import ClassSelect from "../select2.js" +import { ChatDepartmentUserDatatable } from '../datatables/ChatDepartmentDatatable.js' +import Ajax from "../ajax.js" +import { alertConfirmAction, alertError, alertSuccess } from "../alerts/sweetAlert.js" + +class ChatDepartmentForm { + constructor(domItem) { + this.item = domItem + this.chatDepartmentId = this.item.data("id") + this.btnAddUserToDepartment = this.item.find("#add-user-admin-chat-department") + this.btnUpdate = this.item.find("#btn-chat-department-update") + this.chatDepartmentUsersDatatable = new ChatDepartmentUserDatatable($("#tableChatDepartmentUsers")) + this.seletChatDepartmentUserItem = this.item.find("#selectChatDepartmentUser") + this.seletChatDepartmentUser = new ClassSelect( + this.seletChatDepartmentUserItem, + `/chat/department/users/select/add/${this.chatDepartmentId}` + ) + } + init() { + this.seletChatDepartmentUser.init() + this.chatDepartmentUsersDatatable.init() + this.btnAddUserToDepartment.on('click', this._handleUserToDepartment.bind(this)) + this.btnUpdate.on("click", this._handleUpdateDepartment.bind(this)) + } + getFormData() { + return { + display: this.item.find("#chat-department-display").val(), + description: this.item.find("#chat-department-description").val() + } + } + updateFormData(data) { + this.item.find("#chat-department-display").val(data.display) + this.item.find("#chat-department-description").val(data.description) + } + _handleUserToDepartment() { + this.btnAddUserToDepartment.attr("disabled", "disabled") + const ajax = new Ajax("/chat/department/subscribe/admin/user", + { + user_id: this.seletChatDepartmentUser.getVal(), + chat_department_id: this.chatDepartmentId + }, + null, + this._handleUserToDepartmentSuccess.bind(this), + this._handleUserToDepartmentError.bind(this) + ) + if (this.seletChatDepartmentUser.getVal()) { + ajax.post(); + } else { + this.btnAddUserToDepartment.removeAttr("disabled") + } + } + _handleUserToDepartmentSuccess(response) { + this.btnAddUserToDepartment.removeAttr("disabled") + this.chatDepartmentUsersDatatable.datatable.ajax.reload() + alertSuccess(response.message).fire() + this.seletChatDepartmentUser.reset() + } + _handleUserToDepartmentError(response) { + alertError(response.message ?? "").fire() + this.btnAddUserToDepartment.removeAttr("disabled") + + } + _handleUpdateDepartment() { + this.btnUpdate.attr("disabled") + const ajax = new Ajax("/chat/department/update/" + this.chatDepartmentId, + this.getFormData(), + null, + this._handleUserToDepartmentSuccess.bind(this), + this._handleUserToDepartmentError.bind(this) + ) + if (this.getFormData()) { + ajax.post(); + } else { + this.btnUpdate.removeAttr("disabled") + } + } + __handleUpdateDepartmentSuccess(response) { + this.btnUpdate.removeAttr("disabled") + alertSuccess(response.message).fire() + this.updateFormData(response.data) + } + _handleUpdateDepartmentError(response) { + this.btnUpdate.removeAttr("disabled") + alertError(response.message ?? "").fire() + } + + + +} + +export default ChatDepartmentForm \ No newline at end of file diff --git a/httpdocs/assets/js/safekat/components/internalMessagesSection.js b/httpdocs/assets/js/safekat/components/internalMessagesSection.js index 751678a0..a761db22 100644 --- a/httpdocs/assets/js/safekat/components/internalMessagesSection.js +++ b/httpdocs/assets/js/safekat/components/internalMessagesSection.js @@ -5,8 +5,8 @@ import ClassSelect from "./select2.js" const getInitials = (name) => name.split(" ").map(e => e.charAt(0)).join("") const hebraList = (message) => `
-
+
@@ -346,7 +346,6 @@ $picture = "/assets/img/default-user.png";
-
diff --git a/ci4/app/Views/themes/vuexy/main/menus/configuracion_menu.php b/ci4/app/Views/themes/vuexy/main/menus/configuracion_menu.php
index 5fe14fba..5a3621f9 100644
--- a/ci4/app/Views/themes/vuexy/main/menus/configuracion_menu.php
+++ b/ci4/app/Views/themes/vuexy/main/menus/configuracion_menu.php
@@ -120,6 +120,13 @@ if (
+ user()->inGroup('admin') || auth()->user()->inGroup('beta')) { ?>
+
- ${row.totalMessages ?? 0}
+ ${row.countMessages}
`
@@ -265,7 +302,7 @@ class Chat {
null,
null,
(data) => {
- this.chatList.find(`#chat_${row_name} .messages-unread-contact`).text(data.count)
+
},
null
@@ -307,6 +344,7 @@ class Chat {
_getChatMessageSuccess(data) {
this.domItem.find(".chat-loader").addClass("d-none")
this._setBtnDeparment()
+ this.chatList.find(`#chat_${data.department.name} .messages-unread-contact`).text(data.count ?? 0)
if (data.messages) {
data.messages.map((m) => {
this._addChatMessage(m)
@@ -326,19 +364,18 @@ class Chat {
${chatMessage?.message}
+
-
${chatMessage?.user?.first_name + " " + chatMessage?.user?.last_name}
-
+
${chatMessage.created_at}
-
@@ -398,6 +435,7 @@ class Chat {
message: messageText,
chat_department_id: this.chatDeparmentId,
user: this.userId,
+ client: this.selectClientUser.getVal() ?? null,
model_id: this.modelId
}
if (messageText) {
@@ -415,6 +453,7 @@ class Chat {
_sendMessageSuccess(data) {
this.messageInput.val("")
this._getChatMessage(this.chatDeparmentId)
+ this._getChatDeparmentUsers()
}
_sendMessageError(err) {
console.error(err)
@@ -493,8 +532,6 @@ class Chat {
}
_handleGetSingleContactMessagesSuccess(data) {
try {
-
-
if (data) {
data.map((m) => {
this._addChatMessage(m)
@@ -647,7 +684,7 @@ class Chat {
}
_handleReloadChatDirectMessagesError(error) { }
_handleStoreChatDirectUsers() {
- const data = { "users": this.selectParticipants.getVal() ,"notification" : this.checkboxNotificationMessage.prop("checked")}
+ const data = { "users": this.selectParticipants.getVal(), "notification": this.checkboxNotificationMessage.prop("checked") }
this.domItem.find(".chat-loader").removeClass("d-none")
const ajax = new Ajax(
@@ -689,7 +726,7 @@ class Chat {
this._addChatDirectMessages(message)
this.messageInput.val("")
} catch (error) {
-
+
} finally {
this.scrollbarChatHistory.update()
this.chatHistoryBody[0].scrollTop = this.scrollbarChatHistory.containerHeight
@@ -708,11 +745,73 @@ class Chat {
)
ajax.post()
}
- _handleUpdateChatMessagesUnreadSuccess(){
+ _handleUpdateChatMessagesUnreadSuccess() {
this._handleReloadChatDirectMessages();
}
- _handleUpdateChatMessagesUnreadError(){}
+ _handleUpdateChatMessagesUnreadError() { }
+ _handleRequestExitChatDeparment() {
+ const ajax = new Ajax('/chat/department/user/' + this.chatDeparmentId,
+ {
+ model_fk: this.chatType + "_id",
+ model_id_fk: this.modelId
+ },
+ null,
+ (response) => {
+ if (response.status) {
+ alertSuccess(response.message).fire()
+ this._getChatDeparmentUsers()
+ } else {
+ alertError(response.message).fire()
+ }
+ },
+ (error) => {
+ alertError("Error")
+ }
+ )
+ ajax.delete();
+ }
+ _handleRequestSubscribeChatDeparment() {
+ const ajax = new Ajax('/chat/department/user',
+ {
+ chat_department_id: this.chatDeparmentId,
+ model_fk: this.chatType + "_id",
+ model_id_fk: this.modelId
+ },
+ null,
+ (response) => {
+ if (response.status) {
+ alertSuccess(response.message).fire()
+ this._getChatDeparmentUsers()
+ } else {
+ alertError(response.message).fire()
+ }
+ },
+ (error) => {
+ alertError("Error")
+ }
+
+ )
+ ajax.post();
+ }
+ _handleExitChatDepartment() {
+ if (this.chatDeparmentId) {
+ alertConfirmationDelete('¿Estás seguro de salir de la conversación?').then((result) => {
+ if (result.isConfirmed) {
+ this._handleRequestExitChatDeparment()
+ }
+ })
+ }
+ }
+ _handleSubscribeChatDepartment() {
+ if (this.chatDeparmentId) {
+ alertConfirmAction('¿Estás seguro de subscribirte al chat?').then((result) => {
+ if (result.isConfirmed) {
+ this._handleRequestSubscribeChatDeparment()
+ }
+ })
+ }
+ }
@@ -722,106 +821,73 @@ class Chat {
}
+const addInternalNotification = (e) => {
+ let numberOfMessages = e.unreadMessages
+ if (numberOfMessages > 0) {
+ $("#chat-notification-list").append(
+ `
+
- ${chatMessage?.user?.first_name.charAt(0) + chatMessage?.user?.last_name.charAt(0)}
+
+
${messageInput.value}
`; -// // const lastChatMessageWrapper = document.querySelector('li:last-child .chat-message-wrapper'); -// // if (lastChatMessageWrapper) { -// // lastChatMessageWrapper.appendChild(renderMsg); -// // } -// // messageInput.value = ''; -// // scrollToBottom(); -// // } -// // }); -// // } diff --git a/httpdocs/assets/js/safekat/components/datatables/ChatDepartmentDatatable.js b/httpdocs/assets/js/safekat/components/datatables/ChatDepartmentDatatable.js new file mode 100644 index 00000000..3b33a0c2 --- /dev/null +++ b/httpdocs/assets/js/safekat/components/datatables/ChatDepartmentDatatable.js @@ -0,0 +1,160 @@ +import Ajax from "../ajax.js"; +import { alertConfirmationDelete, alertSuccess, alertError, alertConfirmAction } from '../alerts/sweetAlert.js' +export class ChatDepartmentDatatable { + constructor(domItem) { + this.item = domItem + this.chatDepartmentDisplay = $("#chat-department-display") + this.btnStoreChatDepartment = $("#btn-add-new-chat-department") + + this.datatableColumns = [ + { data: 'id', searchable: false, sortable: true }, + { data: 'display', searchable: true, sortable: true }, + { data: 'description', searchable: true, sortable: true }, + { + data: 'action', searchable: false, sortable: false, + render: (d, t) => { + return `` + } + } + ] + } + init() { + this.btnStoreChatDepartment.on('click', this.storeNewChatDepartment.bind(this)) + this.item.on('click', '.chat-department-delete', this.deleteChatDepartment.bind(this)) + + this.datatable = this.item.DataTable({ + processing: true, + order: [[0, 'asc']], + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + serverSide: true, + pageLength: 10, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/chat/department/datatable' + }); + } + deleteChatDepartment(event) { + const ajax = new Ajax( + `/chat/department/${$(event.currentTarget).data("id")}`, + null, + null, + this.deleteChatDepartmentSuccess.bind(this), + this.deleteChatDepartmentError.bind(this) + ) + alertConfirmationDelete().then(result => { + if (result.isConfirmed) { + ajax.delete() + } + }) + } + deleteChatDepartmentSuccess(response) { + this.datatable.ajax.reload() + alertSuccess(response.message).fire() + } + deleteChatDepartmentError(response) { + alertError(response.message).fire() + } + storeNewChatDepartment() { + this.btnStoreChatDepartment.attr("disabled") + const ajax = new Ajax("/chat/department", { + display: this.chatDepartmentDisplay.val() + }, + null, + this.storeNewChatDepartmentSuccess.bind(this), + this.storeNewChatDepartmentError.bind(this) + ) + if (this.chatDepartmentDisplay.val()) { + alertConfirmAction().then(result => { + if (result.isConfirmed) { + ajax.post() + } + }) + } else { + this.btnStoreChatDepartment.removeAttr("disabled") + } + } + storeNewChatDepartmentSuccess(response) { + this.datatable.ajax.reload() + alertSuccess(response.message).fire() + } + storeNewChatDepartmentError(response) { + console.log(response) + alertError(response.message).fire() + } + +} +export class ChatDepartmentUserDatatable { + constructor(domItem) { + this.item = domItem + this.datatableColumns = [ + { data: 'userFullName', searchable: true, sortable: true }, + { data: 'username', searchable: true, sortable: true }, + { + data: 'action', searchable: false, sortable: false, + render: (d, t) => { + return `` + } + } + ] + } + init() { + this.actions() + this.datatable = this.item.DataTable({ + processing: true, + order: [[0, 'desc']], + layout: { + topStart: 'pageLength', + topEnd: 'search', + bottomStart: 'info', + bottomEnd: 'paging' + }, + serverSide: true, + pageLength: 10, + language: { + url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json" + }, + columns: this.datatableColumns, + ajax: '/chat/department/users/datatable/' + this.item.data('id') + }); + } + actions() { + this.item.on("click", ".chat-department-user-delete", this.deleteRow.bind(this)) + } + deleteRow(event) { + const ajax = new Ajax(`/chat/department/admin/user/${this.item.data('id')}/${$(event.currentTarget).data("id")}`, + null, + null, + this.deleteRowSuccess.bind(this), + this.deleteRowError.bind(this), + ) + alertConfirmationDelete().then(result => { + if (result.isConfirmed) { + ajax.delete() + } + }) + } + deleteRowSuccess(response) { + this.datatable.ajax.reload(); + alertSuccess(response.message).fire() + } + deleteRowError(response) { + alertError(response?.message).fire() + } + + +} + + + diff --git a/httpdocs/assets/js/safekat/components/datatables/MessagesDatatable.js b/httpdocs/assets/js/safekat/components/datatables/MessagesDatatable.js index c27f70ef..0322a033 100644 --- a/httpdocs/assets/js/safekat/components/datatables/MessagesDatatable.js +++ b/httpdocs/assets/js/safekat/components/datatables/MessagesDatatable.js @@ -7,11 +7,13 @@ class MessagesDatatable { this.datatablePresupuestoMessageItem = this.item.find("#tablePresupuestoMessages") this.datatablePedidoMessageItem = this.item.find("#tablePedidoMessages") this.datatableFacturaMessageItem = this.item.find("#tableFacturaMessages") - + this.columnDefs = [ + ] this.datatableColumns = [ { data: 'created_at', searchable: true, sortable: true }, { data: 'updated_at', searchable: true, sortable: true }, - { data: 'title', searchable: true, sortable: true }, + { data: 'title', name:"chats.title",searchable: true, sortable: true }, + { data: 'message', searchable: false, sortable: true }, { data: 'creator', searchable: false, sortable: false }, { data: 'viewed', searchable: false, sortable: true, @@ -27,10 +29,10 @@ class MessagesDatatable { ${d.isAdmin ? `
-
` : ""
}
@@ -46,13 +48,16 @@ class MessagesDatatable {
}
init() {
this.item.on('click', '.btn-notification-viewed', (event) => {
- const chatId = $(event.currentTarget).data('id')
- $(`#dropdown-viewed-${chatId}`).empty()
- this.handleDropUp(chatId)
+ const chatMessageId = $(event.currentTarget).data('id')
+ $(`#dropdown-viewed-${chatMessageId}`).empty()
+ this.handleDropUp(chatMessageId)
})
+
this.datatable = this.datatableItem.DataTable({
processing: true,
order: [[1, 'desc']],
+ columnDefs : this.columnDefs,
+ orderCellsTop : true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
@@ -71,6 +76,8 @@ class MessagesDatatable {
this.datatablePresupuestoMessage = this.datatablePresupuestoMessageItem.DataTable({
processing: true,
order: [[1, 'desc']],
+ columnDefs : this.columnDefs,
+ orderCellsTop : true,
layout: {
topStart: 'pageLength',
topEnd: 'search',
@@ -87,6 +94,8 @@ class MessagesDatatable {
});
this.datatablePedidoMessage = this.datatablePedidoMessageItem.DataTable({
processing: true,
+ orderCellsTop : true,
+ columnDefs : this.columnDefs,
order: [[1, 'desc']],
layout: {
topStart: 'pageLength',
@@ -104,6 +113,8 @@ class MessagesDatatable {
});
this.datatableFacturaMessage = this.datatableFacturaMessageItem.DataTable({
processing: true,
+ orderCellsTop : true,
+ columnDefs : this.columnDefs,
order: [[1, 'desc']],
layout: {
topStart: 'pageLength',
@@ -119,11 +130,23 @@ class MessagesDatatable {
columns: this.datatableColumns,
ajax: '/messages/datatable/factura'
});
+ this.datatablePresupuestoMessageItem.on("keyup", ".datatable-message-filter", (event) => {
+ let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
+ this.datatablePresupuestoMessage.column(columnIndex).search($(event.currentTarget).val()).draw()
+ })
+ this.datatablePedidoMessageItem.on("keyup", ".datatable-message-filter", (event) => {
+ let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
+ this.datatablePedidoMessage.column(columnIndex).search($(event.currentTarget).val()).draw()
+ })
+ this.datatableFacturaMessageItem.on("keyup", ".datatable-message-filter", (event) => {
+ let columnIndex = this.datatableColumns.findIndex((element) => element.data == $(event.currentTarget).attr("name"))
+ this.datatableFacturaMessage.column(columnIndex).search($(event.currentTarget).val()).draw()
+ })
}
- handleDropUp(chatId) {
- let ajax = new Ajax('/chat/users/notifications-unviewed/' + chatId,
+ handleDropUp(chatMessageId) {
+ let ajax = new Ajax('/chat/users/message/notifications-unviewed/' + chatMessageId,
null,
null,
this.handleDropUpSuccess.bind(this),
@@ -133,34 +156,49 @@ class MessagesDatatable {
ajax.get();
}
handleDropUpSuccess(response) {
- const chatId = response.chat_id
- const users = response.data
- if (users.length > 0) {
+ const chat_message_id = response.chat_message_id
+ const notifications = response.data.notifications
- users.forEach(user => {
- const viewed = (user.notification_count - user.viewed_count) == 0
+ if (notifications.length > 0) {
+
+ notifications.forEach(user => {
if (user.userFullName || user.userName) {
- $(`#dropdown-viewed-${chatId}`)
- .append(`
-
-
- ${getInitials(message.senderFullName)}
+
`
const hebraUsersList = (user) => `
+ ").attr("type", "button").addClass("btn btn-danger btn-sm btn-new-hebra")
btnNewHebra.append('')
btnNewHebra.append("Nuevo hilo")
- headerHebra.append(contentHeaderHebra,btnNewHebra)
+ headerHebra.append(contentHeaderHebra, btnNewHebra)
itemHebra.append(headerHebra)
let itemMessagesHebraRow = $("").addClass("row")
let itemMessagesHebraCol = $("").addClass("col")
diff --git a/httpdocs/assets/js/safekat/components/select2.js b/httpdocs/assets/js/safekat/components/select2.js
index c7fdfa51..c6199c56 100644
--- a/httpdocs/assets/js/safekat/components/select2.js
+++ b/httpdocs/assets/js/safekat/components/select2.js
@@ -5,97 +5,96 @@
* @param {String} placeholder
*/
let ClassSelect = function (domItem, url, placeholder, allowClear = false, params = {}, dropdownParent = "", hideSearch = false) {
- this.url = url;
- this.item = domItem;
- this.params = params;
- this.dropdownParent = dropdownParent;
- this.hideSearch = hideSearch;
+ this.url = url;
+ this.item = domItem;
+ this.params = params;
+ this.dropdownParent = dropdownParent;
+ this.hideSearch = hideSearch;
- this.config = {
- placeholder: placeholder,
- allowClear: allowClear,
- dropdownParent: dropdownParent!=""?dropdownParent:domItem.parent(),
- language: "es",
- ajax: {
- url: () => {
- return this.url;
- },
- data: (params) => {
- let q = $.trim(params.term);
- let d = {
- q: q,
- page: params.page || 1,
- };
-
- for (let key in this.params) {
- d[key] = this.params[key];
- }
-
- return d;
- },
- processResults: function (data) {
- return {
- results: $.map(data, function (obj) {
- return {
- id: obj.id,
- text: obj.nombre ?? obj.name,
- desc: obj.description,
- };
- }),
- };
- },
- cache: true,
+ this.config = {
+ placeholder: placeholder,
+ allowClear: allowClear,
+ dropdownParent: dropdownParent != "" ? dropdownParent : domItem.parent(),
+ language: "es",
+ ajax: {
+ url: () => {
+ return this.url;
},
- };
- this.init = function () {
- if (this.item.length) {
+ data: (params) => {
+ let q = $.trim(params.term);
+ let d = {
+ q: q,
+ page: params.page || 1,
+ };
- if(this.hideSearch){
- this.config.minimumResultsForSearch = -1;
+ for (let key in this.params) {
+ d[key] = this.params[key];
}
- this.item = this.item.select2(this.config);
- // $.fn.modal.Constructor.prototype.enforceFocus = function () {};
- }
- };
- this.setOption = function (id, nombre) {
- var newOption = new Option(nombre , id, false, false);
- this.item.append(newOption);
- this.item.val(id).trigger("change");
- };
- this.reset = function () {
- this.item.val(null).trigger("change");
- };
- this.setParams = function(params){
- this.params = params;
- };
- this.getVal = function () {
- return this.item.val();
- };
- this.setVal = function (val) {
- return this.item.val(val).trigger("change");
- };
- this.empty = function () {
- return this.item.empty().trigger("change");
- };
- this.readOnly = function () {
- this.item.enable(false);
- };
- this.enable = () => {
- this.item.enable(true);
- };
- this.fixWithScroll = function () {};
- this.getText = () => {
- return this.item.find(":selected").text();
- };
- this.onChange = function(callback) {
- this.item.on('change', callback);
- };
- this.offChange = function() {
- this.item.off('change');
- };
-
+ return d;
+ },
+ processResults: function (data) {
+ return {
+ results: $.map(data, function (obj) {
+ return {
+ id: obj.id,
+ text: obj.nombre ?? obj.name,
+ desc: obj.description,
+ };
+ }),
+ };
+ },
+ cache: true,
+ },
};
-
+ this.init = function () {
+ if (this.item.length) {
+
+ if (this.hideSearch) {
+ this.config.minimumResultsForSearch = -1;
+ }
+
+ this.item = this.item.select2(this.config);
+ // $.fn.modal.Constructor.prototype.enforceFocus = function () {};
+ }
+ };
+ this.setOption = function (id, nombre) {
+ var newOption = new Option(nombre, id, false, false);
+ this.item.append(newOption);
+ this.item.val(id).trigger("change");
+ };
+ this.reset = function () {
+ this.item.val(null).trigger("change");
+ };
+ this.setParams = function (params) {
+ this.params = params;
+ };
+ this.getVal = function () {
+ return this.item.val();
+ };
+ this.setVal = function (val) {
+ return this.item.val(val).trigger("change");
+ };
+ this.empty = function () {
+ return this.item.empty().trigger("change");
+ };
+ this.readOnly = function () {
+ this.item.enable(false);
+ };
+ this.enable = () => {
+ this.item.enable(true);
+ };
+ this.fixWithScroll = function () { };
+ this.getText = () => {
+ return this.item.find(":selected").text();
+ };
+ this.onChange = function (callback) {
+ this.item.on('change', callback);
+ };
+ this.offChange = function () {
+ this.item.off('change');
+ };
+
+};
+
export default ClassSelect;
-
\ No newline at end of file
diff --git a/httpdocs/assets/js/safekat/pages/chatNotification.js b/httpdocs/assets/js/safekat/pages/chatNotification.js
index 060d824d..d966e6e3 100644
--- a/httpdocs/assets/js/safekat/pages/chatNotification.js
+++ b/httpdocs/assets/js/safekat/pages/chatNotification.js
@@ -2,12 +2,12 @@ import { showNotificationMessages } from "../components/chat.js";
$(() => {
- showNotificationMessages($("#chat-notification-list"))
+ showNotificationMessages()
const chatNotificationInterval = setInterval(() => {
- showNotificationMessages($("#chat-notification-list"))
+ showNotificationMessages()
}, 10000)
$("#message-notification-dropdown").on("click", (e) => {
- showNotificationMessages($("#chat-notification-list"))
+ showNotificationMessages()
})
$("#btn-log-out").on("click",() => {
clearInterval(chatNotificationInterval)
diff --git a/httpdocs/assets/js/safekat/pages/configuracion/messages/configView.js b/httpdocs/assets/js/safekat/pages/configuracion/messages/configView.js
new file mode 100644
index 00000000..5c17e5b2
--- /dev/null
+++ b/httpdocs/assets/js/safekat/pages/configuracion/messages/configView.js
@@ -0,0 +1,13 @@
+
+import Ajax from '../../../components/ajax.js'
+import { ChatDepartmentDatatable } from '../../../components/datatables/ChatDepartmentDatatable.js'
+
+
+
+
+
+$(() => {
+ const chatDepartmentDatatable = new ChatDepartmentDatatable($("#tableChatDepartments"))
+ chatDepartmentDatatable.init()
+})
+
diff --git a/httpdocs/assets/js/safekat/pages/configuracion/messages/editChatDepartmentView.js b/httpdocs/assets/js/safekat/pages/configuracion/messages/editChatDepartmentView.js
new file mode 100644
index 00000000..94b36ab8
--- /dev/null
+++ b/httpdocs/assets/js/safekat/pages/configuracion/messages/editChatDepartmentView.js
@@ -0,0 +1,8 @@
+
+import ChatDepartmentForm from '../../../components/forms/chatDepartmentForm.js'
+
+$(() => {
+
+ const chatDepartmentForm = new ChatDepartmentForm($("#chatDepartmentForm"))
+ chatDepartmentForm.init()
+})
\ No newline at end of file
+
@@ -18,7 +18,7 @@ const hebraList = (message) => `
${message.created_at}
- ${message.senderFullName} (${message.senderUserName}) + ${message.user.first_name} ${message.user.last_name} (${message.user.username})
${message.message}
@@ -27,12 +27,10 @@ const hebraList = (message) => `
+
+
`
-
- ${getInitials(user.userFullName)}
-
-
-`
class InternalMessages {
constructor(domItem) {
this.item = domItem
@@ -53,14 +51,14 @@ class InternalMessages {
this.type = this.item.data("type")
this.chatId = null
- this.selectMessageUsers = new ClassSelect(this.selectUsers, '/chat/users/internal', "Seleccione un usuario",true)
+ this.selectMessageUsers = new ClassSelect(this.selectUsers, '/chat/users/internal', "Seleccione un usuario", true)
}
init() {
this.selectMessageUsers.init()
this.item.on("click", ".btn-new-hebra", this.handleBtnNewHebra.bind(this))
this.item.on("click", ".btn-new-hebra-message", this.handleBtnUpdateHebra.bind(this))
- this.modalNewMessage.item.on("click","#submit_new_hebra",this.handlePostNewHebra.bind(this))
- this.modalNewMessage.item.on("click","#submit_update_hebra",this.handleUpdateHebra.bind(this))
+ this.modalNewMessage.item.on("click", "#submit_new_hebra", this.handlePostNewHebra.bind(this))
+ this.modalNewMessage.item.on("click", "#submit_update_hebra", this.handleUpdateHebra.bind(this))
this.handleGetInternalMessages()
}
@@ -75,7 +73,7 @@ class InternalMessages {
)
ajax.get()
}
- handlePostNewHebra(){
+ handlePostNewHebra() {
this._handleUpdateFormNewHebraValues()
let ajax = new Ajax(
`/chat/hebra/${this.type}`,
@@ -87,12 +85,12 @@ class InternalMessages {
ajax.post()
}
- handlePostNewHebraSuccess(data){
+ handlePostNewHebraSuccess(data) {
this.modalNewMessage.toggle()
this.handleGetInternalMessages()
}
- handlePostNewHebraError(err){}
- handleUpdateHebra(){
+ handlePostNewHebraError(err) { }
+ handleUpdateHebra() {
this._handleUpdateFormUpdateHebraValues()
let ajax = new Ajax(
`/chat/hebra/${this.chatId}`,
@@ -103,11 +101,11 @@ class InternalMessages {
)
ajax.post()
}
- handleUpdateNewHebraSuccess(data){
+ handleUpdateNewHebraSuccess(data) {
this.modalNewMessage.toggle()
this.handleGetInternalMessages()
}
- handleUpdateNewHebraError(err){}
+ handleUpdateNewHebraError(err) { }
handleBtnNewHebra(e) {
e.preventDefault()
this.chatId = null
@@ -137,34 +135,34 @@ class InternalMessages {
}
_handleUpdateFormNewHebraValues() {
this.formNewValues = {
- title : this.hebraTitle.val(),
+ title: this.hebraTitle.val(),
users: this.selectMessageUsers.getVal(),
message: this.textAreaMessage.val(),
- modelId : this.modelId
+ modelId: this.modelId
}
}
_handleUpdateFormUpdateHebraValues() {
this.formUpdateValues = {
users: this.selectMessageUsers.getVal(),
message: this.textAreaMessage.val(),
- modelId : this.modelId
+ modelId: this.modelId
}
}
- _handleGetInternalMessagesSuccess(data){
+ _handleGetInternalMessagesSuccess(data) {
Object.values(data).map((k) => {
- this._addHebraDOM(k.chatId,k.chatTitle,k.messages,k.users)
+ this._addHebraDOM(k.id, k.title, k.messages, k.internalUsers)
})
}
- _handleGetInternalMessagesError(err){}
+ _handleGetInternalMessagesError(err) { }
- _addHebraDOM(key,chatTitle,messages,users) {
+ _addHebraDOM(key, chatTitle, messages, users) {
const itemHebra = $(``).addClass("border border-container flex-grow-0 container-p-y mt-4 p-5")
const headerHebra = $("").addClass("d-flex justify-content-between align-items-center")
const contentHeaderHebra = $("").text(`${chatTitle}`)
const btnNewHebra = $("