Commit 0f6ecaa1 authored by Fatih Acet's avatar Fatih Acet

Implement canAward.

parent 654355a0
...@@ -16,6 +16,7 @@ export default { ...@@ -16,6 +16,7 @@ export default {
emojiSmiling, emojiSmiling,
emojiSmile, emojiSmile,
emojiSmiley, emojiSmiley,
canAward: !!window.gon.current_user_id,
}; };
}, },
computed: { computed: {
...@@ -42,6 +43,12 @@ export default { ...@@ -42,6 +43,12 @@ export default {
getAwardHTML(name) { getAwardHTML(name) {
return glEmojiTag(name); return glEmojiTag(name);
}, },
getAwardClassBindings(awardList) {
return {
active: this.amIAwarded(awardList),
disabled: !this.canAward,
};
},
amIAwarded(awardList) { amIAwarded(awardList) {
const myUserId = window.gon.current_user_id; const myUserId = window.gon.current_user_id;
const isAwarded = awardList.filter(award => award.user.id === myUserId); const isAwarded = awardList.filter(award => award.user.id === myUserId);
...@@ -97,7 +104,7 @@ export default { ...@@ -97,7 +104,7 @@ export default {
<button <button
v-for="(awardList, awardName) in groupedAwards" v-for="(awardList, awardName) in groupedAwards"
class="btn award-control has-tooltip" class="btn award-control has-tooltip"
:class="{ active: amIAwarded(awardList) }" :class="getAwardClassBindings(awardList)"
:title="awardTitle(awardList)" :title="awardTitle(awardList)"
data-placement="bottom" data-placement="bottom"
type="button"> type="button">
...@@ -106,7 +113,9 @@ export default { ...@@ -106,7 +113,9 @@ export default {
{{awardList.length}} {{awardList.length}}
</span> </span>
</button> </button>
<div class="award-menu-holder"> <div
v-if="canAward"
class="award-menu-holder">
<button <button
aria-label="Add reaction" aria-label="Add reaction"
class="award-control btn has-tooltip" class="award-control btn has-tooltip"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment