diff --git a/addons/default/visiosoft/advs-module/resources/js/editContactInformation.js b/addons/default/visiosoft/advs-module/resources/js/editContactInformation.js index 8c4e95740..7b852843d 100644 --- a/addons/default/visiosoft/advs-module/resources/js/editContactInformation.js +++ b/addons/default/visiosoft/advs-module/resources/js/editContactInformation.js @@ -1,30 +1,48 @@ phoneMask("input[name='gsm_phone'],input[name='office_phone'],input[name='land_phone']") $('.formEditInfo').on('submit', function (e) { e.preventDefault(); + + const oldBtnHtml = $(this).find('.btn-success').html(); + $(this).find('.btn-success').attr('disabled', true).html(` + + `); + var form = $(this); - crud(form.serialize() + "&action=update", '/ajax/update-user-info', 'POST', function (callback) { - if (callback.status == "success") { - var profile = callback.data; - $('.infoName').html(profile.first_name + " " + profile.last_name); - $('.infoGsmPhone').html(profile.gsm_phone); - $('.infoOfficePhone').html(profile.office_phone); - $('.infoLandPhone').html(profile.land_phone); - $('#editMyInfo').modal('hide'); + $.ajax({ + type: 'POST', + data: form.serialize() + "&action=update", + url: '/ajax/update-user-info', + success: function (response) { + if (response.status == "success") { + var profile = response.data; + $('.infoName').html(profile.first_name + " " + profile.last_name); + $('.infoGsmPhone').html(profile.gsm_phone); + $('.infoOfficePhone').html(profile.office_phone); + $('.infoLandPhone').html(profile.land_phone); + $('#editMyInfo').modal('hide'); + + $('.formEditInfo .btn-success').attr('disabled', false).html(oldBtnHtml); + } } - }) -}) + }); +}); $('.editInformationUser').on('click', function () { $('#editMyInfo').modal('show'); - crud({}, '/ajax/update-user-info', 'POST', function (callback) { - if (callback.status == "success") { - var profile = callback.data; - $('input[name="first_name"]').val(profile.first_name) - $('input[name="last_name"]').val(profile.last_name) - intlTelInput(document.querySelector("input[name='gsm_phone']")).setNumber(profile.gsm_phone) - intlTelInput(document.querySelector("input[name='office_phone']")).setNumber(profile.office_phone) - intlTelInput(document.querySelector("input[name='land_phone']")).setNumber(profile.land_phone) + + $.ajax({ + type: 'POST', + url: '/ajax/update-user-info', + success: function (response) { + if (response.status == "success") { + var profile = response.data; + $('input[name="first_name"]').val(profile.first_name) + $('input[name="last_name"]').val(profile.last_name) + intlTelInput(document.querySelector("input[name='gsm_phone']")).setNumber(profile.gsm_phone) + intlTelInput(document.querySelector("input[name='office_phone']")).setNumber(profile.office_phone) + intlTelInput(document.querySelector("input[name='land_phone']")).setNumber(profile.land_phone) + } } - }) + }); }) \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig index 3a58ebaaf..435a6582b 100644 --- a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig +++ b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig @@ -1,8 +1,8 @@ {% extends layout('new-create') %} {% block content %} -
-
+
+
{{ asset_add("scripts.js", "visiosoft.module.advs::js/editContactInformation.js") }} - -