Skip to content

Commit

Permalink
SAK-40185 Add details to closed view of rubric (sakaiproject#6156)
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianfish authored and ern committed Oct 17, 2018
1 parent 188304b commit 748daea
Show file tree
Hide file tree
Showing 16 changed files with 190 additions and 39 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package org.sakaiproject.rubrics.logic;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;

import java.io.IOException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeFormatterBuilder;
import java.time.temporal.ChronoField;

public class RubricsLocalDateTimeSerializer extends LocalDateTimeSerializer {

@Override
public void serialize(LocalDateTime value, JsonGenerator g, SerializerProvider provider)
throws IOException {

DateTimeFormatterBuilder builder
= new DateTimeFormatterBuilder()
.appendText(ChronoField.MONTH_OF_YEAR)
.appendLiteral(" ")
.appendText(ChronoField.DAY_OF_MONTH)
.appendLiteral(", ")
.appendText(ChronoField.YEAR)
.appendLiteral(" ")
.appendText(ChronoField.CLOCK_HOUR_OF_AMPM)
.appendLiteral(":")
.appendValue(ChronoField.MINUTE_OF_HOUR, 2)
.appendLiteral(" ")
.appendText(ChronoField.AMPM_OF_DAY);

DateTimeFormatter dtf = builder.toFormatter();
g.writeString(value.format(dtf));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ void saveRubricEvaluation(String toolId,

String generateJsonWebToken(String tool);

String getCurrentSessionId();

String generateLang();

String getRubricEvaluationObjectId(String associationId, String userId, String toolId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import javax.persistence.Embeddable;
import javax.persistence.Transient;

import org.sakaiproject.rubrics.logic.RubricsLocalDateTimeSerializer;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
Expand All @@ -45,7 +47,7 @@ public class Metadata {
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime created;

@JsonSerialize(using = LocalDateTimeSerializer.class)
@JsonSerialize(using = RubricsLocalDateTimeSerializer.class)
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
private LocalDateTime modified;
private String ownerId;
Expand Down
3 changes: 3 additions & 0 deletions rubrics/impl/src/main/bundle/rubricsMessages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ shared_rubrics=Shared Rubrics
toggle_site_rubrics=Toggle Site Rubrics
toggle_shared_rubrics=Toggle Shared Rubrics
copy_to_site=Copy to site list
site_title=Origin
creator_name=Author
modified=Modified
share=Share
revoke=Revoke sharing for
no_rubrics=No rubrics have been created.
Original file line number Diff line number Diff line change
Expand Up @@ -849,5 +849,9 @@ public String generateLang(){
return lines.toString();
}

public String getCurrentSessionId() {
return sessionManager.getCurrentSession().getId();
}


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<dom-module id="creator-name">
<script>
Polymer({
is: "creator-name",
properties: {
creatorId: String
},
ready: function () {
var self = this;
jQuery.ajax({
url: '/sakai-ws/rest/sakai/getUserDisplayName?sessionid=' + sakaiSessionId + '&userid=' + this.creatorId
}).done(function (response) {
self.innerText = response;
}).fail(function () {
self.innerText = self.creatorId;
});
}
});
</script>
</dom-module>
16 changes: 10 additions & 6 deletions rubrics/tool/src/main/frontend/imports/sakai-rubric-readonly.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,23 @@
<style include="sakai-rubrics-styles"></style>
<style include="polymer-bootstrap"></style>


<div class="rubric-title" on-focus="activate" on-tap="toggleRubric" >
<iron-a11y-keys id="a11y" target="[[getNode('.rubric-title')]]" keys="space" on-keys-pressed="toggleRubric"></iron-a11y-keys>
<span class="rubric-name" tabindex="0" id$="rubric_toggle_[[rubric.id]]" aria-expanded$="[[rubricExpanded]]" role="tab" title="[[lang('toggle_details', 'Toggle details for')]] [[rubric.title]]">
<iron-icon class="collpase-icon" icon="rubrics-icons:chevron-right"></iron-icon>
{{rubric.title}}
</span>
<div>
<span class="rubric-name" tabindex="0" id$="rubric_toggle_[[rubric.id]]" aria-expanded$="[[rubricExpanded]]" role="tab" title="[[lang('toggle_details', 'Toggle details for')]] [[rubric.title]]">
<iron-icon class="collpase-icon" icon="rubrics-icons:chevron-right"></iron-icon>
{{rubric.title}}
</span>
</div>

<div><site-title site-id="[[rubric.metadata.ownerId]]"></site-title></div>
<div><creator-name creator-id="[[rubric.metadata.creatorId]]"></creator-name></div>
<div><span>[[rubric.metadata.modified]]</span></div>

<div class="actions">
<template is="dom-if" if="{{rubric.metadata.public}}">
<iron-icon title="[[lang('copy_to_site', 'Copy to site list')]]: [[rubric.title]]" tabindex="0" class="clone" icon="rubrics-icons:content-copy" on-tap="copyToSite"></iron-icon>
</template>

</div>

</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<dom-module id="site-title">
<script>
Polymer({
is: "site-title",
properties: {
siteId: String
},
ready: function () {
var self = this;
jQuery.ajax({
url: '/sakai-ws/rest/sakai/getSiteTitle?sessionid=' + sakaiSessionId + '&siteid=' + this.siteId
}).done(function (response) {
self.innerText = response;
}).fail(function () {
self.innerText = self.siteId;
});
}
});
</script>
</dom-module>
26 changes: 16 additions & 10 deletions rubrics/tool/src/main/frontend/imports/sakai-rubric.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,23 @@

<div class="rubric-title" on-tap="toggleRubric">
<iron-a11y-keys id="a11y" target="[[getNode('.rubric-name')]]" keys="space" on-keys-pressed="toggleRubric"></iron-a11y-keys>
<span class="rubric-name" id$="rubric_toggle_[[rubric.id]]" aria-expanded$="[[rubricExpanded]]" role="tab" title="[[lang('toggle_details', 'Toggle details for')]] [[rubric.title]]" tabindex="0" >
<iron-icon class="collpase-icon" icon="rubrics-icons:chevron-right"></iron-icon>
{{rubric.title}}
</span>
<div>
<span class="rubric-name" id$="rubric_toggle_[[rubric.id]]" aria-expanded$="[[rubricExpanded]]" role="tab" title="[[lang('toggle_details', 'Toggle details for')]] [[rubric.title]]" tabindex="0" >
<iron-icon class="collpase-icon" icon="rubrics-icons:chevron-right"></iron-icon>
{{rubric.title}}
</span>

<template is="dom-if" if="{{rubric.metadata.locked}}">
<iron-icon tabindex="0" role="display" title="[[rubric.title]] [[lang('is_locked', 'is locked')]]" class="locked" icon="rubrics-icons:lock"></iron-icon>
</template>
<template is="dom-if" if="[[!rubric.metadata.locked]]">
<sakai-rubric-edit rubric="{{rubric}}"></sakai-rubric-edit>
</template>
<template is="dom-if" if="{{rubric.metadata.locked}}">
<iron-icon tabindex="0" role="display" title="[[rubric.title]] [[lang('is_locked', 'is locked')]]" class="locked" icon="rubrics-icons:lock"></iron-icon>
</template>
<template is="dom-if" if="[[!rubric.metadata.locked]]">
<sakai-rubric-edit rubric="{{rubric}}"></sakai-rubric-edit>
</template>
</div>

<div><site-title site-id="[[rubric.metadata.ownerId]]"></site-title></div>
<div><creator-name creator-id="[[rubric.metadata.creatorId]]"></creator-name></div>
<div><span>[[rubric.metadata.modified]]</span></div>

<div class="actions">
<iron-icon role="button" title="[[lang(shareTitleKey, shareTitle)]] [[rubric.title]]" tabindex="0" class="share" icon$="rubrics-icons:{{shareicon}}" on-tap="sharingChange"></iron-icon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@
<br>
<button class="btn btn-link add-rubric" on-tap="addRubric">
<iron-icon class="add" icon="rubrics-icons:add"></iron-icon>
<sr-lang key="add_rubric">
Add Rubric
</sr-lang>
<sr-lang key="add_rubric">add_rubric</sr-lang>
</button>


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,44 @@
<link rel="import" href="sakai-rubrics-icons.html">
<link rel="import" href="sakai-rubric.html">
<link rel="import" href="sakai-rubric-readonly.html">
<link rel="import" href="sakai-rubric-site-title.html">
<link rel="import" href="sakai-rubric-creator-name.html">

<dom-module id="sakai-rubrics-manager">
<template>
<style include="sakai-rubrics-styles"></style>

<h1>
<sr-lang key="manage_rubrics">
Manage Rubrics
</sr-lang>
<sr-lang key="manage_rubrics">manage_rubrics</sr-lang>
</h1>

<div role="tablist">
<div id="site-rubrics-title" aria-expanded$="[[siteRubricsExpanded]]" role="tab" aria-multiselectable="true" class="manager-collapse-title" title="[[lang('toggle_site_rubrics', 'Toggle site rubrics')]]" tabindex="0" on-tap="showLocalRubrics">
<iron-a11y-keys id="a11y" target="[[getNode('#site-rubrics-title')]]" keys="space" on-keys-pressed="showLocalRubrics"></iron-a11y-keys>
<iron-icon class="collpase-icon" icon="rubrics-icons:chevron-right"></iron-icon>
<sr-lang key="site_rubrics">
Site Rubrics
</sr-lang>
<div>
<iron-icon class="collpase-icon" icon="rubrics-icons:chevron-right"></iron-icon>
<sr-lang key="site_rubrics">site_rubrics</sr-lang>
</div>
<div><sr-lang key="site_title">site_title</sr-lang></div>
<div><sr-lang key="creator_name">creator_name</sr-lang></div>
<div><sr-lang key="modified">modified</sr-lang></div>
<div class="actions"></div>
</div>

<iron-collapse role="tabpanel" aria-labelledby="site-rubrics-title" id="site_rubrics">
<sakai-rubrics-list></sakai-rubrics-list>
</iron-collapse>



<div id="shared-rubrics-title" aria-expanded$="[[sharedRubricsExpanded]]" role="tab" aria-multiselectable="true" class="manager-collapse-title" title="[[lang('toggle_shared_rubrics', 'Toggle shared rubrics')]]" tabindex="0" on-tap="showSharedRubrics">
<iron-a11y-keys id="a11y" target="[[getNode('#shared-rubrics-title')]]" keys="space" on-keys-pressed="showSharedRubrics"></iron-a11y-keys>
<iron-icon class="collpase-icon" icon="rubrics-icons:chevron-right"></iron-icon>
<sr-lang key="shared_rubrics">
Shared Rubrics
</sr-lang>
<div>
<iron-icon class="collpase-icon" icon="rubrics-icons:chevron-right"></iron-icon>
<sr-lang key="shared_rubrics">shared_rubrics</sr-lang>
</div>
<div><sr-lang key="site_title">site_title</sr-lang></div>
<div><sr-lang key="creator_name">creator_name</sr-lang></div>
<div><sr-lang key="modified">modified</sr-lang></div>
<div class="actions"></div>
</div>

<iron-collapse role="tabpanel" aria-labelledby="shared-rubrics-title" id="shared_rubrics">
Expand Down
22 changes: 20 additions & 2 deletions rubrics/tool/src/main/frontend/imports/sakai-rubrics-styles.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@
border: 1px solid #e4e4e6;
border-width: 1px 0px;
font-weight: bold;
overflow: auto; }
display: flex;
justify-content: space-between; }
.rubric-title div {
font-weight: normal;
flex: 1; }
.rubric-title .rubric-name {
cursor: default;
color: #0093b8; }
Expand All @@ -33,7 +37,21 @@
.rubric-title .edit {
margin-left: 10px; }
.rubric-title .actions {
float: right; }
width: 100px; }

#site-rubrics-title {
display: flex;
justify-content: space-between; }
#site-rubrics-title div {
font-weight: bold;
flex: 1; }

#shared-rubrics-title {
display: flex;
justify-content: space-between; }
#shared-rubrics-title div {
font-weight: bold;
flex: 1; }

