From ba8ef63e95fc2fa461eb18274f4d8a4b37b390b5 Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Thu, 19 Feb 2026 12:32:53 +0100 Subject: [PATCH] feat: Add task edit message notifications with success and error handling --- .vscode/ftp-kr.sync.cache.json | 46 +++++++++++++----- templates/tasks/task_edit.php | 87 ++++++++++++++++++++++++++++++++++ 2 files changed, 120 insertions(+), 13 deletions(-) diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index 29d5d20..dde2aed 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -121,8 +121,8 @@ }, "class.Tasks.php": { "type": "-", - "size": 24179, - "lmtime": 1771336367894, + "size": 25433, + "lmtime": 1771495209476, "modified": false }, "class.Users.php": { @@ -164,14 +164,14 @@ }, "MailToTaskImporter.php": { "type": "-", - "size": 43841, - "lmtime": 1771426284341, + "size": 56836, + "lmtime": 1771496082257, "modified": false }, "TaskAttachmentRepository.php": { "type": "-", - "size": 8806, - "lmtime": 1770731454505, + "size": 11955, + "lmtime": 1771496082258, "modified": false }, "WorkTimeRepository.php": { @@ -335,14 +335,14 @@ }, "main_view.php": { "type": "-", - "size": 42784, + "size": 41808, "lmtime": 1771336223833, - "modified": false + "modified": true }, "task_edit.php": { "type": "-", - "size": 10758, - "lmtime": 1771237304287, + "size": 29190, + "lmtime": 1771495910826, "modified": false }, "task_popup.php": { @@ -478,12 +478,32 @@ "lmtime": 1770653587539, "modified": false } + }, + "Tasks": { + "MailToTaskImporterTest.php": { + "type": "-", + "size": 3494, + "lmtime": 1771496082259, + "modified": false + }, + "TaskAttachmentRepositoryTest.php": { + "type": "-", + "size": 1728, + "lmtime": 1771496082260, + "modified": false + }, + "WorkTimeRepositoryTest.php": { + "type": "-", + "size": 1913, + "lmtime": 0, + "modified": false + } } }, "run.php": { "type": "-", - "size": 851, - "lmtime": 1770653605021, + "size": 970, + "lmtime": 1771496082261, "modified": false } }, @@ -515,7 +535,7 @@ "VIDOK_Instrukcja Montażu I Uruchomienia - Wyroby Elektryczne.pdf": { "type": "-", "size": 230708, - "lmtime": 0, + "lmtime": 1771496082255, "modified": false } } diff --git a/templates/tasks/task_edit.php b/templates/tasks/task_edit.php index ab7c07e..863905d 100644 --- a/templates/tasks/task_edit.php +++ b/templates/tasks/task_edit.php @@ -418,6 +418,44 @@ ob_start(); font-style: italic; } + .task-edit-message { + margin: 12px 0 16px 0; + padding: 12px 16px; + border-radius: 6px; + display: flex; + align-items: center; + position: relative; + animation: slideDown 0.3s ease; + border-left: 4px solid; + } + + @keyframes slideDown { + from { + opacity: 0; + transform: translateY(-10px); + } + to { + opacity: 1; + transform: translateY(0); + } + } + + .task-edit-message.alert-success { + background-color: #d4edda; + border-color: #28a745; + color: #155724; + } + + .task-edit-message.alert-danger { + background-color: #f8d7da; + border-color: #dc3545; + color: #721c24; + } + + .task-edit-message i { + font-size: 16px; + } + @media (max-width: 991px) { .task-edit-tabs .task-tabs-nav .js-task-edit-tab-btn { flex: 1 1 50%; @@ -892,5 +930,54 @@ echo $grid -> draw(); } }, 0 ); }); + + // Override globalne funkcje komunikatów dla tej strony + window.create_message_original = window.create_message; + window.create_error_original = window.create_error; + + function showTaskEditMessage( msg, type ) { + var messageClass = type === 'success' ? 'alert-success' : 'alert-danger'; + var icon = type === 'success' ? '' : ''; + var containerId = 'task-edit-message-container'; + + // Usuń stary komunikat jeśli istnieje + $( '#' + containerId ).remove(); + + // Dodaj DIV dla komunikatów na górze formularza + task_edit_root.before( '' ); + + // Handler dla przycisku zamknięcia + $( '#' + containerId ).find( '.task-edit-message-close' ).on( 'click', function() { + $( '#' + containerId ).fadeOut( 300, function() { + $( this ).remove(); + }); + }); + + // Automatycznie ukryj komunikat po 5 sekundach jeśli to sukces + if ( type === 'success' ) { + setTimeout( function() { + var msg = $( '#' + containerId ); + if ( msg.length ) { + msg.fadeOut( 300, function() { + $( this ).remove(); + }); + } + }, 5000 ); + } + } + + // Przechwytuj wywołania funkcji create_message + window.create_message = function( text ) { + showTaskEditMessage( text, 'success' ); + }; + + // Przechwytuj wywołania funkcji create_error + window.create_error = function( text ) { + showTaskEditMessage( text, 'error' ); + }; });