ver 0.262 - pages module refactor and admin UX fixes

This commit is contained in:
2026-02-13 21:17:21 +01:00
parent 26ebf59849
commit 67705f1f56
44 changed files with 2235 additions and 1803 deletions

View File

@@ -1,89 +1,87 @@
<?
<?php
global $gdb;
$pageId = (int)($this->page_id ?? 0);
$articles = is_array($this->articles ?? null) ? $this->articles : [];
ob_start();
?>
<ol class="sortable" id="article-list">
<?
if ( is_array( $this -> articles ) ) foreach ( $this -> articles as $article )
{
?>
<li id="list_<?= $article['article_id'];?>">
<div class="content <? if ( !$article['status'] ) echo 'text-danger';?>"><span class="disclose"><span></span></span> <?= $article['title'];?></div>
</li>
<?
}
<ol class="sortable" id="article-list">
<?php foreach ($articles as $article): ?>
<?php
$articleId = (int)($article['article_id'] ?? 0);
$title = (string)($article['title'] ?? '');
$status = (int)($article['status'] ?? 0);
?>
</ol>
<?
<li id="list_<?= $articleId; ?>">
<div class="content <?= $status === 1 ? '' : 'text-danger'; ?>"><span class="disclose"><span></span></span> <?= htmlspecialchars($title, ENT_QUOTES, 'UTF-8'); ?></div>
</li>
<?php endforeach; ?>
</ol>
<?php
$out = ob_get_clean();
$grid = new \gridEdit;
$grid -> gdb_opt = $gdb;
$grid -> include_plugins = true;
$grid -> default_buttons = false;
$grid -> external_code = $out;
$grid -> title = 'Lista artykułów';
$grid -> buttons = [
[
'label' => 'Wstecz',
'url' => '/admin/pages/view_list/',
'icon' => 'fa-reply',
'class' => 'btn-dark'
]
];
echo $grid -> draw();
$grid->gdb_opt = $gdb;
$grid->include_plugins = true;
$grid->default_buttons = false;
$grid->external_code = $out;
$grid->title = 'Lista artyku&#322;&#243;w';
$grid->buttons = [
[
'label' => 'Wstecz',
'url' => '/admin/pages/list/',
'icon' => 'fa-reply',
'class' => 'btn-dark',
],
];
echo $grid->draw();
?>
<script type="text/javascript" src="/libraries/jquery-nested-sortable/jquery.mjs.nestedSortable.js"></script>
<script type="text/javascript">
$( document ).ready( function()
{
$( 'ol.sortable' ).nestedSortable(
{
forcePlaceholderSize: true,
handle: 'div',
helper: 'clone',
items: 'li',
opacity: .6,
placeholder: 'placeholder',
revert: 250,
tabSize: 25,
tolerance: 'pointer',
toleranceElement: '> div',
maxLevels: 1,
isTree: true,
expandOnHover: 700,
$(document).ready(function() {
$('ol.sortable').nestedSortable({
forcePlaceholderSize: true,
handle: 'div',
helper: 'clone',
items: 'li',
opacity: 0.6,
placeholder: 'placeholder',
revert: 250,
tabSize: 25,
tolerance: 'pointer',
toleranceElement: '> div',
maxLevels: 1,
isTree: true,
expandOnHover: 700,
save_articles_order: true
});
});
});
function save_articles_order()
{
articles = $( 'ol.sortable' ).nestedSortable( 'toArray', { startDepthCount: 0 } );
$.ajax(
{
function save_articles_order() {
var articles = $('ol.sortable').nestedSortable('toArray', { startDepthCount: 0 });
$.ajax({
type: 'POST',
cache: false,
url: '/admin/ajax.php',
data:
{
a: 'save_articles_order',
page_id: <?= $this -> page_id;?>,
url: '/admin/pages/saveArticlesOrder/',
data: {
page_id: <?= $pageId; ?>,
articles: articles
},
beforeSend: function()
{
$.prompt( 'Trwa zapisywanie...', { title: 'Proszę czekać' } );
beforeSend: function() {
$.prompt('Trwa zapisywanie...', { title: 'Prosz\\u0119 czeka\\u0107' });
},
success: function( data )
{
$( '.jqibox' ).remove();
response = jQuery.parseJSON( data );
success: function(data) {
$('.jqibox').remove();
var response = jQuery.parseJSON(data);
if ( response.status === 'error' )
create_error( response.msg );
if (response.status === 'error') {
create_error(response.msg);
}
}
});
}
</script>
</script>