Files
gerrit/polygerrit-ui/app/elements/change/gr-file-list/gr-file-list.html
Andrew Bonventre cbbb8ba45c Clean up gr-file-list
+ Use gr-rest-api-interface instead of gr-ajax and gr-request.
+ Use strict equality operators.
+ Clean up tests.
+ Add hover state to non-header rows.

Change-Id: I8589dc7f9466d61928add8f2587af2b8a2a56497
2016-03-12 10:37:44 -05:00

152 lines
4.4 KiB
HTML

<!--
Copyright (C) 2015 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<link rel="import" href="../../../bower_components/polymer/polymer.html">
<link rel="import" href="../../../behaviors/keyboard-shortcut-behavior.html">
<link rel="import" href="../../shared/gr-request/gr-request.html">
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
<dom-module id="gr-file-list">
<template>
<style>
:host {
display: block;
}
.row {
display: flex;
padding: .1em .25em;
}
.header {
font-weight: bold;
}
.positionIndicator,
.reviewed,
.status {
align-items: center;
display: inline-flex;
}
.reviewed,
.status {
justify-content: center;
width: 1.5em;
}
.positionIndicator {
justify-content: flex-start;
visibility: hidden;
width: 1.25em;
}
.row:not(.header):hover {
background-color: #f5fafd;
}
.row[selected] {
background-color: #ebf5fb;
}
.row[selected] .positionIndicator {
visibility: visible;
}
.path {
flex: 1;
overflow: hidden;
padding-left: .35em;
text-decoration: none;
text-overflow: ellipsis;
white-space: nowrap;
}
.row:not(.header) .path:hover {
text-decoration: underline;
}
.comments,
.stats {
text-align: right;
}
.comments {
min-width: 10em;
}
.stats {
min-width: 7em;
}
.invisible {
visibility: hidden;
}
.row:not(.header) .stats {
font-family: var(--monospace-font-family);
}
.added {
color: #388E3C;
}
.removed {
color: #D32F2F;
}
.reviewed input[type="checkbox"] {
display: inline-block;
}
.drafts {
color: #C62828;
font-weight: bold;
}
@media screen and (max-width: 50em) {
.row[selected] {
background-color: transparent;
}
.positionIndicator,
.stats {
display: none;
}
.reviewed,
.status {
justify-content: flex-start;
}
.comments {
min-width: initial;
}
}
</style>
<div class="row header">
<div class="positionIndicator"></div>
<div class="reviewed" hidden$="[[!_loggedIn]]" hidden></div>
<div class="status"></div>
<div class="path">Path</div>
<div class="comments">Comments</div>
<div class="stats">Stats</div>
</div>
<template is="dom-repeat" items="{{_files}}" as="file">
<div class="row" selected$="[[_computeFileSelected(index, selectedIndex)]]">
<div class="positionIndicator">&#x25b6;</div>
<div class="reviewed" hidden$="[[!_loggedIn]]" hidden>
<input type="checkbox" checked$="[[_computeReviewed(file, _reviewed)]]"
data-path$="[[file.__path]]" on-change="_handleReviewedChange">
</div>
<div class$="[[_computeClass('status', file.__path)]]">
[[_computeFileStatus(file.status)]]
</div>
<a class="path" href$="[[_computeDiffURL(changeNum, patchNum, file.__path)]]">
[[_computeFileDisplayName(file.__path)]]
</a>
<div class="comments">
<span class="drafts">[[_computeDraftsString(drafts, patchNum, file.__path)]]</span>
[[_computeCommentsString(comments, patchNum, file.__path)]]
</div>
<div class$="[[_computeClass('stats', file.__path)]]">
<span class="added">+[[file.lines_inserted]]</span>
<span class="removed">-[[file.lines_deleted]]</span>
</div>
</div>
</template>
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
</template>
<script src="gr-file-list.js"></script>
</dom-module>