gerrit/polygerrit-ui/app/samples/suggest-vote.html
Viktar Donich 3ae72b3526 Suggest label score plugin sample
Change-Id: I746ebd99c97d10e921b196ba8d219e50a4f84a2d
2018-03-02 09:55:02 -08:00

24 lines
763 B
HTML

<dom-module id="suggested-vote">
<script>
Gerrit.install(plugin => {
const replyApi = plugin.changeReply();
let wasSuggested = false;
plugin.on('showchange', () => {
wasSuggested = false;
});
const CODE_REVIEW = 'Code-Review';
replyApi.addLabelValuesChangedCallback(({name, value}) => {
if (wasSuggested && name === CODE_REVIEW) {
replyApi.showMessage('');
wasSuggested = false;
} else if (replyApi.getLabelValue(CODE_REVIEW) === '+1' &&
!wasSuggested) {
replyApi.setLabelValue(CODE_REVIEW, '+2');
replyApi.showMessage(`Suggested ${CODE_REVIEW} upgrade: +2`);
wasSuggested = true;
}
});
});
</script>
</dom-module>