From cfa8225c8298fd933d92f62928edbd1f6f9096fc Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 26 Jul 2015 12:28:03 +1200 Subject: Extra parameters for commands --- web/app/view/command/CommandDialog.js | 23 ++++++++++++++++++++++- web/app/view/command/CommandDialogController.js | 21 ++++++++++++++++++--- 2 files changed, 40 insertions(+), 4 deletions(-) (limited to 'web/app/view') diff --git a/web/app/view/command/CommandDialog.js b/web/app/view/command/CommandDialog.js index ef99c4db6..7f4b3c592 100644 --- a/web/app/view/command/CommandDialog.js +++ b/web/app/view/command/CommandDialog.js @@ -37,7 +37,28 @@ Ext.define('Traccar.view.command.CommandDialog', { fieldLabel: strings.command_type, store: 'CommandTypes', displayField: 'name', - valueField: 'key' + valueField: 'key', + listeners: { + select: 'onSelect' + } + }, { + xtype: 'fieldcontainer', + reference: 'paramPositionFix', + name: 'other', + hidden: true, + + items: [{ + xtype: 'numberfield', + fieldLabel: strings.command_frequency, + name: 'frequency' + }, { + xtype: 'combobox', + fieldLabel: strings.command_unit, + name: 'unit', + store: 'TimeUnits', + displayField: 'name', + valueField: 'multiplier' + }] }] }, diff --git a/web/app/view/command/CommandDialogController.js b/web/app/view/command/CommandDialogController.js index 08624bf73..14d4ba2e0 100644 --- a/web/app/view/command/CommandDialogController.js +++ b/web/app/view/command/CommandDialogController.js @@ -18,10 +18,25 @@ Ext.define('Traccar.view.command.CommandDialogController', { extend: 'Ext.app.ViewController', alias: 'controller.commanddialog', + onSelect: function(selected) { + this.lookupReference('paramPositionFix').setHidden(selected.getValue() !== 'positionFix'); + }, + onSendClick: function(button) { - var dialog = button.up('window').down('form'); - dialog.updateRecord(); - var record = dialog.getRecord(); + var other; + var form = button.up('window').down('form'); + form.updateRecord(); + var record = form.getRecord(); + + if (record.get('type') === 'positionFix') { + other = this.lookupReference('paramPositionFix'); + var value = other.down('numberfield[name="frequency"]').getValue(); + value *= other.down('combobox[name="unit"]').getValue(); + + record.set('other', { + frequency: value + }); + } Ext.Ajax.request({ scope: this, -- cgit v1.2.3