Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AM-119 Add cancel button to new appointment form #3

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -61,6 +61,8 @@ public class AppointmentFormController {
/** Logger for this class and subclasses */
protected final Log log = LogFactory.getLog(getClass());

private static String URL_PREVIOUS = "url_previous";

@InitBinder
public void initBinder(WebDataBinder binder) {
binder.registerCustomEditor(TimeSlot.class, new TimeSlotEditor());
Expand All @@ -70,6 +72,7 @@ public void initBinder(WebDataBinder binder) {

@RequestMapping(value = "/module/appointmentscheduling/appointmentForm", method = RequestMethod.GET)
public void showForm(ModelMap model, HttpServletRequest request) {
request.getSession().setAttribute(URL_PREVIOUS, request.getHeader("Referer"));
if (Context.isAuthenticated()) {
model.put("selectedLocation", Context.getUserContext().getLocation());
if (request.getParameter("patientId") != null) {
Expand All @@ -78,6 +81,16 @@ public void showForm(ModelMap model, HttpServletRequest request) {
}
}

@RequestMapping(value = "/module/appointmentscheduling/appointmentForm.action", method = RequestMethod.GET)
public String cancelForm(HttpServletRequest request) {
String url = request.getSession().getAttribute(URL_PREVIOUS).toString();
if (url.equalsIgnoreCase(null) || url.equalsIgnoreCase("")) {
return "appointmentForm.form";
} else {
return "redirect:" + url;
}
}

@ModelAttribute("selectedLocation")
public Location getLocation(@RequestParam(value = "locationId", required = false) Location location) {
if (location != null)
Expand Down
10 changes: 8 additions & 2 deletions omod/src/main/webapp/appointmentForm.jsp
Expand Up @@ -210,7 +210,9 @@
function ConfirmationDialogOpen(){
$j('#appointmentInformationDialog').dialog('open');
}

function CancelAppointmentForm(){
window.location = "appointmentForm.action";
}
function addQueryParameter(paramName){
var value = queryParameters[paramName];
var currentURL = window.location.href;
Expand Down Expand Up @@ -503,8 +505,12 @@
<td></td>
<td><input type="button" class="saveButton"
value="<spring:message code='appointmentscheduling.Appointment.create.save'/>"
name="save" onclick="ConfirmationDialogOpen();"></td>
name="save" onclick="ConfirmationDialogOpen();">
<input type="button" class="saveButton"
value="<spring:message code='appointmentscheduling.Appointment.create.cancel'/>"
name="cancel" onclick="CancelAppointmentForm();"></td>
</tr>

</table>
</fieldset>
</form:form>
Expand Down