Compare commits
4
Commits
6670487ac0
...
4c78533976
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c78533976 | ||
|
|
240293cf01 | ||
|
|
95fe77ce16 | ||
|
|
90079c70cd |
+29
-13
@@ -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,13 +202,15 @@ function perform_query() {
|
|||||||
|
|
||||||
function container_onchange() {
|
function container_onchange() {
|
||||||
var selected_container_id = $('#container-dropdown').val();
|
var selected_container_id = $('#container-dropdown').val();
|
||||||
$('img#map').attr('src', 'parts/map/' + selected_container_id);
|
if (selected_container_id > 0) {
|
||||||
$('#location-dropdown').empty();
|
$('img#map').attr('src', 'parts/map/' + selected_container_id);
|
||||||
$.getJSON('parts/getlocationsInContainer/' + selected_container_id, function(data) {
|
$('#location-dropdown').empty();
|
||||||
$.each(data, function(location_id, location_name) {
|
$.getJSON('parts/getlocationsInContainer/' + selected_container_id, function(data) {
|
||||||
$('#location-dropdown').append('<option val="' + location_id + '">' + location_name + '</option>');
|
$.each(data, function(location_id, location_name) {
|
||||||
|
$('#location-dropdown').append('<option val="' + location_id + '">' + location_name + '</option>');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|||||||
@@ -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%;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user