Various small changes

master
Davide Bongiovanni 6 years ago
parent 95fe77ce16
commit 240293cf01

@ -1,6 +1,7 @@
function init_edit(partID) {
$('table#details tr#location td p').hide();
$('table#details tr#location td select').show();
$('#location-dropdown').show();
$('#container-dropdown').show();
$('table#details tr#partno td p').hide();
$('table#details tr#partno td input').show();
@ -25,6 +26,7 @@ function new_entry() {
$('table#details tr#description td p').text('');
$('table#details tr#partno td input').val('');
$('table#details tr#description td input').val('');
container_onchange();
init_edit(-1);
overlay_in();
}
@ -33,7 +35,8 @@ function end_edit() {
$('table#details tr#location td p').text($('table#details tr#location td select option:checked').text());
$('table#details tr#location td p').show();
$('table#details tr#location td select').hide();
$('#location-dropdown').hide();
$('#container-dropdown').hide();
$('table#details tr#partno td p').text($('table#details tr#partno td input').val());
$('table#details tr#partno td p').show();
@ -132,14 +135,17 @@ function delete_entry(partID) {
function show_part_info(partID) {
$.getJSON(rootURL + 'getpartinfo/' + partID, function(data) {
$('table#details tr#location td p').text(text_filter(data.location_descriptor)); // name is the location friendly name
$('table#details tr#location td select').val(data.location_id); // name is the location friendly name
$('#location-dropdown').val(data.location_id);
$('#container-dropdown').val(data.container_id);
$('table#details tr#partno td p').text(text_filter(data.partno));
$('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));
$('img#map').attr('src', 'parts/map/' + data.container_id);
if (data.datasheet != null)
$('tr#datasheet-head').html($('<td>DATASHEET: <a href="' + rootURL + 'getfile/' + data.datasheet.substring(0, data.datasheet.length - 4) + '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
container_onchange();
if (data.datasheet != null) {
$('tr#datasheet-head').html($('<td>DATASHEET: <a href="' data.datasheet '"><i class="fa fa-file-text" aria-hidden="true"></i></a></td>'));
$('#datasheet-input').val(data.datasheet);
}
else
$('tr#datasheet-head td').text('DATASHEET: ');
$('#edit-button').click(function() {
@ -188,6 +194,7 @@ function perform_query() {
function container_onchange() {
var selected_container_id = $('#container-dropdown').val();
if (selected_container_id > 0) {
$('img#map').attr('src', 'parts/map/' + selected_container_id);
$('#location-dropdown').empty();
$.getJSON('parts/getlocationsInContainer/' + selected_container_id, function(data) {
@ -196,6 +203,7 @@ function container_onchange() {
});
});
}
}
$(document).ready(function() {
$.ajaxSetup({ cache: false });

Loading…
Cancel
Save