UI add jquery and began a new_stay script in main.js
This commit is contained in:
parent
b21af09fcb
commit
dfbed7248e
|
@ -22,8 +22,9 @@
|
|||
<link rel="stylesheet" href="{% static "css/gpp.css" %}">
|
||||
|
||||
<link rel="icon" type="image/png" href="{% static "images/favicon.png" %}">
|
||||
<!--
|
||||
<script src="{% static "js/jquery-3.4.1.min.js" %}"></script>
|
||||
<script src="{% static "js/main.js" %}"></script>
|
||||
<!--
|
||||
<link href="{% static "css/bootstrap.css" %}" rel="stylesheet" type="text/css"/>
|
||||
<script src="{% static "js/bootstrap.js" %}"></script>
|
||||
-->
|
||||
|
|
|
@ -2,12 +2,26 @@
|
|||
{% block form %}
|
||||
<div class="search" id="search_boat">
|
||||
{{ boat_search_form }}
|
||||
{% if search_name %}
|
||||
<label for="id_search_results_none">
|
||||
<input type="radio"
|
||||
name="search_results"
|
||||
value="-1"
|
||||
id="id_search_results_none"/>
|
||||
None ( create a new boat )
|
||||
</label>
|
||||
{% endif %}
|
||||
<input type="submit" value="Search boat" />
|
||||
</div>
|
||||
{% endblock %}
|
||||
{% block formnew %}
|
||||
<form action="{% url 'boat:add' %}" method="post">
|
||||
<div class="new hidden" id="new_boat">
|
||||
<a
|
||||
id="switch_boat_search"
|
||||
href="#search_boat">
|
||||
Switch to boat search
|
||||
</a>
|
||||
{{ boat_form }}
|
||||
<input type="submit" value="Add boat" />
|
||||
</div>
|
||||
|
|
|
@ -43,6 +43,7 @@ def new_stay(request):
|
|||
return new_stay_4(request)
|
||||
|
||||
def new_stay_0(request):
|
||||
new_boat_search = True
|
||||
try:
|
||||
boat_id = int(request.POST.get('search_results'))
|
||||
boat = Boat.objects.get(pk=boat_id)
|
||||
|
@ -58,8 +59,8 @@ def new_stay_0(request):
|
|||
else None
|
||||
|
||||
return new_stay(request)
|
||||
except TypeError:
|
||||
pass
|
||||
except TypeError as e:
|
||||
new_boat_search = False
|
||||
except Exception as e:
|
||||
pprint(e)
|
||||
|
||||
|
@ -71,6 +72,7 @@ def new_stay_0(request):
|
|||
boat_search_form = BoatSearchForm(
|
||||
name=name,
|
||||
choices=boat_existing)
|
||||
|
||||
boat_form = BoatForm()
|
||||
|
||||
|
||||
|
@ -78,7 +80,8 @@ def new_stay_0(request):
|
|||
'new_stay/new_stay-0.html',
|
||||
{
|
||||
'boat_search_form': boat_search_form,
|
||||
'boat_form': boat_form
|
||||
'boat_form': boat_form,
|
||||
'search_name': name
|
||||
})
|
||||
|
||||
def new_stay_1(request):
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,29 @@
|
|||
$(function () {
|
||||
// Events
|
||||
$('[name=search_results]').on('change',
|
||||
function (e) {
|
||||
new_stay_0($(this));
|
||||
})
|
||||
|
||||
$('#id_search_name').on('keyup',
|
||||
function (e) {
|
||||
$('#id_name').val($(this).val())
|
||||
})
|
||||
|
||||
$('#switch_boat_search').on('click',
|
||||
function (e) {
|
||||
console.log('lol')
|
||||
$('#new_boat').hide();
|
||||
$('#search_boat').show();
|
||||
})
|
||||
|
||||
// New Stay
|
||||
// new_stay-0
|
||||
function new_stay_0(elem) {
|
||||
if (elem.val() < 0) {
|
||||
$('#new_boat').show();
|
||||
$('#search_boat').hide();
|
||||
}
|
||||
}
|
||||
|
||||
})
|
Loading…
Reference in New Issue