Skip to content

Commit

Permalink
Supported editing or updating comment and priority on Notes manager
Browse files Browse the repository at this point in the history
  • Loading branch information
k-joseph committed Jun 18, 2015
1 parent ec7e80e commit 048b70b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 23 deletions.
Expand Up @@ -396,7 +396,7 @@ public JSONArray fetchAllNotesForManageUI(boolean wholePageIsToBeLoaded) {

for (ChartSearchNote note : allNotes) {
JSONObject json = new JSONObject();
if (note.getNoteOwner().getUserId().equals(Context.getAuthenticatedUser().getUserId()) && null != note) {//manage owned notes only
if (note.getNoteOwner().getUserId().equals(Context.getAuthenticatedUser().getUserId()) && note != null) {//manage owned notes only
json.put("uuid", note.getUuid());
json.put("createdOrLastModifiedAt", note.getCreatedOrLastModifiedAt().getTime());
json.put("backgroundColor", note.getDisplayColor());
Expand Down Expand Up @@ -427,6 +427,23 @@ public JSONArray deleteSelectedNotes(String[] uuids) {
return fetchAllNotesForManageUI(false);
}

public JSONArray saveEdittedNote(String uuid, String comment, String priority) {
ChartSearchNote note = chartSearchService.getSearchNoteByUuid(uuid);
if (note != null) {
if (note.getComment().equals(comment) && note.getPriority().equals(priority)) {
return null;
} else {
note.setComment(comment);
note.setPriority(priority);

chartSearchService.saveSearchNote(note);

return fetchAllNotesForManageUI(false);
}
} else
return null;
}

private <T> T getComponent(Class<T> clazz) {
List<T> list = Context.getRegisteredComponents(clazz);
if (list == null || list.size() == 0)
Expand Down
Expand Up @@ -26,4 +26,8 @@ public void controller(FragmentModel fragmentModel) {
public JSONArray deleteSelectedNotes(@RequestParam("selectedUuids[]") String[] selectedUuids) {
return cache.deleteSelectedNotes(selectedUuids);
}

public JSONArray saveEdittedNote(@RequestParam("uuid") String uuid, @RequestParam("comment") String comment, @RequestParam("priority") String priority) {
return cache.saveEdittedNote(uuid, comment, priority);
}
}
58 changes: 46 additions & 12 deletions omod/src/main/webapp/fragments/manageNotes.gsp
Expand Up @@ -22,16 +22,16 @@
checkOrUnAllOtherCheckBoxesInADiv("#manage-notes-display", "select-all-notes");
}
if(event.target.className.indexOf("m-notes-actions") >= 0) {
//TODO either purform a delete or a save functionality here
if(event.target.id) {
if(event.target.id && event.target.title === "Delete") {
if(confirm("Do you really want to delete this Note?")) {
deleteSelectedNotes(event.target.id);
} else {
//Do nothing
}
} else {
} else if (event.target.id && event.target.title === "Save") {
if(confirm("Have you finished Editing?")) {
//TODO save the edited Note
//TODO save the edited Note
saveEdittedNote(event.target.id);
}
}
}
Expand Down Expand Up @@ -60,11 +60,11 @@
var uuid = note.uuid;
var patient = "<td><input type='checkbox' class='select-this-note' id='" + uuid + "' style='width:55%;height:1.5em;'/>" + note.patientFName + "</td>";
var phrase = "<td>" + note.searchPhrase + "</td>";
var comment = "<td><textarea class='m-notes-comment' style='width: 488px;height:80px;'>" + note.comment + "</textarea></td>";
var priority = setPriorityDisplay(note.priority);
var comment = "<td><textarea class='m-notes-comment " + uuid + "' style='width: 488px;height:80px;'>" + note.comment + "</textarea></td>";
var priority = setPriorityDisplay(note.priority, uuid);
var date = new Date(note.createdOrLastModifiedAt);
displayNotes += "<tr>" + patient + phrase + comment + priority + "<td>" + date.toString() + "</td><td><i class='icon-remove medium m-notes-actions' id='" + uuid + "'><i class='icon-save medium m-notes-actions'></td></tr>";
displayNotes += "<tr>" + patient + phrase + comment + priority + "<td>" + date.toString() + "</td><td><i class='icon-remove medium m-notes-actions' id='" + uuid + "' title='Delete'></i><i class='icon-save medium m-notes-actions' title='Save' id='" + uuid + "'></i></td></tr>";
}
}
}
Expand All @@ -75,14 +75,14 @@
}
function setPriorityDisplay(priority) {
function setPriorityDisplay(priority, uuid) {
var allPiorities = ["LOW", "HIGH"];
var priorityDisplay = "";
if(priority === allPiorities[1]) {
priorityDisplay = "<td><select class='m-notes-priority'><option>" + allPiorities[1] + "</option><option>" + allPiorities[0] + "</option></select></td>";
priorityDisplay = "<td><select class='m-notes-priority " + uuid + "'><option>" + allPiorities[1] + "</option><option>" + allPiorities[0] + "</option></select></td>";
} else {
priorityDisplay = "<td><select class='m-notes-priority'><option>" + allPiorities[0] + "</option><option>" + allPiorities[1] + "</option></select></td>";
priorityDisplay = "<td><select class='m-notes-priority " + uuid + "'><option>" + allPiorities[0] + "</option><option>" + allPiorities[1] + "</option></select></td>";
}
return priorityDisplay;
Expand Down Expand Up @@ -132,6 +132,42 @@
return selectedUuids;
}
function saveEdittedNote(uuid) {
var comment;
var priority;
jq(".m-notes-priority").each(function(event) {
if(jq(this).attr("class").indexOf(uuid) >= 0) {
priority = jq(this).find('option:selected').text();
}
});
jq(".m-notes-comment").each(function(event) {
if(jq(this).attr("class").indexOf(uuid) >= 0) {
comment = jq(this).text();
}
});
if(uuid && comment && priority) {
jq.ajax({
type: "POST",
url: "${ ui.actionLink('saveEdittedNote') }",
data: {"uuid":uuid, "comment":comment, "priority":priority},
dataType: "json",
success: function(allExistingNotes) {
if(allExistingNotes) {
notesAfterparse = allExistingNotes;
displayExistingNotes();
alert("Successfully Editted Note");
} else {
alert("Note is not edited to be saved!");
}
},
error: function(e) {
}
});
}
}
});
</script>
Expand All @@ -141,8 +177,6 @@





