From 053374907cd954bd2643d1658f9a83ee4f12c9fb Mon Sep 17 00:00:00 2001 From: hyung-hwan Date: Mon, 19 Dec 2016 14:30:20 +0000 Subject: [PATCH] added autocomplete to the username input box in the project map view --- codepot/src/codepot/views/project_map.php | 27 +++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/codepot/src/codepot/views/project_map.php b/codepot/src/codepot/views/project_map.php index aca71274..f878b090 100644 --- a/codepot/src/codepot/views/project_map.php +++ b/codepot/src/codepot/views/project_map.php @@ -67,6 +67,8 @@ var GraphApp = (function() this.graph = null; this.data = null; + this.initial_uids = null; + return this; } @@ -121,6 +123,19 @@ var GraphApp = (function() return gd; } + function get_all_unique_uids (data) + { + var uids = {}; + for (var prid in data) + { + for (var i = 0; i < data[prid].length; i++) + { + uids[data[prid][i]] = 1; + } + } + return Object.keys(uids); + } + function handle_double_click (nodeid) { // TODO: store node-id to name mapping and use it @@ -158,6 +173,12 @@ var GraphApp = (function() } else { + if (this.initial_uids == null || this.initial_uids.length <= 0) + { + this.initial_uids = get_all_unique_uids.call (this, data); + this.filter.autocomplete('option', 'source', this.initial_uids); + } + this.data = convert_data.call (this, data); if (this.graph === null) { @@ -226,6 +247,12 @@ var GraphApp = (function() this.filter.button().bind ('keyup', function(e) { if (e.keyCode == 13) self.triggerRefresh (); }); + + this.filter.autocomplete ({ + minLength: 1, // is this too small? + delay: 500, + source: [] // to be set upon the first data load + }); }; App.prototype.refresh = function (filter)