solucionados problemas en tarifas cliente

This commit is contained in:
2024-12-07 12:35:08 +01:00
parent 94ca8a5a7a
commit ece908c954

View File

@ -49,7 +49,7 @@ class tarifasClienteView {
this.#initTable();
this.selectorPlantilla.init();
this.#getPlantillaPrecios();
this.convertToTemplateBtn.on('click', function () {
@ -188,15 +188,17 @@ class tarifasClienteView {
this.editorTarifas.editor.on('postEdit', function (e, json, data, action) {
self.#borrarPlantillaTarifa(self.clienteId);
self.selectorPlantilla.offChange();
self.selectorPlantilla.empty();
self.selectorPlantilla.setOption(0, 'Personalizado');
self.selectorPlantilla.onChange(self.#changePlantilla.bind(this));
self.selectorPlantilla.onChange(self.#changePlantilla.bind(self));
})
this.editorTarifas.editor.on('postCreate', function (e, json, data, action) {
self.#borrarPlantillaTarifa(self.clienteId);
self.selectorPlantilla.offChange();
self.selectorPlantilla.empty();
self.selectorPlantilla.setOption(0, 'Personalizado');
self.selectorPlantilla.onChange(self.#changePlantilla.bind(this));
self.selectorPlantilla.onChange(self.#changePlantilla.bind(self));
})
this.editorTarifas.editor.on('postCancel', function (e, json, data) {
@ -246,7 +248,9 @@ class tarifasClienteView {
},
{},
(data) => {
this.selectorPlantilla.offChange();
if (data !== null && typeof data === 'object') {
if (data.hasOwnProperty('id') && data.id != null)
this.selectorPlantilla.setOption(data.id, data.nombre);
else {
@ -254,6 +258,7 @@ class tarifasClienteView {
}
}
else {
this.selectorPlantilla.setOption(0, 'Personalizado');
}
this.selectorPlantilla.onChange(this.#changePlantilla.bind(this));
@ -268,6 +273,7 @@ class tarifasClienteView {
#changePlantilla() {
const self = this;
const data = $('#plantillas').select2('data');
if (data.length > 0) {
if (data[0].id == 0) {
@ -280,12 +286,14 @@ class tarifasClienteView {
const id = data[0].id;
if(id == 0)
id = -1;
new Ajax(
'/clienteprecios/changeplantilla',
{
'cliente_id': self.clienteId,
'plantilla_id': id,
[this.csrf_token]: this.csrf_hash
[self.csrf_token]: self.csrf_hash
},
{},
() => {