Skip to content

Commit

Permalink
SAK-50526 conversations Upvoting and reactions fixes (#13009)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Nov 8, 2024
1 parent 4935e63 commit 11c0edb
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
2 changes: 2 additions & 0 deletions conversations/api/src/main/resources/conversations.properties
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ back=Back
back_to_all=Back to all
by=by
bookmark=Bookmark
unbookmark=Unbookmark
bookmarked_tooltip=You've bookmarked this topic
bookmark_tooltip=Click to bookmark this topic
cancel=Cancel
Expand Down Expand Up @@ -136,6 +137,7 @@ off=Off
on=On
permissions=Permissions
pin=Pin
unpin=Unpin
pin_tooltip=Pin this topic. This will pin the topic towards the top of any user's topic lists
pinned=Pinned
pinned_text=Keep at top of list
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@
}

.lightbulb {
color: #009933;
color: orange;
}

.key {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,7 @@ export class SakaiConversations extends SakaiElement {
?can-view-anonymous=${this._data.canViewAnonymous}
?is-instructor=${this._data.isInstructor}
?can-view-deleted=${this._data.canViewDeleted}
?reactions-allowed=${this._data.settings.allowReactions}
topic="${JSON.stringify(this._currentTopic)}"
@edit-topic=${this._editTopic}
@posts-viewed=${this._postsViewed}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export class SakaiPost extends reactionsAndUpvotingMixin(SakaiElement) {
canViewAnonymous: { attribute: "can-view-anonymous", type: Boolean },
canViewDeleted: { attribute: "can-view-deleted", type: Boolean },
siteId: { attribute: "site-id", type: String },
reactionsAllowed: { attribute: "reactions-allowed", type: Boolean },

_showingComments: { state: true },
_expanded: { state: true },
Expand Down Expand Up @@ -491,7 +492,9 @@ export class SakaiPost extends reactionsAndUpvotingMixin(SakaiElement) {
</div>
${this._editing ? nothing : html`
<div class="discussion-post-bottom-bar">
${this.renderReactionsBar(this.post.reactionTotals)}
${this.reactionsAllowed ? html`
${this.renderReactionsBar(this.post)}
` : nothing}
<div class="conversations-actions-block d-flex mb-1">
${this._renderReactionsBlock(this.post)}
${this._renderUpvoteBlock(this.post)}
Expand Down Expand Up @@ -605,7 +608,7 @@ export class SakaiPost extends reactionsAndUpvotingMixin(SakaiElement) {
${this._editing ? html`
${this._renderEditor()}
` : html`
${this.renderReactionsBar(this.post.reactionTotals)}
${this.renderReactionsBar(this.post)}
<div class="mb-1 d-flex">
<div class="conversations-actions-block d-flex mb-1">
${this._renderReactionsBlock(this.post)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export class SakaiTopic extends reactionsAndUpvotingMixin(SakaiElement) {
isInstructor: { attribute: "is-instructor", type: Boolean },
canViewAnonymous: { attribute: "can-view-anonymous", type: Boolean },
canViewDeleted: { attribute: "can-view-deleted", type: Boolean },
reactionsAllowed: { attribute: "reactions-allowed", type: Boolean },

_postEditorDisplayed: { state: true },
_replying: { state: true },
Expand Down Expand Up @@ -698,7 +699,7 @@ export class SakaiTopic extends reactionsAndUpvotingMixin(SakaiElement) {
>
<div class="topic-option">
<div><i class="si si-bookmark${this.topic.bookmarked ? "-fill" : ""}"></i></div>
<div>${this._i18n.bookmark}</div>
<div>${this.topic.bookmarked ? this._i18n.unbookmark : this._i18n.bookmark}</div>
</div>
</a>
</div>
Expand All @@ -711,13 +712,15 @@ export class SakaiTopic extends reactionsAndUpvotingMixin(SakaiElement) {
title="${this.topic.pinned ? this._i18n.unpin_tooltip : this._i18n.pin_tooltip}">
<div class="topic-option">
<div><i class="si si-pin${this.topic.pinned ? "-fill" : ""}"></i></div>
<div>${this._i18n.pin}</div>
<div>${this.topic.pinned ? this._i18n.unpin : this._i18n.pin}</div>
</div>
</a>
</div>
` : nothing }
</div>
${this.renderReactionsBar(this.topic.reactionTotals)}
${this.reactionsAllowed ? html`
${this.renderReactionsBar(this.topic)}
` : nothing}
<div class="conversations-actions-block d-flex mb-1">
${this._renderReactionsBlock(this.topic)}
${this._renderUpvoteBlock(this.topic)}
Expand Down Expand Up @@ -785,6 +788,7 @@ export class SakaiTopic extends reactionsAndUpvotingMixin(SakaiElement) {
?is-instructor="${this.isInstructor}"
?can-view-anonymous="${this.canViewAnonymous}"
?can-view-deleted="${this.canViewDeleted}"
?reactions-allowed="${this.reactionsAllowed}"
site-id="${this.topic.siteId}"
@post-updated=${this._postUpdated}
@post-deleted=${this._postDeleted}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const reactionsAndUpvotingMixin = Base => class extends Base {
`;
}

renderReactionsBar(reactionTotals) {
renderReactionsBar(reactable) {

const reactionIcons = {
"THUMBS_UP": "hand-thumbs-up",
Expand All @@ -38,7 +38,7 @@ export const reactionsAndUpvotingMixin = Base => class extends Base {

return html`
<div class="d-flex mb-2" tabindex="0">
${Object.entries(reactionTotals).map(pair => html`
${Object.entries(reactable.reactionTotals).map(pair => html`
<div class="d-flex align-items-center border border-1 rounded-pill px-2 me-1">
<div>
<i class="bi bi-${reactionIcons[pair[0]]}-fill ${reactionIcons[pair[0]]} small"></i>
Expand Down

0 comments on commit 11c0edb

Please sign in to comment.