Merge PR #270: Fix the create a scene button
This commit is contained in:
commit
0840fa0c21
@ -275,8 +275,19 @@ Page {
|
|||||||
if (engine.deviceManager.devices.count === 0) {
|
if (engine.deviceManager.devices.count === 0) {
|
||||||
pageStack.push(Qt.resolvedUrl("thingconfiguration/NewThingPage.qml"))
|
pageStack.push(Qt.resolvedUrl("thingconfiguration/NewThingPage.qml"))
|
||||||
} else {
|
} else {
|
||||||
var page = pageStack.push(Qt.resolvedUrl("magic/NewScenePage.qml"))
|
var newRule = engine.ruleManager.createNewRule();
|
||||||
// page.addRule()
|
var editRulePage = pageStack.push(Qt.resolvedUrl("magic/EditRulePage.qml"), {rule: newRule });
|
||||||
|
editRulePage.startAddAction();
|
||||||
|
editRulePage.StackView.onRemoved.connect(function() {
|
||||||
|
newRule.destroy();
|
||||||
|
})
|
||||||
|
editRulePage.onAccept.connect(function() {
|
||||||
|
editRulePage.busy = true;
|
||||||
|
engine.ruleManager.addRule(d.editRulePage.rule);
|
||||||
|
})
|
||||||
|
editRulePage.onCancel.connect(function() {
|
||||||
|
pageStack.pop();
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -221,6 +221,20 @@ Page {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function startAddAction() {
|
||||||
|
if (root.isEmpty) {
|
||||||
|
root.rule.executable = true;
|
||||||
|
}
|
||||||
|
if (root.initialDeviceToBeAdded !== null) {
|
||||||
|
var ruleAction = root.rule.actions.createNewRuleAction();
|
||||||
|
ruleAction.deviceId = root.initialDeviceToBeAdded.id;
|
||||||
|
root.initialDeviceToBeAdded = null;
|
||||||
|
selectRuleActionData(root.rule.actions, ruleAction)
|
||||||
|
} else {
|
||||||
|
var page = pageStack.push(ruleActionQuestionPageComponent, {exitAction: false});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
header: NymeaHeader {
|
header: NymeaHeader {
|
||||||
text: root.rule.name.length === 0 ? qsTr("Add new magic") : qsTr("Edit %1").arg(root.rule.name)
|
text: root.rule.name.length === 0 ? qsTr("Add new magic") : qsTr("Edit %1").arg(root.rule.name)
|
||||||
onBackPressed: {
|
onBackPressed: {
|
||||||
@ -621,17 +635,7 @@ Page {
|
|||||||
text: root.isEmpty ? qsTr("Configure...") :
|
text: root.isEmpty ? qsTr("Configure...") :
|
||||||
actionsRepeater.count == 0 ? qsTr("Add an action...") : qsTr("Add another action...")
|
actionsRepeater.count == 0 ? qsTr("Add an action...") : qsTr("Add another action...")
|
||||||
onClicked: {
|
onClicked: {
|
||||||
if (root.isEmpty) {
|
root.startAddAction();
|
||||||
root.rule.executable = true;
|
|
||||||
}
|
|
||||||
if (root.initialDeviceToBeAdded !== null) {
|
|
||||||
var ruleAction = root.rule.actions.createNewRuleAction();
|
|
||||||
ruleAction.deviceId = root.initialDeviceToBeAdded.id;
|
|
||||||
root.initialDeviceToBeAdded = null;
|
|
||||||
selectRuleActionData(root.rule.actions, ruleAction)
|
|
||||||
} else {
|
|
||||||
var page = pageStack.push(ruleActionQuestionPageComponent, {exitAction: false});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
visible: root.actionsVisible
|
visible: root.actionsVisible
|
||||||
}
|
}
|
||||||
|
|||||||
@ -18,6 +18,7 @@ Page {
|
|||||||
ListView {
|
ListView {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
model: RuleTemplatesFilterModel {
|
model: RuleTemplatesFilterModel {
|
||||||
|
|
||||||
ruleTemplates: RuleTemplates {}
|
ruleTemplates: RuleTemplates {}
|
||||||
filterByDevices: DevicesProxy {
|
filterByDevices: DevicesProxy {
|
||||||
engine: _engine
|
engine: _engine
|
||||||
|
|||||||
Reference in New Issue
Block a user