This commit is contained in:
David Štaleker
2024-03-11 06:46:32 +01:00
parent 4ea291622a
commit 172626c8ee
9 changed files with 367 additions and 124 deletions

View File

@@ -4,16 +4,61 @@ $(function(){
$('#inpOpenEditorForPage').val(0);
openEditor(openEditorForPage);
}
$('[data-toggle="tooltip"]').tooltip();
loadPages();
});
function loadPages(){
$.blockUI();
$.ajax({
type: "GET",
url: "/Pages/Index/?handler=Pages",
data: {
},
success: function (data) {
if (data.successful){
let pageContent = $('.div-pages');
pageContent.empty();
if (data.pages){
data.pages.forEach((page) => {
addPageToDiv(page);
});
}
} else {
Swal.fire('Napaka', data.error, 'error');
console.log(data);
}
$.unblockUI();
},
error: function (xhr, ajaxOptions, thrownError) {
console.log(xhr);
alert(xhr.responseText);
$.unblockUI();
}
});
}
function addPageToDiv(page){
let element = $(`<div class="div-page" data-id="${page.idBulletinBoardPage}">
<img class="img-thumbnail rounded" src="/bulletin-board-images/pages/${page.image}" alt="page image" />
<small>${page.name}</small>
<div class="tools">
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-primary borderless" onclick="pageOpenEditor(this);" data-toggle="tooltip" data-placement="top" title="Urejevalnik" data-state="secondary"><i class="far fa-edit"></i></a>
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-secondary borderless" onclick="openModalEditPage(this);" data-toggle="tooltip" data-placement="top" title="Urejanje" data-state="secondary"><i class="fas fa-pencil-alt"></i></a>
<a href="javascript:;" class="btn btn-xs icon-btn btn-outline-danger borderless" onclick="deletePage(this)"><i class="fas fa-trash-alt"></i></a>
</div>
</div>`);
$('.div-pages').append(element);
element.find('[data-toggle="tooltip"]').tooltip();
}
function openModalAddPage(){
$('#inpModalAddEditPageIdPage').val(0);
$('#inpModalAddEditPageName').val('');
$('#divModalAddEditPage').modal('show');
}
function openModalEditPage(el){
let idBulletinBoardPage = parseInt($(el).parent().parent().attr('data-id'));
if (isNaN(idBulletinBoardPage)){
@@ -105,7 +150,7 @@ function saveModalAddEditPage(){
});
}
function rowOpenEditor(el){
function pageOpenEditor(el){
openEditor(parseInt($(el).parent().parent().attr('data-id')));
}