diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-15 18:48:17 +1200 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2017-07-15 18:48:17 +1200 |
commit | 8a48bca94e9d76bdae60453ca0231543e66c378e (patch) | |
tree | 6f74a2b17cc882c19fe0951c75663c00e09906b4 | |
parent | 167dec228bf9227fbf1f9fa4a428b8bb309c5f94 (diff) | |
download | trackermap-web-8a48bca94e9d76bdae60453ca0231543e66c378e.tar.gz trackermap-web-8a48bca94e9d76bdae60453ca0231543e66c378e.tar.bz2 trackermap-web-8a48bca94e9d76bdae60453ca0231543e66c378e.zip |
Remove only not referenced positions
-rw-r--r-- | web/app/view/EventsController.js | 9 |
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)); } } }, |