Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2920)

Unified Diff: appengine/swarming/ui/res/imp/common/query-column-filter-behavior.html

Issue 2500873004: Make typing in the filter box handle typing filters (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « appengine/swarming/ui/build/js/js.js ('k') | appengine/swarming/ui/res/js/alias.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: appengine/swarming/ui/res/imp/common/query-column-filter-behavior.html
diff --git a/appengine/swarming/ui/res/imp/common/query-column-filter-behavior.html b/appengine/swarming/ui/res/imp/common/query-column-filter-behavior.html
index cf9d4336ac9e27b74cadc367aeaf0307a5e33486..461372eb032a43a53b708b140d91e6342b16eff4 100644
--- a/appengine/swarming/ui/res/imp/common/query-column-filter-behavior.html
+++ b/appengine/swarming/ui/res/imp/common/query-column-filter-behavior.html
@@ -148,6 +148,7 @@
<script>
(function(){
+ var FILTER_SEP = ":";
// Given a space separated list of queries, matchPartCaseInsensitive
// returns an object of any query that matches a part of str, case
// insensitive. The object has an idx (index) and the part that matched.
@@ -180,6 +181,27 @@
};
};
+ var matchFilter = function(toMatch, filterStr, isColumn) {
+ if (!filterStr) {
+ return true;
+ }
+ if (!toMatch) {
+ return false;
+ }
+
+ toMatch = toMatch.toLocaleLowerCase();
+ filterStr = filterStr.trim().toLocaleLowerCase();
+ if (filterStr.indexOf(" ") !== -1 || filterStr.indexOf(":") === -1) {
+ return false;
+ }
+ var col = filterStr.split(FILTER_SEP, 1)[0];
+ var rest = filterStr.substring(col.length + FILTER_SEP.length);
+ if (isColumn) {
+ return toMatch === col;
+ }
+ return toMatch.startsWith(rest);
+ }
+
// Extend the Aliases behavior
SwarmingBehaviors.QueryColumnFilter = [SwarmingBehaviors.CommonBehavior, {
@@ -204,7 +226,7 @@
// private
FILTER_SEP: {
type:String,
- value: ":",
+ value: FILTER_SEP,
},
_filters: {
type:Array,
@@ -357,6 +379,9 @@
// partially match the query or that have secondary values which
// partially match.
var arr = this.primary_arr.filter(function(s){
+ if (matchFilter(s, query, true)) {
+ return true;
+ }
if (matchPartCaseInsensitive(s, query).idx !== -1) {
return true;
}
@@ -404,6 +429,17 @@
return [];
}
var arr = primary_map[primarySelected] || [];
+ if (matchFilter(primarySelected, query, true)) {
+ return arr.sort(function(a, b){
+ var aMatch = matchFilter(a, query, false);
+ var bMatch = matchFilter(b, query, false);
+ if (aMatch === bMatch) {
+ return swarming.naturalCompare(a,b);
+ }
+ // true == 1 and false == 0. So, put the one that matches first.
+ return bMatch - aMatch;
+ });
+ }
if (matchPartCaseInsensitive(primarySelected, query).idx !== -1) {
// Sort the secondaries alphabetically, but prioritize query matches.
return arr.sort(function(a, b){
@@ -426,7 +462,7 @@
// instance of the filter query, making it easier to see why elements
// show up.
_beforeBold: function(item, query) {
- var match = matchPartCaseInsensitive(item, query);
+ var match = matchPartCaseInsensitive(item, query.replace(":", " "));
if (match.idx === -1) {
return item;
}
@@ -434,7 +470,7 @@
},
_bold: function(item, query) {
- var match = matchPartCaseInsensitive(item, query);
+ var match = matchPartCaseInsensitive(item, query.replace(":", " "));
if (match.idx === -1) {
return "";
}
@@ -442,7 +478,7 @@
},
_afterBold: function(item, query) {
- var match = matchPartCaseInsensitive(item, query);
+ var match = matchPartCaseInsensitive(item, query.replace(":", " "));
if (match.idx === -1) {
return "";
}
« no previous file with comments | « appengine/swarming/ui/build/js/js.js ('k') | appengine/swarming/ui/res/js/alias.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698