From 4a30d49d31378e4e86dea77a79c3a478b8f2b43e Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 8 Apr 2019 11:24:01 +0200 Subject: [PATCH] Consistent UX for the single option form --- .../files/acp/templates/userGroupAdd.tpl | 2 +- .../files/acp/templates/userGroupOption.tpl | 42 ++++++++++++++++++- .../acp/form/UserGroupOptionForm.class.php | 15 ++++++- 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl index 94e8fd5e73..41d201d9d2 100644 --- a/wcfsetup/install/files/acp/templates/userGroupAdd.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupAdd.tpl @@ -250,7 +250,7 @@ }); }); {elseif $ownerGroupID} - var input = elBySel('input[name="values[admin.user.accessibleGroups][]"][value="{$ownerGroupID}"]'); + var input = elBySel('input[name="values[admin.user.accessibleGroups][]"][value="{@$ownerGroupID}"]'); if (input) { elRemove(input.closest('label')); } diff --git a/wcfsetup/install/files/acp/templates/userGroupOption.tpl b/wcfsetup/install/files/acp/templates/userGroupOption.tpl index 3e5f28dc4c..e9989a1c99 100644 --- a/wcfsetup/install/files/acp/templates/userGroupOption.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupOption.tpl @@ -50,6 +50,42 @@ elHide(bbcodeHtml); }); }); + + {if $ownerGroupID} + {if $userGroupOption->optionName === 'admin.user.accessibleGroups'} + elBySelAll('dl[data-group-id]', container, function(dl) { + var groupId = parseInt(elData(dl, 'group-id'), 10); + console.log("Group", groupId); + + elBySelAll('input[name="values[' + groupId + '][]"', undefined, function(input) { + if (groupId === {@$ownerGroupID}) { + var shadow = elCreate('input'); + shadow.type = 'hidden'; + shadow.name = input.name; + shadow.value = input.value; + + input.parentNode.appendChild(shadow); + + input.disabled = true; + } + else { + if (parseInt(input.value, 10) === {@$ownerGroupID}) { + elRemove(input.closest('label')); + } + } + }); + }); + {elseif $userGroupOption->optionName|in_array:$ownerGroupPermissions} + elBySelAll('input[name="values[{@$ownerGroupID}]"]', undefined, function (input) { + if (input.value === '1') { + input.checked = true; + } + else { + input.disabled = true; + } + }); + {/if} + {/if} })(); @@ -86,7 +122,11 @@ {foreach from=$groups item=group}
-
{if VISITOR_USE_TINY_BUILD && $guestGroupID == $group->groupID && $userGroupOption->excludedInTinyBuild} {/if}
+
+ {if VISITOR_USE_TINY_BUILD && $guestGroupID == $group->groupID && $userGroupOption->excludedInTinyBuild} {/if} + {if $ownerGroupID == $group->groupID && $userGroupOption->optionName|in_array:$ownerGroupPermissions} {/if} + +
{@$formElements[$group->groupID]} diff --git a/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php b/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php index 39d0981b27..c24562e289 100644 --- a/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserGroupOptionForm.class.php @@ -251,7 +251,7 @@ class UserGroupOptionForm extends AbstractForm { public function assignVariables() { parent::assignVariables(); - $everyoneGroupID = $guestGroupID = $userGroupID = 0; + $everyoneGroupID = $guestGroupID = $ownerGroupID = $userGroupID = 0; foreach ($this->groups as $group) { if ($group->groupType == UserGroup::EVERYONE) { $everyoneGroupID = $group->groupID; @@ -259,11 +259,20 @@ class UserGroupOptionForm extends AbstractForm { else if ($group->groupType == UserGroup::GUESTS) { $guestGroupID = $group->groupID; } + else if ($group->groupType == UserGroup::OWNER) { + $ownerGroupID = $group->groupID; + } else if ($group->groupType == UserGroup::USERS) { $userGroupID = $group->groupID; } } + $ownerGroupPermissions = []; + if ($ownerGroupID) { + $ownerGroupPermissions = UserGroup::getOwnerPermissions(); + $ownerGroupPermissions[] = 'admin.user.accessibleGroups'; + } + WCF::getTPL()->assign([ 'formElements' => $this->formElements, 'groups' => $this->groups, @@ -272,7 +281,9 @@ class UserGroupOptionForm extends AbstractForm { 'values' => $this->values, 'everyoneGroupID' => $everyoneGroupID, 'guestGroupID' => $guestGroupID, - 'userGroupID' => $userGroupID + 'userGroupID' => $userGroupID, + 'ownerGroupID' => $ownerGroupID, + 'ownerGroupPermissions' => $ownerGroupPermissions, ]); } -- 2.20.1