mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
feat: mensajes directos cliente
This commit is contained in:
@ -226,7 +226,7 @@ class Chat {
|
||||
`/chat/department/${this.chatType}/${this.chatDeparmentId}/${this.modelId}`,
|
||||
null,
|
||||
null,
|
||||
(data)=> {
|
||||
(data) => {
|
||||
this.chatList.find(`#chat_${row_name} .messages-unread-contact`).text(data.count)
|
||||
},
|
||||
null
|
||||
@ -290,12 +290,12 @@ class Chat {
|
||||
this.chatHistory.append(chatItem)
|
||||
return chatItem
|
||||
}
|
||||
_sendMessagePressKey(e){
|
||||
if ( e.which == 13 ) {
|
||||
_sendMessagePressKey(e) {
|
||||
if (e.which == 13) {
|
||||
e.preventDefault();
|
||||
this._sendMessage()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
_sendMessage() {
|
||||
|
||||
@ -341,26 +341,36 @@ class Chat {
|
||||
|
||||
}
|
||||
_handleListContactsSuccess(contacts) {
|
||||
if (contacts.length) {
|
||||
console.log(contacts)
|
||||
contacts.map((c) => {
|
||||
this._addContactToList(c)
|
||||
});
|
||||
} else {
|
||||
this.sideBar.find("#contact-list").addClass("d-none")
|
||||
try {
|
||||
|
||||
if (contacts.length) {
|
||||
console.log(contacts)
|
||||
|
||||
contacts.map((c, index) => {
|
||||
this._addContactToList(c)
|
||||
|
||||
});
|
||||
} else {
|
||||
this.sideBar.find("#contact-list").addClass("d-none")
|
||||
}
|
||||
this.sideBar.find(".contact-chat").on("click", (e) => {
|
||||
// $(e.currentTarget).find(".messages-unread-contact").empty()
|
||||
$(".contact-chat").parent().removeClass("active")
|
||||
$(".chat-contact-list-item").removeClass("active")
|
||||
this.chatHistory.empty()
|
||||
this.domItem.find("#chat-header-dropdown-users").addClass("d-none")
|
||||
let userId = $(e.currentTarget).data("id")
|
||||
$(e.currentTarget).parent().addClass('active')
|
||||
this.receiverId = userId
|
||||
this._handleGetSingleContact(userId)
|
||||
this._setBtnInternal()
|
||||
})
|
||||
} catch (error) {
|
||||
|
||||
} finally {
|
||||
this.domItem.find(`#chat-contact-list-item-${contacts[0].id}`).click()
|
||||
|
||||
}
|
||||
this.sideBar.find(".contact-chat").on("click", (e) => {
|
||||
$(e.currentTarget).find(".messages-unread-contact").empty()
|
||||
$(".contact-chat").parent().removeClass("active")
|
||||
$(".chat-contact-list-item").removeClass("active")
|
||||
this.chatHistory.empty()
|
||||
this.domItem.find("#chat-header-dropdown-users").addClass("d-none")
|
||||
let userId = $(e.currentTarget).data("id")
|
||||
$(e.currentTarget).parent().addClass('active')
|
||||
this.receiverId = userId
|
||||
this._handleGetSingleContact(userId)
|
||||
this._setBtnInternal()
|
||||
})
|
||||
}
|
||||
_handleListContactsError(err) {
|
||||
console.error(err)
|
||||
@ -389,10 +399,20 @@ class Chat {
|
||||
ajax.get()
|
||||
}
|
||||
_handleGetSingleContactMessagesSuccess(data) {
|
||||
if (data) {
|
||||
data.map((m) => {
|
||||
this._addChatMessage(m)
|
||||
})
|
||||
try {
|
||||
|
||||
|
||||
if (data) {
|
||||
data.map((m) => {
|
||||
this._addChatMessage(m)
|
||||
})
|
||||
}
|
||||
} catch (error) {
|
||||
|
||||
} finally {
|
||||
// console.log(this.chatHistoryBody[0].scrollTop)
|
||||
this.scrollbarChatHistory.update()
|
||||
this.chatHistoryBody[0].scrollTop = this.scrollbarChatHistory.containerHeight
|
||||
}
|
||||
}
|
||||
_handleGetSingleContactMessagesError(err) { }
|
||||
@ -400,8 +420,8 @@ class Chat {
|
||||
_handleGetSingleContactError(err) {
|
||||
|
||||
}
|
||||
_sendMessageInternalPressKey(e){
|
||||
if ( e.which == 13 ) {
|
||||
_sendMessageInternalPressKey(e) {
|
||||
if (e.which == 13) {
|
||||
e.preventDefault();
|
||||
this._sendMessageInternal()
|
||||
}
|
||||
@ -453,7 +473,7 @@ class Chat {
|
||||
</p>
|
||||
</div>
|
||||
${contact.unreadMessages ? `<span
|
||||
class="badge badge-center rounded-pill bg-primary messages-unread-contact">${contact.unreadMessages}</span>` : ""}
|
||||
class="badge badge-center rounded-pill bg-danger messages-unread-contact">${contact.unreadMessages}</span>` : ""}
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
@ -479,18 +499,18 @@ export const showNotificationMessages = (dom) => {
|
||||
(data) => {
|
||||
dom.empty()
|
||||
$("#chat-notification-number")
|
||||
if(data.totalMessages > 0){
|
||||
if (data.totalMessages > 0) {
|
||||
$("#chat-notification-number").removeClass("d-none")
|
||||
$("#chat-notification-number").text(data.totalMessages ?? 0)
|
||||
}else{
|
||||
} else {
|
||||
$("#chat-notification-number").addClass("d-none")
|
||||
$("#chat-notification-number").text(0)
|
||||
}
|
||||
data?.internals?.map((e) => {
|
||||
let numberOfMessages = e.unreadMessages
|
||||
if(numberOfMessages > 0){
|
||||
dom.append(
|
||||
`
|
||||
if (numberOfMessages > 0) {
|
||||
dom.append(
|
||||
`
|
||||
<li class="mb-2">
|
||||
<a href="${e.uri}" class="d-flex align-items-center flex-grow">
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
@ -503,14 +523,14 @@ export const showNotificationMessages = (dom) => {
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
data?.chatPresupuestos?.map((e) => {
|
||||
let numberOfMessages = e.unreadMessages
|
||||
if(numberOfMessages > 0){
|
||||
dom.append(
|
||||
`
|
||||
if (numberOfMessages > 0) {
|
||||
dom.append(
|
||||
`
|
||||
<li class="">
|
||||
<a href="${e.uri}" class="d-flex align-items-center flex-grow">
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
@ -523,14 +543,14 @@ export const showNotificationMessages = (dom) => {
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
data?.chatFacturas?.map((e) => {
|
||||
let numberOfMessages = e.unreadMessages
|
||||
if(numberOfMessages > 0){
|
||||
dom.append(
|
||||
`
|
||||
if (numberOfMessages > 0) {
|
||||
dom.append(
|
||||
`
|
||||
<li class="">
|
||||
<a href="${e.uri}" class="d-flex align-items-center flex-grow">
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
@ -543,14 +563,14 @@ export const showNotificationMessages = (dom) => {
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
data?.chatPedidos?.map((e) => {
|
||||
let numberOfMessages = e.unreadMessages
|
||||
if(numberOfMessages > 0){
|
||||
dom.append(
|
||||
`
|
||||
if (numberOfMessages > 0) {
|
||||
dom.append(
|
||||
`
|
||||
<li class="">
|
||||
<a href="${e.uri}" class="d-flex align-items-center flex-grow">
|
||||
<div class="avatar d-block flex-shrink-0">
|
||||
@ -563,8 +583,8 @@ export const showNotificationMessages = (dom) => {
|
||||
</a>
|
||||
</li>
|
||||
`
|
||||
)
|
||||
}
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
|
||||
@ -111,7 +111,7 @@ class InternalMessages {
|
||||
handleBtnNewHebra(e) {
|
||||
e.preventDefault()
|
||||
this.chatId = null
|
||||
this.modalNewMessage.item.find(".modal-title").text("Nueva hebra")
|
||||
this.modalNewMessage.item.find(".modal-title").text("Nuevo hilo")
|
||||
this.selectMessageUsers.reset()
|
||||
this.textAreaMessage.val("")
|
||||
this.hebraTitle.val("")
|
||||
@ -163,7 +163,7 @@ class InternalMessages {
|
||||
const contentHeaderHebra = $("<h4></h4>").text(`${chatTitle}`)
|
||||
const btnNewHebra = $("<button></button>").attr("type", "button").addClass("btn btn-danger btn-sm btn-new-hebra")
|
||||
btnNewHebra.append('<span class="ti-xs ti ti-git-branch"></span>')
|
||||
btnNewHebra.append("Nueva hebra")
|
||||
btnNewHebra.append("Nuevo hilo")
|
||||
headerHebra.append(contentHeaderHebra,btnNewHebra)
|
||||
itemHebra.append(headerHebra)
|
||||
let itemMessagesHebraRow = $("<div></div>").addClass("row")
|
||||
|
||||
Reference in New Issue
Block a user