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="stylesheet" href="{% static "css/gpp.css" %}">
|
||||||
|
|
||||||
<link rel="icon" type="image/png" href="{% static "images/favicon.png" %}">
|
<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/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"/>
|
<link href="{% static "css/bootstrap.css" %}" rel="stylesheet" type="text/css"/>
|
||||||
<script src="{% static "js/bootstrap.js" %}"></script>
|
<script src="{% static "js/bootstrap.js" %}"></script>
|
||||||
-->
|
-->
|
||||||
|
@ -2,12 +2,26 @@
|
|||||||
{% block form %}
|
{% block form %}
|
||||||
<div class="search" id="search_boat">
|
<div class="search" id="search_boat">
|
||||||
{{ boat_search_form }}
|
{{ 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" />
|
<input type="submit" value="Search boat" />
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block formnew %}
|
{% block formnew %}
|
||||||
<form action="{% url 'boat:add' %}" method="post">
|
<form action="{% url 'boat:add' %}" method="post">
|
||||||
<div class="new hidden" id="new_boat">
|
<div class="new hidden" id="new_boat">
|
||||||
|
<a
|
||||||
|
id="switch_boat_search"
|
||||||
|
href="#search_boat">
|
||||||
|
Switch to boat search
|
||||||
|
</a>
|
||||||
{{ boat_form }}
|
{{ boat_form }}
|
||||||
<input type="submit" value="Add boat" />
|
<input type="submit" value="Add boat" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -43,6 +43,7 @@ def new_stay(request):
|
|||||||
return new_stay_4(request)
|
return new_stay_4(request)
|
||||||
|
|
||||||
def new_stay_0(request):
|
def new_stay_0(request):
|
||||||
|
new_boat_search = True
|
||||||
try:
|
try:
|
||||||
boat_id = int(request.POST.get('search_results'))
|
boat_id = int(request.POST.get('search_results'))
|
||||||
boat = Boat.objects.get(pk=boat_id)
|
boat = Boat.objects.get(pk=boat_id)
|
||||||
@ -58,8 +59,8 @@ def new_stay_0(request):
|
|||||||
else None
|
else None
|
||||||
|
|
||||||
return new_stay(request)
|
return new_stay(request)
|
||||||
except TypeError:
|
except TypeError as e:
|
||||||
pass
|
new_boat_search = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
pprint(e)
|
pprint(e)
|
||||||
|
|
||||||
@ -71,6 +72,7 @@ def new_stay_0(request):
|
|||||||
boat_search_form = BoatSearchForm(
|
boat_search_form = BoatSearchForm(
|
||||||
name=name,
|
name=name,
|
||||||
choices=boat_existing)
|
choices=boat_existing)
|
||||||
|
|
||||||
boat_form = BoatForm()
|
boat_form = BoatForm()
|
||||||
|
|
||||||
|
|
||||||
@ -78,7 +80,8 @@ def new_stay_0(request):
|
|||||||
'new_stay/new_stay-0.html',
|
'new_stay/new_stay-0.html',
|
||||||
{
|
{
|
||||||
'boat_search_form': boat_search_form,
|
'boat_search_form': boat_search_form,
|
||||||
'boat_form': boat_form
|
'boat_form': boat_form,
|
||||||
|
'search_name': name
|
||||||
})
|
})
|
||||||
|
|
||||||
def new_stay_1(request):
|
def new_stay_1(request):
|
||||||
|
2
static/js/jquery-3.4.1.min.js
vendored
Normal file
2
static/js/jquery-3.4.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
29
static/js/main.js
Normal file
29
static/js/main.js
Normal file
@ -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
Block a user