Neuigkeiten/News/Blog-Editing und Bugfixes
This commit is contained in:
23
public/css/blog/edit.css
Normal file
23
public/css/blog/edit.css
Normal file
@@ -0,0 +1,23 @@
|
||||
.blogEdit {
|
||||
padding: 0.5em;
|
||||
border: 1px solid black;
|
||||
}
|
||||
|
||||
.blogEdit button {
|
||||
padding: 0.7em;
|
||||
font-size: 1em;
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
.blogEdit input[type=text] {
|
||||
font-size: 1em;
|
||||
}
|
||||
|
||||
.blogEdit textarea {
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
.blogEdit select {
|
||||
font-size: 1em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
@@ -83,6 +83,7 @@ html, body {
|
||||
.eingabemaske {
|
||||
border: 5px inset;
|
||||
font-size: 1.2em;
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
.eingabemaske table, th, td {
|
||||
@@ -97,6 +98,7 @@ html, body {
|
||||
padding: 1em;
|
||||
border: 4px outset;
|
||||
font-size: 1.2em;
|
||||
background-color: #ccc;
|
||||
}
|
||||
|
||||
#fehlermeldung {
|
||||
|
||||
96
public/js/blog/blog.js
Normal file
96
public/js/blog/blog.js
Normal file
@@ -0,0 +1,96 @@
|
||||
$(function() {
|
||||
$('select[autocomplete="off"]').each(function() {
|
||||
let selectedValue = $(this).find('option[selected]').val();
|
||||
if (selectedValue) {
|
||||
$(this).val(selectedValue);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function addBlog(){
|
||||
|
||||
let b = {};
|
||||
b.title = $('#blogTitle_new').val();
|
||||
b.body = $('#blogBody_new').val();
|
||||
b.published = $('#blogPublished_new').is(":checked") ? "1" : "0";
|
||||
b.language = $('#blogLanguage_new').val();
|
||||
|
||||
console.log(b);
|
||||
|
||||
if(window.confirm('Eintrag wirklich speichern?')){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "/intern/nachrichten/add",
|
||||
data: b,
|
||||
dataType: "json",
|
||||
success:function(r){
|
||||
if(r.messageStatus === "success"){
|
||||
$('#blogTitle_new').val("");
|
||||
$('#blogBody_new').val("");
|
||||
$('#blogLanguage_new').val("de");
|
||||
location.reload();
|
||||
} else {
|
||||
alert(r.errorMessage);
|
||||
}
|
||||
},
|
||||
error:function(r, a, e){
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function editBlog(blogId){
|
||||
let b = {};
|
||||
b.id = blogId;
|
||||
b.title = $('#blogTitle_'+blogId).val();
|
||||
b.body = $('#blogBody_'+blogId).val();
|
||||
b.published = $('#blogPublished_'+blogId).is(":checked") ? "1" : "0";
|
||||
b.language = $('#blogLanguage_'+blogId).val();
|
||||
|
||||
if(window.confirm('Eintrag wirklich speichern?')){
|
||||
$.ajax({
|
||||
type: "PUT",
|
||||
url: "/intern/nachrichten/edit",
|
||||
data: b,
|
||||
dataType: "json",
|
||||
success:function(r){
|
||||
if(r.messageStatus === "success"){
|
||||
location.reload();
|
||||
} else {
|
||||
alert(r.errorMessage);
|
||||
}
|
||||
},
|
||||
error:function(r, a, e){
|
||||
alert(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function deleteBlog(blogId){
|
||||
let b = {};
|
||||
b.id = blogId;
|
||||
|
||||
if(window.confirm('Eintrag wirklich löschen?')){
|
||||
$.ajax({
|
||||
type:"DELETE",
|
||||
url:"/intern/nachrichten/delete",
|
||||
data:b,
|
||||
dataType:"json",
|
||||
success:function(r){
|
||||
if(r.messageStatus === "success"){
|
||||
$('#blogDelete_' + blogId).closest('.blogEdit').fadeOut(300, function() {
|
||||
$(this).remove();
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
alert(r.errorMessage);
|
||||
}
|
||||
},
|
||||
error:function(r, a, e){
|
||||
alert(e);
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user