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) {
|
||||
pageStack.push(Qt.resolvedUrl("thingconfiguration/NewThingPage.qml"))
|
||||
} else {
|
||||
var page = pageStack.push(Qt.resolvedUrl("magic/NewScenePage.qml"))
|
||||
// page.addRule()
|
||||
var newRule = engine.ruleManager.createNewRule();
|
||||
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 {
|
||||
text: root.rule.name.length === 0 ? qsTr("Add new magic") : qsTr("Edit %1").arg(root.rule.name)
|
||||
onBackPressed: {
|
||||
@ -620,18 +634,8 @@ Page {
|
||||
Layout.margins: app.margins
|
||||
text: root.isEmpty ? qsTr("Configure...") :
|
||||
actionsRepeater.count == 0 ? qsTr("Add an action...") : qsTr("Add another action...")
|
||||
onClicked: {
|
||||
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});
|
||||
}
|
||||
onClicked: {
|
||||
root.startAddAction();
|
||||
}
|
||||
visible: root.actionsVisible
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@ Page {
|
||||
ListView {
|
||||
anchors.fill: parent
|
||||
model: RuleTemplatesFilterModel {
|
||||
|
||||
ruleTemplates: RuleTemplates {}
|
||||
filterByDevices: DevicesProxy {
|
||||
engine: _engine
|
||||
|
||||
Reference in New Issue
Block a user