| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. | 4 found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <link rel="import" href="ct-commit.html"> | 7 <link rel="import" href="ct-commit.html"> |
| 8 | 8 |
| 9 <polymer-element name="ct-commit-list" attributes="first last commits" noscript> | 9 <polymer-element name="ct-commit-list" attributes="commitList"> |
| 10 <template> | 10 <template> |
| 11 <style> | 11 <style> |
| 12 :host { | 12 :host { |
| 13 display: block; | 13 display: block; |
| 14 } | 14 } |
| 15 </style> | 15 </style> |
| 16 <template repeat="{{ repository in commits.commits | _repositories }}"> | 16 <template repeat="{{ repository in commitList | _repositories }}"> |
| 17 <template repeat="{{ commit in repository | _commits }}"> | 17 <template repeat="{{ commit in repository.commits }}"> |
| 18 <ct-commit data="{{ commit }}"></ct-commit> | 18 <ct-commit data="{{ commit }}"></ct-commit> |
| 19 </template> | 19 </template> |
| 20 </template> | 20 </template> |
| 21 </template> | 21 </template> |
| 22 <script> | 22 <script> |
| 23 Polymer({ | 23 Polymer({ |
| 24 commits: null, | 24 _repositories: function() { |
| 25 first: null, | 25 return this.commitList.repositories(); |
| 26 last: null, | 26 } |
| 27 | 27 }); |
| 28 _repositories: function(commits) { | |
| 29 if (!commits) | |
| 30 return []; | |
| 31 return Object.keys(commits).sort(); | |
| 32 }, | |
| 33 | |
| 34 _commits: function(repository) { | |
| 35 var commits = []; | |
| 36 if (!this.first || !this.last) | |
| 37 return commits; | |
| 38 | |
| 39 var first = Number(this.first[repository]); | |
| 40 var last = Number(this.last[repository]); | |
| 41 if (first == last) | |
| 42 return commits; | |
| 43 | |
| 44 if (first > last) { | |
| 45 console.warn('Revision range is backwards, which is invalid:', first,
last); | |
| 46 return commits; | |
| 47 } | |
| 48 | |
| 49 return this.commits.range(repository, first + 1, last); | |
| 50 }, | |
| 51 }); | |
| 52 </script> | 28 </script> |
| 53 </polymer-element> | 29 </polymer-element> |
| OLD | NEW |