aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/EventsController.js
diff options
context:
space:
mode:
Diffstat (limited to 'web/app/view/EventsController.js')
-rw-r--r--web/app/view/EventsController.js37
1 files changed, 35 insertions, 2 deletions
diff --git a/web/app/view/EventsController.js b/web/app/view/EventsController.js
index 5cd9fb8e..1737f264 100644
--- a/web/app/view/EventsController.js
+++ b/web/app/view/EventsController.js
@@ -22,6 +22,11 @@ Ext.define('Traccar.view.EventsController', {
config: {
listen: {
+ controller: {
+ '*': {
+ deselectevent: 'deselectEvent'
+ }
+ },
store: {
'#Events': {
add: 'onAddEvent'
@@ -37,16 +42,28 @@ Ext.define('Traccar.view.EventsController', {
}, Traccar.Style.refreshPeriod);
if (Traccar.app.isMobile()) {
- this.lookupReference('hideEvents').setHidden(false);
+ this.lookupReference('hideEventsButton').setHidden(false);
+ }
+ },
+
+ onRemoveClick: function (button) {
+ var 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')));
+ }
}
},
onClearClick: function (button) {
Ext.getStore('Events').removeAll();
+ Ext.getStore('EventPositions').removeAll();
},
onAddEvent: function (store, data) {
- if (this.lookupReference('scrollToLast').pressed) {
+ if (this.lookupReference('scrollToLastButton').pressed) {
this.getView().scrollBy(0, Number.POSITIVE_INFINITY, true);
}
},
@@ -59,5 +76,21 @@ Ext.define('Traccar.view.EventsController', {
onHideEvents: function () {
Traccar.app.showEvents(false);
+ },
+
+ deselectEvent: function () {
+ this.getView().getSelectionModel().deselectAll();
+ },
+
+ onSelectionChange: function (selection, selected) {
+ var event, position;
+ event = selected.length > 0 ? selected[0] : null;
+ if (event && event.get('positionId')) {
+ position = Ext.getStore('EventPositions').getById(event.get('positionId'));
+ if (position) {
+ this.fireEvent('selectevent', position);
+ }
+ }
+ this.lookupReference('removeEventButton').setDisabled(!event);
}
});