Index: lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/web/controller/MonitoringController.java =================================================================== diff -u -ra8e22ae6f537fb94e709edeaff47e3dfe42d464c -rf9c593122ee2e6b2463a208dfd4b2ab035860af7 --- lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/web/controller/MonitoringController.java (.../MonitoringController.java) (revision a8e22ae6f537fb94e709edeaff47e3dfe42d464c) +++ lams_tool_preview/src/java/org/lamsfoundation/lams/tool/peerreview/web/controller/MonitoringController.java (.../MonitoringController.java) (revision f9c593122ee2e6b2463a208dfd4b2ab035860af7) @@ -37,6 +37,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import org.apache.commons.lang.StringEscapeUtils; import org.apache.log4j.Logger; import org.lamsfoundation.lams.rating.dto.StyledCriteriaRatingDTO; import org.lamsfoundation.lams.rating.model.RatingCriteria; @@ -59,7 +60,6 @@ import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; -import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; @@ -351,7 +351,8 @@ userData.add(i); userData.add((String) ratingDetails[4]); String commentText = HtmlUtils.htmlEscape(comment); - commentText = StringUtils.replace(commentText, "<BR>", "
").replace("\n", "
"); + commentText = commentText.replace("<BR>", "\n
").replace("<br>", "\n
"); + userData.add(commentText); userData.add("Comments"); userData.add(ratingDetails[0].toString()); @@ -690,8 +691,9 @@ @RequestMapping("/saveComment") @ResponseBody public void saveComment(@RequestParam Long criteriaId, @RequestParam Long toolSessionId, - @RequestParam Integer userId, @RequestParam Long itemId, @RequestParam String comment) { + @RequestParam Integer userId, @RequestParam Long itemId, @RequestParam(name = "rating") String comment) { RatingCriteria criteria = service.getCriteriaByCriteriaId(criteriaId); + comment = comment.replace("\n", "
"); service.commentItem(criteria, toolSessionId, userId, itemId, comment); } } \ No newline at end of file Index: lams_tool_preview/web/pages/monitoring/criteriapart.jsp =================================================================== diff -u -ra8e22ae6f537fb94e709edeaff47e3dfe42d464c -rf9c593122ee2e6b2463a208dfd4b2ab035860af7 --- lams_tool_preview/web/pages/monitoring/criteriapart.jsp (.../criteriapart.jsp) (revision a8e22ae6f537fb94e709edeaff47e3dfe42d464c) +++ lams_tool_preview/web/pages/monitoring/criteriapart.jsp (.../criteriapart.jsp) (revision f9c593122ee2e6b2463a208dfd4b2ab035860af7) @@ -1,5 +1,18 @@ <%@ include file="/common/taglibs.jsp"%> + + @@ -86,10 +99,49 @@ colModel:[ {name:'id', index:'id', width:0, hidden:true}, {name:'userName', index:'userName', width:40 }, - {name:'rating', index:'rating', title:false, editable: true}, + {name:'rating', index:'rating', title:false, edittype: 'textarea', editoptions: {rows:"8"}, + formatter:function(cellvalue, options, rowObject, event) { + if (event == "edit") { + cellvalue = cellvalue.replace(/\n/g, '\n
'); + } + var rowData = $(this).jqGrid("getLocalRow", options.rowId); + + // when item is editable - show pencil icon on hover + return rowData.criteriaId == 'Comments' ? + "" + cellvalue + + " " + : cellvalue; + }, + unformat:function(cellvalue, options, rowObject) { + var text = $('
' + cellvalue + '
').text(); + return text.trim(); + }, + editable: function (options) { + // only comments are editable + var rowData = $(this).jqGrid("getLocalRow", options.rowid); + return rowData.criteriaId == 'Comments'; + } + }, {name:'criteriaId', width:0, hidden:true}, {name:'userId', width:0, hidden:true} ], + + editurl: "?&toolSessionId=${toolSessionId}&criteriaId=${criteria.ratingCriteriaId}&itemId=" + itemId, + inlineEditing: { keys: true, defaultFocusField: "rating", focusField: "rating" }, + onSelectRow: function (rowid) { + var grid = $(this), + rowData = grid.jqGrid("getRowData", rowid); + + if (rowData.criteriaId == 'Comments') { + grid.jqGrid("editRow", rowid, { focusField: "rating" }); + // Modify event handler to save on blur + $("textarea[id^='" + rowid + "_rating']", grid).bind('blur', function(){ + grid.saveRow(rowid, null, null, { + userId : rowData.userId + }); + }); + } + }, loadComplete: function(){ //remove empty subgrids var table_value = $('#'+subgridTableId).getGridParam('records'); @@ -100,22 +152,7 @@ loadError: function(xhr,st,err) { jQuery("#"+subgridTableId).clearGridData(); info_dialog("", "", ""); - }, - cellurl: "?&toolSessionId=${toolSessionId}&criteriaId=${criteria.ratingCriteriaId}&itemId=" + itemId, - cellEdit: true, - beforeSelectRow: function(rowId) { - // only comments are editable - var rowData = $(this).jqGrid ('getRowData', rowId); - $(this).setColProp('rating',{editable: rowData.criteriaId == 'Comments'}); - }, - beforeSubmitCell : function (rowId,name,val){ - // send additional information while submitting - var rowData = $(this).jqGrid ('getRowData', rowId); - return { - userId : rowData.userId, - comment : val - }; - } + } }) } }).jqGrid('filterToolbar', {