iron-icon:not(.collpase-icon):not(.reorder-icon):not(.comment-icon) {
background: #6e757d;
Expand Down
27 changes: 25 additions & 2 deletions rubrics/tool/src/main/frontend/sass/sakai-rubrics.scss
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@
border: 1px solid #e4e4e6;
border-width: 1px 0px;
font-weight: bold;
overflow: auto;
display: flex;
justify-content: space-between;
div {
font-weight: normal;
flex: 1;
}
.rubric-name {
cursor: default;
color: #0093b8;
Expand All @@ -40,7 +45,25 @@
margin-left: 10px;
}
.actions {
float: right;
width: 100px;
}
}

#site-rubrics-title {
display: flex;
justify-content: space-between;
div {
font-weight: bold;
flex: 1;
}
}

#shared-rubrics-title {
display: flex;
justify-content: space-between;
div {
font-weight: bold;
flex: 1;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public String indexRedirect() {
public String index(ModelMap model) {
String token = rubricsService.generateJsonWebToken("sakai.rubrics");
model.addAttribute("token", token);
model.addAttribute("sakaiSessionId", rubricsService.getCurrentSessionId());
return "index";
}
}
1 change: 1 addition & 0 deletions rubrics/tool/src/main/resources/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<script th:inline="javascript">
var rbcstoken = /*[[${token}]]*/ null;
var imports = ['/rubrics-service/imports/sakai-rubrics-manager.html'];
var sakaiSessionId = /*[[${sakaiSessionId}]]*/ null;
</script>
<script defer="defer" type="text/javascript" src="/rubrics-service/js/sakai-rubrics.js"></script>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
import org.sakaiproject.user.api.PreferencesEdit;
import org.sakaiproject.user.api.User;
import org.sakaiproject.user.api.UserEdit;
import org.sakaiproject.user.api.UserNotDefinedException;
import org.sakaiproject.util.ArrayUtil;
import org.sakaiproject.util.FormattedText;
import org.sakaiproject.util.ResourceLoader;
Expand Down Expand Up @@ -588,8 +589,14 @@ public String getUserDisplayName(
@WebParam(name = "userid", partName = "userid") @QueryParam("userid") String userid) {
Session session = establishSession(sessionid);
try {
User user = userDirectoryService.getUserByEid(userid);
return user.getDisplayName();
return userDirectoryService.getUserByEid(userid).getDisplayName();
} catch (UserNotDefinedException unde) {
try {
return userDirectoryService.getUser(userid).getDisplayName();
} catch (UserNotDefinedException unde2) {
log.error("WS getUserDisplayName() failed for user: " + userid + " : " + unde2.getClass().getName() + " : " + unde2.getMessage());
return "";
}
} catch (Exception e) {
log.error("WS getUserDisplayName() failed for user: " + userid + " : " + e.getClass().getName() + " : " + e.getMessage());
return "";
Expand Down

0 comments on commit 748daea

Please sign in to comment.