Skip to content

Commit

Permalink
Pupil access restriction
Browse files Browse the repository at this point in the history
  • Loading branch information
tifoha committed Jan 27, 2016
1 parent 336692c commit 662169c
Show file tree
Hide file tree
Showing 6 changed files with 238 additions and 236 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package com.imcode.imcms.addon.ivisclient.utils;

import com.imcode.entities.embed.ApplicationFormQuestion;

import java.util.*;

import static java.util.Comparator.comparing;
import static java.util.Comparator.comparingInt;
import static java.util.Comparator.nullsLast;

/**
* Created by vitaly on 25.01.16.
*/
public class Step implements Comparable<Step> {
private Comparator<Step> naturalComparator = nullsLast(comparing(Step::getSortOrder, nullsLast(comparingInt(Integer::intValue))));
private String name;
private Integer sortOrder;
// private SortedSet<ApplicationFormQuestion> questions = new TreeSet();

public Step(String name, Integer sortOrder) {
this(name, sortOrder, Collections.emptySet());
}

public Step(String name, Integer sortOrder, Collection<ApplicationFormQuestion> questions) {
this.name = name;
this.sortOrder = sortOrder;
questions.addAll(questions);
}

public String getName() {
return name;
}

public Integer getSortOrder() {
return sortOrder;
}

// public SortedSet<ApplicationFormQuestion> getQuestions() {
// return questions;
// }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Step)) return false;

Step step = (Step) o;

if (name != null ? !name.equals(step.name) : step.name != null) return false;

return true;
}

@Override
public int hashCode() {
return name != null ? name.hashCode() : 0;
}

@Override
public int compareTo(Step o) {
return naturalComparator.compare(this, o);
}

@Override
public String toString() {
return name;
}
}
249 changes: 28 additions & 221 deletions ivis-client/src/main/webapp/WEB-INF/templates/text/applications_edit.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
<%@ page import="imcode.services.IvisServiceFactory" %>
<%@ page import="imcode.services.utils.IvisOAuth2Utils" %>
<%@ page import="org.springframework.security.oauth2.client.resource.UserRedirectRequiredException" %>
<%@ page import="com.imcode.entities.embed.ApplicationFormQuestion" %>
<%@ page import="java.util.*" %>
<%@ page import="com.imcode.imcms.addon.ivisclient.utils.Step" %>

<%@taglib prefix="imcms" uri="imcms" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
Expand All @@ -32,65 +35,27 @@
response.sendRedirect(Imcms.getServerProperties().getProperty("ClientAddress") + "/servlet/StartDoc?meta_id=" + viewing.getTextDocument().getId());
return;
}
Map<Step, Set<ApplicationFormQuestion>> steps = new TreeMap<>();
// List<AcademicYear> academicYearList = new ArrayList();
//
// try {
// academicYearList = academicYearService.findAll();
// } catch (Exception ignore) {
// }
//
// List<SchoolTransport> schoolTransportList = new ArrayList();
//
// try {
// schoolTransportList = schoolTransportService.findAll();
// } catch (Exception ignore) {
// }
//
// List<String> reasoneList = new ArrayList();
//
// try {
// reasoneList.add("Ressont #1");
// reasoneList.add("Ressont #2");
// reasoneList.add("Ressont #3");
// reasoneList.add("Ressont #4");
// } catch (Exception ignore) {
// }
//
// List<SchoolTransportSchema> schoolTransportSchema = new LinkedList<SchoolTransportSchema>();
//
// try {
//// schoolTransportSchema = app.getSchoolTransportSchema();
// List<SchoolTransportSchema> ApplicationschoolTransportSchema = app.getSchoolTransportSchema();
//
// for (DayOfWeek dayOfWeek : DayOfWeek.values()) {
// SchoolTransportSchema schema = new SchoolTransportSchema(dayOfWeek);
//
// for (SchoolTransportSchema centerSchema : ApplicationschoolTransportSchema) {
// if (dayOfWeek.equals(centerSchema.getDayOfWeek())) {
// schema = centerSchema;
// break;
// }
// }
//
// schoolTransportSchema.add(schema);
// }
// } catch (Exception ignore) {
// }
//
// request.setAttribute("schoolTransportSchema", schoolTransportSchema);
for (ApplicationFormQuestion formQuestion : app.getApplicationForm().getQuestions()) {
Step step = new Step(formQuestion.getStepName(), formQuestion.getStepSortOrder());
Set<ApplicationFormQuestion> questions = steps.get(step);
if (questions == null) {
questions = new TreeSet<>();
steps.put(step, questions);
}
questions.add(formQuestion);
}
request.setAttribute("steps", steps);
request.setAttribute("app", app);
// request.setAttribute("academicYearList", academicYearList);
// request.setAttribute("schoolTransportList", schoolTransportList);
// request.setAttribute("reasoneList", reasoneList);
pageContext.setAttribute("statusList", Decision.Status.values());
}
%>
<c:if test="${not empty app}">
<%--<h1>Application</h1>--%>
<%--<h1>School transport - issue ${app.id}</h1>--%>
<h1>Ansökan om skolskjuts</h1>

