From 086e5334fbf556b575591cda1e380391bb5ce4df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Cie=C5=9Blak?= Date: Thu, 11 May 2023 16:35:38 +0200 Subject: [PATCH] chore(InDropdown): Search behavior adjusted, added label when no search results Closes: #8879 --- storybook/pages/InDropdownPage.qml | 3 +- .../Chat/controls/community/InDropdown.qml | 54 ++++++++++++++++--- 2 files changed, 49 insertions(+), 8 deletions(-) diff --git a/storybook/pages/InDropdownPage.qml b/storybook/pages/InDropdownPage.qml index 9520457ea2..50faaa8c5e 100644 --- a/storybook/pages/InDropdownPage.qml +++ b/storybook/pages/InDropdownPage.qml @@ -24,6 +24,8 @@ SplitView { parent: pane anchors.centerIn: parent + closePolicy: Popup.NoAutoClose + allowChoosingEntireCommunity: allowChoosingEntireCommunityCheckBox.checked showAddChannelButton: showAddChannelButtonCheckBox.checked @@ -45,7 +47,6 @@ SplitView { logs.logEvent("InDropdown::channelSelected", ["channels"], arguments) } - onOpened: contentItem.parent.parent = pane Component.onCompleted: open() } } diff --git a/ui/app/AppLayouts/Chat/controls/community/InDropdown.qml b/ui/app/AppLayouts/Chat/controls/community/InDropdown.qml index 51540a858c..df66fa698c 100644 --- a/ui/app/AppLayouts/Chat/controls/community/InDropdown.qml +++ b/ui/app/AppLayouts/Chat/controls/community/InDropdown.qml @@ -70,10 +70,12 @@ StatusDropdown { function addToSelectedChannels(model) { selectedChannels.add(model.itemId) + selectedChannelsChanged() } function removeFromSelectedChannels(model) { selectedChannels.delete(model.itemId) + selectedChannelsChanged() } } @@ -222,10 +224,6 @@ StatusDropdown { visible: { if (!isCategory) return d.search(model.name, searcher.text) - || checkBox.checked - - if (checkedCount > 0) - return true const subItemsCount = subItemsRepeater.count @@ -355,7 +353,7 @@ StatusDropdown { id: communitySubItem readonly property bool show: - d.search(model.name, searcher.text) || checked + d.search(model.name, searcher.text) Layout.fillWidth: true @@ -392,12 +390,54 @@ StatusDropdown { } } } + + StatusBaseText { + id: noContactsText + + parent: scrollView + + anchors.centerIn: parent + + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + + visible: { + for (let i = 0; i < topRepeater.count; i++) { + const item = topRepeater.itemAt(i) + if (item && item.visible) + return false + } + + return true + } + + text: qsTr("No channels found") + color: Theme.palette.baseColor1 + font.pixelSize: Theme.tertiaryTextFontSize + elide: Text.ElideRight + lineHeight: 1.2 + } } StatusButton { Layout.fillWidth: true - text: root.acceptMode === InDropdown.AcceptMode.Add - ? qsTr("Add") : qsTr("Update") + + enabled: root.acceptMode === InDropdown.AcceptMode.Update + || d.selectedChannels.size > 0 + + text: { + if (root.acceptMode === InDropdown.AcceptMode.Update) + return qsTr("Update") + + if (radioButton.checked) + return qsTr("Add community") + + if (d.selectedChannels.size === 0) + return qsTr("Add") + + return qsTr("Add %n channel(s)", "", d.selectedChannels.size) + } + onClicked: { if (radioButton.checked) {