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

Show request details in popup modal #750

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
150 changes: 55 additions & 95 deletions mainapp/templates/mainapp/request_list.html
Original file line number Diff line number Diff line change
@@ -1,70 +1,6 @@
{% extends 'base.html' %}
{% load bootstrap3 %}

{% block css %}
<style>
.table{
table-layout: fixed;
}

.table td{
word-wrap: break-word;
}
</style>
<style>
@media only screen and (max-width: 800px) {

#requests-table table, thead, tbody, th, td, tr {
display: block;
}

#requests-table thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}

#requests-table tr {
margin: 0 0 1rem 0;
}

#requests-table tr:nth-child(odd) {
background: #ccc;
}

#requests-table td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}

#requests-table td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 0;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: normal;
}
#requests-table td:nth-of-type(1):before { content: "Request Number - അപേക്ഷ നമ്പര്‍"; }
#requests-table td:nth-of-type(2):before { content: "District - ജില്ല"; }
#requests-table td:nth-of-type(3):before { content: "Location - സ്ഥലം"; }
#requests-table td:nth-of-type(4):before { content: "Requestee - അപേക്ഷകന്‍റെ പേര്"; }
#requests-table td:nth-of-type(5):before { content: "Phone - ഫോണ്‍ നമ്പര്‍"; }
#requests-table td:nth-of-type(6):before { content: "Date - തീയതി"; }
#requests-table td:nth-of-type(7):before { content: "More details - കൂടുതൽ വിശദാംശങ്ങൾ"; }
}
@media only screen and (max-width: 420px) {
#requests-table td {
min-height: 60px;
}
}
</style>
{% endblock %}
{% load static %}

{% block content %}
<!--Navigation Breadcrumbs-->
Expand Down Expand Up @@ -104,8 +40,18 @@ <h2 class="text-center">ഇതു വരെ ആവശ്യപ്പെട്ട
<td>{{ req.requestee }}</td>
<td><a href="tel:{{ req.requestee_phone }}" >{{ req.requestee_phone }}</a></td>
<td>{{ req.dateadded }}</td>
<td><a class="btn btn-sm btn-success" href="{%url 'requestdetailsview' req.id %}" target="_blank">More details</a>
<td><a class="btn btn-sm btn-success" href="{%url 'requestupdateview' req.id %}" target="_blank">Update</a></td>
<td class="hide">
{% if req.latlng %}
<a class="btn btn-sm btn-success" href="https://maps.google.com/?q={{ req.latlng }}" target="_blank">Open in maps</a>
<br>
Accuracy: {{ req.latlng_accuracy }}
{% else %}
NA
{% endif %}
</td>
<td class="hide">{{ req.summarise | linebreaks }} </td>
<td><button class="show-details btn btn-sm btn-success">More details</button></td>
<td><a class="btn btn-sm btn-success" href="{%url 'requestupdateview' req.id %}" target="_blank">Update</a></td>
</tr>
{% endfor %}
</tbody>
Expand Down Expand Up @@ -135,33 +81,47 @@ <h2 class="text-center">ഇതു വരെ ആവശ്യപ്പെട്ട

</div>

<script>
window.onload = function() {
$("input.search").keyup(search);
}

function search() {
$("#req-table").find("tr").each(function(i,el) {
// skip header row
if (i == 0) return
el = $(el)
var tds = el.find("td")
var loc = tds.eq(1).text().toLowerCase()
var requestee = tds.eq(2).text().toLowerCase()
var phone = tds.eq(3).text()
var locKey = $("#search-loc").val().toLowerCase()
var reqKey = $("#search-requestee").val().toLowerCase()
var phoneKey = $("#search-phone").val()
<!-- Modal -->
<div id="req-details" class="modal fade" role="dialog">
<div class="modal-dialog">

<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">&times;</button>
<h4 class="modal-title">Request Details</h4>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<span class="col-xs-6">District: <span id="req-dist"></span></span>
<span class="col-xs-6">Requestee: <span id="req-requestee"></span></span>
</div>
<div class="row">
<span class="col-xs-6">Contact: <span id="req-contact"></span></span>
<span class="col-xs-6">Date: <span id="req-date"></span></span>
</div>
<div class="row">
<span class="col-xs-6">Location: <span id="req-loc"></span></span>
<span class="col-xs-6">GPS Location: <span id="req-gps"></span></span>
</div>
<div class="row">
<div class="col-xs-12">
<h3>Summary</h3>
<p id="req-summary"></p>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>

</div>
</div>
{% endblock %}

if (loc.includes(locKey) &&
requestee.includes(reqKey) &&
phone.includes(phoneKey))
{
el.show()
} else {
el.hide()
}
})
}
</script>
{% block javascript %}
<script src="{% static 'js/request-list.js' %}" async defer></script>
{% endblock %}
63 changes: 63 additions & 0 deletions static/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -311,3 +311,66 @@ table thead tr th {
opacity: 1;
}
}

