Added Notice-Update functionality

. added notice updates functionality by clicking on a row in the notice-table
. log "Notice updated" is set into log-table when note was updated successfully
This commit is contained in:
Cris
2018-04-18 14:34:36 +02:00
parent 4b58ed44ab
commit daab764a14
4 changed files with 133 additions and 22 deletions
+68 -4
View File
@@ -96,11 +96,45 @@ $(document).ready(
$("#notizform").on("submit", function (e)
{
e.preventDefault();
var personid = $("#hiddenpersonid").val();
var personId = $("#hiddenpersonid").val();
var notizId = $("#notizform :input[name='hiddenNotizId']").val();
var data = $(this).serializeArray();
saveNotiz(personid, data);
if (notizId !== '')
{
updateNotiz(notizId, personId, data);
}
else
{
saveNotiz(personId, data);
}
}
)
);
//update notiz - autofill notizform
$(document).on("click", "#notiztable tbody tr", function ()
{
var notizId = $(this).find("td:eq(3)").html();
var notizTitle = $(this).find("td:eq(1)").text();
var notizContent = this.title;
$("#notizform label:first").text("Notiz ändern").css("color", "red");
$("#notizform :input[type='reset']").css("display", "inline-block");
$("#notizform :input[name='hiddenNotizId']").val(notizId);
$("#notizform :input[name='notiztitel']").val(notizTitle);
$("#notizform :input[name='notiz']").val(notizContent);
}
);
//update notiz - abbrechen-button: reset styles
$("#notizform :input[type='reset']").click(function ()
{
resetNotizFields();
}
);
});
// -----------------------------------------------------------------------------------------------------------------
@@ -220,6 +254,29 @@ function saveNotiz(personid, data)
});
}
function updateNotiz(notizId, personId, data)
{
$.ajax({
type: "POST",
dataType: "json",
data: data,
url: "../updateNotiz/" + notizId + "/" + personId,
success: function (data, textStatus, jqXHR)
{
if (data)
{
refreshNotizen();
refreshLog();
resetNotizFields();
}
},
error: function (jqXHR, textStatus, errorThrown)
{
alert(textStatus + " - " + errorThrown + " - " + jqXHR.responseText);
}
});
}
// -----------------------------------------------------------------------------------------------------------------
// methods executed after ajax (refreshers)
@@ -252,7 +309,7 @@ function refreshNotizen()
//readd tablesorter
formatNotizTable()
}
);
);
}
function formatNotizTable()
@@ -261,3 +318,10 @@ function formatNotizTable()
tablesortAddPager("notiztable", "notizpager", 10);
$("#notiztable").addClass("table-condensed");
}
function resetNotizFields()
{
$("#notizform :input[name='hiddenNotizId']").val("");
$("#notizform label:first").text("Notiz hinzufügen").css("color", "black");
$("#notizform :input[type='reset']").css("display", "none");
}