location editor can now be used to edit locations. And add them!

This commit is contained in:
2018-11-12 20:56:12 +01:00
parent a99a356985
commit 954b449757
4 changed files with 87 additions and 41 deletions
+49 -17
View File
@@ -1,27 +1,25 @@
function new_location_entry() {
$('#location-name-input').text('');
$('#location-name-input').show();
$('#mapfile-input').show();
init_Location_edit(-1);
}
function init_Location_edit(locationID, name, containerID) {
var newButton = '<div class="round-button-left"><a href="#" onclick="saveLocation(' + locationID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
$('#save-button').attr("onclick", "saveLocation(" + locationID + ")");
$('#location-name-input').val(name);
if(containerID > 0){
$("#container-input").val(containerID);
}
overlay_in();
}
function init_Location_edit(locationID) {
$('table#details tr#datasheet td input').show();
var newButton = '<div class="round-button-left"><a href="#" onclick="saveLocation(' + locationID + ')"><i class="fa fa-check" aria-hidden="true"></i></a></div>';
$('.round-button-left').replaceWith(newButton);
}
function update_clickable_map() {
var selected_map_file = $('#mapfile-input').val();
$('#clickablemap').attr('src', 'map/' + selected_map_file);
function update_map() {
var selected_map_file = $('#container-input').val();
$('#map').attr('src', 'map/' + selected_map_file);
}
function saveLocation(locationID) {
var map_v = $('#clickablemap').attr('src').substring(4);
var container_v = $('#container-input').val();
var name_v = $('#location-name-input').val();
if(name_v.length > 100) {
@@ -30,7 +28,7 @@ function saveLocation(locationID) {
}
var data = new FormData();
data.append('map', map_v);
data.append('container', container_v);
data.append('name', name_v)
$.ajax({
@@ -54,7 +52,41 @@ function saveLocation(locationID) {
});
}
function end_edit(){
//intentionally left blank
}
function show_location_info(locationID) {
$.getJSON(rootURL + 'getpartinfo/' + partID, function(data) {
$('table#details tr#location td p').text(text_filter(data.location_descriptor)); // 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));
container_onchange();
if (data.datasheet != null) {
$('tr#datasheet-head').html($('<td>DATASHEET: <a href="parts/getfile/' + 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() {
init_edit(partID);
});
$('#delete-button').click(function() {
delete_entry(partID);
});
overlay_in();
}).fail(function() {
console.log( "Fetching part info failed" );
});
}
function placeMarker(locationID){
//temporarily not used
var $img = $('#clickablemap');
var currentClickPosX = event.pageX - $img.offset().left;
var currentClickPosY = event.pageY - $img.offset().top;
+10
View File
@@ -399,4 +399,14 @@ td p {
.pinfo-input {
display: none;
width: 90%;
}
.nothidden{
display: initial !important;
}
.results-locations{
max-width: 1000px;
margin-left: auto;
margin-right: auto;
}