<h2>Skapas</h2><fmt:formatDate value="${app.createDate}" pattern="yyy-MM-dd HH:mm:ss"/>
Expand All @@ -109,105 +74,20 @@
Logg
</div>
</div>
<%--<form:form modelAttribute="pupil" action="<%=Imcms.getServerProperties().getProperty("ClientAddress")%>/api/content/ivis/pupils" method="post">--%>
<%--<form:form modelAttribute="app" action="${clientAddress}/api/content/ivis/applications" method="post"--%>
<%--id="application-form">--%>
<div id="applicationTabPage" class="tab-page">
<c:forEach items="${app.applicationForm.questions}" var="question" varStatus="fileOptionStatus">
<dl>
<dt>
${question.text}
</dt>
<c:if test="${question.value != 'true'}">
<dd>
${question.value}
</dd>
</c:if>
</dl>
<c:forEach items="${steps.entrySet()}" var="entry" varStatus="fileOptionStatus">
<div class="step">
<div class="name">${entry.key.name}</div>
</div>
<div class="questions">
<c:forEach items="${entry.value}" var="question" varStatus="fileOptionStatus">
<div class="question">
<div class="name">${question.text}</div>
<div class="ansqer">${question.value}</div>
</div>
</c:forEach>
</div>
</c:forEach>

<%--<input type="hidden" name="app" value="${app.id}">--%>
<%--<ihtml:personalizedShortInfo value="${app.pupil}" path="pupil" editUrl="${clientAddress}/pupils/edit"--%>
<%--label="Pupil"/>--%>
<%--<ihtml:personalizedShortInfo value="${app.guardian}" path="guardian" editUrl="" label="Guardian"/>--%>
<%--<ihtml:addressShortInfo value="${app.address}" label="Address"/>--%>
<%--<div>--%>
<%--<h2>Requested school transport</h2>--%>
<%--<ihtml:formSelect items="${academicYearList}" path="academicYear" label="School transport for period"/>--%>
<%--<ihtml:formSelect items="${schoolTransportList}" path="schoolTransport" label="Means of conveyance"/>--%>
<%--<div class="field" id="${path}Select">--%>
<%--<form:label path="reasone">Reason for transport</form:label>--%>
<%--<form:select path="reasone">--%>
<%--<form:option value="">-----</form:option>--%>
<%--<form:options items="${reasoneList}"/>--%>
<%--</form:select>--%>
<%--<form:errors path="reasone" cssClass="error-description"/>--%>
<%--</div>--%>


<%--</div>--%>
<%--<div>--%>
<%--<h2>School transport is required to school</h2>--%>
<%--<table cellpadding="0" cellspacing="0">--%>
<%--<thead>--%>
<%--<tr>--%>
<%--<c:forEach items="${schoolTransportSchema}" var="schema">--%>
<%--<td>--%>
<%--${schema.dayOfWeek}--%>
<%--</td>--%>
<%--</c:forEach>--%>
<%--</tr>--%>
<%--</thead>--%>
<%--<tbody>--%>
<%--<c:forEach items="${schoolTransportSchema}" var="schema" varStatus="status">--%>
<%--<td>--%>
<%--<input type="hidden" name="schoolTransportSchema[${status.index}].dayOfWeek"--%>
<%--value="${schema.dayOfWeek}">--%>
<%--<input type="checkbox"--%>
<%--name="schoolTransportSchema[${status.index}].to" ${schema.isTo() ? "checked": ""}>--%>

<%--</td>--%>
<%--</c:forEach>--%>
<%--</tbody>--%>
<%--</table>--%>
<%--<h2>School transport is required from school</h2>--%>
<%--<table cellpadding="0" cellspacing="0">--%>
<%--<thead>--%>
<%--<tr>--%>
<%--<c:forEach items="${schoolTransportSchema}" var="schema">--%>
<%--<td>${schema.dayOfWeek}</td>--%>
<%--</c:forEach>--%>
<%--</tr>--%>
<%--</thead>--%>
<%--<tbody>--%>
<%--<c:forEach items="${schoolTransportSchema}" var="schema" varStatus="status">--%>
<%--<td>--%>
<%--<input type="hidden" name="schoolTransportSchema[${status.index}].dayOfWeek"--%>
<%--value="${schema.dayOfWeek}">--%>
<%--<input type="checkbox"--%>
<%--name="schoolTransportSchema[${status.index}].from" ${schema.isFrom() ? "checked": ""}>--%>

