2016-03-04 17:48:22 -05:00
|
|
|
<!--
|
|
|
|
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="../../../bower_components/iron-autogrow-textarea/iron-autogrow-textarea.html">
|
|
|
|
<link rel="import" href="../../shared/gr-button/gr-button.html">
|
|
|
|
<link rel="import" href="../../shared/gr-date-formatter/gr-date-formatter.html">
|
2016-11-08 15:49:05 -08:00
|
|
|
<link rel="import" href="../../shared/gr-formatted-text/gr-formatted-text.html">
|
2016-05-18 12:37:53 -07:00
|
|
|
<link rel="import" href="../../shared/gr-storage/gr-storage.html">
|
2016-05-03 15:14:57 -04:00
|
|
|
<link rel="import" href="../../shared/gr-rest-api-interface/gr-rest-api-interface.html">
|
2016-03-04 17:48:22 -05:00
|
|
|
|
|
|
|
<dom-module id="gr-diff-comment">
|
|
|
|
<template>
|
|
|
|
<style>
|
|
|
|
:host {
|
|
|
|
display: block;
|
2016-11-08 15:49:05 -08:00
|
|
|
font-family: var(--font-family);
|
|
|
|
margin: .7em 0;
|
2016-03-04 17:48:22 -05:00
|
|
|
--iron-autogrow-textarea: {
|
|
|
|
padding: 2px;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
:host([disabled]) {
|
|
|
|
pointer-events: none;
|
|
|
|
}
|
|
|
|
:host([disabled]) .container {
|
|
|
|
opacity: .5;
|
|
|
|
}
|
|
|
|
.header {
|
2016-10-06 10:18:32 -07:00
|
|
|
cursor: pointer;
|
2016-03-04 17:48:22 -05:00
|
|
|
display: flex;
|
|
|
|
font-family: 'Open Sans', sans-serif;
|
2016-11-08 15:49:05 -08:00
|
|
|
margin: 0.7em 0;
|
2016-10-06 10:18:32 -07:00
|
|
|
padding-bottom: 0;
|
2016-03-04 17:48:22 -05:00
|
|
|
}
|
2016-11-08 15:49:05 -08:00
|
|
|
.container.collapsed .header {
|
|
|
|
margin: 0;
|
|
|
|
}
|
2016-10-06 10:18:32 -07:00
|
|
|
.headerMiddle {
|
|
|
|
color: #666;
|
2016-03-04 17:48:22 -05:00
|
|
|
flex: 1;
|
2016-10-06 10:18:32 -07:00
|
|
|
overflow: hidden;
|
2016-03-04 17:48:22 -05:00
|
|
|
}
|
|
|
|
.authorName,
|
|
|
|
.draftLabel {
|
2016-10-06 10:18:32 -07:00
|
|
|
display: block;
|
|
|
|
float: left;
|
2016-03-04 17:48:22 -05:00
|
|
|
font-weight: bold;
|
|
|
|
}
|
|
|
|
.draftLabel {
|
|
|
|
color: #999;
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.date {
|
|
|
|
justify-content: flex-end;
|
|
|
|
margin-left: 5px;
|
2016-10-06 10:18:32 -07:00
|
|
|
white-space: nowrap;
|
2016-03-04 17:48:22 -05:00
|
|
|
}
|
|
|
|
a.date:link,
|
|
|
|
a.date:visited {
|
|
|
|
color: #666;
|
|
|
|
}
|
|
|
|
.actions {
|
|
|
|
display: flex;
|
|
|
|
padding-top: 0;
|
|
|
|
}
|
|
|
|
.action {
|
|
|
|
margin-right: .5em;
|
|
|
|
}
|
|
|
|
.danger {
|
|
|
|
display: flex;
|
|
|
|
flex: 1;
|
|
|
|
justify-content: flex-end;
|
|
|
|
}
|
|
|
|
.editMessage {
|
|
|
|
display: none;
|
|
|
|
margin: .5em .7em;
|
|
|
|
width: calc(100% - 1.4em - 2px);
|
|
|
|
}
|
|
|
|
.danger .action {
|
|
|
|
margin-right: 0;
|
|
|
|
}
|
|
|
|
.container:not(.draft) .actions :not(.reply):not(.quote):not(.done) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.draft .reply,
|
|
|
|
.draft .quote,
|
|
|
|
.draft .done {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.draft .draftLabel {
|
|
|
|
display: inline;
|
|
|
|
}
|
|
|
|
.draft:not(.editing) .save,
|
|
|
|
.draft:not(.editing) .cancel {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.editing .message,
|
|
|
|
.editing .reply,
|
|
|
|
.editing .quote,
|
|
|
|
.editing .done,
|
|
|
|
.editing .edit {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.editing .editMessage {
|
|
|
|
background-color: #fff;
|
|
|
|
display: block;
|
|
|
|
}
|
2016-10-06 10:18:32 -07:00
|
|
|
.show-hide {
|
|
|
|
margin-left: .4em;
|
|
|
|
}
|
|
|
|
input.show-hide {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
label.show-hide {
|
|
|
|
color: #000;
|
|
|
|
cursor: pointer;
|
|
|
|
display: block;
|
|
|
|
font-size: .8em;
|
|
|
|
height: 1.1em;
|
|
|
|
margin-top: .1em;
|
|
|
|
}
|
|
|
|
#container .collapsedContent {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
#container.collapsed {
|
|
|
|
padding-bottom: 3px;
|
|
|
|
}
|
|
|
|
#container.collapsed .collapsedContent {
|
|
|
|
display: block;
|
|
|
|
overflow: hidden;
|
|
|
|
padding-left: 5px;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
white-space: nowrap;
|
|
|
|
}
|
|
|
|
#container.collapsed .actions,
|
2016-11-08 15:49:05 -08:00
|
|
|
#container.collapsed gr-formatted-text,
|
2016-10-06 10:18:32 -07:00
|
|
|
#container.collapsed iron-autogrow-textarea {
|
|
|
|
display: none;
|
|
|
|
}
|
2016-03-04 17:48:22 -05:00
|
|
|
</style>
|
2016-06-09 16:08:04 -07:00
|
|
|
<div id="container"
|
|
|
|
class="container"
|
|
|
|
on-mouseenter="_handleMouseEnter"
|
|
|
|
on-mouseleave="_handleMouseLeave">
|
2016-10-06 10:18:32 -07:00
|
|
|
<div class="header" id="header" on-click="_handleToggleCollapsed">
|
2016-03-04 17:48:22 -05:00
|
|
|
<div class="headerLeft">
|
|
|
|
<span class="authorName">[[comment.author.name]]</span>
|
|
|
|
<span class="draftLabel">DRAFT</span>
|
|
|
|
</div>
|
2016-10-06 10:18:32 -07:00
|
|
|
<div class="headerMiddle">
|
|
|
|
<span class="collapsedContent">[[comment.message]]</span>
|
|
|
|
</div>
|
2016-03-04 17:48:22 -05:00
|
|
|
<a class="date" href$="[[_computeLinkToComment(comment)]]" on-tap="_handleLinkTap">
|
|
|
|
<gr-date-formatter date-str="[[comment.updated]]"></gr-date-formatter>
|
|
|
|
</a>
|
2016-10-06 10:18:32 -07:00
|
|
|
<div class="show-hide">
|
|
|
|
<label class="show-hide">
|
|
|
|
<input type="checkbox" class="show-hide"
|
2016-10-10 17:31:56 -07:00
|
|
|
checked$="[[collapsed]]"
|
2016-10-06 10:18:32 -07:00
|
|
|
on-change="_handleToggleCollapsed">
|
2016-10-10 17:31:56 -07:00
|
|
|
[[_computeShowHideText(collapsed)]]
|
2016-10-06 10:18:32 -07:00
|
|
|
</label>
|
|
|
|
</div>
|
2016-03-04 17:48:22 -05:00
|
|
|
</div>
|
|
|
|
<iron-autogrow-textarea
|
|
|
|
id="editTextarea"
|
|
|
|
class="editMessage"
|
2016-11-15 13:12:21 -08:00
|
|
|
autocomplete="on"
|
2016-03-04 17:48:22 -05:00
|
|
|
disabled="{{disabled}}"
|
|
|
|
rows="4"
|
2016-05-23 13:53:10 -07:00
|
|
|
bind-value="{{_messageText}}"
|
2016-03-04 17:48:22 -05:00
|
|
|
on-keydown="_handleTextareaKeydown"></iron-autogrow-textarea>
|
2016-11-08 15:49:05 -08:00
|
|
|
<gr-formatted-text class="message"
|
2016-03-04 17:48:22 -05:00
|
|
|
content="[[comment.message]]"
|
2016-10-10 17:31:56 -07:00
|
|
|
collapsed="[[collapsed]]"
|
2016-11-08 15:49:05 -08:00
|
|
|
config="[[projectConfig.commentlinks]]"></gr-formatted-text>
|
2016-03-04 17:48:22 -05:00
|
|
|
<div class="actions" hidden$="[[!showActions]]">
|
|
|
|
<gr-button class="action reply" on-tap="_handleReply">Reply</gr-button>
|
|
|
|
<gr-button class="action quote" on-tap="_handleQuote">Quote</gr-button>
|
|
|
|
<gr-button class="action done" on-tap="_handleDone">Done</gr-button>
|
|
|
|
<gr-button class="action edit" on-tap="_handleEdit">Edit</gr-button>
|
|
|
|
<gr-button class="action save" on-tap="_handleSave"
|
2016-05-23 13:53:10 -07:00
|
|
|
disabled$="[[_computeSaveDisabled(_messageText)]]">Save</gr-button>
|
2016-03-04 17:48:22 -05:00
|
|
|
<gr-button class="action cancel" on-tap="_handleCancel" hidden>Cancel</gr-button>
|
|
|
|
<div class="danger">
|
|
|
|
<gr-button class="action discard" on-tap="_handleDiscard">Discard</gr-button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2016-05-03 15:14:57 -04:00
|
|
|
<gr-rest-api-interface id="restAPI"></gr-rest-api-interface>
|
2016-05-23 13:53:10 -07:00
|
|
|
<gr-storage id="storage"></gr-storage>
|
2016-03-04 17:48:22 -05:00
|
|
|
</template>
|
|
|
|
<script src="gr-diff-comment.js"></script>
|
|
|
|
</dom-module>
|