Backend für Anträge; unnötiges location.reload() entfernt

This commit is contained in:
2026-03-30 00:41:32 +02:00
parent e5d970333f
commit 4c94066bf9
7 changed files with 165 additions and 39 deletions

View File

@@ -82,7 +82,6 @@ function deleteBlog(blogId){
if(r.messageStatus === "success"){
$('#blogDelete_' + blogId).closest('.blogEdit').fadeOut(300, function() {
$(this).remove();
location.reload();
});
} else {
alert(r.errorMessage);

View File

@@ -1,27 +1,63 @@
$(function() {
$('select[autocomplete="off"]').each(function() {
let selectedValue = $(this).find('option[selected]').val();
if (selectedValue) {
$(this).val(selectedValue);
}
});
function updateMaxlengths(element) {
const row = $(element).closest('tr');
const passportType = row.find('.passport-type-select').val();
let maxLength;
switch (passportType) {
case 'd':
maxLength = 17;
break;
case 'k':
maxLength = 25;
break;
default:
maxLength = 17;
}
row.find('.first-name-input, .last-name-input, .location-input').attr('maxlength', maxLength);
}
$('.passport-type-select').each(function() {
updateMaxlengths(this);
});
$(document).on('change', '.passport-type-select', function() {
updateMaxlengths(this);
});
});
function addApplication(){
let data = {};
data.district_region = $('#region_new').val();
data.passport_type = $('#passport_type').val();
data.mail = $('#mail').val();
data.first_name = $('#firstname').val();
data.last_name = $('#lastname').val();
data.location = $('#location').val();
data.passport_type = $('#passport_type_new').val();
data.mail = $('#mail_new').val();
data.first_name = $('#first_name_new').val();
data.last_name = $('#last_name_new').val();
data.location = $('#location_new').val();
console.log(data);
$.ajax({
type: "POST",
url: "/intern/antraege/neu",
url: "/intern/antraege/hinzufuegen",
data: data,
dataType: "json",
success:function(r){
if(r.messageStatus === "success"){
$('#mail').val("");
$('#firstname').val("");
$('#lastname').val("");
$('#location').val("");
alert(r.errorMessage);
$('#mail_new').val("");
$('#first_name_new').val("");
$('#last_name_new').val("");
$('#location_new').val("");
location.reload();
} else {
alert(r.errorMessage);
}
@@ -35,7 +71,9 @@ function addApplication(){
function deleteApplication(applicationId){
let data = {};
data.id = applicationId;
console.log(data);
if(window.confirm(i18n.blog.confirm_delete)){
$.ajax({
type: "DELETE",
@@ -44,7 +82,40 @@ function deleteApplication(applicationId){
dataType: "json",
success:function(r){
if(r.messageStatus === "success"){
alert(r.errorMessage);
$('#application_' + applicationId).fadeOut(300, function() {
$(this).remove();
});
} else {
alert(r.errorMessage);
}
},
error:function(r, a, e){
alert(i18n.common.error_occurred + e);
}
});
}
}
function editApplication(applicationId){
let data = {};
data.id = applicationId;
data.first_name = $('#first_name_'+applicationId).val();
data.last_name = $('#last_name_'+applicationId).val();
data.location = $('#location_'+applicationId).val();
data.mail = $('#mail_'+applicationId).val();
data.passport_type = $('#passport_type_'+applicationId).val();
console.log(data);
if(window.confirm(i18n.blog.confirm_save)){
$.ajax({
type: "PUT",
url: "/intern/antraege/bearbeiten",
data: data,
dataType: "json",
success:function(r){
if(r.messageStatus === "success"){
location.reload();
} else {
alert(r.errorMessage);
}