| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 | 5 |
| 6 This file contains most of the logic needed to create a dynamic table. It is b
roken up into two | 6 This file contains most of the logic needed to create a dynamic table. It is b
roken up into two |
| 7 parts, a style dom-module called "dynamic-table-style" and a behavior called | 7 parts, a style dom-module called "dynamic-table-style" and a behavior called |
| 8 SwarmingBehaviors.DynamicTableBehavior. This behavior ties together filtering,
sorting and column | 8 SwarmingBehaviors.DynamicTableBehavior. This behavior ties together filtering,
sorting and column |
| 9 content. It also offers a few utilities to make creating the table easier. A c
lient of these two | 9 content. It also offers a few utilities to make creating the table easier. A c
lient of these two |
| 10 parts needs to create the templates to actually draw the <table>,<tr> and so o
n. See | 10 parts needs to create the templates to actually draw the <table>,<tr> and so o
n. See |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 var dir = 1; | 147 var dir = 1; |
| 148 if (this._sort.direction === "desc") { | 148 if (this._sort.direction === "desc") { |
| 149 dir = -1; | 149 dir = -1; |
| 150 } | 150 } |
| 151 var sort = this._specialSort[this._sort.name]; | 151 var sort = this._specialSort[this._sort.name]; |
| 152 if (sort) { | 152 if (sort) { |
| 153 return sort.bind(this)(dir, a, b); | 153 return sort.bind(this)(dir, a, b); |
| 154 } | 154 } |
| 155 // Default to a natural compare of the columns. | 155 // Default to a natural compare of the columns. |
| 156 var aCol = this._column(this._sort.name, a); | 156 var aCol = this._column(this._sort.name, a); |
| 157 if (aCol === "none"){ |
| 158 // put "none" at the bottom of the sort order |
| 159 aCol = "ZZZ"; |
| 160 } |
| 157 var bCol = this._column(this._sort.name, b); | 161 var bCol = this._column(this._sort.name, b); |
| 162 if (bCol === "none"){ |
| 163 // put "none" at the bottom of the sort order |
| 164 bCol = "ZZZ"; |
| 165 } |
| 158 | 166 |
| 159 return dir * swarming.naturalCompare(aCol, bCol); | 167 return dir * swarming.naturalCompare(aCol, bCol); |
| 160 }, | 168 }, |
| 161 | 169 |
| 162 _filterAndSort: function() { | 170 _filterAndSort: function() { |
| 163 // We intentionally sort this._items (and not a copy) to allow users to | 171 // We intentionally sort this._items (and not a copy) to allow users to |
| 164 // "chain" sorts, that is, sort by one thing and then another, and | 172 // "chain" sorts, that is, sort by one thing and then another, and |
| 165 // have both orderings properly impact the list. | 173 // have both orderings properly impact the list. |
| 166 swarming.stableSort(this._items, this._compare.bind(this)); | 174 swarming.stableSort(this._items, this._compare.bind(this)); |
| 167 var items = this._items; | 175 var items = this._items; |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 var pool = this._attribute(bot, "pool"); | 263 var pool = this._attribute(bot, "pool"); |
| 256 return pool.join(" | "); | 264 return pool.join(" | "); |
| 257 }, | 265 }, |
| 258 }; | 266 }; |
| 259 }, | 267 }, |
| 260 | 268 |
| 261 | 269 |
| 262 }]; | 270 }]; |
| 263 })(); | 271 })(); |
| 264 </script> | 272 </script> |
| OLD | NEW |