<h1>Manage Notes</h1>
<div id="notes-grouped-functionality">
<input type="button" id="delete-selected-notes" value="Delete Selected"/>
Expand Down
20 changes: 10 additions & 10 deletions omod/src/main/webapp/pages/chartSearchManager.gsp
Expand Up @@ -34,9 +34,9 @@ input[type="radio"], input[type="checkbox"] {
Launcher
</a>
</li>
<li class="ui-state-default ui-corner-top">
<a class="ui-tabs-anchor" href="#preferences">
Preferences
<li class="ui-state-default ui-corner-top ui-state-active" >
<a class="ui-tabs-anchor" href="#history" >
History
</a>
</li>
<li class="ui-state-default ui-corner-top">
Expand All @@ -45,8 +45,13 @@ input[type="radio"], input[type="checkbox"] {
</a>
</li>
<li class="ui-state-default ui-corner-top ui-state-active" >
<a class="ui-tabs-anchor" href="#history" >
History
<a class="ui-tabs-anchor" href="#notes" >
Notes
</a>
</li>
<li class="ui-state-default ui-corner-top">
<a class="ui-tabs-anchor" href="#preferences">
Preferences
</a>
</li>
<li class="ui-state-default ui-corner-top ui-state-active" >
Expand All @@ -59,11 +64,6 @@ input[type="radio"], input[type="checkbox"] {
Settings
</a>
</li>
<li class="ui-state-default ui-corner-top ui-state-active" >
<a class="ui-tabs-anchor" href="#notes" >
Notes
</a>
</li>
<li class="ui-state-default ui-corner-top ui-state-active" >
<a class="ui-tabs-anchor" href="#aggregate-searches" >
Aggregate Searches
Expand Down

0 comments on commit 048b70b

Please sign in to comment.