diff --git a/api/pom.xml b/api/pom.xml index 2827f81..f9908c2 100644 --- a/api/pom.xml +++ b/api/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module teammodule - 2.0.0 + 2.0.0A teammodule-api diff --git a/api/src/main/java/org/openmrs/module/teammodule/api/TeamMemberLogService.java b/api/src/main/java/org/openmrs/module/teammodule/api/TeamMemberLogService.java index f873f0b..5f9e122 100644 --- a/api/src/main/java/org/openmrs/module/teammodule/api/TeamMemberLogService.java +++ b/api/src/main/java/org/openmrs/module/teammodule/api/TeamMemberLogService.java @@ -10,7 +10,9 @@ public interface TeamMemberLogService extends OpenmrsService { public void saveTeamMemberLog(TeamMemberLog teamMemberLog); - + + public void updateTeamMemberLog(TeamMemberLog teamMemberLog); + public TeamMemberLog getTeamMemberLog(int id); public TeamMemberLog getTeamMemberLog(String uuid); diff --git a/api/src/main/java/org/openmrs/module/teammodule/api/db/TeamMemberLogDAO.java b/api/src/main/java/org/openmrs/module/teammodule/api/db/TeamMemberLogDAO.java index 9bbd5f5..592a3b2 100644 --- a/api/src/main/java/org/openmrs/module/teammodule/api/db/TeamMemberLogDAO.java +++ b/api/src/main/java/org/openmrs/module/teammodule/api/db/TeamMemberLogDAO.java @@ -8,6 +8,8 @@ public interface TeamMemberLogDAO { public void saveTeamMemberLog(TeamMemberLog teamMemberLog); + public void updateTeamMemberLog(TeamMemberLog teamMemberlog); + public TeamMemberLog getTeamMemberLog(int id); public TeamMemberLog getTeamMemberLog(String id); diff --git a/api/src/main/java/org/openmrs/module/teammodule/api/db/hibernate/HibernateTeamMemberLogDAO.java b/api/src/main/java/org/openmrs/module/teammodule/api/db/hibernate/HibernateTeamMemberLogDAO.java index ee5024f..60b81f8 100644 --- a/api/src/main/java/org/openmrs/module/teammodule/api/db/hibernate/HibernateTeamMemberLogDAO.java +++ b/api/src/main/java/org/openmrs/module/teammodule/api/db/hibernate/HibernateTeamMemberLogDAO.java @@ -37,6 +37,10 @@ public void saveTeamMemberLog(TeamMemberLog teamMemberLog) { sessionFactory.getCurrentSession().saveOrUpdate(teamMemberLog); } + public void updateTeamMemberLog(TeamMemberLog teamMemberLog) { + sessionFactory.getCurrentSession().update(teamMemberLog); + } + public TeamMemberLog getTeamMemberLog(int id) { return (TeamMemberLog)sessionFactory.getCurrentSession().createQuery("from TeamMemberLog teamMemberLog where teamMemberLog.logId = :id").setInteger("id", id).uniqueResult(); } diff --git a/api/src/main/java/org/openmrs/module/teammodule/api/impl/TeamMemberLogServiceImpl.java b/api/src/main/java/org/openmrs/module/teammodule/api/impl/TeamMemberLogServiceImpl.java index a50c4f8..6029566 100644 --- a/api/src/main/java/org/openmrs/module/teammodule/api/impl/TeamMemberLogServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/teammodule/api/impl/TeamMemberLogServiceImpl.java @@ -32,6 +32,10 @@ public void saveTeamMemberLog(TeamMemberLog teamMemberlog) { dao.saveTeamMemberLog(teamMemberlog); } + public void updateTeamMemberLog(TeamMemberLog teamMemberlog) { + dao.updateTeamMemberLog(teamMemberlog); + } + public List getAllLogs(Integer offset, Integer pageSize) { return dao.getAllLogs(offset, pageSize); } diff --git a/api/src/main/java/org/openmrs/module/teammodule/api/impl/TeamServiceImpl.java b/api/src/main/java/org/openmrs/module/teammodule/api/impl/TeamServiceImpl.java index 81ec706..4a45b6f 100644 --- a/api/src/main/java/org/openmrs/module/teammodule/api/impl/TeamServiceImpl.java +++ b/api/src/main/java/org/openmrs/module/teammodule/api/impl/TeamServiceImpl.java @@ -85,7 +85,6 @@ public void updateTeam(Team team) { @Override public Team getTeam(String teamName, int locationid) { - // TODO Auto-generated method stub return dao.getTeam(teamName,locationid); } diff --git a/omod/pom.xml b/omod/pom.xml index 5090c21..310a592 100644 --- a/omod/pom.xml +++ b/omod/pom.xml @@ -4,7 +4,7 @@ org.openmrs.module teammodule - 2.0.0 + 2.0.0A teammodule-omod diff --git a/omod/src/main/java/org/openmrs/module/teammodule/extension/html/AdminList.java b/omod/src/main/java/org/openmrs/module/teammodule/extension/html/AdminList.java index 927cee6..a681fbb 100644 --- a/omod/src/main/java/org/openmrs/module/teammodule/extension/html/AdminList.java +++ b/omod/src/main/java/org/openmrs/module/teammodule/extension/html/AdminList.java @@ -36,9 +36,10 @@ public Map getLinks() { LinkedHashMap map = new LinkedHashMap(); map.put("module/teammodule/addTeam.form", "New Team"); map.put("module/teammodule/teamMemberAddForm.form", "New Team Member"); - map.put("module/teammodule/teamRole.form", "Team Hierarchy (Roles)"); + map.put("module/teammodule/addRole.form", "New Team Hierarchy (Role)"); map.put("module/teammodule/team.form", "Manage Teams"); map.put("module/teammodule/teamMemberView.form", "Manage Team Members"); + map.put("module/teammodule/teamRole.form", "Manage Team Hierarchy (Roles)"); return map; } } diff --git a/omod/src/main/java/org/openmrs/module/teammodule/web/controller/RoleAddFormController.java b/omod/src/main/java/org/openmrs/module/teammodule/web/controller/RoleAddFormController.java index 720eed3..74ca9d0 100644 --- a/omod/src/main/java/org/openmrs/module/teammodule/web/controller/RoleAddFormController.java +++ b/omod/src/main/java/org/openmrs/module/teammodule/web/controller/RoleAddFormController.java @@ -72,11 +72,14 @@ public String showForm(Model model, HttpServletRequest request) { @RequestMapping(method = RequestMethod.POST) public String onSubmit(HttpSession httpSession, @ModelAttribute("anyRequestObject") Object anyRequestObject, HttpServletRequest request, - @ModelAttribute("roleData") TeamRole teamRole, Model model) { - + @ModelAttribute("roleData") TeamRole teamRole, Model model) { + String reportsToUuid = request.getParameter("reportsTo"); + System.out.println("reportsTo: " + reportsToUuid); + TeamRole tr = Context.getService(TeamRoleService.class).getTeamRoleByUuid(reportsToUuid); + if(tr!=null) { teamRole.setReportTo(tr); } teamRole.setUuid(UUID.randomUUID().toString()); Context.getService(TeamRoleService.class).saveTeamRole(teamRole); - String saved = "Role saved successfully"; + String saved = "Role Saved Successfully"; model.addAttribute("saved", saved); List roles = Context.getService(TeamRoleService.class).getAllTeamRole(); model.addAttribute("reportsTo", roles); @@ -86,4 +89,4 @@ public String onSubmit(HttpSession httpSession, @ModelAttribute("anyRequestObjec -} +} \ No newline at end of file diff --git a/omod/src/main/java/org/openmrs/module/teammodule/web/controller/RoleEditFormController.java b/omod/src/main/java/org/openmrs/module/teammodule/web/controller/RoleEditFormController.java index 0f3a592..7e56ca0 100644 --- a/omod/src/main/java/org/openmrs/module/teammodule/web/controller/RoleEditFormController.java +++ b/omod/src/main/java/org/openmrs/module/teammodule/web/controller/RoleEditFormController.java @@ -4,7 +4,6 @@ package org.openmrs.module.teammodule.web.controller; import java.util.List; -import java.util.UUID; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; @@ -12,8 +11,6 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.openmrs.api.context.Context; -//import org.openmrs.module.teammodule.api.TeamMemberService; -//import org.openmrs.module.teammodule.api.TeamMemberService; import org.openmrs.module.teammodule.Team; import org.openmrs.module.teammodule.TeamRole; import org.openmrs.module.teammodule.api.TeamRoleService; @@ -46,11 +43,19 @@ public class RoleEditFormController { * @return String form view name */ @RequestMapping(method = RequestMethod.GET) - public String showForm(Model model, HttpServletRequest request,@RequestParam(value = "roleId", required = true) int id, @ModelAttribute("teamData") Team team) { + public String showForm(Model model, HttpServletRequest request,@RequestParam(value = "roleId", required = true) String uuid, @ModelAttribute("teamData") Team team) { - TeamRole roleData = Context.getService(TeamRoleService.class).getTeamRoleById(id); + System.out.println(uuid); + TeamRole roleData = Context.getService(TeamRoleService.class).getTeamRoleByUuid(uuid); List roles = Context.getService(TeamRoleService.class).getAllTeamRole(); - model.addAttribute("reportsTo", roles); + + + System.out.println(uuid); + System.out.println(roles); + System.out.println(roleData); + + model.addAttribute("reportsToOptions", roles); + model.addAttribute("reportsTo", roleData.getReportTo()); model.addAttribute("roleData", roleData); return SUCCESS_FORM_VIEW; @@ -69,10 +74,13 @@ public String showForm(Model model, HttpServletRequest request,@RequestParam(val @RequestMapping(method = RequestMethod.POST) public String onSubmit(HttpSession httpSession, @ModelAttribute("anyRequestObject") Object anyRequestObject, HttpServletRequest request, @ModelAttribute("roleData") TeamRole teamRole, Model model) { - - teamRole.setUuid(UUID.randomUUID().toString()); + String reportsToUuid = request.getParameter("reportsTo"); + System.out.println("reportsTo: " + reportsToUuid); + TeamRole tr = Context.getService(TeamRoleService.class).getTeamRoleByUuid(reportsToUuid); + if(tr!=null) { teamRole.setReportTo(tr); } + //teamRole.setUuid(UUID.randomUUID().toString()); Context.getService(TeamRoleService.class).saveTeamRole(teamRole); - String saved = "Role saved successfully"; + String saved = "Role Updated Successfully"; model.addAttribute("saved", saved); TeamRole roleData = Context.getService(TeamRoleService.class).getTeamRoleById(teamRole.getTeamRoleId()); model.addAttribute("roleData", roleData); @@ -80,7 +88,7 @@ public String onSubmit(HttpSession httpSession, @ModelAttribute("anyRequestObjec List roles = Context.getService(TeamRoleService.class).getAllTeamRole(); model.addAttribute("reportsTo", roles); - return "redirect:/module/teammodule/editRole.form?teamId=" + teamRole.getTeamRoleId(); + return SUCCESS_FORM_VIEW; } diff --git a/omod/src/main/java/org/openmrs/module/teammodule/web/controller/TeamEditFormController.java b/omod/src/main/java/org/openmrs/module/teammodule/web/controller/TeamEditFormController.java index d7bf064..08a4e51 100644 --- a/omod/src/main/java/org/openmrs/module/teammodule/web/controller/TeamEditFormController.java +++ b/omod/src/main/java/org/openmrs/module/teammodule/web/controller/TeamEditFormController.java @@ -47,6 +47,7 @@ public String showFormEidt(Model model, HttpServletRequest request, @RequestPara teamData = Context.getService(TeamService.class).getTeam(teamId); String error = request.getParameter("error"); model.addAttribute("error", error); + model.addAttribute("defaultLocation", teamData.getLocation()); String edit = request.getParameter("edit"); model.addAttribute("edit", edit); model.addAttribute("teamData", teamData); @@ -60,6 +61,12 @@ public String showFormEdit(Model model, HttpServletRequest request, @RequestPara Location location = Context.getLocationService().getLocationByUuid(locationUuid); teamData = Context.getService(TeamService.class).getTeam(teamName, location.getLocationId()); String error = request.getParameter("error"); + System.out.println(teamData); + System.out.println(teamData.getLocation()); + System.out.println(teamData.getLocation()); + model.addAttribute("defaultLocation", location); + model.addAttribute("locations", Context.getLocationService().getAllLocations()); + model.addAttribute("error", error); String edit = request.getParameter("edit"); model.addAttribute("edit", edit); diff --git a/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamMemberLogRequestResource.java b/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamMemberLogRequestResource.java index 31076d2..efc9d58 100644 --- a/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamMemberLogRequestResource.java +++ b/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamMemberLogRequestResource.java @@ -11,6 +11,8 @@ import org.openmrs.module.webservices.rest.web.RestConstants; import org.openmrs.module.webservices.rest.web.annotation.PropertyGetter; import org.openmrs.module.webservices.rest.web.annotation.Resource; +import org.openmrs.module.webservices.rest.web.representation.DefaultRepresentation; +import org.openmrs.module.webservices.rest.web.representation.FullRepresentation; import org.openmrs.module.webservices.rest.web.representation.Representation; import org.openmrs.module.webservices.rest.web.resource.impl.DataDelegatingCrudResource; import org.openmrs.module.webservices.rest.web.resource.impl.DelegatingResourceDescription; @@ -30,15 +32,48 @@ public DelegatingResourceDescription getRepresentationDescription(Representation DelegatingResourceDescription description = null; if (Context.isAuthenticated()) { description = new DelegatingResourceDescription(); - description.addProperty("logId"); + if (rep instanceof DefaultRepresentation) { + description.addProperty("display"); description.addProperty("teamMember"); description.addProperty("action"); description.addProperty("dataNew"); description.addProperty("dataOld"); description.addProperty("log"); - description.addProperty("dateCreated"); + } else if (rep instanceof FullRepresentation) { + description.addProperty("display"); + description.addProperty("teamMember"); + description.addProperty("action"); + description.addProperty("dataNew"); + description.addProperty("dataOld"); + description.addProperty("log"); + description.addProperty("auditInfo"); + description.addSelfLink(); + } } - + return description; + } + + @Override + public DelegatingResourceDescription getCreatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("display"); + description.addProperty("teamMember"); + description.addProperty("action"); + description.addProperty("dataNew"); + description.addProperty("dataOld"); + description.addProperty("log"); + return description; + } + + @Override + public DelegatingResourceDescription getUpdatableProperties() { + DelegatingResourceDescription description = new DelegatingResourceDescription(); + description.addProperty("display"); + description.addProperty("teamMember"); + description.addProperty("action"); + description.addProperty("dataNew"); + description.addProperty("dataOld"); + description.addProperty("log"); return description; } @@ -48,18 +83,22 @@ public TeamMemberLog newDelegate() { } @Override - public TeamMemberLog save(TeamMemberLog teamLog) { - return null; + public TeamMemberLog save(TeamMemberLog delegate) { + try { + if(delegate.getId() != null && delegate.getId() > 0) { Context.getService(TeamMemberLogService.class).updateTeamMemberLog(delegate); return delegate; } + else { Context.getService(TeamMemberLogService.class).saveTeamMemberLog(delegate); return delegate; } + } + catch(Exception e) { e.printStackTrace(); throw new RuntimeException(e); } } @Override - protected void delete(TeamMemberLog teamMemberLog, String reason, RequestContext context) throws ResponseException { - // TODO Auto-generated method stub + protected void delete(TeamMemberLog delegate, String reason, RequestContext context) throws ResponseException { + Context.getService(TeamMemberLogService.class).purgeTeamMemberLog(delegate); } @Override - public void purge(TeamMemberLog arg0, RequestContext arg1) throws ResponseException { - // TODO Auto-generated method stub + public void purge(TeamMemberLog delegate, RequestContext arg1) throws ResponseException { + Context.getService(TeamMemberLogService.class).purgeTeamMemberLog(delegate); } @Override @@ -69,17 +108,13 @@ public SimpleObject search(RequestContext context) { } @PropertyGetter("display") - public List getDisplayString(int team) { - return Context.getService(TeamMemberLogService.class).searchTeamMemberLogByTeamMember(team); + public String getDisplayString(TeamMemberLog teamMemberLog) { + if (teamMemberLog == null) { return ""; } return teamMemberLog.getTeamMember().getPerson().getPersonName().toString(); } - + @Override public TeamMemberLog getByUniqueId(String uniqueId) { return Context.getService(TeamMemberLogService.class).getTeamMemberLog(uniqueId); } - - public TeamMemberLog getById(Integer id) { - return Context.getService(TeamMemberLogService.class).getTeamMemberLog(id); - } } diff --git a/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamMemberRequestResource.java b/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamMemberRequestResource.java index fd98f67..988091d 100644 --- a/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamMemberRequestResource.java +++ b/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamMemberRequestResource.java @@ -75,7 +75,6 @@ public DelegatingResourceDescription getRepresentationDescription(Representation description.addProperty("teamRole", Representation.DEFAULT); description.addProperty("locations", Representation.DEFAULT); description.addProperty("patients", Representation.DEFAULT); - } else if (rep instanceof FullRepresentation) { description.addProperty("display"); description.addProperty("identifier"); @@ -259,8 +258,9 @@ public String getDisplayString(TeamMember teamMember) { } @PropertyGetter("subTeams") - public String getSubTeam(TeamMember teamMember) { - List teams = Context.getService(TeamService.class).getSubTeams(teamMember); if(teams == null) { return ""; } else { String str = ""; for (int i = 0; i < teams.size(); i++) { if(i==teams.size()-1) { str += teams.get(i).getTeamName(); } else { str += teams.get(i).getTeamName() + ", "; } } return str; } + public List getSubTeam(TeamMember teamMember) { + List teams = Context.getService(TeamService.class).getSubTeams(teamMember); //if(teams == null) { return ""; } else { String str = ""; for (int i = 0; i < teams.size(); i++) { if(i==teams.size()-1) { str += teams.get(i).getTeamName(); } else { str += teams.get(i).getTeamName() + ", "; } } return str; } + if(teams == null) return null; else { return teams; } } @PropertyGetter("subTeamRoles") diff --git a/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamRequestResource.java b/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamRequestResource.java index 68ea575..8c65bce 100644 --- a/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamRequestResource.java +++ b/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamRequestResource.java @@ -114,8 +114,18 @@ else if(context.getParameter("supervisor")!=null) { listTeam.add(team); return new NeedsPaging(listTeam, context).toSimpleObject(this); } + else if(context.getParameter("teamName")!=null && context.getParameter("locationId")!=null && context.getParameter("identifier")!=null) { + Location l = Context.getLocationService().getLocationByUuid(context.getParameter("locationId")); + Team team = (Context.getService(TeamService.class).searchTeam(context.getParameter("teamName"))).get(0); + team.setTeamIdentifier(context.getParameter("identifier")); + team.setLocation(l); + Context.getService(TeamService.class).updateTeam(team); + List listTeam = new ArrayList<>(); + listTeam.add(team); + return new NeedsPaging(listTeam, context).toSimpleObject(this); + } else if(context.getParameter("teamName")!=null && context.getParameter("locationId")!=null) { - Team team = Context.getService(TeamService.class).getTeam(context.getParameter("teamName"),Integer.parseInt(context.getParameter("locationId"))); + Team team = Context.getService(TeamService.class).getTeam(context.getParameter("teamName"), Integer.parseInt(context.getParameter("locationId"))); List listTeam = new ArrayList<>(); listTeam.add(team); return new NeedsPaging(listTeam, context).toSimpleObject(this); diff --git a/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamRoleRequestResource.java b/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamRoleRequestResource.java index 200bc30..bfee1b7 100644 --- a/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamRoleRequestResource.java +++ b/omod/src/main/java/org/openmrs/module/teammodule/web/resource/TeamRoleRequestResource.java @@ -37,14 +37,14 @@ public DelegatingResourceDescription getRepresentationDescription(Representation description.addProperty("uuid"); description.addProperty("name"); description.addProperty("ownsTeam"); - description.addProperty("reportTo"); + description.addProperty("reportToName"); description.addProperty("reportByName"); } else if (rep instanceof FullRepresentation) { description.addProperty("display"); description.addProperty("name"); description.addProperty("uuid"); description.addProperty("ownsTeam"); - description.addProperty("reportTo"); + description.addProperty("reportToName"); description.addProperty("reportByName"); description.addProperty("auditInfo"); description.addSelfLink(); @@ -93,7 +93,7 @@ public String getDisplayString(TeamRole teamRole) { if(teamRole == null) { return ""; } return teamRole.getName(); } - @PropertyGetter("reportTo") + @PropertyGetter("reportToName") public String getReportToName(TeamRole teamRole) { if(teamRole == null || teamRole.getReportTo() == null) { return ""; } return teamRole.getReportTo().getName(); } diff --git a/omod/src/main/webapp/roleAddForm.jsp b/omod/src/main/webapp/roleAddForm.jsp index 0aa6ce7..213c078 100644 --- a/omod/src/main/webapp/roleAddForm.jsp +++ b/omod/src/main/webapp/roleAddForm.jsp @@ -14,22 +14,20 @@

Add Role

+

${error}

+

${saved}

+

${edit}

@@ -60,13 +60,12 @@ - diff --git a/omod/src/main/webapp/roleEditForm.jsp b/omod/src/main/webapp/roleEditForm.jsp index 7b7e00f..96da522 100644 --- a/omod/src/main/webapp/roleEditForm.jsp +++ b/omod/src/main/webapp/roleEditForm.jsp @@ -17,19 +17,22 @@ jQuery(document).ready(function() { jQuery("#ownsTeam").attr('checked', false); + console.log("edit") }); function validation() { document.getElementById("saveButton").disabled = true; var name = roleName.value; - var reportsTo = document.getElementById("reportsTo"); - var selectedValue = reportsTo.options[reportsTo.selectedIndex].value; + var reportsTo = document.getElementById("reportsTo").value; + + console.log("name: "+name); + console.log("reportsTo: "+reportsTo); var mustSelectMessage = ""; if (name == null || name == "") { mustSelectMessage += "Role name can't be empty."; alertify.alert(mustSelectMessage); document.getElementById("saveButton").disabled = false; } - if (selectedValue == 0) { + if (reportsTo == 0) { mustSelectMessage += "Must Select Report To Field"; alertify.alert(mustSelectMessage); document.getElementById("saveButton").disabled = false; @@ -42,7 +45,9 @@ contentType : "application/json;charset=UTF-8", dataType : "json", success : function(data, status) { - document.getElementById("saveRole").submit(); + console.log(data) + console.log(status) + document.getElementById("saveRole").submit(); } }); } @@ -51,6 +56,9 @@

Edit Role

+

${error}

+

${saved}

+

${edit}

Reports To - +
Owns Team ?
@@ -60,13 +68,16 @@ - diff --git a/omod/src/main/webapp/team.jsp b/omod/src/main/webapp/team.jsp index eb9b7da..479a323 100644 --- a/omod/src/main/webapp/team.jsp +++ b/omod/src/main/webapp/team.jsp @@ -41,16 +41,16 @@ GenerateTable(); $('#general').DataTable({ "language": { - "search": "_INPUT_", - "searchPlaceholder": "Search..." - }, - "paging" : true, - "lengthChange" : false, - "searching" : true, - "ordering" : true, - "info" : false, - "autoWidth" : true, - "sDom" : 'lfrtip', + "search": "_INPUT_", + "searchPlaceholder": "Search..." + }, + "paging" : true, + "lengthChange" : false, + "searching" : true, + "ordering" : true, + "info" : false, + "autoWidth" : true, + "sDom" : 'lfrtip', }); }); }); diff --git a/omod/src/main/webapp/teamAddForm.jsp b/omod/src/main/webapp/teamAddForm.jsp index 1fe4fcc..5cb4ab9 100644 --- a/omod/src/main/webapp/teamAddForm.jsp +++ b/omod/src/main/webapp/teamAddForm.jsp @@ -16,22 +16,12 @@ +

