chat select cliente contactos

This commit is contained in:
amazuecos
2025-04-02 20:19:16 +02:00
parent 9d071e462c
commit 69f6d6cbeb
8 changed files with 166 additions and 92 deletions

View File

@ -112,9 +112,22 @@ class Chat {
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 = new ClassSelect(
this.selectItem, `/chat/direct/client/users/select/${this.chatType}/${this.modelId}`,
"Seleccione contacto", true)
this.selectClientUser.config.templateResult = (state) => {
let $state = $(`
<div class="d-flex flex-column justify-content-start align-items-start gap-1">
<span class="item-text">${state.text}</span>
<span class="badge text-bg-secondary">${state.desc ?? ''}</span>
</div>`)
console.log(state)
return $state;
}
this.selectClientUser.init()
this.selectItem.on('change', () => {
console.log(this.selectClientUser.getVal(),this.selectClientUser.getText())
if (this.selectClientUser.getVal()) {
this.sendBtnMessageDepartment.attr('disabled', null)
} else {
@ -302,7 +315,7 @@ class Chat {
null,
null,
(data) => {
},
null
@ -364,7 +377,7 @@ class Chat {
<div class="chat-message-text">
<p class="mb-0">${chatMessage?.message}</p>
</div>
<div class="text-${chatMessage?.pos == "left" ? "start" : "end"} text-muted mt-1">
<div class="text-${chatMessage?.pos == "left" ? "start" : "end"} text-muted mt-1">
<div class="text-${chatMessage?.pos == "left" ? "start" : "end"} text-muted mt-1">
<small>${chatMessage?.user?.first_name + " " + chatMessage?.user?.last_name}</small>
</div>
@ -821,7 +834,7 @@ class Chat {
}
const addInternalNotification = (e) => {
const addInternalNotification = (e) => {
let numberOfMessages = e.unreadMessages
if (numberOfMessages > 0) {
$("#chat-notification-list").append(
@ -841,7 +854,7 @@ const addInternalNotification = (e) => {
)
}
}
const addDepartmentNotification = (e) => {
const addDepartmentNotification = (e) => {
let numberOfMessages = e.unreadMessages
if (numberOfMessages > 0) {
$("#chat-notification-list").append(
@ -862,8 +875,7 @@ const addDepartmentNotification = (e) => {
}
}
const addNotificationsToDom = (data) =>
{
const addNotificationsToDom = (data) => {
$("#chat-notification-list").empty()
if (data.totalMessages > 0) {
$("#chat-message-notification-title").addClass("d-none")
@ -874,11 +886,13 @@ const addNotificationsToDom = (data) =>
$("#chat-notification-number").addClass("d-none")
$("#chat-notification-number").text(0)
}
data.departmentNotifications?.map( e => {
addDepartmentNotification(e)}
data.departmentNotifications?.map(e => {
addDepartmentNotification(e)
}
)
data.internalNotifications?.map(e => {
addInternalNotification(e)}
addInternalNotification(e)
}
)
}