|
|
@ -20,6 +20,10 @@ function init_edit(partID) {
|
|
|
|
block_input.val($('#block-info').text());
|
|
|
|
block_input.val($('#block-info').text());
|
|
|
|
$('#block-info').replaceWith(block_input);
|
|
|
|
$('#block-info').replaceWith(block_input);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var type_input = $('<input type="text" class="part-edit-input" id="type-input" placeholder="Manufacturer">')
|
|
|
|
|
|
|
|
type_input.val($('#type-info').text());
|
|
|
|
|
|
|
|
$('#type-info').replaceWith(type_input);
|
|
|
|
|
|
|
|
|
|
|
|
var partno_input = $('<input type="text" class="part-edit-input" id="partno-input" placeholder="Part number">')
|
|
|
|
var partno_input = $('<input type="text" class="part-edit-input" id="partno-input" placeholder="Part number">')
|
|
|
|
partno_input.val($('#partno-info').text());
|
|
|
|
partno_input.val($('#partno-info').text());
|
|
|
|
$('#partno-info').replaceWith(partno_input);
|
|
|
|
$('#partno-info').replaceWith(partno_input);
|
|
|
@ -45,6 +49,7 @@ function init_edit(partID) {
|
|
|
|
|
|
|
|
|
|
|
|
function new_entry() {
|
|
|
|
function new_entry() {
|
|
|
|
$('#block-info').text('');
|
|
|
|
$('#block-info').text('');
|
|
|
|
|
|
|
|
$('#type-info').text('');
|
|
|
|
$('#partno-info').text('');
|
|
|
|
$('#partno-info').text('');
|
|
|
|
$('#description-info').text('');
|
|
|
|
$('#description-info').text('');
|
|
|
|
$('#quantity-info').text('');
|
|
|
|
$('#quantity-info').text('');
|
|
|
@ -57,6 +62,9 @@ function end_edit() {
|
|
|
|
var block_par = '<p id="block-info">' + $('#block-input').val() + '</p>';
|
|
|
|
var block_par = '<p id="block-info">' + $('#block-input').val() + '</p>';
|
|
|
|
$('#block-input').replaceWith(block_par);
|
|
|
|
$('#block-input').replaceWith(block_par);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var type_par = '<p id="type-info">' + $('#type-input').val() + '</p>';
|
|
|
|
|
|
|
|
$('#type-input').replaceWith(type_par);
|
|
|
|
|
|
|
|
|
|
|
|
var partno_par = '<p id="partno-info">' + $('#partno-input').val() + '</p>';
|
|
|
|
var partno_par = '<p id="partno-info">' + $('#partno-input').val() + '</p>';
|
|
|
|
$('#partno-input').replaceWith(partno_par);
|
|
|
|
$('#partno-input').replaceWith(partno_par);
|
|
|
|
|
|
|
|
|
|
|
@ -78,6 +86,7 @@ function end_edit() {
|
|
|
|
|
|
|
|
|
|
|
|
function save(partID) {
|
|
|
|
function save(partID) {
|
|
|
|
var block_v = $('#block-input').val();
|
|
|
|
var block_v = $('#block-input').val();
|
|
|
|
|
|
|
|
var type_v = $('#type-input').val();
|
|
|
|
var partno_v = $('#partno-input').val();
|
|
|
|
var partno_v = $('#partno-input').val();
|
|
|
|
var description_v = $('#description-input').val();
|
|
|
|
var description_v = $('#description-input').val();
|
|
|
|
var quantity_v = $('#quantity-input').val();
|
|
|
|
var quantity_v = $('#quantity-input').val();
|
|
|
@ -99,6 +108,7 @@ function save(partID) {
|
|
|
|
if (datasheet.length == 1)
|
|
|
|
if (datasheet.length == 1)
|
|
|
|
data.append('datasheet-file', datasheet[0]);
|
|
|
|
data.append('datasheet-file', datasheet[0]);
|
|
|
|
data.append('block', block_v);
|
|
|
|
data.append('block', block_v);
|
|
|
|
|
|
|
|
data.append('type', type_v);
|
|
|
|
data.append('partno', partnos[0]);
|
|
|
|
data.append('partno', partnos[0]);
|
|
|
|
if (partnos.length > 1)
|
|
|
|
if (partnos.length > 1)
|
|
|
|
data.append('partnoalt', partnos[1]);
|
|
|
|
data.append('partnoalt', partnos[1]);
|
|
|
@ -124,6 +134,9 @@ function save(partID) {
|
|
|
|
var datasheet_par = '<p id="datasheet-info"><i class="fa fa-check"></i></p>';
|
|
|
|
var datasheet_par = '<p id="datasheet-info"><i class="fa fa-check"></i></p>';
|
|
|
|
$('#datasheet-info').replaceWith(datasheet_par);
|
|
|
|
$('#datasheet-info').replaceWith(datasheet_par);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
error: function() {
|
|
|
|
|
|
|
|
alert("Couldn't update the part information. Please retry.");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -141,6 +154,7 @@ function text_filter(string) {
|
|
|
|
function show_part_info(partID) {
|
|
|
|
function show_part_info(partID) {
|
|
|
|
$.getJSON('https://www.elab.kth.se/parts/getpartinfo/' + partID, function(data) {
|
|
|
|
$.getJSON('https://www.elab.kth.se/parts/getpartinfo/' + partID, function(data) {
|
|
|
|
$('#block-info').text(text_filter(data.block));
|
|
|
|
$('#block-info').text(text_filter(data.block));
|
|
|
|
|
|
|
|
$('#type-info').text(text_filter(data.type));
|
|
|
|
$('#partno-info').text(text_filter(data.partno) + ' ' + text_filter(data.partnoalt) + ' ' + text_filter(data.partnoalt2));
|
|
|
|
$('#partno-info').text(text_filter(data.partno) + ' ' + text_filter(data.partnoalt) + ' ' + text_filter(data.partnoalt2));
|
|
|
|
$('#description-info').text(text_filter(data.description));
|
|
|
|
$('#description-info').text(text_filter(data.description));
|
|
|
|
$('#quantity-info').text(text_filter(data.quantity));
|
|
|
|
$('#quantity-info').text(text_filter(data.quantity));
|
|
|
|