<%--</td>--%>
<%--</c:forEach>--%>
<%--</tbody>--%>
<%--</table>--%>
<%--</div>--%>
<%--<div>--%>
<%--<h2>School transport is required from school</h2>--%>
<%--<div class="checkbox">--%>
<%--<form:checkbox path="accompanyingAssistant" />--%>
<%--<form:label path="accompanyingAssistant">Accompanying assistant</form:label>--%>

<%--<form:checkbox path="byMobilPhone"/>--%>
<%--<form:label path="byMobilPhone">Permobil</form:label>--%>

<%--<form:checkbox path="shorty"/>--%>
<%--<form:label path="shorty">Shorter than 135 centimeters</form:label>--%>

<%--<form:checkbox path="wheelchair"/>--%>
<%--<form:label path="wheelchair">Wheelchair</form:label>--%>
<%--</div>--%>
<%--</div>--%>
</div>

<div id="decisionTabPage" class="tab-page">
Expand All @@ -220,12 +100,6 @@
<dt>Comment</dt>
<dd>${app.decision.comment}</dd>
</dl>
<%--<form:label path="status">Status</form:label>--%>
<%--<form:select path="status">--%>
<%--<form:option value="">-----</form:option>--%>
<%--<form:options items="${statusList}"/>--%>
<%--</form:select>--%>
<%--<form:errors path="reasone" cssClass="error-description"/>--%>
<div class="buttons">
<form action="<%=Imcms.getServerProperties().getProperty("ClientAddress")%>/api/content/ivis/${app.id}"
method="get">
Expand All @@ -243,77 +117,10 @@
</div>
<div id="loggTabPage" class="tab-page">
</div>
<%--<div class="buttons">--%>
<%--<button class="positive" type="submit">Save</button>--%>
<%--<a class="button neutral" type="/pupils">Cancel</a>--%>
<%--</div>--%>
<%--</form:form>--%>
</c:if>
<script type="text/javascript">
<%--var communicationTypeEnum = [<%--%>
<%--Enum[] values = CommunicationTypeEnum.values();--%>
<%--for(int i = 0; i < values.length; i++) {--%>
<%--Enum typeEnum = values[i];--%>
<%--out.print("{name:\"");--%>
<%--out.print(typeEnum.name());--%>
<%--out.print("\", description:\"");--%>
<%--out.print(typeEnum.toString());--%>
<%--out.print("\"}, ");--%>
<%--}--%>
<%--%>];--%>
<%--var addressTypeEnum = [<%--%>
<%--values = AddressTypeEnum.values();--%>
<%--for(int i = 0; i < values.length; i++) {--%>
<%--Enum typeEnum = values[i];--%>
<%--out.print("{name:\"");--%>
<%--out.print(typeEnum.name());--%>
<%--out.print("\", description:\"");--%>
<%--out.print(typeEnum.toString());--%>
<%--out.print("\"}, ");--%>
<%--}--%>
<%--%>];--%>
// $(document).ready(function () {
//// alert("asdfasdf");
// $('#application-form').validate();
// });
var onOpen = function () {
$('#application-form').validate();
};
</script>
<%--<c:if test="${not empty statement}">--%>
<%--<table cellpadding="0" cellspacing="0">--%>
<%--<tbody>--%>
<%--<tr>--%>
<%--<td>Id</td>--%>
<%--<td>${statement.id}</td>--%>
<%--</tr>--%>
<%--<tr>--%>
<%--<td>Submit date</td>--%>
<%--<td>${statement.submitDate}</td>--%>
<%--</tr>--%>
<%--<tr>--%>
<%--<td>Change date</td>--%>
<%--<td>${statement.changedDate}</td>--%>
<%--</tr>--%>
<%--<tr>--%>
<%--<td>Status</td>--%>
<%--<td>${statement.status}</td>--%>
<%--</tr>--%>
<%--<tr>--%>
<%--<td>Submitted person</td>--%>
<%--<td>${statement.submittedPerson}</td>--%>
<%--</tr>--%>
<%--<tr>--%>
<%--<td>Pupil</td>--%>
<%--<td>${statement.pupil}</td>--%>
<%--</tr>--%>
<%--</tbody>--%>
<%--</table>--%>
<%--<div class="buttons">--%>
<%--<a class="button neutral" href="<%=Imcms.getServerProperties().getProperty("StatementsAddress")%>">Back</a>--%>
<%--</div>--%>
<%--</c:if>--%>
<jsp:include page="ivis_footer.jsp"/>

0 comments on commit 662169c

Please sign in to comment.