Added notes feature

This commit is contained in:
2018-11-13 19:24:33 +01:00
parent d6f0421b9f
commit 3793f4a865
3 changed files with 35 additions and 24 deletions
+15 -8
View File
@@ -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 = $('<input type="file" class="part-edit-file" id="datasheet-input" accept=".pdf">')
// $('#datasheet-info').replaceWith(datasheet_input);
$('input[name=notes-input]').show();
$('table#details tr#notes td p').hide();
var newButton = '<div class="round-button-left"><a href="#" onclick="save(' + partID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
$('.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($('<td>DATASHEET: <a href="' + data.datasheet + '" target="_blank"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
@@ -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" );
});