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 <link rel="import" href="../bower_components/paper-button/paper-button.html"> | |
8 | 9 |
9 <polymer-element name="ct-commit-list" attributes="first last commits" noscript> | 10 <polymer-element name="ct-commit-list" attributes="commits" noscript> |
10 <template> | 11 <template> |
11 <style> | 12 <style> |
12 :host { | 13 :host { |
13 display: block; | 14 display: block; |
14 } | 15 } |
16 paper-icon-button { | |
17 vertical-align: middle; | |
18 } | |
19 .repository-info { | |
20 display: block; | |
21 } | |
15 </style> | 22 </style> |
16 <template repeat="{{ repository in commits.commits | _repositories }}"> | 23 <template repeat="{{ repository in commitList | _repositories }}"> |
17 <template repeat="{{ commit in repository | _commits }}"> | 24 <div class="repository-info"> |
18 <ct-commit data="{{ commit }}"></ct-commit> | 25 {{ repository.name }} {{ repository.range }} |
19 </template> | 26 <paper-icon-button icon="more-vert" |
ojan
2014/08/15 17:51:49
Nit: use unfold-more instead of more-vert to be co
dsinclair
2014/08/15 18:58:34
Done.
| |
27 on-click="{{ _expand }}" repositoryName="{{ repository.name }}" repo sitoryRange="{{ repository.range }}"></paper-icon-button> | |
28 <template if="{{ repository.expanded }}"> | |
29 <template repeat="{{ commit in repository.commits }}"> | |
30 <ct-commit data="{{ commit }}"></ct-commit> | |
31 </template> | |
32 </template> | |
33 </div> | |
20 </template> | 34 </template> |
21 </template> | 35 </template> |
22 <script> | 36 <script> |
23 Polymer({ | 37 Polymer({ |
24 commits: null, | 38 repositories: undefined, |
25 first: null, | |
26 last: null, | |
27 | 39 |
28 _repositories: function(commits) { | 40 created: function() { |
29 if (!commits) | 41 this.repositories = []; |
30 return []; | 42 }, |
31 return Object.keys(commits).sort(); | |
32 }, | |
33 | 43 |
34 _commits: function(repository) { | 44 _repositories: function() { |
35 var commits = []; | 45 if (this.commitList) |
36 if (!this.first || !this.last) | 46 this.repositories = this.commitList.repositories(); |
37 return commits; | 47 return this.repositories; |
48 }, | |
38 | 49 |
39 var first = Number(this.first[repository]); | 50 _expand: function(event, detail, sender, target) { |
ojan
2014/08/15 17:51:50
Maybe call this _toggle?
dsinclair
2014/08/15 18:58:34
Done.
| |
40 var last = Number(this.last[repository]); | 51 var repo = sender.getAttribute('repositoryName'); |
41 if (first == last) | 52 var range = sender.getAttribute('repositoryRange'); |
ojan
2014/08/15 17:51:49
Do sender.repositoryName/sender.repositoryRange no
dsinclair
2014/08/15 18:58:34
That doesn't seem to work in this case? I can neve
| |
42 return commits; | |
43 | 53 |
44 if (first > last) { | 54 for(var i = 0; i < this.repositories.length; i++) { |
ojan
2014/08/15 17:51:49
Missing space after "for". Also, if you wanted you
dsinclair
2014/08/15 18:58:34
Done.
Don't need to check range, that was a hold-
| |
45 console.warn('Revision range is backwards, which is invalid:', first, last); | 55 var r = this.repositories[i]; |
46 return commits; | 56 if (r.name === repo && r.range === range) { |
57 r.expanded = !r.expanded; | |
58 break; | |
47 } | 59 } |
48 | 60 } |
49 return this.commits.range(repository, first + 1, last); | 61 } |
50 }, | 62 }); |
51 }); | |
52 </script> | 63 </script> |
53 </polymer-element> | 64 </polymer-element> |
OLD | NEW |