mirror of
https://git.imnavajas.es/jjimenez/safekat.git
synced 2025-07-25 22:52:08 +00:00
message chat section
This commit is contained in:
@ -168,8 +168,6 @@ class Chat {
|
||||
null,
|
||||
this._handleGetChatListSuccess.bind(this),
|
||||
this._handleGetChatListError.bind(this),
|
||||
|
||||
|
||||
);
|
||||
ajax.get();
|
||||
}
|
||||
@ -182,7 +180,7 @@ class Chat {
|
||||
this.chatList.find(`#chat_${row.name}`).on("click", (event) => {
|
||||
$(".chat-contact-list-item").removeClass("active")
|
||||
$(event.currentTarget).parent().addClass("active")
|
||||
this.chatHistoryBody.empty()
|
||||
this.chatHistory.empty()
|
||||
this.chatDeparmentId = this.chatList.find(`#chat_${row.name}`).data("id")
|
||||
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)
|
||||
@ -290,7 +288,7 @@ class Chat {
|
||||
_getChatDepartmentMessageCountError() { }
|
||||
|
||||
_getChatMessage() {
|
||||
|
||||
this.chatHistory.empty()
|
||||
this.domItem.find(".chat-loader").removeClass("d-none")
|
||||
let ajax = new Ajax(
|
||||
`/chat/department/${this.chatType}/${this.chatDeparmentId}/${this.modelId}`,
|
||||
@ -305,7 +303,6 @@ class Chat {
|
||||
}
|
||||
_getChatMessageSuccess(data) {
|
||||
this.domItem.find(".chat-loader").addClass("d-none")
|
||||
this.chatHistory.empty()
|
||||
this._setBtnDeparment()
|
||||
if (data.messages) {
|
||||
data.messages.map((m) => {
|
||||
|
||||
@ -4,28 +4,34 @@ class MessagesDatatable {
|
||||
constructor(domItem) {
|
||||
this.item = domItem
|
||||
this.datatableItem = this.item.find("#tableMessages")
|
||||
this.datatablePresupuestoMessageItem = this.item.find("#tablePresupuestoMessages")
|
||||
this.datatablePedidoMessageItem = this.item.find("#tablePedidoMessages")
|
||||
this.datatableFacturaMessageItem = this.item.find("#tableFacturaMessages")
|
||||
|
||||
this.datatableColumns = [
|
||||
{ data: 'created_at', searchable: true, sortable: true },
|
||||
{ data: 'updated_at', searchable: true, sortable: true },
|
||||
{ data: 'title', searchable: true, sortable: true },
|
||||
{ data: 'creator', searchable: false, sortable: false },
|
||||
{ data: 'viewed', searchable: false, sortable: false ,
|
||||
render : (d,t) => {
|
||||
{
|
||||
data: 'viewed', searchable: false, sortable: false,
|
||||
render: (d, t) => {
|
||||
const iconClass = d == true ? "ti ti-sm ti-check" : "ti ti-sm ti-x"
|
||||
return `<span class="${iconClass}"</span>`
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
data: 'action', sortable: false, searchable: false,
|
||||
data: 'action', searchable: false, sortable: false,
|
||||
render: (d, t) => {
|
||||
return `
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="/chat/direct/${d}" data-id="${d}" class="message-edit"><i class="ti ti-eye ti-sm mx-2"></i></a>
|
||||
</div>
|
||||
`
|
||||
return `<div class="btn-group btn-group-sm">
|
||||
<a href="/chat/${d.type}/${d.modelId}" class="message-edit"><i class="ti ti-eye ti-sm mx-2"></i></a>
|
||||
</div>`
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
|
||||
}
|
||||
init() {
|
||||
this.datatable = this.datatableItem.DataTable({
|
||||
@ -45,6 +51,55 @@ class MessagesDatatable {
|
||||
ajax: '/messages/datatable'
|
||||
});
|
||||
|
||||
this.datatablePresupuestoMessage = this.datatablePresupuestoMessageItem.DataTable({
|
||||
processing: true,
|
||||
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: '/messages/datatable/presupuesto'
|
||||
});
|
||||
this.datatablePedidoMessage = this.datatablePedidoMessageItem.DataTable({
|
||||
processing: true,
|
||||
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: '/messages/datatable/pedido'
|
||||
});
|
||||
this.datatableFacturaMessage = this.datatableFacturaMessageItem.DataTable({
|
||||
processing: true,
|
||||
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: '/messages/datatable/factura'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -5,18 +5,27 @@ import ClassSelect from "../../../components/select2.js";
|
||||
import Alert from "../../../components/alerts/alert.js";
|
||||
class MessagePage {
|
||||
constructor() {
|
||||
this.messageDatatable = new MessagesDatatable($("#messagesViewCard")) // mensajesView.php
|
||||
this.messageDatatable = new MessagesDatatable($("#message-datatables-container")) // mensajesView.php
|
||||
this.modalNewMessage = new Modal($("#modalNewDirectMessage"))
|
||||
this.btnNewMessage = $("#btn-new-message")
|
||||
this.btnSubmitNewDirectMessage = this.modalNewMessage.item.find("#submit-new-direct-message")
|
||||
this.btnSubmitNewDirectMessageCliente = this.modalNewMessage.item.find("#submit-new-direct-message-client")
|
||||
|
||||
this.formNewDirectMessage = this.modalNewMessage.item.find("#formNewDirectMessage")
|
||||
this.alert = new Alert($("#alertDirectMessage"))
|
||||
this.selectUsers = $("#select-users")
|
||||
this.selectUsers = $("#select-departments")
|
||||
|
||||
this.selectPlaceholder = {
|
||||
id: '0',
|
||||
text: "Seleccione un usuario"
|
||||
}
|
||||
this.selectDepartmentPlaceholder = {
|
||||
id: '0',
|
||||
text: "Seleccione un departamento"
|
||||
}
|
||||
this.selectMessageUsers = new ClassSelect(this.selectUsers, '/chat/users/all', this.selectPlaceholder, true)
|
||||
this.selectChatDepartment = new ClassSelect(this.selectUsers, '/chat/department/select', this.selectDepartmentPlaceholder, true)
|
||||
|
||||
}
|
||||
init() {
|
||||
@ -27,6 +36,20 @@ class MessagePage {
|
||||
// Open new message when click in btn-new-message
|
||||
this.btnNewMessage.on("click", this.openNewMessageModal.bind(this))
|
||||
this.btnSubmitNewDirectMessage.on("click", this.handleSubmitNewMessage.bind(this))
|
||||
this.btnSubmitNewDirectMessageCliente.on("click", this.handleSubmitNewMessageClient.bind(this))
|
||||
|
||||
$("#navs-top-align-directos-tab").on("click",()=>{
|
||||
this.messageDatatable.datatable.ajax.reload()
|
||||
})
|
||||
$("#navs-top-align-presupuestos-tab").on("click",()=>{
|
||||
this.messageDatatable.datatablePresupuestoMessage.ajax.reload()
|
||||
})
|
||||
$("#navs-top-align-pedidos-tab").on("click",()=>{
|
||||
this.messageDatatable.datatablePedidoMessage.ajax.reload()
|
||||
})
|
||||
$("#navs-top-align-facturas-tab").on("click",()=>{
|
||||
this.messageDatatable.datatableFacturaMessage.ajax.reload()
|
||||
})
|
||||
|
||||
}
|
||||
openNewMessageModal() {
|
||||
@ -60,6 +83,21 @@ class MessagePage {
|
||||
this.alert.show()
|
||||
this.alert.setAsError()
|
||||
this.alert.setHeadingTitle(error.message)
|
||||
}
|
||||
handleSubmitNewMessageClient(){
|
||||
this.btnNewMessage.addClass("loading")
|
||||
const ajax = new Ajax("/messages/direct/client",
|
||||
this.getNewMessageDataFormClient(),
|
||||
null,
|
||||
this.handleSubmitNewMessageSuccess.bind(this),
|
||||
this.handleSubmitNewMessageError.bind(this))
|
||||
ajax.post()
|
||||
}
|
||||
handleSubmitNewMessageClientSuccess(){
|
||||
|
||||
}
|
||||
handleSubmitNewMessageClientError(){
|
||||
|
||||
}
|
||||
getNewMessageDataForm() {
|
||||
return {
|
||||
@ -68,13 +106,24 @@ class MessagePage {
|
||||
"users": this.selectMessageUsers.getVal()
|
||||
}
|
||||
}
|
||||
getNewMessageDataFormClient() {
|
||||
return {
|
||||
"title": this.formNewDirectMessage.find("#new-direct-message-title").val(),
|
||||
"message": this.formNewDirectMessage.find("#new-direct-message-text").val(),
|
||||
"chat_department_id": this.selectChatDepartment.getVal()
|
||||
}
|
||||
}
|
||||
hideForm() {
|
||||
this.formNewDirectMessage.addClass("d-none")
|
||||
this.btnSubmitNewDirectMessage.addClass("d-none")
|
||||
this.btnSubmitNewDirectMessageCliente.addClass("d-none")
|
||||
|
||||
}
|
||||
showForm() {
|
||||
this.formNewDirectMessage.removeClass("d-none")
|
||||
this.btnSubmitNewDirectMessage.removeClass("d-none")
|
||||
this.btnSubmitNewDirectMessageCliente.addClass("d-none")
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,9 @@
|
||||
import Chat from "../../components/chat.js";
|
||||
|
||||
$(function(){
|
||||
|
||||
const chatDirectMessage = new Chat($("#chat-factura"))
|
||||
chatDirectMessage.init()
|
||||
chatDirectMessage.initFactura()
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,10 @@
|
||||
import InternalMessages from "../../components/internalMessagesSection.js";
|
||||
|
||||
$(function () {
|
||||
|
||||
if ($("#internal_messages_chat").length > 0) {
|
||||
const internalMessages = new InternalMessages($("#internal_messages_chat"))
|
||||
internalMessages.init()
|
||||
}
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,9 @@
|
||||
import Chat from "../../components/chat.js";
|
||||
|
||||
$(function(){
|
||||
|
||||
const chatDirectMessage = new Chat($("#chat-pedido"))
|
||||
chatDirectMessage.init()
|
||||
chatDirectMessage.initPedido()
|
||||
}
|
||||
)
|
||||
@ -0,0 +1,18 @@
|
||||
import Chat from "../../components/chat.js";
|
||||
import InternalMessages from "../../components/internalMessagesSection.js";
|
||||
|
||||
$(function () {
|
||||
|
||||
if ($("#chat-presupuesto").length > 0) {
|
||||
|
||||
const chatDirectMessage = new Chat($("#chat-presupuesto"))
|
||||
chatDirectMessage.init()
|
||||
chatDirectMessage.initPresupuesto()
|
||||
}
|
||||
|
||||
if ($("#internal_messages_chat").length > 0) {
|
||||
const internalMessages = new InternalMessages($("#internal_messages_chat"))
|
||||
internalMessages.init()
|
||||
}
|
||||
}
|
||||
)
|
||||
Reference in New Issue
Block a user