blob: 27c5baa969ecff1748b2823248aa6cf4b1e58a86 [file] [log] [blame]
<!--
@license
Copyright (C) 2017 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-selector/iron-selector.html">
<link rel="import" href="../../shared/gr-button/gr-button.html">
<link rel="import" href="../../../styles/gr-voting-styles.html">
<link rel="import" href="../../../styles/shared-styles.html">
<dom-module id="gr-label-score-row">
<template>
<style include="gr-voting-styles"></style>
<style include="shared-styles">
.labelContainer {
align-items: center;
display: flex;
margin-bottom: .5em;
}
.labelName {
display: inline-block;
flex: 0 0 auto;
margin-right: .5em;
min-width: 7em;
text-align: left;
width: 20%;
}
.labelMessage {
color: var(--deemphasized-text-color);
}
.placeholder::before {
content: ' ';
}
.selectedValueText {
color: var(--deemphasized-text-color);
font-style: italic;
margin: 0 .5em 0 .5em;
}
.selectedValueText.hidden {
display: none;
}
.buttonWrapper {
flex: none;
}
gr-button {
min-width: 40px;
--gr-button: {
background-color: var(--button-background-color, var(--table-header-background-color));
color: var(--primary-text-color);
padding: .2em .85em;
@apply --vote-chip-styles;
}
}
gr-button.iron-selected.max {
--button-background-color: var(--vote-color-approved);
}
gr-button.iron-selected.positive {
--button-background-color: var(--vote-color-recommended);
}
gr-button.iron-selected.min {
--button-background-color: var(--vote-color-rejected);
}
gr-button.iron-selected.negative {
--button-background-color: var(--vote-color-disliked);
}
gr-button.iron-selected.neutral {
--button-background-color: var(--vote-color-neutral);
}
.placeholder {
display: inline-block;
width: 40px;
}
@media only screen and (max-width: 50em) {
.selectedValueText {
display: none;
}
}
@media only screen and (max-width: 25em) {
.labelName {
margin: 0;
text-align: center;
width: 100%;
}
.labelContainer {
display: block;
}
}
</style>
<div class="labelContainer">
<span class="labelName">[[label.name]]</span>
<div class="buttonWrapper">
<template is="dom-repeat"
items="[[_computeBlankItems(permittedLabels, label.name, 'start')]]"
as="value">
<span class="placeholder" data-label$="[[label.name]]"></span>
</template>
<iron-selector
attr-for-selected="value"
selected="[[_computeLabelValue(labels, permittedLabels, label)]]"
hidden$="[[!_computeAnyPermittedLabelValues(permittedLabels, label.name)]]"
on-selected-item-changed="_setSelectedValueText">
<template is="dom-repeat"
items="[[_items]]"
as="value">
<gr-button
class$="[[_computeButtonClass(value, index, _items.length)]]"
has-tooltip
name="[[label.name]]"
value$="[[value]]"
title$="[[_computeLabelValueTitle(labels, label.name, value)]]">
[[value]]</gr-button>
</template>
</iron-selector>
<template is="dom-repeat"
items="[[_computeBlankItems(permittedLabels, label.name, 'end')]]"
as="value">
<span class="placeholder" data-label$="[[label.name]]"></span>
</template>
<span class="labelMessage"
hidden$="[[_computeAnyPermittedLabelValues(permittedLabels, label.name)]]">
You don't have permission to edit this label.
</span>
</div>
<div class$="selectedValueText [[_computeHiddenClass(permittedLabels, label.name)]]">
<span id="selectedValueLabel">[[_selectedValueText]]</span>
</div>
</div>
</template>
<script src="gr-label-score-row.js"></script>
</dom-module>