.table{
table-layout: fixed;
}

.table td{
word-wrap: break-word;
}
#req-summary { margin-top: 15px; }
.modal-body .row { padding: 5px 0 }


@media only screen and (max-width: 800px) {

#requests-table table, thead, tbody, th, td, tr {
display: block;
}

#requests-table thead tr {
position: absolute;
top: -9999px;
left: -9999px;
}

#requests-table tr {
margin: 0 0 1rem 0;
}

#requests-table tr:nth-child(odd) {
background: #ccc;
}

#requests-table td {
/* Behave like a "row" */
border: none;
border-bottom: 1px solid #eee;
position: relative;
padding-left: 50%;
}

#requests-table td:before {
/* Now like a table header */
position: absolute;
/* Top/left values mimic padding */
top: 0;
left: 6px;
width: 45%;
padding-right: 10px;
white-space: normal;
}
#requests-table td:nth-of-type(1):before { content: "Request Number - അപേക്ഷ നമ്പര്‍"; }
#requests-table td:nth-of-type(2):before { content: "District - ജില്ല"; }
#requests-table td:nth-of-type(3):before { content: "Location - സ്ഥലം"; }
#requests-table td:nth-of-type(4):before { content: "Requestee - അപേക്ഷകന്‍റെ പേര്"; }
#requests-table td:nth-of-type(5):before { content: "Phone - ഫോണ്‍ നമ്പര്‍"; }
#requests-table td:nth-of-type(6):before { content: "Date - തീയതി"; }
#requests-table td:nth-of-type(9):before { content: "More details - കൂടുതൽ വിശദാംശങ്ങൾ"; }
}
@media only screen and (max-width: 420px) {
#requests-table td {
min-height: 60px;
}
}
55 changes: 55 additions & 0 deletions static/js/request-list.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const iDist = 1
const iLoc = 2
const iRequestee = 3
const iContact = 4
const iDate = 5
const iGps = 6
const iSummary = 7

$("input.search").keyup(search);
$(".show-details").click(showDetails);

function showDetails(evt) {
var tds = $(evt.target).parent().siblings()
var dist = tds.eq(iDist).text().toLowerCase()
var loc = tds.eq(iLoc).text().toLowerCase()
var requestee = tds.eq(iRequestee).text().toLowerCase()
var phone = tds.eq(iContact).html()
var date = tds.eq(iDate).text()
var gps = tds.eq(iGps).html()
var summary = tds.eq(iSummary).html()

$("#req-dist").text(dist)
$("#req-loc").text(loc)
$("#req-requestee").text(requestee)
$("#req-contact").html(phone)
$("#req-date").text(date)
$("#req-gps").html(gps)
$("#req-summary").html(summary)

$("#req-details").modal("show")
}

function search() {
$("#req-table").find("tr").each(function(i,el) {
// skip header row
if (i == 0) return
el = $(el)
var tds = el.find("td")
var loc = tds.eq(iLoc).text().toLowerCase()
var requestee = tds.eq(iRequestee).text().toLowerCase()
var phone = tds.eq(iContact).text()
var locKey = $("#search-loc").val().toLowerCase()
var reqKey = $("#search-requestee").val().toLowerCase()
var phoneKey = $("#search-phone").val()

if (loc.includes(locKey) &&
requestee.includes(reqKey) &&
phone.includes(phoneKey))
{
el.show()
} else {
el.hide()
}
})
}