diff --git a/parts/server.py b/parts/server.py index 3ad9887..ab9fbd3 100644 --- a/parts/server.py +++ b/parts/server.py @@ -114,7 +114,7 @@ def alterLocation(locationID): @app.route('/parts/getpartinfo/') def get_part_info(partID): - s = 'select p.id,partno,description, c.name || l.name as location_descriptor, location_id, container_id, datasheet 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 p.id = :id;' + s = 'select p.id,partno,description,notes, c.name || l.name as location_descriptor, location_id, container_id, datasheet 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 p.id = :id;' r = db_engine.execute(text(s), id=partID) l = [] for row in r: @@ -132,7 +132,7 @@ def query(filter_dummy, query): for i in range(len(keywords)): kw_dict["kw" + str(i)] = keywords[i] - s = 'select p.id,partno,description,notes, 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 ' + 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'] == 'true': s += '(' @@ -201,8 +201,8 @@ def alter(partID): r = {} if partID < 0: # New entry - s = 'insert into parts (partno, description, datasheet, location_id) ' - s += 'values (:partno, :description, :datasheet, :location_id) returning id;' + s = 'insert into parts (partno, description, datasheet, location_id, notes) ' + s += 'values (:partno, :description, :datasheet, :location_id, :notes) returning id;' s = text(s) if len(request.files) != 0: datasheet_file = request.files['datasheet-file'] @@ -223,7 +223,8 @@ def alter(partID): r = db_engine.execute(s, partno=request.form['partno'], description=request.form['description'], datasheet=datasheet_filename, - location_id=request.form['location_id']) + location_id=request.form['location_id'], + notes=request.form['notes']) else: # Modify entry r = db_engine.execute(text('select * from parts where id=:id;'), id=partID) @@ -232,7 +233,7 @@ def alter(partID): l.append(dict(row)) r.close() s = 'update parts ' - s += 'set partno=:partno, description=:description, datasheet=:datasheet, location_id=:location_id ' + s += 'set partno=:partno, description=:description, datasheet=:datasheet, location_id=:location_id, notes=:notes ' if len(request.files) != 0: datasheet_file = request.files['datasheet-file'] datasheet_filename = secure_filename(datasheet_file.filename) @@ -257,7 +258,8 @@ def alter(partID): description=request.form['description'], datasheet=datasheet_filename, location_id=request.form['location_id'], - id=partID) + id=partID, + notes=request.form['notes']) new_id = r.fetchone()[0] r.close() diff --git a/parts/static/script.js b/parts/static/script.js index 42aacec..a20cc87 100644 --- a/parts/static/script.js +++ b/parts/static/script.js @@ -12,13 +12,13 @@ function init_edit(partID) { $('table#details tr#datasheet td input').closest().show(); $('table#details tr#datasheet td input').show(); - // $('input[name=datasheet-url-input]').closest().show(); $('#duplicate-button').closest('div').hide(); $('tr#datasheet').show(); - // var datasheet_input = $('') - // $('#datasheet-info').replaceWith(datasheet_input); + + $('input[name=notes-input]').show(); + $('table#details tr#notes td p').hide(); var newButton = '
'; $('.round-button-left').replaceWith(newButton); @@ -54,9 +54,9 @@ function end_edit() { $('table#details tr#description td input').hide(); $('tr#datasheet').hide(); - // $('table#details tr#datasheet td input').closest().hide(); - // $('table#details tr#datasheet td input').hide(); - // $('input[name=datasheet-url-input]').closest().hide(); + + $('input[name=notes-input]').hide(); + $('table#details tr#notes td p').show(); $('#duplicate-button').closest('div').show(); @@ -74,6 +74,7 @@ function save(partID) { var description_v = $('input[name=description-input]').val(); var datasheet = $('table#details tr#datasheet td input')[0].files; var datasheet_url_v = $('input[name=datasheet-url-input]').val(); + var notes_v = $('input[name=notes-input]').val(); if(partno_v.length == 0){ alert('Please enter a part number.'); return; @@ -102,8 +103,9 @@ function save(partID) { data.append('datasheet-url', datasheet_url_v); } data.append('partno', partno_v); - data.append('location_id', location_id_v) + data.append('location_id', location_id_v); data.append('description', description_v); + data.append('notes', notes_v); $.ajax({ // Your server script to process the upload @@ -171,6 +173,8 @@ function show_part_info(partID) { $('table#details tr#partno td input').val(text_filter(data.partno)); $('table#details tr#description td p').text(text_filter(data.description)); $('table#details tr#description td input').val(text_filter(data.description)); + $('table#details tr#notes td p').text(text_filter(data.notes)); + $('input[name=notes-input]').val(text_filter(data.notes)); container_onchange(); if (data.datasheet != null) { $('tr#datasheet-head').html($('DATASHEET: ')); @@ -193,6 +197,7 @@ function show_part_info(partID) { function perform_query() { $('#no-results').stop(); $('#no-results').css("opacity", 0); + $('#no-results').hide(); var query = $('.search-bar').val(); var data = { l:$('#location').is(':checked'), @@ -211,9 +216,11 @@ function perform_query() { $('#results').append(newRow); } if(data.length == 0) { - $('#no-results').animate({opacity:1},2000); + $('#no-results').show(); + $('#no-results').animate({opacity:1},2000); } }).fail(function() { + $('#no-results').show(); $('#no-results').animate({opacity:1},2000); console.log( "Query failed" ); }); diff --git a/parts/templates/partsearch.html b/parts/templates/partsearch.html index 8e4eca3..bb795a4 100644 --- a/parts/templates/partsearch.html +++ b/parts/templates/partsearch.html @@ -44,8 +44,8 @@

Part Details

- - + - - - - - - + + + + + + - + + +
LOCATION

+
LOCATION

PART NUMBER

DESCRIPTION

DATASHEET:
PART NUMBER

DESCRIPTION

DATASHEET:
NOTES