feat: Add task edit message notifications with success and error handling

This commit is contained in:
2026-02-19 12:32:53 +01:00
parent a115d881de
commit ba8ef63e95
2 changed files with 120 additions and 13 deletions

View File

@@ -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
}
}

View File

@@ -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' ? '<i class="fa fa-check-circle"></i>' : '<i class="fa fa-exclamation-circle"></i>';
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( '<div id="' + containerId + '" class="task-edit-message alert ' + messageClass + '" role="alert">' +
icon +
'<span style="margin-left: 8px;">' + msg + '</span>' +
'<button type="button" class="task-edit-message-close" aria-label="Zamknij" style="position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: none; border: none; font-size: 20px; cursor: pointer; color: inherit;">&times;</button>' +
'</div>' );
// 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' );
};
});
</script>