allow to move account type position

This commit is contained in:
Roland Gruber 2018-04-11 19:52:32 +02:00
parent 7d35991bb4
commit 7541a15193
2 changed files with 38 additions and 3 deletions

View File

@ -3659,7 +3659,7 @@ class htmlResponsiveRow extends htmlElement {
public function add($content, $numMobile, $numTablet = null, $numDesktop = null, $classes = '') { public function add($content, $numMobile, $numTablet = null, $numDesktop = null, $classes = '') {
$tabletCols = ($numTablet === null) ? $numMobile : $numTablet; $tabletCols = ($numTablet === null) ? $numMobile : $numTablet;
$desktopCols = ($numDesktop === null) ? $tabletCols : $numDesktop; $desktopCols = ($numDesktop === null) ? $tabletCols : $numDesktop;
$this->addCell(new htmlResponsiveCell($content, $numMobile, $tabletCols, $tabletCols, $classes)); $this->addCell(new htmlResponsiveCell($content, $numMobile, $tabletCols, $desktopCols, $classes));
} }
/** /**

View File

@ -7,6 +7,7 @@ use \htmlOutputText;
use \htmlSpacer; use \htmlSpacer;
use \htmlButton; use \htmlButton;
use \htmlGroup; use \htmlGroup;
use \htmlDiv;
use \htmlResponsiveInputCheckbox; use \htmlResponsiveInputCheckbox;
use \LAMConfig; use \LAMConfig;
use \htmlResponsiveRow; use \htmlResponsiveRow;
@ -179,6 +180,7 @@ $_SESSION['conftypes_optionTypes'] = array();
// show active types // show active types
if (sizeof($activeTypes) > 0) { if (sizeof($activeTypes) > 0) {
$container->add(new htmlSubTitle(_("Active account types")), 12); $container->add(new htmlSubTitle(_("Active account types")), 12);
$index = 0;
foreach ($activeTypes as $activeType) { foreach ($activeTypes as $activeType) {
// title // title
$titleGroup = new htmlGroup(); $titleGroup = new htmlGroup();
@ -189,12 +191,28 @@ if (sizeof($activeTypes) > 0) {
$titleGroup->addElement($titleText); $titleGroup->addElement($titleText);
$container->addField($titleGroup); $container->addField($titleGroup);
$descriptionRow = new htmlResponsiveRow(); $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 // delete button
$delButton = new htmlButton('rem_'. $activeType->getId(), 'del.png', true); $delButton = new htmlButton('rem_'. $activeType->getId(), 'del.png', true);
$delButton->setTitle(_("Remove this account type")); $delButton->setTitle(_("Remove this account type"));
$delButton->setCSSClasses(array('size16')); $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->addField($descriptionRow);
$container->addVerticalSpacer('0.5rem'); $container->addVerticalSpacer('0.5rem');
// LDAP suffix // LDAP suffix
@ -272,6 +290,7 @@ if (sizeof($activeTypes) > 0) {
$container->add($advancedOptions, 12); $container->add($advancedOptions, 12);
$container->addVerticalSpacer('2rem'); $container->addVerticalSpacer('2rem');
$index++;
} }
} }
@ -328,6 +347,22 @@ function checkInput() {
$accountTypes = array_flip($accountTypes); $accountTypes = array_flip($accountTypes);
$accountTypes = array_values($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 // set suffixes
elseif (substr($key, 0, 7) == "suffix_") { elseif (substr($key, 0, 7) == "suffix_") {
$typeSettings[$key] = trim($_POST[$key]); $typeSettings[$key] = trim($_POST[$key]);