From: Vladimir Fomichev Date: Thu, 2 Oct 2025 12:20:21 +0000 (+0300) Subject: Перенос JS X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=6c28c77a8a6491f55de1035bac2c0a6d85c88732;p=erp24_rep%2Fyii-erp24%2F.git Перенос JS --- diff --git a/erp24/web/js/matrix-erp/index.js b/erp24/web/js/matrix-erp/index.js new file mode 100644 index 00000000..a8edda71 --- /dev/null +++ b/erp24/web/js/matrix-erp/index.js @@ -0,0 +1,67 @@ +// Matrix ERP Feed Active Toggle Functions + +function toggleFeedActive(id, isActive) { + // Попробуем получить CSRF токен из мета-тега + let csrfToken = $('meta[name=csrf-token]').attr('content'); + if (!csrfToken) { + csrfToken = window.csrfToken || ''; + } + + $.ajax({ + url: window.matrixErpToggleFeedActiveUrl, + type: 'POST', + data: { + id: id, + is_feed_active: isActive ? 1 : 0, + _csrf: csrfToken + }, + success: function(response) { + showAlert(response.success ? 'success' : 'danger', response.message); + }, + error: function(xhr, status, error) { + let message = 'Произошла ошибка при обновлении статуса фида'; + if (xhr.responseJSON && xhr.responseJSON.message) { + message = xhr.responseJSON.message; + } + showAlert('danger', message); + } + }); +} + +function showAlert(type, message) { + // Проверяем, что jQuery доступен + if (typeof $ === 'undefined') { + console.error('jQuery not found!'); + alert(message); // fallback + return; + } + + const alertContainer = $('#feed-alert-container'); + if (alertContainer.length === 0) { + console.error('Alert container not found!'); + alert(message); // fallback + return; + } + + const alertId = 'alert-' + Date.now(); + const alertHtml = ` + + `; + + alertContainer.append(alertHtml); + + // Auto remove after 5 seconds + setTimeout(function() { + const alertElement = $('#' + alertId); + if (alertElement.length > 0) { + alertElement.fadeOut(function() { + $(this).remove(); + }); + } + }, 5000); +} + +// Functions for Matrix ERP Feed Active Toggle