4 Commits
Author SHA1 Message Date
davide 4c78533976 Added part number empty check 2018-11-11 22:30:27 +01:00
davide 240293cf01 Various small changes 2018-11-11 22:26:18 +01:00
davide 95fe77ce16 Gave class to dropdown 2018-11-11 22:25:26 +01:00
davide 90079c70cd Removed map upper margin 2018-11-11 22:25:11 +01:00
3 changed files with 31 additions and 15 deletions
+23 -7
View File
@@ -1,6 +1,7 @@
function init_edit(partID) { function init_edit(partID) {
$('table#details tr#location td p').hide(); $('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 p').hide();
$('table#details tr#partno td input').show(); $('table#details tr#partno td input').show();
@@ -25,6 +26,7 @@ function new_entry() {
$('table#details tr#description td p').text(''); $('table#details tr#description td p').text('');
$('table#details tr#partno td input').val(''); $('table#details tr#partno td input').val('');
$('table#details tr#description td input').val(''); $('table#details tr#description td input').val('');
container_onchange();
init_edit(-1); init_edit(-1);
overlay_in(); 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').text($('table#details tr#location td select option:checked').text());
$('table#details tr#location td p').show(); $('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').text($('table#details tr#partno td input').val());
$('table#details tr#partno td p').show(); $('table#details tr#partno td p').show();
@@ -56,8 +59,16 @@ function save(partID) {
var partno_v = $('table#details tr#partno td input').val(); var partno_v = $('table#details tr#partno td input').val();
var description_v = $('table#details tr#description td input').val(); var description_v = $('table#details tr#description td input').val();
var datasheet = $('table#details tr#datasheet td input')[0].files; var datasheet = $('table#details tr#datasheet td input')[0].files;
if(partno_v.length == 0){
alert('Please enter a part number.');
return;
}
if(description_v.length > 200) { if(description_v.length > 200) {
alert('Description too long (max 200 characters).') alert('Description too long (max 200 characters).');
return;
}
if(description_v.length == 0) {
alert('Please enter a description.');
return; return;
} }
var data = new FormData(); var data = new FormData();
@@ -132,14 +143,17 @@ function delete_entry(partID) {
function show_part_info(partID) { function show_part_info(partID) {
$.getJSON(rootURL + 'getpartinfo/' + partID, function(data) { $.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 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 p').text(text_filter(data.partno));
$('table#details tr#partno td input').val(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 p').text(text_filter(data.description));
$('table#details tr#description td input').val(text_filter(data.description)); $('table#details tr#description td input').val(text_filter(data.description));
$('img#map').attr('src', 'parts/map/' + data.container_id); container_onchange();
if (data.datasheet != null) 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>')); $('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 else
$('tr#datasheet-head td').text('DATASHEET: '); $('tr#datasheet-head td').text('DATASHEET: ');
$('#edit-button').click(function() { $('#edit-button').click(function() {
@@ -188,6 +202,7 @@ function perform_query() {
function container_onchange() { function container_onchange() {
var selected_container_id = $('#container-dropdown').val(); var selected_container_id = $('#container-dropdown').val();
if (selected_container_id > 0) {
$('img#map').attr('src', 'parts/map/' + selected_container_id); $('img#map').attr('src', 'parts/map/' + selected_container_id);
$('#location-dropdown').empty(); $('#location-dropdown').empty();
$.getJSON('parts/getlocationsInContainer/' + selected_container_id, function(data) { $.getJSON('parts/getlocationsInContainer/' + selected_container_id, function(data) {
@@ -195,6 +210,7 @@ function container_onchange() {
$('#location-dropdown').append('<option val="' + location_id + '">' + location_name + '</option>'); $('#location-dropdown').append('<option val="' + location_id + '">' + location_name + '</option>');
}); });
}); });
}
} }
$(document).ready(function() { $(document).ready(function() {
+1 -1
View File
@@ -392,7 +392,7 @@ td p {
.map { .map {
position: absolute; position: absolute;
right: 5%; right: 5%;
margin-top: 4%; /*margin-top: 4%;*/
max-height: calc(90% - 42pt); max-height: calc(90% - 42pt);
max-width: 50%; max-width: 50%;
} }
+1 -1
View File
@@ -49,7 +49,7 @@
<option value="{{container['id']}}">{{container['name']}}</option> <option value="{{container['id']}}">{{container['name']}}</option>
{% endfor %} {% endfor %}
</select> </select>
<select id="location-dropdown"> <select class="pinfo-input" id="location-dropdown">
<option value="-1" selected="true">-- Select a container --</option> <option value="-1" selected="true">-- Select a container --</option>
</select> </select>
</td></tr> </td></tr>