Skip to content

Commit

Permalink
Implement multi-row delete with new DataTables library in cartable
Browse files Browse the repository at this point in the history
* Add copyright notices
* Add libraries (jquery, jquery.dataTables)
* Updated the cartable according to:
** http://datatables.net/examples/api/select_row.html
** http://datatables.net/examples/api/select_single_row.html
  • Loading branch information
oskopek committed Sep 8, 2014
1 parent d8e3d1a commit 8e5075b
Show file tree
Hide file tree
Showing 5 changed files with 756 additions and 17 deletions.
83 changes: 83 additions & 0 deletions NOTICE.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,86 @@ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABI
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
----

=== CarCV WebApp
==== DataTables

----
MIT license
Copyright (C) 2008-2014, SpryMedia Ltd.
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
----

==== JQuery

Copyright 2005, 2014 jQuery Foundation and other contributors,

https://jquery.org/[]

This software consists of voluntary contributions made by many
individuals. For exact contribution history, see the revision history
available at https://github.com/jquery/jquery

The following license applies to all parts of this software except as
documented below:

----
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
----

==== jsTimezoneDetect

----
MIT License
Copyright (c) 2012 Jon Nylander, project maintained at
https://bitbucket.org/pellepim/jstimezonedetect
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to
do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
----
55 changes: 38 additions & 17 deletions carcv-webapp/src/main/webapp/app/cartable.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,30 @@
height: 25px
}
</style>

<script type="text/javascript" language="javascript" src="/resources/jquery-1.11.1.min.js"></script>
<script type="text/javascript" language="javascript" src="/resources/jquery.dataTables.min.js"></script>
<script type="text/javascript" class="init">
$(document).ready(function() {
var table = $('#carTable').DataTable();
$('#carTable tbody').on( 'click', 'tr', function () {
$(this).toggleClass('selected');
} );
$('#deleteButton').click( function () {
table.rows('.selected').remove().draw( false );
} );
} );
</script>

</head>
<body>
<table style="border: 1px solid #C0C0C0;">
<c:if test="${isAdmin}"><button id="deleteButton">Delete selected rows</button></c:if><br>
<table id="carTable" style="border: 1px solid #C0C0C0;" class="display" cellspacing="0" width="100%">
<thead>
<tr>
<th style="width: 160px; height: 15px; background-color: #B0C4DE;">Car preview</th>
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Date</th>
Expand All @@ -24,11 +45,23 @@
<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>
<c:if test="${isAdmin}">
<th style="width: 10%; height: 15px; background-color: #B0C4DE;">Delete</th>
</c:if>

</tr>
</thead>

<tfoot>
<tr>
<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>

<tbody>
<c:forEach var="member" items="${wrtmList}">
<tr>
<td><img src="/servlet/DisplayImage?path=${member.previewPath}&width=150" style="border: 2px" width="150"
Expand All @@ -41,20 +74,8 @@
<td><a href="/servlet/DisplayImage?path=${member.previewPath}" target="_top">View preview</a></td>
<td><a href="/servlet/GenerateReport?entry_id=${member.entryId}&timezone=${member.timeZone}" target="_top">Generate
report</a></td>
<c:if test="${isAdmin}">
<td>
<button onclick="confirmRemove()">Delete</button>
<script>
function confirmRemove() {
var result = confirm("Are you sure you want to delete?");
if (result) { // TODO remove the correct entry! See issue #28
window.parent.location.replace("/admin/servlet/RemoveEntry?entry_id=${member.entryId}");
}
}
</script>
</td>
</c:if>
</tr>
</tbody>
</c:forEach>
</table>
</body>
Expand Down
4 changes: 4 additions & 0 deletions carcv-webapp/src/main/webapp/resources/jquery-1.11.1.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 8e5075b

Please sign in to comment.