Implement adding/removing general rule conditions
This commit is contained in:
parent
64b8ee03e3
commit
5b296ed6be
|
@ -7,14 +7,15 @@ import "../../Base"
|
||||||
import "../../Base/Buttons"
|
import "../../Base/Buttons"
|
||||||
|
|
||||||
HColumnLayout {
|
HColumnLayout {
|
||||||
|
id: root
|
||||||
|
|
||||||
readonly property alias idField: idField
|
readonly property alias idField: idField
|
||||||
|
|
||||||
readonly property var matrixConditions: {
|
readonly property var matrixConditions: {
|
||||||
const results = []
|
const results = []
|
||||||
|
|
||||||
for (let i = 0; i < conditionRepeater.count; i++) {
|
for (let i = 0; i < conditionRepeater.count; i++)
|
||||||
results.push(conditionRepeater.itemAt(i).control.matrixObject)
|
results.push(conditionRepeater.itemAt(i).control.matrixObject)
|
||||||
}
|
|
||||||
|
|
||||||
return results
|
return results
|
||||||
}
|
}
|
||||||
|
@ -54,20 +55,39 @@ HColumnLayout {
|
||||||
|
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
text: qsTr("Room has a certain number of members")
|
text: qsTr("Room has a certain number of members")
|
||||||
|
onTriggered: conditionRepeater.model.append({
|
||||||
|
kind: "room_member_count",
|
||||||
|
is: "2",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
text: qsTr("Message property matches value")
|
text: qsTr("Message property matches value")
|
||||||
|
onTriggered: conditionRepeater.model.append({
|
||||||
|
kind: "event_match",
|
||||||
|
key: "content.body",
|
||||||
|
pattern: "",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
text: qsTr("Message contains my display name")
|
text: qsTr("Message contains my display name")
|
||||||
|
onTriggered: conditionRepeater.model.append({
|
||||||
|
kind: "contains_display_name",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
text: qsTr(
|
text: qsTr(
|
||||||
"Sender has permission to trigger special notification"
|
"Sender has permission to trigger special notification"
|
||||||
)
|
)
|
||||||
|
onTriggered: conditionRepeater.model.append({
|
||||||
|
kind: "sender_notification_permission",
|
||||||
|
key: "room",
|
||||||
|
})
|
||||||
}
|
}
|
||||||
HMenuItem {
|
HMenuItem {
|
||||||
text: qsTr("Custom JSON condition")
|
text: qsTr("Custom JSON condition")
|
||||||
|
onTriggered: conditionRepeater.model.append({
|
||||||
|
condition: ({kind: "example"}),
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +104,16 @@ HColumnLayout {
|
||||||
|
|
||||||
Repeater {
|
Repeater {
|
||||||
id: conditionRepeater
|
id: conditionRepeater
|
||||||
model: JSON.parse(rule.conditions)
|
model: ListModel {}
|
||||||
|
|
||||||
|
Component.onCompleted: {
|
||||||
|
// Dummy item to setup all the possible roles for this model
|
||||||
|
model.append({
|
||||||
|
kind: "", key: "", pattern: "", condition: {}, is: ""
|
||||||
|
})
|
||||||
|
for (const c of JSON.parse(rule.conditions)) model.append(c)
|
||||||
|
model.remove(0)
|
||||||
|
}
|
||||||
|
|
||||||
HRowLayout {
|
HRowLayout {
|
||||||
readonly property Item control: loader.item
|
readonly property Item control: loader.item
|
||||||
|
@ -94,15 +123,15 @@ HColumnLayout {
|
||||||
HLoader {
|
HLoader {
|
||||||
id: loader
|
id: loader
|
||||||
|
|
||||||
readonly property var condition: modelData
|
readonly property var condition: model
|
||||||
readonly property string filename:
|
readonly property string filename:
|
||||||
modelData.kind === "event_match" ?
|
model.kind === "event_match" ?
|
||||||
"PushEventMatch" :
|
"PushEventMatch" :
|
||||||
modelData.kind === "contains_display_name" ?
|
model.kind === "contains_display_name" ?
|
||||||
"PushContainsDisplayName" :
|
"PushContainsDisplayName" :
|
||||||
modelData.kind === "room_member_count" ?
|
model.kind === "room_member_count" ?
|
||||||
"PushRoomMemberCount" :
|
"PushRoomMemberCount" :
|
||||||
modelData.kind === "sender_notification_permission" ?
|
model.kind === "sender_notification_permission" ?
|
||||||
"PushSenderNotificationPermission" :
|
"PushSenderNotificationPermission" :
|
||||||
"PushUnknownCondition"
|
"PushUnknownCondition"
|
||||||
|
|
||||||
|
@ -116,6 +145,7 @@ HColumnLayout {
|
||||||
iconItem.small: true
|
iconItem.small: true
|
||||||
Layout.fillHeight: true
|
Layout.fillHeight: true
|
||||||
Layout.fillWidth: false
|
Layout.fillWidth: false
|
||||||
|
onClicked: conditionRepeater.model.remove(model.index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,7 @@ import ".."
|
||||||
import "../../../Base"
|
import "../../../Base"
|
||||||
|
|
||||||
CustomLabel {
|
CustomLabel {
|
||||||
readonly property var matrixObject: ({kind: "contains_display_name"})
|
readonly property var matrixObject: ({kind: model.kind})
|
||||||
|
|
||||||
text: qsTr("Message contains my display name")
|
text: qsTr("Message contains my display name")
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ import "../../../Base"
|
||||||
|
|
||||||
CustomFlow {
|
CustomFlow {
|
||||||
readonly property var matrixObject: ({
|
readonly property var matrixObject: ({
|
||||||
kind: "event_match",
|
kind: model.kind,
|
||||||
key: keyCombo.editText,
|
key: keyCombo.editText,
|
||||||
pattern: patternField.text,
|
pattern: patternField.text,
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ import "../../../Base"
|
||||||
|
|
||||||
CustomFlow {
|
CustomFlow {
|
||||||
readonly property var matrixObject: ({
|
readonly property var matrixObject: ({
|
||||||
kind: "room_member_count",
|
kind: model.kind,
|
||||||
is: operatorCombo.operators[operatorCombo.currentIndex]
|
is: operatorCombo.operators[operatorCombo.currentIndex]
|
||||||
.replace("==", "") + countSpin.value,
|
.replace("==", "") + countSpin.value,
|
||||||
})
|
})
|
||||||
|
|
|
@ -8,7 +8,7 @@ import "../../../Base"
|
||||||
|
|
||||||
CustomFlow {
|
CustomFlow {
|
||||||
readonly property var matrixObject: ({
|
readonly property var matrixObject: ({
|
||||||
kind: "sender_notification_permission",
|
kind: model.kind,
|
||||||
key: keyCombo.editText,
|
key: keyCombo.editText,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user