Merge PR #354: Fix the check for preventing to remove auto things

This commit is contained in:
Jenkins nymea 2020-04-03 12:29:53 +02:00
commit ce99769e6c
2 changed files with 4 additions and 5 deletions

View File

@ -59,12 +59,12 @@ Page {
deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Rename"), iconSource: "../images/edit.svg", functionName: "renameThing"})) deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Rename"), iconSource: "../images/edit.svg", functionName: "renameThing"}))
// FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated // FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated
// This check might be wrong for thingClasses with multiple create methods... // This check might be wrong for thingClasses with multiple create methods...
if (!root.device.isChild || root.deviceClass.createMethods !== ["auto"]) { if (!root.device.isChild || root.deviceClass.createMethods.indexOf("CreateMethodAuto") < 0) {
deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Delete"), iconSource: "../images/delete.svg", functionName: "deleteThing"})) deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Delete"), iconSource: "../images/delete.svg", functionName: "deleteThing"}))
} }
// FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated // FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated
// This check might be wrong for thingClasses with multiple create methods... // This check might be wrong for thingClasses with multiple create methods...
if (!root.device.isChild || root.deviceClass.createMethods !== ["auto"]) { if (!root.device.isChild || root.deviceClass.createMethods.indexOf("CreateMethodAuto") < 0) {
deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Reconfigure"), iconSource: "../images/configure.svg", functionName: "reconfigureThing"})) deviceMenu.addItem(menuEntryComponent.createObject(deviceMenu, {text: qsTr("Reconfigure"), iconSource: "../images/configure.svg", functionName: "reconfigureThing"}))
} }
} }

View File

@ -107,9 +107,8 @@ Page {
device: deviceProxy.getDevice(model.id) device: deviceProxy.getDevice(model.id)
// FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated // FIXME: This isn't entirely correct... we should have a way to know if a particular thing is in fact autocreated
// This check might be wrong for thingClasses with multiple create methods... // This check might be wrong for thingClasses with multiple create methods...
canDelete: !device.isChild && device.deviceClass.createMethods === ["auto"] canDelete: !device.isChild || device.deviceClass.createMethods.indexOf("CreateMethodAuto") < 0
onClicked: { onClicked: {
print("clicked:", model.id)
pageStack.push(Qt.resolvedUrl("ConfigureThingPage.qml"), {device: device}) pageStack.push(Qt.resolvedUrl("ConfigureThingPage.qml"), {device: device})
} }
onDeleteClicked: { onDeleteClicked: {