Починил кнопку назад и убрал перенаправление после сохранения на страницу списка
This commit is contained in:
@@ -54,17 +54,20 @@
|
||||
@method('PATCH')
|
||||
<!-- Кнопки действий -->
|
||||
<div class="flex space-x-4 mb-8">
|
||||
<button type="submit" class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
|
||||
<button type="submit"
|
||||
onclick="saveAndRefresh(event)"
|
||||
class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600">
|
||||
Сохранить
|
||||
</button>
|
||||
<button class="px-4 py-2 bg-green-500 text-white rounded hover:bg-green-600">
|
||||
Провести
|
||||
</button>
|
||||
<a href="{{ route('teacher.statements.generatePdf', ['statementId' => $statement['id'], 'with_grades' => false]) }}"
|
||||
target="_blank"
|
||||
class="px-4 py-2 bg-gray-500 text-white rounded hover:bg-gray-600">
|
||||
Скачать ведомость без оценок
|
||||
</a>
|
||||
<a href="{{ url()->previous() }}" class="px-4 py-2 bg-gray-300 text-gray-700 rounded hover:bg-gray-400">
|
||||
<a href="/statements" class="px-4 py-2 bg-gray-300 text-gray-700 rounded hover:bg-gray-400">
|
||||
Назад
|
||||
</a>
|
||||
|
||||
@@ -107,4 +110,32 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function saveAndRefresh(event) {
|
||||
event.preventDefault();
|
||||
|
||||
const form = event.target.closest('form');
|
||||
const formData = new FormData(form);
|
||||
|
||||
fetch(form.action, {
|
||||
method: 'POST',
|
||||
body: formData,
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
'Accept': 'application/json, text/html'
|
||||
}
|
||||
})
|
||||
.then(response => {
|
||||
if (!response.ok) throw new Error('Ошибка сохранения');
|
||||
return response.text();
|
||||
})
|
||||
.then(() => {
|
||||
window.location.reload();
|
||||
})
|
||||
.catch(error => {
|
||||
console.error('Ошибка:', error);
|
||||
alert(error.message);
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endsection
|
||||
|
||||
Reference in New Issue
Block a user