aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--web/app/view/EventsController.js9
1 files changed, 5 insertions, 4 deletions
diff --git a/web/app/view/EventsController.js b/web/app/view/EventsController.js
index 1737f264..16b3c779 100644
--- a/web/app/view/EventsController.js
+++ b/web/app/view/EventsController.js
@@ -47,12 +47,13 @@ Ext.define('Traccar.view.EventsController', {
},
onRemoveClick: function (button) {
- var event = this.getView().getSelectionModel().getSelection()[0];
+ var event, positionId;
+ event = this.getView().getSelectionModel().getSelection()[0];
if (event) {
Ext.getStore('Events').remove(event);
- if (event.get('positionId')) {
- Ext.getStore('EventPositions').remove(
- Ext.getStore('EventPositions').getById(event.get('positionId')));
+ positionId = event.get('positionId');
+ if (positionId && !Ext.getStore('Events').findRecord('positionId', positionId, 0, false, false, true)) {
+ Ext.getStore('EventPositions').remove(Ext.getStore('EventPositions').getById(positionId));
}
}
},