Commit 54509ef6 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Can now filter by clicking on tags in incidence info

parent 98fa1a8f
Pipeline #97714 passed with stage
in 4 minutes and 48 seconds
......@@ -16,6 +16,7 @@ Kirigami.OverlayDrawer {
signal addSubTodo(var parentWrapper)
signal editIncidence(var incidencePtr, var collectionId)
signal deleteIncidence(var incidencePtr, date deleteDate)
signal tagClicked(string tagName)
/**
* We use both incidenceData and incidenceWrapper to get info about the occurrence.
......@@ -29,6 +30,7 @@ Kirigami.OverlayDrawer {
property var incidenceData
property var incidenceWrapper
property var collectionData
property var activeTags : []
component HoverLabel: QQC2.Label {
Layout.fillWidth: true
......@@ -237,6 +239,7 @@ Kirigami.OverlayDrawer {
visible: incidenceInfo.incidenceWrapper.categories.length > 0
}
Flow {
id: tagFlow
Layout.fillWidth: true
visible: incidenceInfo.incidenceWrapper.categories.length > 0
spacing: Kirigami.Units.largeSpacing
......@@ -247,6 +250,10 @@ Kirigami.OverlayDrawer {
icon.name: "edit-delete-remove"
actionText: i18n("Remove %1 tag", modelData)
showAction: false
implicitWidth: itemLayout.implicitWidth > tagFlow.width ? tagFlow.width : itemLayout.implicitWidth
activeFocusOnTab: true
backgroundColor: sidebar.activeTags.includes(modelData) ? Kirigami.Theme.highlightColor : Kirigami.Theme.backgroundColor
onClicked: incidenceInfo.tagClicked(modelData)
}
}
}
......
......@@ -431,18 +431,7 @@ Kirigami.ApplicationWindow {
// HACK: The Todo View should be able to detect change in collection filtering independently
}
}
onTagClicked: if(!root.filter || !root.filter.tags || !root.filter.tags.includes(tagName)) {
root.filter ? root.filter.tags ?
root.filter.tags.push(tagName) :
root.filter.tags = [tagName] :
root.filter = {"tags" : [tagName]};
root.filterChanged();
filterHeader.active = true;
pageStack.currentItem.header = filterHeader.item;
} else if (root.filter.tags.includes(tagName)) {
root.filter.tags = root.filter.tags.filter((tag) => tag !== tagName);
root.filterChanged();
}
onTagClicked: root.toggleFilterTag(tagName)
onViewAllTodosClicked: if(todoMode) {
root.filter.collectionId = -1;
root.filter.tags = [];
......@@ -476,6 +465,8 @@ Kirigami.ApplicationWindow {
handleVisible: enabled && pageStack.layers.depth < 2 && pageStack.depth < 3
interactive: Kirigami.Settings.isMobile // Otherwise get weird bug where drawer gets dragged around despite no click
activeTags: root.filter && root.filter.tags ?
root.filter.tags : []
onIncidenceDataChanged: root.openOccurrence = incidenceData;
onVisibleChanged: {
if(visible) {
......@@ -497,6 +488,7 @@ Kirigami.ApplicationWindow {
setUpDelete(incidencePtr, deleteDate)
if (modal) { incidenceInfo.close() }
}
onTagClicked: root.toggleFilterTag(tagName)
readonly property int minWidth: Kirigami.Units.gridUnit * 15
readonly property int maxWidth: Kirigami.Units.gridUnit * 25
......@@ -779,6 +771,21 @@ Kirigami.ApplicationWindow {
}
}
function toggleFilterTag(tagName) {
if(!root.filter || !root.filter.tags || !root.filter.tags.includes(tagName)) {
root.filter ? root.filter.tags ?
root.filter.tags.push(tagName) :
root.filter.tags = [tagName] :
root.filter = {"tags" : [tagName]};
root.filterChanged();
filterHeader.active = true;
pageStack.currentItem.header = filterHeader.item;
} else if (root.filter.tags.includes(tagName)) {
root.filter.tags = root.filter.tags.filter((tag) => tag !== tagName);
root.filterChanged();
}
}
function editorToUse() {
if (!Kirigami.Settings.isMobile) {
editorWindowedLoader.active = true
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment