Skip to content

Commit

Permalink
SAK-47494 Update sakai-user-photo to update on atttribute updates (sa…
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored Jul 12, 2022
1 parent 668b782 commit 054d1bf
Show file tree
Hide file tree
Showing 9 changed files with 19 additions and 17 deletions.
2 changes: 1 addition & 1 deletion commons/tool/src/webapp/WEB-INF/templates/comment.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<sakai-user-photo user-id="{{creatorId}}"></sakai-user-photo>
<sakai-user-photo user-id="{{creatorId}}" popup="on"></sakai-user-photo>
<div class="commons-comment-body">
<span id="commons-comment-author-name-{{id}}"><a id="commons-author-name-{{id}}" href="javascript:;" class="commons-comment-author-name" data-user-id="{{creatorId}}">{{creatorDisplayName}}</a></span>
<span id="commons-comment-content-{{id}}" class="commons-comment-content">{{{content}}}</span>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<sakai-user-photo user-id="{{#if currentUserId}}{{currentUserId}}{{else}}{{creatorId}}{{/if}}" no-popup></sakai-user-photo>
<sakai-user-photo user-id="{{#if currentUserId}}{{currentUserId}}{{else}}{{creatorId}}{{/if}}"></sakai-user-photo>
<div class="commons-editor-text-wrapper">
<div class="commons-editor-text commons-comment-editor-text" data-post-id="{{id}}"><textarea id="commons-comment-textarea-{{id}}" class="commons-comment-textarea" data-post-id="{{id}}"></textarea></div>
<div id="commons-comment-post-buttons-{{id}}">
Expand Down
2 changes: 1 addition & 1 deletion commons/tool/src/webapp/WEB-INF/templates/post.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

<div class="commons-post-inner-container" id="commons-post-inner-container-{{id}}">

<sakai-user-photo user-id="{{creatorId}}"></sakai-user-photo>
<sakai-user-photo user-id="{{creatorId}}" popup="on"></sakai-user-photo>
<div class="commons-post-text-container">
<div class="commons-post-body">
<div class="commons-post-content">
Expand Down
2 changes: 1 addition & 1 deletion commons/tool/src/webapp/WEB-INF/templates/posts.hbs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="commons-post-editor">
<div class="commons-photo-text-wrapper">
<sakai-user-photo user-id="{{currentUserId}}" no-popup></sakai-user-photo>
<sakai-user-photo user-id="{{currentUserId}}"></sakai-user-photo>
<div class="commons-editor-text-wrapper">
<div class="commons-editor-text"><div id="commons-post-creator-editor" contenteditable="true">{{tr 'post_editor_initial_text'}}</div></div>
</div>
Expand Down
1 change: 0 additions & 1 deletion roster2/tool/src/handlebars/members_cards.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{{#if ../printMode}}
print
{{/if}}
no-popup
>
</sakai-user-photo>
</div> <!-- /roster-picture-card -->
Expand Down
6 changes: 3 additions & 3 deletions roster2/tool/src/handlebars/members_photogrid.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
{{#if ../printMode}}
print
{{/if}}
{{#unless ../viewPicture}}
no-popup
{{/unless}}
{{#if ../viewPicture}}
popup="on"
{{/if}}
>
</sakai-user-photo>
</div> <!-- /roster-picture-card -->
Expand Down
1 change: 0 additions & 1 deletion roster2/tool/src/handlebars/members_table.handlebars
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
{{#if ../printMode}}
print
{{/if}}
no-popup
>
</sakai-user-photo>
</td> <!-- /roster-table-cell -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export class SakaiGrader extends gradableDataMixin(SakaiElement) {
<div class="grader ${this.graderOnLeft ? "on-left" : ""}">
<div id="grader-submitted-block" class="grader-block">
<div style="display: flex;">
<sakai-user-photo user-id="${this._getPhotoUserId()}" classes="grader-photo" ?official=${this.showOfficialPhoto}></sakai-user-photo>
<sakai-user-photo user-id="${this._getPhotoUserId()}" classes="grader-photo" popup="on"></sakai-user-photo>
<div class="submitted-time" style="flex: 4;">
${this.submission.submittedTime || (this.submission.draft && this.submission.visible) ? html`
<span class="submitter-name">${this.renderSubmitter()}</span>
Expand Down
18 changes: 11 additions & 7 deletions webcomponents/tool/src/main/frontend/js/sakai-user-photo.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { html } from "./assets/lit-html/lit-html.js";
* @element sakai-user-photo
* @property {string} user-id - A Sakai user id
* @property {string} [classes] - Extra classes to style the content
* @property {boolean} [no-popup] Set this if you don't want the profile popup
* @property {string} [popup] By default, profile popups are off. Set this to "on" if you want them
* @property {boolean} [official] Set this if you want the official Sakai photo
* @property {string} [site-id] Set this to trigger permissions checks on the photo
* @property {boolean} [print] Set this to trigger the render of a print friendly img tag
Expand All @@ -22,14 +22,15 @@ class SakaiUserPhoto extends SakaiElement {
super();

this.classes = "large-thumbnail";
this.popup = SakaiUserPhoto.OFF;
}

static get properties() {

return {
userId: { attribute: "user-id", type: String },
classes: { type: String },
noPopup: { attribute: "no-popup", type: Boolean },
popup: { type: String },
official: { type: Boolean },
siteId: { attribute: "site-id", type: String },
print: { type: Boolean },
Expand All @@ -45,12 +46,12 @@ class SakaiUserPhoto extends SakaiElement {

this.url = `/direct/profile/${this.userId}/image/${this.official ? "official" : "thumb"}`
+ (this.siteId && `?siteId=${this.siteId}`);
}

if (!this.noPopup) {
this.updateComplete.then(() => {
profile.attachPopups($(`#${this.generatedId}`));
});
}
if (this.popup == SakaiUserPhoto.ON && this.generatedId) {
this.updateComplete.then(() => {
profile.attachPopups($(`#${this.generatedId}`));
});
}
}

Expand All @@ -75,5 +76,8 @@ class SakaiUserPhoto extends SakaiElement {
}
}

SakaiUserPhoto.OFF = "off";
SakaiUserPhoto.ON = "on";

const tagName = "sakai-user-photo";
!customElements.get(tagName) && customElements.define(tagName, SakaiUserPhoto);

0 comments on commit 054d1bf

Please sign in to comment.