Edition de page sélecteur OK

This commit is contained in:
Fred Tempez 2022-05-06 18:55:14 +02:00
parent b09bb1a85a
commit f8a1dd5761
3 changed files with 58 additions and 17 deletions

View File

@ -475,7 +475,7 @@ class page extends common {
'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG), 'metaDescription' => $this->getInput('pageEditMetaDescription', helper::FILTER_STRING_LONG),
'metaTitle' => $this->getInput('pageEditMetaTitle'), 'metaTitle' => $this->getInput('pageEditMetaTitle'),
'moduleId' => $this->getInput('pageEditModuleId'), 'moduleId' => $this->getInput('pageEditModuleId'),
'modulePosition' => $this->getInput('configModulePosition'), 'modulePosition' => $this->getInput('pageModulePosition'),
'parentPageId' => $this->getInput('pageEditParentPageId'), 'parentPageId' => $this->getInput('pageEditParentPageId'),
'position' => $position, 'position' => $position,
'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0, 'group' => $this->getinput('pageEditBlock') !== 'bar' ? $this->getInput('pageEditGroup', helper::FILTER_INT) : 0,

View File

@ -52,15 +52,22 @@ function protectModule() {
*/ */
$( document ).ready(function() { $( document ).ready(function() {
/** /**
* Position initiales des blocs * Sélection des onglets
*/ */
var pageLayout = getCookie("pageLayout");
if (pageLayout == null) {
pageLayout = "content";
setCookie("pageLayout", "content");
}
$("#pageEditContentContainer").hide();
$("#pageEditExtensionContainer").hide(); $("#pageEditExtensionContainer").hide();
$("#pageEditPositionContainer").hide(); $("#pageEditPositionContainer").hide();
$("#pageEditLayoutContainer").hide(); $("#pageEditLayoutContainer").hide();
$("#pageEditPermissionContainer").hide(); $("#pageEditPermissionContainer").hide();
$("#pageEditContentButton").addClass("activeButton"); $("#pageEdit" + capitalizeFirstLetter(pageLayout) + "Container").show();
$("#pageEdit" + capitalizeFirstLetter(pageLayout) + "Button").addClass("activeButton");
/* /*
* Enleve le menu fixe en édition de page * Enleve le menu fixe en édition de page
@ -87,12 +94,12 @@ $( document ).ready(function() {
*/ */
if( $("#pageEditModuleId").val() === "redirection" || if( $("#pageEditModuleId").val() === "redirection" ||
$("#pageEditModuleId").val() === "" ) { $("#pageEditModuleId").val() === "" ) {
$("#configModulePositionWrapper").removeClass("disabled"); $("#pageModulePositionWrapper").removeClass("disabled");
$("#configModulePositionWrapper").slideUp(); $("#pageModulePositionWrapper").slideUp();
} }
else { else {
$("#configModulePositionWrapper").addClass("disabled"); $("#pageModulePositionWrapper").addClass("disabled");
$("#configModulePositionWrapper").slideDown(); $("#pageModulePositionWrapper").slideDown();
} }
@ -275,6 +282,7 @@ $( document ).ready(function() {
$("#PageEditPositionButton").removeClass("activeButton"); $("#PageEditPositionButton").removeClass("activeButton");
$("#pageEditLayoutButton").removeClass("activeButton"); $("#pageEditLayoutButton").removeClass("activeButton");
$("#pageEditPermissionButton").removeClass("activeButton"); $("#pageEditPermissionButton").removeClass("activeButton");
setCookie("pageLayout", "content");
}); });
$("#pageEditExtensionButton").on("click", function () { $("#pageEditExtensionButton").on("click", function () {
$("#pageEditContentContainer").hide(); $("#pageEditContentContainer").hide();
@ -287,6 +295,7 @@ $( document ).ready(function() {
$("#PageEditPositionButton").removeClass("activeButton"); $("#PageEditPositionButton").removeClass("activeButton");
$("#pageEditLayoutButton").removeClass("activeButton"); $("#pageEditLayoutButton").removeClass("activeButton");
$("#pageEditPermissionButton").removeClass("activeButton"); $("#pageEditPermissionButton").removeClass("activeButton");
console.log("extension");
}); });
$("#PageEditPositionButton").on("click", function () { $("#PageEditPositionButton").on("click", function () {
$("#pageEditContentContainer").hide(); $("#pageEditContentContainer").hide();
@ -299,6 +308,7 @@ $( document ).ready(function() {
$("#PageEditPositionButton").addClass("activeButton"); $("#PageEditPositionButton").addClass("activeButton");
$("#pageEditLayoutButton").removeClass("activeButton"); $("#pageEditLayoutButton").removeClass("activeButton");
$("#pageEditPermissionButton").removeClass("activeButton"); $("#pageEditPermissionButton").removeClass("activeButton");
setCookie("pageLayout", "position");
}); });
$("#pageEditLayoutButton").on("click", function () { $("#pageEditLayoutButton").on("click", function () {
$("#pageEditContentContainer").hide(); $("#pageEditContentContainer").hide();
@ -311,6 +321,7 @@ $( document ).ready(function() {
$("#PageEditPositionButton").removeClass("activeButton"); $("#PageEditPositionButton").removeClass("activeButton");
$("#pageEditLayoutButton").addClass("activeButton"); $("#pageEditLayoutButton").addClass("activeButton");
$("#pageEditPermissionButton").removeClass("activeButton"); $("#pageEditPermissionButton").removeClass("activeButton");
setCookie("pageLayout", "layout");
}); });
$("#pageEditPermissionButton").on("click", function () { $("#pageEditPermissionButton").on("click", function () {
$("#pageEditContentContainer").hide(); $("#pageEditContentContainer").hide();
@ -323,6 +334,7 @@ $( document ).ready(function() {
$("#pageEditPositionButton").removeClass("activeButton"); $("#pageEditPositionButton").removeClass("activeButton");
$("#pageEditLayoutButton").removeClass("activeButton"); $("#pageEditLayoutButton").removeClass("activeButton");
$("#pageEditPermissionButton").addClass("activeButton"); $("#pageEditPermissionButton").addClass("activeButton");
setCookie("pageLayout", "permission");
}); });
/** /**
@ -381,12 +393,12 @@ var pageEditModuleIdDOM = $("#pageEditModuleId");
pageEditModuleIdDOM.on("change", function() { pageEditModuleIdDOM.on("change", function() {
if( $(this).val() === "redirection" || if( $(this).val() === "redirection" ||
$(this).val() === "") { $(this).val() === "") {
$("#configModulePositionWrapper").removeClass("disabled"); $("#pageModulePositionWrapper").removeClass("disabled");
$("#configModulePositionWrapper").slideUp(); $("#pageModulePositionWrapper").slideUp();
} }
else { else {
$("#configModulePositionWrapper").addClass("disabled"); $("#pageModulePositionWrapper").addClass("disabled");
$("#configModulePositionWrapper").slideDown(); $("#pageModulePositionWrapper").slideDown();
} }
}); });
@ -691,3 +703,32 @@ function buildPagesList(extraPosition) {
// Sélectionne la bonne position // Sélectionne la bonne position
positionDOM.val(positionSelected); positionDOM.val(positionSelected);
}; };
/**
* Cookies
*/
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/; samesite=lax";
}
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
// Define function to capitalize the first letter of a string
function capitalizeFirstLetter(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}

View File

@ -43,7 +43,7 @@
<div class="tab"> <div class="tab">
<?php echo template::button('pageEditContentButton', [ <?php echo template::button('pageEditContentButton', [
'value' => 'Contenu', 'value' => 'Contenu',
'class' => 'buttonTab activeButton' 'class' => 'buttonTab'
]); ?> ]); ?>
<?php echo template::button('PageEditPositionButton', [ <?php echo template::button('PageEditPositionButton', [
'value' => 'Menu', 'value' => 'Menu',
@ -52,15 +52,15 @@
<?php echo template::button('pageEditExtensionButton', [ <?php echo template::button('pageEditExtensionButton', [
'value' => 'Extension', 'value' => 'Extension',
'class' => 'buttonTab' 'class' => 'buttonTab'
]); ?> ]); ?>
<?php echo template::button('pageEditLayoutButton', [ <?php echo template::button('pageEditLayoutButton', [
'value' => 'Mise en page', 'value' => 'Mise en page',
'class' => 'buttonTab' 'class' => 'buttonTab'
]); ?> ]); ?>
<?php echo template::button('pageEditPermissionButton', [ <?php echo template::button('pageEditPermissionButton', [
'value' => 'Référencement', 'value' => 'Permission',
'class' => 'buttonTab' 'class' => 'buttonTab'
]); ?> ]); ?>
</div> </div>
<div id="pageEditContentContainer" class="tabContent"> <div id="pageEditContentContainer" class="tabContent">
@ -244,7 +244,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="col12"> <div class="col12">
<?php echo template::select('configModulePosition', $module::$modulePosition,[ <?php echo template::select('pageModulePosition', $module::$modulePosition,[
'help' => 'En position libre ajoutez le module en plaçant [MODULE] à l\'endroit voulu dans votre page.', 'help' => 'En position libre ajoutez le module en plaçant [MODULE] à l\'endroit voulu dans votre page.',
'label' => 'Position du module', 'label' => 'Position du module',
'selected' => $this->getData(['page', $this->getUrl(2), 'modulePosition']) 'selected' => $this->getData(['page', $this->getUrl(2), 'modulePosition'])