Bug fixes on UI

This commit is contained in:
Diego Najar 2021-09-12 20:57:44 +02:00
parent 2eac988843
commit 6a0f32900b
5 changed files with 367 additions and 339 deletions

View file

@ -80,6 +80,7 @@ function table($type)
global $scheduled; global $scheduled;
global $static; global $static;
global $sticky; global $sticky;
global $unlisted;
if ($type == 'published') { if ($type == 'published') {
$list = $published; $list = $published;
@ -113,6 +114,14 @@ function table($type)
echo '</p>'; echo '</p>';
return false; return false;
} }
} elseif ($type == 'unlisted') {
$list = $unlisted;
if (empty($list)) {
echo '<p class="text-muted p-4">';
echo $L->g('There are no unlisted pages at this moment.');
echo '</p>';
return false;
}
} elseif ($type == 'sticky') { } elseif ($type == 'sticky') {
$list = $sticky; $list = $sticky;
if (empty($list)) { if (empty($list)) {
@ -234,6 +243,9 @@ function table($type)
} ?> } ?>
</a> </a>
</li> </li>
<li class="nav-item">
<a class="nav-link" id="unlisted-tab" data-bs-toggle="tab" href="#unlisted" role="tab" aria-controls="unlisted" aria-selected="true"><?php $L->p('Unlisted') ?></a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" id="draft-tab" data-bs-toggle="tab" href="#draft" role="tab" aria-controls="draft" aria-selected="true"><?php $L->p('Draft') ?></a> <a class="nav-link" id="draft-tab" data-bs-toggle="tab" href="#draft" role="tab" aria-controls="draft" aria-selected="true"><?php $L->p('Draft') ?></a>
</li> </li>
@ -295,6 +307,11 @@ function table($type)
<?php table('scheduled'); ?> <?php table('scheduled'); ?>
</div> </div>
<!-- TABS UNLISTED -->
<div class="tab-pane" id="unlisted" role="tabpanel">
<?php table('unlisted'); ?>
</div>
<!-- TABS DRAFT --> <!-- TABS DRAFT -->
<div class="tab-pane" id="draft" role="tabpanel"> <div class="tab-pane" id="draft" role="tabpanel">
<?php table('draft'); ?> <?php table('draft'); ?>

View file

@ -134,8 +134,11 @@
var args = { var args = {
title: $('#title').val(), title: $('#title').val(),
content: editorGetContent(), content: editorGetContent(),
coverImage: $('#coverImage').val(),
category: $('#category option:selected').val(), category: $('#category option:selected').val(),
tags: $('#tags').val() tags: $("#tags option:selected").map(function() {
return this.value
}).get().join(",")
} }
savePage(args); savePage(args);
disableBtnSave(); disableBtnSave();
@ -177,6 +180,7 @@
var args = { var args = {
title: $('#title').val(), title: $('#title').val(),
content: editorGetContent(), content: editorGetContent(),
coverImage: $('#coverImage').val(),
category: $('#category option:selected').val(), category: $('#category option:selected').val(),
tags: $("#tags option:selected").map(function() { tags: $("#tags option:selected").map(function() {
return this.value return this.value
@ -288,7 +292,9 @@
// ------------------------------------------------------------------------ // ------------------------------------------------------------------------
$('#btnSaveSeo').on('click', function() { $('#btnSaveSeo').on('click', function() {
var args = { var args = {
parent: $('#parent').val() noindex: $('input[name="noindex"]').is(':checked'),
nofollow: $('input[name="nofollow"]').is(':checked'),
noarchive: $('input[name="noarchive"]').is(':checked')
}; };
savePage(args); savePage(args);
disableBtnSave(); disableBtnSave();
@ -594,7 +600,8 @@
<!-- Cover Image --> <!-- Cover Image -->
<h6 class="text-uppercase"><?php $L->p('Cover Image') ?></h6> <h6 class="text-uppercase"><?php $L->p('Cover Image') ?></h6>
<div> <div>
<img id="jscoverImagePreview" class="mx-auto d-block w-100" alt="Cover image preview" src="<?php echo (($pageKey && $page->coverImage()) ? $page->coverImage() : HTML_PATH_CORE_IMG . 'default.svg') ?>" /> <input id="coverImage" name="coverImage" data-save="true" type="hidden" value="<?php echo (($pageKey && $page->coverImage()) ? $page->coverImage(false) : '') ?>">
<img id="coverImagePreview" class="mx-auto d-block w-100" alt="Cover image preview" src="<?php echo (($pageKey && $page->coverImage()) ? $page->coverImage() : HTML_PATH_CORE_IMG . 'default.svg') ?>" />
</div> </div>
<!-- End Cover Image --> <!-- End Cover Image -->

View file

@ -94,6 +94,12 @@
}); });
} }
function setCoverImage(filename) {
var image = DOMAIN_UPLOADS_PAGES+_pageKey+'/'+filename;
$("#coverImage").val(filename);
$("#coverImagePreview").attr("src", image);
}
// Displays the files in the table // Displays the files in the table
function fmDisplayFiles(files) { function fmDisplayFiles(files) {
$('#fmFiles').empty(); $('#fmFiles').empty();
@ -107,7 +113,7 @@
console.log(file); console.log(file);
var row = '<tr>' + var row = '<tr>' +
'<td class="align-middle">' + '<td class="align-middle">' +
' <img style="width: 32px" src="'+ file.thumbnailSmall +'" />' + ' <img style="width: 32px" src="' + file.thumbnailSmall + '" />' +
'</td>' + '</td>' +
'<td class="align-middle">' + file.filename + '</td>' + '<td class="align-middle">' + file.filename + '</td>' +
'<td class="align-middle">' + file.mime + '</td>' + '<td class="align-middle">' + file.mime + '</td>' +
@ -115,9 +121,12 @@
'<td class="align-middle text-center">' + '<td class="align-middle text-center">' +
'<div class="dropdown">' + '<div class="dropdown">' +
' <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="fileOptions" data-bs-toggle="dropdown" aria-expanded="false"><i class="bi bi-gear"></i>Options</button>' + ' <button class="btn btn-sm btn-secondary dropdown-toggle" type="button" id="fileOptions" data-bs-toggle="dropdown" aria-expanded="false"><i class="bi bi-gear"></i>Options</button>' +
' <ul class="dropdown-menu" aria-labelledby="fileOptions">' + ' <ul class="dropdown-menu dropdown-menu-dark" aria-labelledby="fileOptions">' +
' <li><a class="dropdown-item" href="#" onClick="fmInsertFile(\'' + file.filename + '\', \'' + file.absoluteURL + '\', \'' + file.mime + '\'); fmClose();"><i class="bi bi-plus-circle"></i><?php $L->p('Insert') ?></a></li>' + ' <li><a class="dropdown-item" href="#" onClick="fmInsertFile(\'' + file.filename + '\', \'' + file.absoluteURL + '\', \'' + file.mime + '\'); fmClose();"><i class="bi bi-plus-circle"></i><?php $L->p('Insert original') ?></a></li>' +
' <li><a class="dropdown-item" href="#"><i class="bi bi-image"></i>Set as cover image</a></li>' + ' <li><a class="dropdown-item" href="#" onClick="fmInsertFile(\'' + file.filename + '\', \'' + file.thumbnailSmall + '\', \'' + file.mime + '\'); fmClose();"><i class="bi bi-plus-circle"></i><?php $L->p('Insert small') ?></a></li>' +
' <li><a class="dropdown-item" href="#" onClick="fmInsertFile(\'' + file.filename + '\', \'' + file.thumbnailMedium + '\', \'' + file.mime + '\'); fmClose();"><i class="bi bi-plus-circle"></i><?php $L->p('Insert medium') ?></a></li>' +
' <li><hr class="dropdown-divider"></li>' +
' <li><a class="dropdown-item" href="#" onClick="setCoverImage(\'' + file.filename + '\')"><i class="bi bi-image"></i>Set as cover image</a></li>' +
' <li><hr class="dropdown-divider"></li>' + ' <li><hr class="dropdown-divider"></li>' +
' <li><a class="dropdown-item" href="#"><i class="bi bi-trash"></i><?php $L->p('Delete') ?></a></li>' + ' <li><a class="dropdown-item" href="#"><i class="bi bi-trash"></i><?php $L->p('Delete') ?></a></li>' +
' </ul>' + ' </ul>' +

View file

@ -16,7 +16,7 @@
api.activatePlugin(args).then(function(response) { api.activatePlugin(args).then(function(response) {
if (response.status == 0) { if (response.status == 0) {
logs('Plugin activated: ' + response.data.key); logs('Plugin activated: ' + response.data.key);
window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins-settings/' ?>'+response.data.key); window.location.replace('<?php echo HTML_PATH_ADMIN_ROOT . 'plugins-settings/' ?>' + response.data.key);
} else { } else {
logs('An error occurred while trying to activate the plugin.'); logs('An error occurred while trying to activate the plugin.');
showAlertError(response.message); showAlertError(response.message);
@ -92,85 +92,74 @@
<?php <?php
// Plugins installed
echo Bootstrap::formTitle(array('icon' => 'check-square', 'title' => $L->g('Enabled plugins'))); echo Bootstrap::formTitle(array('icon' => 'check-square', 'title' => $L->g('Enabled plugins')));
echo '<table class="table table-striped"><tbody>';
echo '
<table class="table table-striped">
<tbody>
';
// Show installed plugins
foreach ($pluginsInstalled as $plugin) { foreach ($pluginsInstalled as $plugin) {
echo '<tr id="' . $plugin->className() . '" class="searchItem">'; echo '<tr id="' . $plugin->className() . '" class="searchItem">';
echo '<td class="align-middle pt-3 pb-3 w-25"> echo '<td class="align-middle pt-3 pb-3 w-25">';
<div class="searchText">' . $plugin->name() . '</div> echo '<div class="searchText">' . $plugin->name().'</div>';
<div class="mt-1">'; echo '<div class="mt-1">';
if (method_exists($plugin, 'form')) { if (method_exists($plugin, 'form')) {
echo '<a class="me-3" href="' . HTML_PATH_ADMIN_ROOT . 'plugins-settings/' . $plugin->className() . '">' . $L->g('Settings') . '</a>'; echo '<a class="me-3" href="' . HTML_PATH_ADMIN_ROOT . 'plugins-settings/' . $plugin->className() . '">' . $L->g('Settings') . '</a>';
} }
// You can not disable a plugin for an activated theme // You can not disable a plugin for theme which is active
if ($plugin->type()!='theme') { if ($plugin->type() != 'theme') {
echo '<span class="link deactivatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Deactivate') . '</a>'; echo '<span class="link deactivatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Deactivate') . '</a>';
} }
echo '</div>'; echo '</div>';
echo '</td>'; echo '</td>';
echo '<td class="searchText align-middle d-none d-sm-table-cell">'; echo '<td class="searchText align-middle d-none d-sm-table-cell">';
echo $plugin->description(); echo '<div>' . $plugin->description() . '</div>';
if (in_array($plugin->type(), array('dashboard','theme','editor'))) {
echo '<div class="badge bg-primary">'.$L->g($plugin->type()).'</div>';
}
echo '</td>'; echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">'; echo '<td class="text-center align-middle d-none d-lg-table-cell">';
echo '<span>' . $plugin->version() . '</span>'; echo '<span>' . $plugin->version() . '</span>';
echo '</td>'; echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell"> echo '<td class="text-center align-middle d-none d-lg-table-cell">';
<a target="_blank" href="' . $plugin->website() . '">' . $plugin->author() . '</a> echo '<a target="_blank" href="' . $plugin->website() . '">' . $plugin->author() . '</a>';
</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
} }
echo '</tbody></table>';
echo '
</tbody>
</table>
';
echo Bootstrap::formTitle(array('icon' => 'dash-square', 'title' => $L->g('Disabled plugins')));
echo '
<table class="table table-striped">
<tbody>
';
// Plugins not installed // Plugins not installed
echo Bootstrap::formTitle(array('icon' => 'dash-square', 'title' => $L->g('Disabled plugins')));
echo '<table class="table table-striped"><tbody>';
$pluginsNotInstalled = array_diff_key($plugins['all'], $pluginsInstalled); $pluginsNotInstalled = array_diff_key($plugins['all'], $pluginsInstalled);
foreach ($pluginsNotInstalled as $plugin) { foreach ($pluginsNotInstalled as $plugin) {
echo '<tr id="' . $plugin->className() . '" class="searchItem">'; echo '<tr id="' . $plugin->className() . '" class="searchItem">';
echo '<td class="align-middle pt-3 pb-3 w-25"> echo '<td class="align-middle pt-3 pb-3 w-25">';
<div class="searchText">' . $plugin->name() . '</div> echo '<div class="searchText">' . $plugin->name() . '</div>';
<div class="mt-1"> echo '<div class="mt-1"><span class="link activatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Activate') . '</a></div>';
<span class="link activatePlugin" data-class-name="' . $plugin->className() . '">' . $L->g('Activate') . '</a> echo '</td>';
</div>
</td>';
echo '<td class="searchText align-middle d-none d-sm-table-cell">'; echo '<td class="searchText align-middle d-none d-sm-table-cell">';
echo $plugin->description(); echo '<div>' . $plugin->description() . '</div>';
if (in_array($plugin->type(), array('dashboard','theme','editor'))) {
echo '<div class="badge bg-primary">'.$L->g($plugin->type()).'</div>';
}
echo '</td>'; echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell">'; echo '<td class="text-center align-middle d-none d-lg-table-cell">';
echo '<span>' . $plugin->version() . '</span>'; echo '<span>' . $plugin->version() . '</span>';
echo '</td>'; echo '</td>';
echo '<td class="text-center align-middle d-none d-lg-table-cell"> echo '<td class="text-center align-middle d-none d-lg-table-cell">';
<a target="_blank" href="' . $plugin->website() . '">' . $plugin->author() . '</a> echo '<a target="_blank" href="' . $plugin->website() . '">' . $plugin->author() . '</a>';
</td>'; echo '</td>';
echo '</tr>'; echo '</tr>';
} }
echo ' echo '</tbody></table>';
</tbody>
</table>
';

View file

@ -42,6 +42,12 @@
args[key] = value; args[key] = value;
}); });
$('textarea[data-save="true"]').each(function() {
var key = $(this).attr('name');
var value = $(this).val();
args[key] = value;
});
api.saveSettings(args).then(function(response) { api.saveSettings(args).then(function(response) {
if (response.status == 0) { if (response.status == 0) {
logs('Settings saved.'); logs('Settings saved.');