Permalink
Browse files

Merge branch 'master' of github.com:strandls/biodiv

  • Loading branch information...
2 parents 0b01033 + 9978a04 commit ce48db9b12b1cc0ae4294c976b86ac9b38fb0242 @pearlsravanthi pearlsravanthi committed May 28, 2012
@@ -750,6 +750,7 @@ class ObservationController {
private Map getRecommendationVote(params) {
def observation = params.observation?:Observation.get(params.obvId);
def author = params.author;
+ def recoComment = (params.recoComment?.trim().length() > 0)? params.recoComment.trim():null;
def reco;
if(params.recoId)
@@ -760,7 +761,7 @@ class ObservationController {
ConfidenceType confidence = observationService.getConfidenceType(params.confidence?:ConfidenceType.CERTAIN.name());
RecommendationVote existingRecVote = RecommendationVote.findByAuthorAndObservation(author, observation);
- RecommendationVote newRecVote = new RecommendationVote(observation:observation, recommendation:reco, author:author, confidence:confidence);
+ RecommendationVote newRecVote = new RecommendationVote(observation:observation, recommendation:reco, author:author, confidence:confidence, comment:recoComment);
if(!reco){
log.debug "Not a valid recommendation"
@@ -215,6 +215,15 @@ class Observation implements Taggable{
map.put("votedOn", recos.collect{it.votedOn})
map.put("noOfVotes", recoVote[1]);
+
+ def recoComments = []
+ recos.each{
+ String comment = it.comment;
+ if(comment){
+ recoComments << [comment:comment, author:it.author, votedOn:it.votedOn]
+ }
+ }
+ map.put("recoComments", recoComments);
result.add(map);
}
return ['recoVotes':result, 'totalVotes':this.recommendationVote.size(), 'uniqueVotes':getRecommendationCount()];
@@ -30,17 +30,20 @@ class RecommendationVote {
ConfidenceType confidence;
Date votedOn = new Date();
float userWeight;
+ String comment;
static belongsTo = [observation:Observation];
static constraints = {
author(unique:['observation']);
votedOn validator : {val -> val < new Date()};
confidence(nullable:true);
+ comment nullable:true, blank: true;
+ comment (size:0..400);
}
static mapping = {
-
+ comment type:'text';
}
}
@@ -187,5 +187,8 @@ class ObservationTagLib {
out << render(template:"/common/observation/identificationByEmailTemplate",model:emailInfoModel);
}
+ def showRecoComment = { attrs, body->
+ out << render(template:"/common/observation/showRecoCommentTemplate",model:attrs.model);
+ }
}
@@ -1,4 +1,5 @@
-<%@ page import="species.participation.RecommendationVote.ConfidenceType" %>
+<%@ page
+ import="species.participation.RecommendationVote.ConfidenceType"%>
<!-- TODO change this r:script which is used by resources framework for script not to be repeated multiple times -->
<g:javascript>
@@ -70,11 +71,67 @@ $(document).ready(function() {
//species_name = observationInstance?.maxVotedSpeciesName
}
%>
- <input type="text" name="recoName" id="name"
- value="${species_name}" placeholder='Suggest a species name'
- class="input-xlarge ${hasErrors(bean: recommendationInstance, field: 'name', 'errors')} ${hasErrors(bean: recommendationVoteInstance, field: 'recommendation', 'errors')}" />
-
+ <input type="text" name="recoName" id="name" value="${species_name}"
+ placeholder='Suggest a species name'
+ class="input-xlarge ${hasErrors(bean: recommendationInstance, field: 'name', 'errors')} ${hasErrors(bean: recommendationVoteInstance, field: 'recommendation', 'errors')}" />
+
<input type="hidden" name="canName" id="canName" />
-<div id="nameSuggestions" style="display:block;"></div>
-</div>
+ <div id="nameSuggestions" style="display: block;"></div>
+ <div>
+ <a id="reco-action" data-toggle="dropdown" href="#">Comment</a>
+
+ <div id="reco-options" style="display: none">
+ <input type="text" name="recoComment" id="recoComment"
+ placeholder="Write comment" style="width: 80%"></input><br /> <input
+ class="btn btn-mini" style="top:5px;" type="button" value="cancel"
+ onclick="cancelRecoComment();return false;"></input>
+ </div>
+ </div>
+</div>
+<script>
+ $(document).ready(function() {
+ $('#recoComment').val('');
+
+ $('#reco-action').click(function() {
+ $('#reco-options').show();
+ $('#reco-action').hide();
+ });
+ });
+
+ function cancelRecoComment(){
+ $('#recoComment').val('');
+ $('#reco-options').hide();
+ $('#reco-action').show();
+ }
+
+</script>
+<style>
+#reco-options {
+ background-clip: padding-box;
+ background-color: #FFFFFF;
+ border-color: rgba(0, 0, 0, 0.2);
+ border-radius: 0 0 5px 5px;
+ border-style: solid;
+ border-width: 1px;
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ display: none;
+ float: left;
+ left: 0;
+ list-style: none outside none;
+ margin: 0;
+ min-width: 400px;
+ max-width: 400px;
+ width : 400px;
+ padding: 10px;
+ top: 100%;
+ z-index: 1000;
+ color: #000000;
+}
+
+#reco-close {
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+</style>
@@ -34,6 +34,7 @@
${r.name}
</i>
</g:else> </span>
+ <obv:showRecoComment model="['recoComments':r.recoComments, 'recoId': r.recoId]" />
</div> <g:javascript>
$(document).ready(function(){
@@ -0,0 +1,71 @@
+<%@page import="species.utils.ImageType"%>
+
+<g:if test="${!recoComments.isEmpty()}">
+ <div class="btn-group" id="reco_comment_${recoId}">
+
+ <a class="reco-comment-action" data-toggle="dropdown" href="#">View
+ comment</a>
+ <div class="reco-comment-table" style="display: none">
+ <div class="reco-comment-close" value="close">
+ <i class="icon-remove"></i>
+ </div>
+ <div id="flagged">
+ <ul>
+ <g:each var="commentInstance" in="${recoComments}">
+ <li style="padding: 0 5px; clear: both;"><span
+ class="flagInstanceClass">
+ <g:link controller="SUser" action="show" id="${commentInstance.author?.id}">
+ <img class="very_small_profile_pic"
+ src="${commentInstance.author?.icon(ImageType.VERY_SMALL)}"
+ title="${commentInstance.author.username}"/>
+ </g:link> on <g:formatDate date="${commentInstance.votedOn}" type="datetime" style="LONG" timeStyle="SHORT"/> : ${commentInstance.comment}
+ </span></li>
+ </g:each>
+ </ul>
+ </div>
+ </div>
+
+ </div>
+</g:if>
+
+<script>
+ $(document).ready(function() {
+ $('#reco_comment_' + ${recoId} + ' .reco-comment-action').click(function() {
+ $('#reco_comment_' + ${recoId} +' .reco-comment-table').show();
+ });
+ $('#reco_comment_' + ${recoId} +' .reco-comment-close').click(function() {
+ $('#reco_comment_' + ${recoId} + ' .reco-comment-table').hide();
+ });
+ });
+</script>
+
+<style>
+.reco-comment-table {
+ background-clip: padding-box;
+ background-color: #FFFFFF;
+ border-color: rgba(0, 0, 0, 0.2);
+ border-radius: 0 0 5px 5px;
+ border-style: solid;
+ border-width: 1px;
+ box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2);
+ display: none;
+ float: left;
+ left: 0;
+ list-style: none outside none;
+ margin: 0;
+ min-width: 400px;
+ max-width: 400px;
+ width: 400px;
+ padding: 10px;
+ position: absolute;
+ top: 100%;
+ z-index: 1000;
+ color: #000000;
+}
+
+.reco-comment-close {
+ position: absolute;
+ top: 0;
+ right: 0;
+}
+</style>
@@ -168,7 +168,7 @@ fbImagePath = r.fileName.trim().replaceFirst(/\.[a-zA-Z]{3,4}$/, grailsApplicati
<div id="seeMoreMessage" class="message"></div>
<div id="seeMore" class="btn btn-mini">see all</div>
</div>
- <div class="input-append">
+ <div class="input-append" style="position: relative;">
<g:hasErrors bean="${recommendationInstance}">
<div class="errors">
<g:renderErrors bean="${recommendationInstance}" as="list" />
@@ -188,7 +188,7 @@ fbImagePath = r.fileName.trim().replaceFirst(/\.[a-zA-Z]{3,4}$/, grailsApplicati
model="['recommendationInstance':recommendationInstance]" />
<input type="hidden" name='obvId'
value="${observationInstance.id}" /> <input type="submit"
- value="Add" class="btn" style="position: relative;top: -28px;float: right;" />
+ value="Add" class="btn" style="position:absolute; top:0; right:0;" />
</form>
@@ -310,7 +310,8 @@ fbImagePath = r.fileName.trim().replaceFirst(/\.[a-zA-Z]{3,4}$/, grailsApplicati
var uniqueVotes = parseInt(data.uniqueVotes);
if(uniqueVotes > 3){
$("#seeMore").show();
- }
+ }
+
}, error: function(xhr, status, error) {
handleError(xhr, status, error, undefined, function() {
var msg = $.parseJSON(xhr.responseText);
@@ -346,6 +347,7 @@ fbImagePath = r.fileName.trim().replaceFirst(/\.[a-zA-Z]{3,4}$/, grailsApplicati
},
success: function(data, statusText, xhr, form) {
showRecos(data, null);
+ cancelRecoComment();
return false;
},
error:function (xhr, ajaxOptions, thrownError){

0 comments on commit ce48db9

Please sign in to comment.