Skip to content

Commit

Permalink
Fix items being deleted without confirmation
Browse files Browse the repository at this point in the history
  • Loading branch information
Álan Crístoffer committed Mar 20, 2018
1 parent f5a262e commit 9fffb9a
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 20 deletions.
12 changes: 8 additions & 4 deletions src/typescript/control.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
27 changes: 16 additions & 11 deletions src/typescript/live_graph.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 6 additions & 2 deletions src/typescript/system_response.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion src/typescript/translation/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?'
}
3 changes: 2 additions & 1 deletion src/typescript/translation/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?'
}
3 changes: 2 additions & 1 deletion src/typescript/translation/pt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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?'
}

0 comments on commit 9fffb9a

Please sign in to comment.