From 7541a151939668417deebe9db695b4212dc41ea5 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Wed, 11 Apr 2018 19:52:32 +0200 Subject: [PATCH] allow to move account type position --- lam/lib/html.inc | 2 +- lam/templates/config/conftypes.php | 39 ++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/lam/lib/html.inc b/lam/lib/html.inc index b273b9f9..ced3bb87 100644 --- a/lam/lib/html.inc +++ b/lam/lib/html.inc @@ -3659,7 +3659,7 @@ class htmlResponsiveRow extends htmlElement { public function add($content, $numMobile, $numTablet = null, $numDesktop = null, $classes = '') { $tabletCols = ($numTablet === null) ? $numMobile : $numTablet; $desktopCols = ($numDesktop === null) ? $tabletCols : $numDesktop; - $this->addCell(new htmlResponsiveCell($content, $numMobile, $tabletCols, $tabletCols, $classes)); + $this->addCell(new htmlResponsiveCell($content, $numMobile, $tabletCols, $desktopCols, $classes)); } /** diff --git a/lam/templates/config/conftypes.php b/lam/templates/config/conftypes.php index ccc4d341..040f1dff 100644 --- a/lam/templates/config/conftypes.php +++ b/lam/templates/config/conftypes.php @@ -7,6 +7,7 @@ use \htmlOutputText; use \htmlSpacer; use \htmlButton; use \htmlGroup; +use \htmlDiv; use \htmlResponsiveInputCheckbox; use \LAMConfig; use \htmlResponsiveRow; @@ -179,6 +180,7 @@ $_SESSION['conftypes_optionTypes'] = array(); // show active types if (sizeof($activeTypes) > 0) { $container->add(new htmlSubTitle(_("Active account types")), 12); + $index = 0; foreach ($activeTypes as $activeType) { // title $titleGroup = new htmlGroup(); @@ -189,12 +191,28 @@ if (sizeof($activeTypes) > 0) { $titleGroup->addElement($titleText); $container->addField($titleGroup); $descriptionRow = new htmlResponsiveRow(); - $descriptionRow->add(new htmlOutputText($activeType->getBaseType()->getDescription()), 10, 10, 10, 'responsiveField'); + $descriptionRow->add(new htmlOutputText($activeType->getBaseType()->getDescription()), 12, 12, 9, 'responsiveField'); + $buttons = new htmlGroup(); + // move buttons + if ($index > 0) { + $upButton = new htmlButton('moveup_'. $activeType->getId(), 'up.gif', true); + $upButton->setTitle(_("Up")); + $upButton->setCSSClasses(array('size16')); + $buttons->addElement($upButton); + } + if ($index < (sizeof($activeTypes) - 1)) { + $upButton = new htmlButton('movedown_'. $activeType->getId(), 'down.gif', true); + $upButton->setTitle(_("Down")); + $upButton->setCSSClasses(array('size16')); + $buttons->addElement($upButton); + } // delete button $delButton = new htmlButton('rem_'. $activeType->getId(), 'del.png', true); $delButton->setTitle(_("Remove this account type")); $delButton->setCSSClasses(array('size16')); - $descriptionRow->add($delButton, 2, 2, 2, 'responsiveLabel'); + $buttons->addElement($delButton); + $buttonsDiv = new htmlDiv(null, $buttons, array('text-right')); + $descriptionRow->add($buttonsDiv, 12, 12, 3, 'responsiveLabel'); $container->addField($descriptionRow); $container->addVerticalSpacer('0.5rem'); // LDAP suffix @@ -272,6 +290,7 @@ if (sizeof($activeTypes) > 0) { $container->add($advancedOptions, 12); $container->addVerticalSpacer('2rem'); + $index++; } } @@ -328,6 +347,22 @@ function checkInput() { $accountTypes = array_flip($accountTypes); $accountTypes = array_values($accountTypes); } + // check if up button was pressed + elseif (substr($key, 0, 7) == "moveup_") { + $type = substr($key, 7); + $pos = array_search($type, $accountTypes); + $temp = $accountTypes[$pos - 1]; + $accountTypes[$pos - 1] = $accountTypes[$pos]; + $accountTypes[$pos] = $temp; + } + // check if down button was pressed + elseif (substr($key, 0, 9) == "movedown_") { + $type = substr($key, 9); + $pos = array_search($type, $accountTypes); + $temp = $accountTypes[$pos + 1]; + $accountTypes[$pos + 1] = $accountTypes[$pos]; + $accountTypes[$pos] = $temp; + } // set suffixes elseif (substr($key, 0, 7) == "suffix_") { $typeSettings[$key] = trim($_POST[$key]);