made location listing part of the template, rather than an unnecesary AJAX request + secret sauce sorting

pull/3/head
Marek Baczynski 6 years ago
parent fd4f29ca7d
commit 2029ef5aeb

@ -47,17 +47,13 @@ def serveImage(img):
@app.route('/parts')
def index():
return render_template('partsearch.html')
@app.route('/parts/getlocations/')
def get_locations():
s = 'select id, name from locations order by name;'
r = db_engine.execute(text(s))
l = {}
query = "select id, name from locations order by left(map, strpos(map, '.')-1), UPPER(name);"
r = db_engine.execute(text(query))
locations = []
for row in r:
l[row[0]]=row[1]
locations.append(dict(row))
r.close()
return json.dumps(l)
return render_template('partsearch.html', locations=locations)
@app.route('/parts/getlocationURL/<locationID>')
def get_locationURL(locationID):

@ -225,11 +225,6 @@ function update_map() {
}
$(document).ready(function() {
$.getJSON('parts/getlocations', function(data){
$.each(data, function(i, val) {
$('table#details tr#location td select').append('<option value="' + i + '">' + val + '</option>');
});
});
$.ajaxSetup({ cache: false });
$('.search-bar').on('keyup', function() {
perform_query();

@ -43,7 +43,13 @@
<h2>Part Details</h2>
<table id="details">
<tr id="location-head"><td>LOCATION</td></tr>
<tr id="location"><td><p></p><select class="pinfo-input" onchange="update_map()"></select></td></tr>
<tr id="location"><td><p></p>
<select class="pinfo-input" onchange="update_map()">
{% for location in locations %}
<option value="{{location['id']}}">{{location['name']}}</option>
{% endfor %}
</select>
</td></tr>
<tr id="partno-head"><td>PART NUMBER</td></tr>
<tr id="partno"><td><p></p><input type="text" name="partno-input" placeholder="Part Number" class="pinfo-input"/></td></tr>
<tr id="description-head"><td>DESCRIPTION</td></tr>

Loading…
Cancel
Save