From 5502e0657caa5d941de8139e834c8d8c089fa389 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 13 Mar 2016 09:31:41 +1300 Subject: Add search bar to devices list --- web/app/view/Devices.js | 25 +++++++++++++++++++++++++ web/l10n/en.json | 1 + 2 files changed, 26 insertions(+) (limited to 'web') diff --git a/web/app/view/Devices.js b/web/app/view/Devices.js index ebe3ca195..2e9509609 100644 --- a/web/app/view/Devices.js +++ b/web/app/view/Devices.js @@ -62,6 +62,31 @@ Ext.define('Traccar.view.Devices', { }] }, + bbar: [{ + xtype: 'tbtext', + html: Strings.sharedSearch + }, { + xtype: 'textfield', + listeners: { + change: function () { + var tree, expr; + tree = this.up('treepanel'); + expr = new RegExp(this.getValue(), 'i'); + tree.store.filter({ + id: 'nameFilter', + filterFn: function (node) { + var children, len, visible, i; + children = node.childNodes; + len = children && children.length; + visible = node.isLeaf() ? expr.test(node.get('name')) : false; + for (i = 0; i < len && !(visible = children[i].get('visible')); i++); + return visible; + } + }); + } + } + }], + listeners: { selectionchange: 'onSelectionChange', beforeselect: 'onBeforeSelect' diff --git a/web/l10n/en.json b/web/l10n/en.json index cabd76362..b0ea6ad26 100644 --- a/web/l10n/en.json +++ b/web/l10n/en.json @@ -14,6 +14,7 @@ "sharedMinute": "Minute", "sharedSecond": "Second", "sharedName": "Name", + "sharedSearch": "Search", "errorTitle": "Error", "errorUnknown": "Unknown error", "errorConnection": "Connection error", -- cgit v1.2.3