From 9fffb9a0545cee17357c5cbb99a7d6cf6ee9c8ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lan=20Cr=C3=ADstoffer?= Date: Tue, 20 Mar 2018 17:40:07 -0300 Subject: [PATCH] Fix items being deleted without confirmation --- src/typescript/control.component.ts | 12 ++++++--- src/typescript/live_graph.component.ts | 27 ++++++++++++--------- src/typescript/system_response.component.ts | 8 ++++-- src/typescript/translation/de.ts | 3 ++- src/typescript/translation/fr.ts | 3 ++- src/typescript/translation/pt.ts | 3 ++- 6 files changed, 36 insertions(+), 20 deletions(-) diff --git a/src/typescript/control.component.ts b/src/typescript/control.component.ts index d24d1f3..1e7534b 100644 --- a/src/typescript/control.component.ts +++ b/src/typescript/control.component.ts @@ -105,10 +105,14 @@ export class ControlComponent implements OnInit { } remove(controller: Controller): void { - this.controllers = _.filter(this.controllers, c => c != controller) - this.service.save(this.controllers).subscribe(() => { - this.service.load().subscribe(cs => this.controllers = cs) - }) + const msg = 'Are you sure that you want to delete this item?' + const r = confirm(this.i18n.instant(msg)) + if (r) { + this.controllers = _.filter(this.controllers, c => c != controller) + this.service.save(this.controllers).subscribe(() => { + this.service.load().subscribe(cs => this.controllers = cs) + }) + } } run(controller: Controller) { diff --git a/src/typescript/live_graph.component.ts b/src/typescript/live_graph.component.ts index cdaa107..2c874e5 100644 --- a/src/typescript/live_graph.component.ts +++ b/src/typescript/live_graph.component.ts @@ -144,18 +144,23 @@ export class LiveGraphComponent implements OnInit, OnDestroy { } removeTest(test: Test): void { - if (this.test != null && - this.test.name == test.name && - this.test.date == test.date) { - this.test = this.testData = this.testExportVariables = null - } + const msg = 'Are you sure that you want to delete this item?' + const running = this.test != null && this.test.running + const r = running || confirm(this.i18n.instant(msg)) + if (r) { + if (this.test != null && + this.test.name == test.name && + this.test.date == test.date) { + this.test = this.testData = this.testExportVariables = null + } - this.lg.removeTest(test).subscribe( - () => this.tests = _.filter(this.tests, t => { - return t.name != test.name || t.date != test.date - }), - this.httpError() - ) + this.lg.removeTest(test).subscribe( + () => this.tests = _.filter(this.tests, t => { + return t.name != test.name || t.date != test.date + }), + this.httpError() + ) + } } saveTest(): void { diff --git a/src/typescript/system_response.component.ts b/src/typescript/system_response.component.ts index 5bdf713..8f31170 100644 --- a/src/typescript/system_response.component.ts +++ b/src/typescript/system_response.component.ts @@ -80,8 +80,12 @@ export class SystemResponseComponent implements OnInit { } removeTest(test: ResponseTest): void { - this.tests = this.tests.filter(t => t.id !== test.id) - this.saveTests() + const msg = 'Are you sure that you want to delete this item?' + const r = confirm(this.i18n.instant(msg)) + if (r) { + this.tests = this.tests.filter(t => t.id !== test.id) + this.saveTests() + } } addTest(): void { diff --git a/src/typescript/translation/de.ts b/src/typescript/translation/de.ts index b2eaee7..6cc4602 100644 --- a/src/typescript/translation/de.ts +++ b/src/typescript/translation/de.ts @@ -121,5 +121,6 @@ export const LANG_DE_TRANS = { 'Controller': 'Regler', 'After': 'Nach', 'This code will be executed after the controller leaves. Even if something goes wrong.': 'Dies Code wird nach dem Regler laufen, auch wenn etwas Schiff geht.', - 'Stop': 'Stopen' + 'Stop': 'Stopen', + 'Are you sure that you want to delete this item?': 'Sind Sie sicher, dass Sie diesem Eintrag löschen möchten?' } diff --git a/src/typescript/translation/fr.ts b/src/typescript/translation/fr.ts index 6edbaad..531deac 100644 --- a/src/typescript/translation/fr.ts +++ b/src/typescript/translation/fr.ts @@ -121,5 +121,6 @@ export const LANG_FR_TRANS = { 'Controller': 'Contrôleur', 'After': 'Après', 'This code will be executed after the controller leaves. Even if something goes wrong.': 'Ce code sera exécuté après la sortie du contrôleur. Même si quelque chose ne va pas.', - 'Stop': 'Arrêter' + 'Stop': 'Arrêter', + 'Are you sure that you want to delete this item?': 'Êtes-vous sûr de vouloir supprimer cet élément?' } diff --git a/src/typescript/translation/pt.ts b/src/typescript/translation/pt.ts index e7de5a1..3b85fcb 100644 --- a/src/typescript/translation/pt.ts +++ b/src/typescript/translation/pt.ts @@ -121,5 +121,6 @@ export const LANG_PT_TRANS = { 'Controller': 'Controlador', 'After': 'Depois', 'This code will be executed after the controller leaves. Even if something goes wrong.': 'Este código será executado depois do controlador, mesmo se algo der errado.', - 'Stop': 'Parar' + 'Stop': 'Parar', + 'Are you sure that you want to delete this item?': 'Tem certeza que deseja excluir este item?' }