From 21ab0b2c306a8838300d65bd8571e7c79c7e3fc7 Mon Sep 17 00:00:00 2001 From: Michael Zanetti Date: Mon, 8 May 2023 15:57:14 +0200 Subject: [PATCH] Add a confirmation question when removing a thing --- nymea-app/translations/nymea-app.de.ts | 16 +++++++++ nymea-app/translations/nymea-app.en.ts | 16 +++++++++ nymea-app/translations/nymea-app.en_US.ts | 16 +++++++++ nymea-app/translations/nymea-app.it.ts | 16 +++++++++ nymea-app/translations/nymea-app.ko.ts | 16 +++++++++ nymea-app/translations/nymea-app.nl.ts | 16 +++++++++ nymea-app/translations/nymea-app.tr.ts | 16 +++++++++ nymea-app/translations/nymea-app.vi.ts | 16 +++++++++ .../thingconfiguration/ConfigureThingPage.qml | 34 +++++++++++++++---- .../ui/thingconfiguration/EditThingsPage.qml | 31 +++++++++++------ 10 files changed, 177 insertions(+), 16 deletions(-) diff --git a/nymea-app/translations/nymea-app.de.ts b/nymea-app/translations/nymea-app.de.ts index ab7fdc64..f6fd1a5c 100644 --- a/nymea-app/translations/nymea-app.de.ts +++ b/nymea-app/translations/nymea-app.de.ts @@ -683,6 +683,14 @@ ID ID + + Remove thing? + "Thing" entfernen? + + + Are you sure you want to remove %1 and all associated settings? + Bist Du sicher, dass %1 und alle zugehörigen Einstellungen entfernt werden sollen? + ConnectingPage @@ -1726,6 +1734,14 @@ In order for your %1 system to be useful, go ahead and add some things. Damit Dein %1 System sich nützlich machen kann, füge einige "Things" hinzu. + + Remove thing? + "Thing" entfernen? + + + Are you sure you want to remove %1 and all associated settings? + Bist Du sicher, dass %1 und alle zugehörigen Einstellungen entfernt werden sollen? + EditTimeEventItemPage diff --git a/nymea-app/translations/nymea-app.en.ts b/nymea-app/translations/nymea-app.en.ts index f987aa08..919905bd 100644 --- a/nymea-app/translations/nymea-app.en.ts +++ b/nymea-app/translations/nymea-app.en.ts @@ -683,6 +683,14 @@ ID + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + ConnectingPage @@ -1720,6 +1728,14 @@ In order for your %1 system to be useful, go ahead and add some things. + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + EditTimeEventItemPage diff --git a/nymea-app/translations/nymea-app.en_US.ts b/nymea-app/translations/nymea-app.en_US.ts index 9f503cc6..c8a3e50e 100644 --- a/nymea-app/translations/nymea-app.en_US.ts +++ b/nymea-app/translations/nymea-app.en_US.ts @@ -683,6 +683,14 @@ ID + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + ConnectingPage @@ -1720,6 +1728,14 @@ In order for your %1 system to be useful, go ahead and add some things. + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + EditTimeEventItemPage diff --git a/nymea-app/translations/nymea-app.it.ts b/nymea-app/translations/nymea-app.it.ts index 18357c01..1f8841bf 100644 --- a/nymea-app/translations/nymea-app.it.ts +++ b/nymea-app/translations/nymea-app.it.ts @@ -683,6 +683,14 @@ ID + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + ConnectingPage @@ -1720,6 +1728,14 @@ In order for your %1 system to be useful, go ahead and add some things. + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + EditTimeEventItemPage diff --git a/nymea-app/translations/nymea-app.ko.ts b/nymea-app/translations/nymea-app.ko.ts index 530464cb..0255e8c4 100644 --- a/nymea-app/translations/nymea-app.ko.ts +++ b/nymea-app/translations/nymea-app.ko.ts @@ -682,6 +682,14 @@ ID + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + ConnectingPage @@ -1722,6 +1730,14 @@ In order for your %1 system to be useful, go ahead and add some things. %1 시스템이 유용하려면 먼저 몇 가지를 추가하십시오. + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + EditTimeEventItemPage diff --git a/nymea-app/translations/nymea-app.nl.ts b/nymea-app/translations/nymea-app.nl.ts index 81fbe03f..aa9ec0c6 100644 --- a/nymea-app/translations/nymea-app.nl.ts +++ b/nymea-app/translations/nymea-app.nl.ts @@ -683,6 +683,14 @@ ID + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + ConnectingPage @@ -1720,6 +1728,14 @@ In order for your %1 system to be useful, go ahead and add some things. + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + EditTimeEventItemPage diff --git a/nymea-app/translations/nymea-app.tr.ts b/nymea-app/translations/nymea-app.tr.ts index 24a2d30c..1fd47db8 100644 --- a/nymea-app/translations/nymea-app.tr.ts +++ b/nymea-app/translations/nymea-app.tr.ts @@ -682,6 +682,14 @@ ID + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + ConnectingPage @@ -1722,6 +1730,14 @@ In order for your %1 system to be useful, go ahead and add some things. %1 sisteminizin kullanışlı olması için devam edin ve bazı şeyler ekleyin. + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + EditTimeEventItemPage diff --git a/nymea-app/translations/nymea-app.vi.ts b/nymea-app/translations/nymea-app.vi.ts index a76997a7..f0fe0067 100644 --- a/nymea-app/translations/nymea-app.vi.ts +++ b/nymea-app/translations/nymea-app.vi.ts @@ -682,6 +682,14 @@ ID + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + ConnectingPage @@ -1719,6 +1727,14 @@ In order for your %1 system to be useful, go ahead and add some things. + + Remove thing? + + + + Are you sure you want to remove %1 and all associated settings? + + EditTimeEventItemPage diff --git a/nymea-app/ui/thingconfiguration/ConfigureThingPage.qml b/nymea-app/ui/thingconfiguration/ConfigureThingPage.qml index e1c476de..10c33f8c 100644 --- a/nymea-app/ui/thingconfiguration/ConfigureThingPage.qml +++ b/nymea-app/ui/thingconfiguration/ConfigureThingPage.qml @@ -38,6 +38,7 @@ import "../delegates" SettingsPageBase { id: root property Thing thing: null + busy: d.pendingCommand != -1 header: NymeaHeader { text: root.thing.name @@ -80,7 +81,8 @@ SettingsPageBase { } function deleteThing() { - engine.thingManager.removeThing(root.thing.id) + var popup = removeDialogComponent.createObject(root) + popup.open() } function reconfigureThing() { @@ -101,15 +103,16 @@ SettingsPageBase { Connections { target: engine.thingManager onRemoveThingReply: { + if (d.pendingCommand != commandId) { + return; + } + + d.pendingCommand = -1 + switch (thingError) { case Thing.ThingErrorNoError: pageStack.pop(); return; - case Thing.ThingErrorThingInRule: - var removeMethodComponent = Qt.createComponent(Qt.resolvedUrl("../components/RemoveThingMethodDialog.qml")) - var popup = removeMethodComponent.createObject(root, {thing: root.thing, rulesList: ruleIds}); - popup.open(); - return; default: var popup = errorDialog.createObject(root, {error: thingError}) popup.open(); @@ -117,6 +120,11 @@ SettingsPageBase { } } + QtObject { + id: d + property int pendingCommand: -1 + } + SettingsPageSectionHeader { text: qsTr("Information") } @@ -289,6 +297,20 @@ SettingsPageBase { ErrorDialog { } } + Component { + id: removeDialogComponent + NymeaDialog { + id: removeDialog + title: qsTr("Remove thing?") + text: qsTr("Are you sure you want to remove %1 and all associated settings?").arg(root.thing.name) + standardButtons: Dialog.Yes | Dialog.No + + onAccepted: { + d.pendingCommand = engine.thingManager.removeThing(root.thing.id) + } + } + } + Component { id: renameDialog Dialog { diff --git a/nymea-app/ui/thingconfiguration/EditThingsPage.qml b/nymea-app/ui/thingconfiguration/EditThingsPage.qml index 8013ddd7..9d11855e 100644 --- a/nymea-app/ui/thingconfiguration/EditThingsPage.qml +++ b/nymea-app/ui/thingconfiguration/EditThingsPage.qml @@ -56,24 +56,20 @@ Page { QtObject { id: d - property var thingToRemove: null + property int pendingCommandId: -1 } Connections { target: engine.thingManager onRemoveThingReply: { - if (!d.thingToRemove) { + if (commandId != d.pendingCommandId) { return; } + d.pendingCommandId = -1 + switch (thingError) { case Thing.ThingErrorNoError: - d.thingToRemove = null; - return; - case Thing.ThingErrorThingInRule: - var removeMethodComponent = Qt.createComponent(Qt.resolvedUrl("../components/RemoveThingMethodDialog.qml")) - var popup = removeMethodComponent.createObject(root, {thing: d.thingToRemove, rulesList: ruleIds}); - popup.open(); return; default: var errorDialog = Qt.createComponent(Qt.resolvedUrl("../components/ErrorDialog.qml")) @@ -112,13 +108,28 @@ Page { pageStack.push(Qt.resolvedUrl("ConfigureThingPage.qml"), {thing: thing}) } onDeleteClicked: { - d.thingToRemove = thing; - engine.thingManager.removeThing(d.thingToRemove.id) + var popup = removeDialogComponent.createObject(root, {thing: thing}) + popup.open() } } } } + Component { + id: removeDialogComponent + NymeaDialog { + id: removeDialog + title: qsTr("Remove thing?") + text: qsTr("Are you sure you want to remove %1 and all associated settings?").arg(thing.name) + standardButtons: Dialog.Yes | Dialog.No + + property Thing thing: null + + onAccepted: { + d.pendingCommand = engine.thingManager.removeThing(thing.id) + } + } + } EmptyViewPlaceholder { anchors { left: parent.left; right: parent.right; margins: app.margins }