diff --git a/parts/server.py b/parts/server.py index 03fe262..ddaee93 100644 --- a/parts/server.py +++ b/parts/server.py @@ -131,31 +131,30 @@ def query(filter_dummy, query): kw_dict["kw" + str(i)] = keywords[i] s = 'select p.id,partno,description, c.name || l.name as location_descriptor from parts as p inner join locations as l on p.location_id = l.id inner join containers as c on l.container_id = c.id where ' - if filter['l']: + + if filter['l'] == 'true': s += '(' for i in range(len(keywords)): s += 'LOWER(l.name) like LOWER(:kw'+ str(i) +') AND ' s = s[:-5] s += ') OR ' - if filter['p']: + if filter['p'] == 'true': s += '(' for i in range(len(keywords)): s += 'LOWER(partno) like LOWER(:kw'+ str(i) +') AND ' s = s[:-5] s += ') OR ' - if filter['d']: + if filter['d'] == 'true': s += '(' for i in range(len(keywords)): s += 'LOWER(description) like LOWER(:kw'+ str(i) +') AND ' s = s[:-5] s += ') OR ' - if filter['n']: - s += '(' - for i in range(len(keywords)): - s += 'LOWER(notes) like LOWER(:kw'+ str(i) +') AND ' - s = s[:-5] - s += ') OR ' + if filter['n'] == 'true': + s = s[:-4] + s += "AND (datasheet='' IS NOT FALSE) IS FALSE OR " s = s[:-4] + ';' + print(s) s = text(s) r = db_engine.execute(s, kw_dict) l = [] diff --git a/parts/static/script.js b/parts/static/script.js index c1a9548..9dfc048 100644 --- a/parts/static/script.js +++ b/parts/static/script.js @@ -169,13 +169,14 @@ function show_part_info(partID) { } function perform_query() { + $('#no-results').stop(); $('#no-results').css("opacity", 0); var query = $('.search-bar').val(); var data = { l:$('#type').is(':checked'), p:$('#partno').is(':checked'), d:$('#description').is(':checked'), - n:$('#notes').is(':checked') + n:$('#has-docs').is(':checked') }; filter = '0'; $("#results").find("tr:not(:first)").remove(); // Delete all table rows @@ -192,10 +193,7 @@ function perform_query() { $('#no-results').animate({opacity:1},2000); } }).fail(function() { - var newResults = '
'; - newResults += '

No results.

'; - newResults += '
'; - $('.results').replaceWith(newResults); + $('#no-results').animate({opacity:1},2000); console.log( "Query failed" ); }); } @@ -222,7 +220,7 @@ $(document).ready(function() { if ( !$('#location').is(':checked') && !$('#partno').is(':checked') && !$('#description').is(':checked') - && !$('#notes').is(':checked')) + && !$('#has-docs').is(':checked')) $(this).prop('checked', true); else perform_query(); diff --git a/parts/static/style.css b/parts/static/style.css index 848ba5c..ef11f39 100644 --- a/parts/static/style.css +++ b/parts/static/style.css @@ -59,7 +59,6 @@ input[type=text].search-bar { padding: 10pt 15pt 10pt 15pt; margin-top: 10pt; margin-bottom: 10pt; - border-radius: 2pt; display: inline-block; } @@ -81,7 +80,6 @@ input[type=checkbox]{ } input[type=checkbox] + label.toggle-btn { - border-radius: 3pt; display: inline-block; padding: 5pt; color: #D7E2E2; @@ -89,7 +87,8 @@ input[type=checkbox] + label.toggle-btn { margin-bottom: 6pt; margin-left: 3pt; margin-right: 3pt; - width: 100pt; + width: 80pt; + line-height: 300%; text-align: center; border: 1pt solid #D7E2E2; transition: 0.2s; diff --git a/parts/templates/partsearch.html b/parts/templates/partsearch.html index 35ca3f1..6b9c551 100644 --- a/parts/templates/partsearch.html +++ b/parts/templates/partsearch.html @@ -22,10 +22,10 @@

Search in:

- - - - + + + +