summaryrefslogtreecommitdiffstats
path: root/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js
diff options
context:
space:
mode:
Diffstat (limited to 'polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js')
-rw-r--r--polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js65
1 files changed, 46 insertions, 19 deletions
diff --git a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js
index 82664f8300..f472331025 100644
--- a/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js
+++ b/polygerrit-ui/app/elements/change/gr-label-score-row/gr-label-score-row.js
@@ -1,16 +1,19 @@
-// 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.
+/**
+ * @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.
+ */
(function() {
'use strict';
@@ -39,15 +42,19 @@
type: String,
value: 'No value selected',
},
+ _items: {
+ type: Array,
+ computed: '_computePermittedLabelValues(permittedLabels, label.name)',
+ },
},
get selectedItem() {
- if (!this._ironSelector) { return; }
+ if (!this._ironSelector) { return undefined; }
return this._ironSelector.selectedItem;
},
get selectedValue() {
- if (!this._ironSelector) { return; }
+ if (!this._ironSelector) { return undefined; }
return this._ironSelector.selected;
},
@@ -62,7 +69,8 @@
},
_computeBlankItems(permittedLabels, label, side) {
- if (!permittedLabels || !permittedLabels[label] || !this.labelValues ||
+ if (!permittedLabels || !permittedLabels[label] ||
+ !permittedLabels[label].length || !this.labelValues ||
!Object.keys(this.labelValues).length) {
return [];
}
@@ -87,6 +95,19 @@
}
},
+ _computeButtonClass(value, index, totalItems) {
+ if (value < 0 && index === 0) {
+ return 'min';
+ } else if (value < 0) {
+ return 'negative';
+ } else if (value > 0 && index === totalItems - 1) {
+ return 'max';
+ } else if (value > 0) {
+ return 'positive';
+ }
+ return 'neutral';
+ },
+
_computeLabelValue(labels, permittedLabels, label) {
if (!labels[label.name]) { return null; }
const labelValue = this._getLabelValue(labels, permittedLabels, label);
@@ -108,11 +129,15 @@
this._selectedValueText = e.target.selectedItem.getAttribute('title');
// Needed to update the style of the selected button.
this.updateStyles();
- this.fire('labels-changed');
+ const name = e.target.selectedItem.name;
+ const value = e.target.selectedItem.getAttribute('value');
+ this.dispatchEvent(new CustomEvent(
+ 'labels-changed', {detail: {name, value}, bubbles: true}));
},
_computeAnyPermittedLabelValues(permittedLabels, label) {
- return permittedLabels.hasOwnProperty(label);
+ return permittedLabels.hasOwnProperty(label) &&
+ permittedLabels[label].length;
},
_computeHiddenClass(permittedLabels, label) {
@@ -125,7 +150,9 @@
},
_computeLabelValueTitle(labels, label, value) {
- return labels[label] && labels[label].values[value];
+ return labels[label] &&
+ labels[label].values &&
+ labels[label].values[value];
},
});
})();