Add Team

${error}

${saved}

${edit}

-

Add Team

Reports To - - - ${reportsTo.name} - - + + +
Owns Team ?
@@ -123,19 +106,6 @@ * - - - - - - - - - - - - diff --git a/omod/src/main/webapp/teamEditForm.jsp b/omod/src/main/webapp/teamEditForm.jsp index 32e9971..d016249 100644 --- a/omod/src/main/webapp/teamEditForm.jsp +++ b/omod/src/main/webapp/teamEditForm.jsp @@ -31,6 +31,7 @@ }); function validation() { document.getElementById("saveButton").disabled = true; + document.getElementById("teamName").disabled = true; var regexp = /^[a-z/i][a-z\- ]*[a-z/i\-|0-9]{2,}$/i; var idRegExp = /^[a-z|0-9]+[a-z.\-_]*[a-z|0-9]{2,}$/i; var name = teamName.value; @@ -64,18 +65,16 @@ alertify.alert(dataTypeMessage); document.getElementById("saveButton").disabled = false; }else{jQuery.ajax({ - url:"/openmrs/ws/rest/v1/team/team?teamName="+name+"&locationId="+selectedValue+"&v=full", + url:"/openmrs/ws/rest/v1/team/team?identifier="+id+"&teamName="+name+"&locationId="+selectedValue+"&v=full", type:"GET", contentType:"application/json;charset=UTF-8", dataType:"json", success: function(data,status){ - alert(status) - if(status==200) - { - document.getElementById("saveTeam").submit(); - } + //document.getElementById("saveTeam").submit(); + document.getElementById("savedId").innerHTML = "Team Updated Successfully"; + document.getElementById("saveButton").disabled = false; } - }); + }); } @@ -83,10 +82,10 @@ -

${error}

-

${saved}

-

${edit}

Edit Team

+

${error}

+

${saved}

+

${edit}

Retire Team ?
Reason - must be written
Retire Reason
@@ -94,10 +93,10 @@ - + + + diff --git a/omod/src/main/webapp/teamMemberAddForm.jsp b/omod/src/main/webapp/teamMemberAddForm.jsp index 9e5c914..bf5d90d 100644 --- a/omod/src/main/webapp/teamMemberAddForm.jsp +++ b/omod/src/main/webapp/teamMemberAddForm.jsp @@ -432,15 +432,8 @@ Choose Existing Person + - + + + + + + + + + + + + + + + + @@ -641,12 +650,16 @@ Add + - + + + +
Team Name * + onblur="jQuery('#nameTip').hide();" readonly="true" /> Must start with alphabet.Min 3 and - max 20.Alphanumeric text,- is allowed
Team Identifier - ${defaultLocation.name} - - - ${location.name} + ${defaultLocation.name} + + + ${locations.name} *
Retire Team ?

@@ -452,6 +445,7 @@

@@ -476,6 +470,7 @@ * Min 3 and max 20.Alphabets,[-.] are allowed
@@ -486,6 +481,7 @@ * Min 3 and max 20.Alphabets,[-.] are allowed
@@ -500,6 +496,7 @@ Date shouldn't be in future
@@ -513,11 +510,14 @@ *
Add Login Detail
@@ -526,6 +526,7 @@
@@ -561,6 +562,7 @@
@@ -571,6 +573,7 @@ * Min 3 and max 20.All data types and [-_] are allowed
@@ -585,6 +588,7 @@ *
@@ -599,6 +603,7 @@ *
@@ -608,6 +613,7 @@ Date shouldn't be in future
@@ -617,6 +623,7 @@ Date shouldn't be in future
@@ -625,6 +632,7 @@
@@ -633,6 +641,7 @@
- Back to Team List + Back to Team Member List
diff --git a/omod/src/main/webapp/teamMemberView.jsp b/omod/src/main/webapp/teamMemberView.jsp index 424b3f1..49cfa94 100644 --- a/omod/src/main/webapp/teamMemberView.jsp +++ b/omod/src/main/webapp/teamMemberView.jsp @@ -108,7 +108,14 @@ /* Sub Ordinate Teams */ var cell = row.insertCell(-1); cell.setAttribute("style", "border: 1px solid"); - if(members[i].subTeams === "") { cell.innerHTML = ""; } else { cell.innerHTML = members[i].subTeams + " (" + members[i].subTeamsCount +")"; } + if(members[i].subTeams === null) { cell.innerHTML = ""; } else { + var text = ""; + for(var j=0; j"+members[i].subTeams[j].teamName+"
" + } + cell.innerHTML = text; + } /* History */ var cell = row.insertCell(-1); cell.setAttribute("style", "border: 1px solid"); @@ -116,7 +123,7 @@ /* Voided */ var cell = row.insertCell(-1); cell.setAttribute("style", "border: 1px solid"); - cell.innerHTML = members[i].voided + "";; + cell.innerHTML = members[i].voided + ""; /* Patients */ var cell = row.insertCell(-1); cell.setAttribute("style", "border: 1px solid"); @@ -138,40 +145,19 @@ else if(type==="memberTeamInfo") { $('#editTeamMemberTeamDiv').dialog('close'); } else if(type==="memberInfo") { $('#editTeamMemberDiv').dialog('close'); } else if(type==="memberVoided") { $('#editTeamMemberVoidedDiv').dialog('close'); } - else if(type==="memberLocationInfo") { $('#editTeamMemberLocationDiv').dialog('close'); } + } + function teamMemberTeamDetail(teamMemberUuid, teamUuid) { + $.ajax({ + url: "/openmrs/ws/rest/v1/team/team/"+teamUuid+"?v=full", + success : function(team) { + document.getElementById("teamMemberTeamDetailDiv").innerHTML = "
Identifier: "+team.teamIdentifier+"
Name: "+team.teamName+"
Supervisor: "+team.supervisor+"
Voided: "+team.voided+"
Location: "+team.location.display+"
Members: "+team.members+"
";; + //document.getElementById("teamMemberTeamDetailDiv").innerHTML = "
Identifier: "+team.teamIdentifier+"
Name: "+team.teamName+"
Supervisor: "+team.supervisor+"
Voided: "+team.voided+"
Location: "+team.location.display+"
Members: "+team.members+"
";; + $("#teamMemberTeamDetailDiv").dialog({ width: "auto", height: "auto", title: "Team Member - Sub Team" , closeText: ""}); + }, error: function(jqXHR, textStatus, errorThrown) { console.log("ERROR-TEAM-DETAIL"); console.log(jqXHR); } + }); } function editTeamMemberSuccess(index, type) { - if(type==="memberLocationInfo") { - /* var uuid = members[index].uuid; - var role = document.getElementById("teamMemberRole"+index).value; - var url = "/openmrs/ws/rest/v1/team/teammember/"+uuid+"/role"; - var data = '{ '; if(role != "") { data += '"role" : "' + role + '"'; } data += ' }'; - console.log(url); - $.ajax({ - url: url, - data : data, - type: "POST", - contentType: "application/json", - success : function(result) { - console.log("SUCCESS-EDIT TEAM MEMBER ROLE"); - console.log(result); - var teamMember = result.results[0]; - console.log(teamMember); - for (var i = 0; i < members.length; i++) { - if(members[i].uuid.toString() === teamMember.uuid.toString()) { - replace(members, members[i], teamMember); - console.log(members); - GenerateTable(); - //$('#example').DataTable({"bFilter": false}); - document.getElementById("errorHead").innerHTML = ""; - document.getElementById("saveHead").innerHTML = "

Team Member Role Updated Successfully

"; - $('#editTeamMemberRoleDiv').dialog('close'); - } - } - }, error: function(jqXHR, textStatus, errorThrown) { console.log("ERROR-EDIT TEAM MEMBER ROLE"); console.log(jqXHR); document.getElementById("saveHead").innerHTML = ""; document.getElementById("errorHead").innerHTML = "

Error Occured While Updating Team Member Role

"; } - }); */ - } - else if(type==="memberRoleInfo") { + if(type==="memberRoleInfo") { var uuid = members[index].uuid; var role = document.getElementById("teamMemberRole"+index).value; var url = "/openmrs/ws/rest/v1/team/teammember/"+uuid+"/role"; @@ -326,16 +312,7 @@ html += ""; } html += "REMOVE"; html += ""; - /* var html = "
Locations:
"; - */document.getElementById("editTeamMemberLocationDiv").innerHTML = html; + document.getElementById("editTeamMemberLocationDiv").innerHTML = html; $("#editTeamMemberLocationDiv").dialog({ width: "auto", height: "auto", title: "Team Member - Location" , closeText: ""}); } else if(type==="memberRoleInfo") { @@ -465,5 +442,6 @@
+
<%@ include file="/WEB-INF/template/footer.jsp"%> diff --git a/omod/src/main/webapp/teamRole.jsp b/omod/src/main/webapp/teamRole.jsp index 9b04cbc..39d34f6 100644 --- a/omod/src/main/webapp/teamRole.jsp +++ b/omod/src/main/webapp/teamRole.jsp @@ -25,104 +25,107 @@ border-collapse: collapse; } - + function teamsHierarchyHistory(teamId) { + $.get("/openmrs/ws/rest/v1/team/teamrolelog?teamRole=" + teamId, + function(data) { + var myTable = document.getElementById("history"); + var rowCount = myTable.rows.length; + + for (i = 0; i < rowCount; i++) { + $("#historyRow").remove(); + } + for (i = 0; i < data.length; i++) { + $("#history") + .append( + "" + + "" + + data.results[i].teamRole.name + + "" + + "" + + data[i].action + + "" + + "" + + data[i].dataNew + + "" + + "" + + data[i].log + + "" + ""); + } + }); + $("#historyDialog").dialog({ + width : "auto", + height : "auto", + title : "History", + closeText : "" + }); + } + +
@@ -148,7 +151,7 @@
-

Teams Hierarchy

+

Teams Role

diff --git a/pom.xml b/pom.xml index 9cb0312..0d0e6d7 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.openmrs.moduleteammodule - 2.0.0 + 2.0.0ApomTeam Management ModuleA module that manages the teams.