Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
gruberroland committed Jan 6, 2024
1 parent 650c82d commit c2eb9c8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 11 deletions.
11 changes: 2 additions & 9 deletions lam/lib/baseType.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use LAM\TYPES\ConfiguredType;
/*
This code is part of LDAP Account Manager (http://www.ldap-account-manager.org/)
Copyright (C) 2005 - 2023 Roland Gruber
Copyright (C) 2005 - 2024 Roland Gruber
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -244,14 +244,7 @@ class baseType {
$onchange = '';
if ($hasLockOptions && $hasUnlockOptions) {
$radioDisabled = false;
$onchange = 'if (jQuery(\'#lam_accountStatusAction0:checked\').val()) {' .
'jQuery(\'#lam_accountStatusDialogLockDiv\').removeClass(\'hidden\');' .
'jQuery(\'#lam_accountStatusDialogUnlockDiv\').addClass(\'hidden\');' .
'}' .
'else {' .
'jQuery(\'#lam_accountStatusDialogLockDiv\').addClass(\'hidden\');' .
'jQuery(\'#lam_accountStatusDialogUnlockDiv\').removeClass(\'hidden\');' .
'};';
$onchange = 'window.lam.accountLists.lockUnlockRadioChange();';
}
if (!$hasUnlockOptions) {
$selectedRadio = 'lock';
Expand Down
2 changes: 1 addition & 1 deletion lam/lib/lists.inc
Original file line number Diff line number Diff line change
Expand Up @@ -1030,7 +1030,7 @@ class lamList {
$refreshButton->setTitle(_("Refresh"));
$rightButtonGroup->addElement($refreshButton);
$settingsLink = new htmlLink('', '#', '../../graphics/configure.svg');
$settingsLink->setOnClick('listShowSettingsDialog(\'' . _('Change list settings') . '\', \'' . _('Ok') . '\', \'' . _('Cancel') . '\');');
$settingsLink->setOnClick('window.lam.accountLists.listShowSettingsDialog(\'' . _('Change list settings') . '\', \'' . _('Ok') . '\', \'' . _('Cancel') . '\');');
$settingsLink->setTitle(_('Change settings'));
$settingsLink->setCSSClasses(array('icon'));
$rightButtonGroup->addElement($settingsLink);
Expand Down
18 changes: 17 additions & 1 deletion lam/templates/lib/500_lam.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,16 @@ function listPageNumberKeyPress(url, e) {
return true;
}

window.lam.accountLists = window.lam.accountLists || {};

/**
* Shows the dialog to change the list settings.
*
* @param title dialog title
* @param okText text for Ok button
* @param cancelText text for Cancel button
*/
function listShowSettingsDialog(title, okText, cancelText) {
window.lam.accountLists.listShowSettingsDialog = function (title, okText, cancelText) {
const dialogContent = document.getElementById('settingsDialog').cloneNode(true);
dialogContent.classList.remove('hidden');
dialogContent.firstElementChild.id = 'settingsDialogForm_dlg';
Expand All @@ -89,6 +91,20 @@ function listShowSettingsDialog(title, okText, cancelText) {
});
}

/**
* Executed when radio buttons change for (un)locking accounts.
*/
window.lam.accountLists.lockUnlockRadioChange = function () {
if (document.querySelector('#lam_accountStatusAction0:checked')) {
document.getElementById('lam_accountStatusDialogLockDiv').classList.remove('hidden');
document.getElementById('lam_accountStatusDialogUnlockDiv').classList.add('hidden');
}
else {
document.getElementById('lam_accountStatusDialogLockDiv').classList.add('hidden');
document.getElementById('lam_accountStatusDialogUnlockDiv').classList.remove('hidden');
}
}

/**
* Submits the form by clicking on the given button if enter was pressed.
* Example: SubmitForm('apply_filter', event);
Expand Down

0 comments on commit c2eb9c8

Please sign in to comment.