From: Alexander Smirnov Date: Fri, 24 May 2024 10:33:02 +0000 (+0300) Subject: return city-store/index.js from old project X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=f9908f480da1d0d87e2bc96d921ba15b7c0a2341;p=yii-erp24%2F.git return city-store/index.js from old project --- diff --git a/erp24/web/js/city-store/index.js b/erp24/web/js/city-store/index.js new file mode 100644 index 0000000..7fe1616 --- /dev/null +++ b/erp24/web/js/city-store/index.js @@ -0,0 +1,37 @@ +/* jshint esversion: 6 */ +const param30 = $('meta[name=csrf-param]').attr("content"); +const token30 = $('meta[name=csrf-token]').attr("content"); + + +function setTgDialog(storeId, tg_chat_id) { + const $mainModal = $('#mainModal'); + const $modalBody = $mainModal.find('.modal-body'); + $modalBody.html(''); + const $modalFooter = $mainModal.find('.modal-footer'); + $modalFooter.html(''); + $modalFooter.get(0).insertAdjacentHTML('beforeend', ''); + const $saveButton = $modalFooter.find('button'); + $saveButton.addClass(['btn', 'btn-success', 'btn-lg']); + $saveButton.on('click', () => { + $.ajax({ + method: 'POST', + url: window.location.href, + data: {action: 'saveTg', storeId, tgInput: $tgInput.val(), [param30]: token30}, + dataType: "text", + success: function (data) { + console.log(data); + if (data === 'ok') { + window.location.reload(); + } + } + }); + }) + const $tgInput = $modalBody.find('input'); + if (tg_chat_id) { + $tgInput.val(tg_chat_id); + } + $mainModal.find('.modal-title').html('Установка Телеграм чата'); + $mainModal.find('.close').on('click', () => $('#mainModal').modal('hide')); + + $mainModal.modal('show'); +} \ No newline at end of file