Skip to content

Commit

Permalink
Adds multiple id removal support in cartable and RemoveEntry servlet
Browse files Browse the repository at this point in the history
  • Loading branch information
oskopek committed Sep 8, 2014
1 parent 679e500 commit 4ad7b89
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ protected void processRequest(HttpServletRequest request, HttpServletResponse re
String timeZoneStr = request.getParameter("timezone");
TimeZone tz = TimeZone.getTimeZone(timeZoneStr);

DateFormat dateFormat = new SimpleDateFormat("dd. MM. yyyy");
DateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
dateFormat.setTimeZone(tz);
DateFormat timeFormat = new SimpleDateFormat("HH:mm");
timeFormat.setTimeZone(tz);
Expand Down Expand Up @@ -110,7 +110,7 @@ public int compare(FileEntry o1, FileEntry o2) {
request.setAttribute("wrtmList", wrtmList);

boolean isAdmin = request.isUserInRole(adminRole);
request.setAttribute("isAdmin", Boolean.valueOf(isAdmin));
request.setAttribute("isAdmin", isAdmin);

RequestDispatcher rd = getServletContext().getRequestDispatcher("/app/cartable.jsp");
rd.forward(request, response);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,10 @@ public class RemoveEntryServlet extends HttpServlet {
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws
IOException {
long entryId = Long.parseLong(request.getParameter("entry_id"));
entryBean.remove(entryId);
String[] entryIdArray = request.getParameter("entry_id").split(",");
for (String entryId : entryIdArray) {
entryBean.remove(Long.parseLong(entryId));
}
response.sendRedirect("/app/index.jsp"); // TODO 3 redirect should be more intelligent
}

Expand Down
46 changes: 25 additions & 21 deletions carcv-webapp/src/main/webapp/app/cartable.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ $(document).ready(function() {
if (!confirm("Are you sure you want to delete?")) {
return;
}
var rows = table.rows('.selected')
window.parent.location.replace("/admin/servlet/RemoveEntry?entry_id=" + rows.indexes());
var rows = table.rows('.selected');
var idString = "".concat(rows[0][0]);
for (i = 1; i < rows.length; i++) {
idString = idString.concat(",", rows[i][0]);
}
window.parent.location.replace("/admin/servlet/RemoveEntry?entry_id=" + idString);
//table.rows('.selected').remove().draw( false );
} );
} );
Expand All @@ -41,29 +45,29 @@ $(document).ready(function() {
<table id="carTable" style="border: 1px solid #C0C0C0;" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th style="width: 5%; height: 15px; background-color: #B0C4DE;">ID</th>
<th style="width: 160px; height: 15px; background-color: #B0C4DE;">Car preview</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">ID</th>
<th style="width: 25%; height: 15px; background-color: #B0C4DE;">Car preview</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Date</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">License plate</th>
<th style="width: 20%; height: 15px; background-color: #B0C4DE;">Location</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">Video</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">Pictures</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">Report</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">License plate</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">Location</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Video</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Pictures</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Report</th>
</tr>
</thead>

<tfoot>
<tr>
<th style="width: 5%; height: 15px; background-color: #B0C4DE;">ID</th>
<th style="width: 160px; height: 15px; background-color: #B0C4DE;">Car preview</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Date</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">License plate</th>
<th style="width: 20%; height: 15px; background-color: #B0C4DE;">Location</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">Video</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">Pictures</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">Report</th>
</tr>
</tfoot>
<tr>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">ID</th>
<th style="width: 25%; height: 15px; background-color: #B0C4DE;">Car preview</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Date</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">License plate</th>
<th style="width: 15%; height: 15px; background-color: #B0C4DE;">Location</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Video</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Pictures</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Report</th>
</tr>
</tfoot>

<tbody>
<c:forEach var="member" items="${wrtmList}">
Expand All @@ -80,7 +84,7 @@ $(document).ready(function() {
<td><a href="/servlet/GenerateReport?entry_id=${member.entryId}&timezone=${member.timeZone}" target="_top">Generate
report</a></td>
</tr>
<!-- TODO put script to addROw here -->
<!-- TODO put script to addRow here -->
</c:forEach>
</tbody>
</table>
Expand Down
2 changes: 1 addition & 1 deletion carcv-webapp/src/main/webapp/resources/mystyle.css
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ td {
margin-bottom: 5px;
text-align: left;
position: relative;
top: -9px"
top: -10px"
}

#footer {
Expand Down

0 comments on commit 4ad7b89

Please sign in to comment.