From ef7e0080004b2b9b12fa8459a4628630c8e3dc39 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Fri, 29 Sep 2023 14:11:03 +0200 Subject: [PATCH] Add basic support to select more than one label per group --- .../install/files/acp/templates/labelGroupAdd.tpl | 5 +++++ .../files/lib/acp/form/LabelGroupAddForm.class.php | 13 ++++++++++++- .../files/lib/acp/form/LabelGroupEditForm.class.php | 2 ++ .../files/lib/data/label/group/LabelGroup.class.php | 1 + .../files/lib/system/label/LabelPicker.class.php | 2 ++ wcfsetup/install/lang/de.xml | 1 + wcfsetup/install/lang/en.xml | 1 + wcfsetup/setup/db/install.sql | 3 ++- 8 files changed, 26 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/acp/templates/labelGroupAdd.tpl b/wcfsetup/install/files/acp/templates/labelGroupAdd.tpl index 27d81c790b..6ef2cbc58a 100644 --- a/wcfsetup/install/files/acp/templates/labelGroupAdd.tpl +++ b/wcfsetup/install/files/acp/templates/labelGroupAdd.tpl @@ -78,6 +78,11 @@ +
+
+
+
+
diff --git a/wcfsetup/install/files/lib/acp/form/LabelGroupAddForm.class.php b/wcfsetup/install/files/lib/acp/form/LabelGroupAddForm.class.php index 2e10bcef9b..79249b6ff9 100644 --- a/wcfsetup/install/files/lib/acp/form/LabelGroupAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LabelGroupAddForm.class.php @@ -82,6 +82,12 @@ class LabelGroupAddForm extends AbstractForm */ public $showOrder = 0; + /** + * Allow the selection of multiple labels of the same group. + * @since 6.1 + */ + public bool $multipleSelection = false; + /** * @inheritDoc */ @@ -119,6 +125,9 @@ class LabelGroupAddForm extends AbstractForm if (isset($_POST['showOrder'])) { $this->showOrder = \intval($_POST['showOrder']); } + if (isset($_POST['multipleSelection'])) { + $this->multipleSelection = true; + } } /** @@ -181,6 +190,7 @@ class LabelGroupAddForm extends AbstractForm 'groupName' => $this->groupName, 'groupDescription' => $this->groupDescription, 'showOrder' => $this->showOrder, + 'multipleSelection' => $this->multipleSelection ? 1 : 0, ]), ]); $returnValues = $this->objectAction->executeAction(); @@ -214,7 +224,7 @@ class LabelGroupAddForm extends AbstractForm $this->saved(); // reset values - $this->forceSelection = false; + $this->forceSelection = $this->multipleSelection = false; $this->groupName = $this->groupDescription = ''; $this->objectTypes = []; $this->showOrder = 0; @@ -250,6 +260,7 @@ class LabelGroupAddForm extends AbstractForm 'labelObjectTypeContainers' => $this->labelObjectTypeContainers, 'objectTypeID' => $this->objectTypeID, 'showOrder' => $this->showOrder, + 'multipleSelection' => $this->multipleSelection, ]); } diff --git a/wcfsetup/install/files/lib/acp/form/LabelGroupEditForm.class.php b/wcfsetup/install/files/lib/acp/form/LabelGroupEditForm.class.php index 821a8dcfe3..9a0581b3a6 100644 --- a/wcfsetup/install/files/lib/acp/form/LabelGroupEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/LabelGroupEditForm.class.php @@ -82,6 +82,7 @@ class LabelGroupEditForm extends LabelGroupAddForm 'groupName' => $this->groupName, 'groupDescription' => $this->groupDescription, 'showOrder' => $this->showOrder, + 'multipleSelection' => $this->multipleSelection ? 1 : 0, ]), ] ); @@ -118,6 +119,7 @@ class LabelGroupEditForm extends LabelGroupAddForm $this->groupName = $this->group->groupName; $this->groupDescription = $this->group->groupDescription; $this->showOrder = $this->group->showOrder; + $this->multipleSelection = !!$this->multipleSelection; } } diff --git a/wcfsetup/install/files/lib/data/label/group/LabelGroup.class.php b/wcfsetup/install/files/lib/data/label/group/LabelGroup.class.php index 8432d88238..84751652dd 100644 --- a/wcfsetup/install/files/lib/data/label/group/LabelGroup.class.php +++ b/wcfsetup/install/files/lib/data/label/group/LabelGroup.class.php @@ -18,6 +18,7 @@ use wcf\system\WCF; * @property-read string $groupDescription description of the label group (only shown in ACP) * @property-read int $forceSelection is `1` if a label in the label group has to be selected when creating an object for which the label group is available, otherwise `0` * @property-read int $showOrder position of the label group in relation to the other label groups + * @property-read int $multipleSelection is `1` if more than one label may be selected, otherwise `0` */ class LabelGroup extends DatabaseObject implements IRouteController { diff --git a/wcfsetup/install/files/lib/system/label/LabelPicker.class.php b/wcfsetup/install/files/lib/system/label/LabelPicker.class.php index 75ebcfc197..e86ca4982a 100644 --- a/wcfsetup/install/files/lib/system/label/LabelPicker.class.php +++ b/wcfsetup/install/files/lib/system/label/LabelPicker.class.php @@ -31,6 +31,7 @@ final class LabelPicker id="%s" title="%s" labels="%s" + %s data-group-id="%d" > EOT, @@ -38,6 +39,7 @@ final class LabelPicker $this->getId(), $this->labelGroup->getTitle(), StringUtil::encodeHTML(JSON::encode($labels)), + $this->labelGroup->multipleSelection ? 'multiple' : '', $this->labelGroup->groupID, ); } diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 7d493eca2d..9292d1d07e 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -988,6 +988,7 @@ Sie erreichen das Fehlerprotokoll unter: {link controller='ExceptionLogView' isE + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 202fe0578b..a59ac933d4 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -966,6 +966,7 @@ You can access the error log at: {link controller='ExceptionLogView' isEmail=tru + diff --git a/wcfsetup/setup/db/install.sql b/wcfsetup/setup/db/install.sql index 80631ae6df..a87f7e83d1 100644 --- a/wcfsetup/setup/db/install.sql +++ b/wcfsetup/setup/db/install.sql @@ -617,7 +617,8 @@ CREATE TABLE wcf1_label_group ( groupName VARCHAR(80) NOT NULL, groupDescription VARCHAR(255) NOT NULL DEFAULT '', forceSelection TINYINT(1) NOT NULL DEFAULT 0, - showOrder INT(10) NOT NULL DEFAULT 0 + showOrder INT(10) NOT NULL DEFAULT 0, + multipleSelection TINYINT(1) NOT NULL DEFAULT 0 ); DROP TABLE IF EXISTS wcf1_label_group_to_object; -- 2.20.1