From fd665fef3b222bf8205154b14f676815d2d6ae20 Mon Sep 17 00:00:00 2001 From: Roland Gruber Date: Fri, 15 Nov 2024 07:57:03 +0100 Subject: [PATCH] #342 usability --- lam/HISTORY | 2 +- lam/lib/modules.inc | 19 ++++++++-------- lam/style/100_lam-responsive.css | 12 ++++++++++ lam/style/500_layout.css | 6 ++++- lam/templates/lib/500_lam.js | 38 +++++++++++++++++++++----------- 5 files changed, 52 insertions(+), 25 deletions(-) diff --git a/lam/HISTORY b/lam/HISTORY index f8b56fb15..f6e2038d9 100644 --- a/lam/HISTORY +++ b/lam/HISTORY @@ -1,7 +1,7 @@ December 2024 9.0 - Unix users: allow to create group with same name via account profile (#332) - Group of (unique) names, organisational roles: added member/owner count to PDF fields - - Usability improvements (350) + - Usability improvements (342, 350) - LAM Pro: -> Request access: added comment field for owners/approvers (339) -> Custom scripts: support custom label for module (329) diff --git a/lam/lib/modules.inc b/lam/lib/modules.inc index cb4141d3e..888a44ed9 100644 --- a/lam/lib/modules.inc +++ b/lam/lib/modules.inc @@ -1085,7 +1085,7 @@ class accountContainer { } } echo '
'; - echo "\n"; + echo "
\n"; echo "\n"; @@ -1415,16 +1415,15 @@ class accountContainer { $accountProfilePersistenceManager = new AccountProfilePersistenceManager(); $profilelist = $accountProfilePersistenceManager->getAccountProfileNames($this->type->getId(), $_SESSION['config']->getName()); if (sizeof($profilelist) > 0) { - $profilesSelect = new htmlSelect('accountContainerSelectLoadProfile', $profilelist, [$this->lastLoadedProfile]); - $profilesSelect->setCSSClasses(['auto-width']); - $profilesSelect->setAccessibilityLabel(_('Profile name')); - $rightGroup->addElement($profilesSelect); - $profileButton = new htmlButton('accountContainerLoadProfile', _('Load profile')); - if (!$this->isNewAccount) { - $profileButton->setType('submit'); - $profileButton->setOnClick('confirmLoadProfile(\'' . _('This may overwrite existing values with profile data. Continue?') . '\',' - . ' \'' . _('Ok') . '\', \'' . _('Cancel') . '\', event);'); + $profileButton = new htmlButton('accountContainerLoadProfileButton', _('Load profile')); + $profileButton->setOnClick('confirmLoadProfile(\'' . _('Load profile') . '\', \'' . _('This may overwrite existing values with profile data. Continue?') . '\',' + . ' \'' . _('Ok') . '\', \'' . _('Cancel') . '\', event); return false;'); + $profileButton->addDataAttribute('lastprofile', $this->lastLoadedProfile); + $profileListOptions = []; + foreach ($profilelist as $profileName) { + $profileListOptions[$profileName] = $profileName; } + $profileButton->addDataAttribute('profiles', json_encode($profileListOptions)); $rightGroup->addElement($profileButton); $rightGroup->addElement(new htmlSpacer('1px', null)); $rightGroup->addElement(new htmlHelpLink('401')); diff --git a/lam/style/100_lam-responsive.css b/lam/style/100_lam-responsive.css index 2b271833a..15eca8d72 100644 --- a/lam/style/100_lam-responsive.css +++ b/lam/style/100_lam-responsive.css @@ -208,6 +208,14 @@ div.account-types-popup div.columns:last-child { float: left; } +table.lam-account-edit-table { + border-collapse: collapse; + width: 100%; + border-width: 0; + margin-right: auto; + margin-left: auto; +} + /* mobile */ @media only screen and (max-width: 40.0625em) { @@ -422,6 +430,10 @@ div.account-types-popup div.columns:last-child { padding-bottom: 2rem; } + table.lam-account-edit-table { + max-width: 90rem; + } + } /* desktop */ diff --git a/lam/style/500_layout.css b/lam/style/500_layout.css index 657b0b038..1f05e2268 100644 --- a/lam/style/500_layout.css +++ b/lam/style/500_layout.css @@ -699,7 +699,7 @@ button.lam-account-type img { div.lam-vertical-tab-content { border-width: 0; - padding: 0em 1em 1em 1em; + padding: 1rem 2rem 1rem 1rem; float: left; } @@ -985,6 +985,10 @@ div.swal2-html-container { overflow: auto; } +#swal2-select { + width: unset; +} + .modal { position: fixed; left: 0; diff --git a/lam/templates/lib/500_lam.js b/lam/templates/lib/500_lam.js index 5b49dff80..efecfaac8 100644 --- a/lam/templates/lib/500_lam.js +++ b/lam/templates/lib/500_lam.js @@ -284,28 +284,40 @@ function appendDialogInputsToFormAndSubmit(dialogDiv, formName) { * Shows a simple confirmation dialog. * If the user presses Cancel then the current action is stopped (event.preventDefault()). * + * @param title dialog title * @param text dialog text * @param okText text for OK button * @param cancelText text for cancel button * @param e event */ -function confirmLoadProfile(text, okText, cancelText, e) { - Swal.fire({ +async function confirmLoadProfile(title, text, okText, cancelText, e) { + const button = document.getElementById('btn_accountContainerLoadProfileButton'); + const lastProfile = button.dataset.lastprofile; + const profiles = JSON.parse(button.dataset.profiles); + const {value: selectedProfile} = await Swal.fire({ confirmButtonText: okText, cancelButtonText: cancelText, showCancelButton: true, + title: title, text: text, - }).then(result => { - if (result.isConfirmed) { - const form = document.forms["inputForm"]; - let buttonValue = document.createElement("input"); - buttonValue.type = "hidden"; - buttonValue.name = "accountContainerLoadProfile"; - buttonValue.value = "yes"; - form.appendChild(buttonValue); - form.submit(); - } - }); + input: 'select', + inputValue: lastProfile, + inputOptions: profiles + }); + if (selectedProfile) { + const form = document.forms["inputForm"]; + let buttonValue = document.createElement("input"); + buttonValue.type = "hidden"; + buttonValue.name = "accountContainerLoadProfile"; + buttonValue.value = "yes"; + form.appendChild(buttonValue); + let selectValue = document.createElement('input'); + selectValue.type = 'hidden'; + selectValue.name = 'accountContainerSelectLoadProfile'; + selectValue.value = selectedProfile; + form.appendChild(selectValue); + form.submit(); + }; if (e.preventDefault) { e.preventDefault(); }
\n"; $this->printCommonControls(); echo "