Merge branch 'dev/presu_cliente_v2' of https://git.imnavajas.es/jjimenez/safekat into dev/presu_cliente_v2

This commit is contained in:
2024-10-19 09:42:06 +02:00
14 changed files with 7569 additions and 133 deletions

View File

@ -0,0 +1,46 @@
class ErrorPresupuestoView {
constructor(domItem) {
this.item = domItem
this.datatableItem = this.item.find("#tableErrorPresupuesto")
this.datatableColumns = [
{ data: 'presupuestoId', searchable: true, sortable: false },
{ data: 'presupuestoUser',searchable: true, sortable: false },
{ data: 'lastUser', searchable: true, sortable: false },
{ data: 'visto', searchable: false, sortable: false ,
render : (d,t) => {
const iconClass = d ? "ti ti-sm ti-check" : "ti ti-sm ti-x"
return `<span class="${iconClass}"</span>`
}
},
{ data: 'created_at', searchable: false, sortable: true },
{
data: 'action', sortable: false, searchable: false,
render: (d, t) => {
return `
<div class="btn-group btn-group-sm">
<a href="/configuracion/errores-presupuesto/edit/${d}" data-id="${d}" class="edit-error-presupuesto"><i class="ti ti-eye ti-sm mx-2"></i></a>
</div>
`
}
},
]
}
init() {
this.datatable = this.datatableItem.DataTable({
processing: true,
dom: 'Brtip',
serverSide: true,
language: {
url: "/themes/vuexy/vendor/libs/datatables-sk/plugins/i18n/es-ES.json"
},
columns: this.datatableColumns,
ajax: '/configuracion/errores-presupuesto/datatable'
});
}
}
export default ErrorPresupuestoView;

View File

@ -0,0 +1,75 @@
import Ajax from "../../../components/ajax.js";
import ajax from "../../../components/ajax.js"
class ErrorPresupuestoForm {
constructor(domItem) {
this.item = domItem
this.form = this.item.find("#error-presupuesto-form")
this.inputPresupuestoUserId = this.item.find("#presupuesto-user-id")
this.inputDatos = this.item.find("#datos-presupuesto")
this.inputComments = this.item.find("#comments-presupuesto")
this.errorPresupuestoId = this.item.find("#error-presupuesto-id").attr("value")
this.updateBtnIcon = this.item.find(".button-update-comment")
this.checkVisto = this.item.find("#error-presupuesto-visto")
this.loader = this.item.find("#update-button-loader")
this.btnIcon = this.item.find("#update-button-icon")
}
init() {
this.item.on("click",".button-update-comment",this.handlePostErrorPresupuesto.bind(this))
this.handleGetErrorPresupuesto()
}
handleGetErrorPresupuesto()
{
const ajax = new Ajax(
`/configuracion/errores-presupuesto/get/${this.errorPresupuestoId}`,
null,
null,
this.handleGetErrorPresupuestoSuccess.bind(this),
this.handleGetErrorPresupuestoError.bind(this)
)
ajax.get()
}
handleGetErrorPresupuestoSuccess(data){
this.inputPresupuestoUserId.val(data.data.presupuestoUser)
this.inputDatos.val(data.data.datos)
this.inputComments.val(data.data.comment)
this.updateBtnIcon.prop("disabled",false)
this.checkVisto.prop("checked",parseInt(data.data.visto) == 1 ? true : false)
this.setLoader(false)
}
setLoader(state = true){
this.loader.prop("hidden",!state)
this.btnIcon.prop("hidden",state)
}
handleGetErrorPresupuestoError(){}
handlePostErrorPresupuesto()
{
let data =
{
"comments" : this.inputComments.val()
}
this.updateBtnIcon.prop("disabled",true)
this.setLoader()
const ajax = new Ajax(
`/configuracion/errores-presupuesto/edit/${this.errorPresupuestoId}`,
data,
null,
this.handlePostErrorPresupuestoSuccess.bind(this),
this.handlePostErrorPresupuestoError.bind(this)
)
ajax.post()
}
handlePostErrorPresupuestoSuccess(){
this.handleGetErrorPresupuesto()
}
handlePostErrorPresupuestoError(error){}
}
export default ErrorPresupuestoForm;

View File

@ -0,0 +1,6 @@
import ErrorPresupuestoForm from "./errorPresupuestoForm.js";
$(document).ready(() => {
const errorPresupuestoForm = new ErrorPresupuestoForm($("#error-presupuesto-container"))
errorPresupuestoForm.init()
})

View File

@ -0,0 +1,6 @@
import ErrorPresupuestoView from "./errorPresupuesto.js";
$(document).ready(()=>{
const errorPresupuesto = new ErrorPresupuestoView($("#errorPresupuestoCard"))
errorPresupuesto.init()
})