Commit 079016c3 authored by Stefan Funk's avatar Stefan Funk 🐧
Browse files

Merge branch 'hotfix/2.7.4'

parents d3a571dc bbf4c970
......@@ -17,7 +17,7 @@ node {
sh 'rm -rf PLATIN'
// TODO: Set version number in the HTML pages, too! Decide between releases and snapshots: SNAPSHOTs are put into the SNAPSHOTS repo, releases and BETAs are put into the RELEASES repo!
package_version = '2.7.3'
package_version = '2.7.4'
name = 'dariahde-geobrowser'
description = 'DARIAH-DE Geo-Browser'
url = 'https://geobrowser.de.dariah.eu/'
......
......@@ -228,7 +228,7 @@
</div> <!-- id="content-layout" -->
<div class="row-fluid">
<div class="span12 no-margin footer">
<span>Datasheet Editor version 2.7.3 &copy;2019 DARIAH-DE</span>
<span>Datasheet Editor version 2.7.4 &copy;2019 DARIAH-DE</span>
<ul class="pull-right inline">
<!--li><a href="https://validator.w3.org/nu/?doc=http://geobrowser.de.dariah.eu/v2/edit/index.html">nu HTML checker</a></li-->
<li><a href="https://de.dariah.eu/impressum">Imprint</a></li>
......
......@@ -24,6 +24,7 @@ function initMap() {
map.setCenter(0, 0);
}
/*
function startTGN() {
$('#tgnArea').show();
......@@ -103,6 +104,88 @@ function startTGN() {
});
}
*/
/*
*
*/
function startTGN() {
$('#tgnArea').show();
// do nothing if there are columns missing
if(!checkColumnHeaders()) return;
var arr = $('#dataTable').handsontable('getDataReference');
$('#tgnList').empty();
var addressColumn = findColumn(arr, 'Address');
// get list of places from multidimensional array,
// do not return the "Address" header or emtpy strings
var places = $.map(arr, function(x) {
var ret = x[addressColumn];
if(!isEmptyString(ret) && ret !== 'Address') {
// remove whitespaces
return $.trim(ret);
}
});
// somehow sort() & $.unique() failed on chromium, this solution using underscore.js works:
//http://stackoverflow.com/questions/4833651/javascript-array-sort-and-unique
var sortUnique = _.compose(_.uniq, function(array) {
return _.sortBy(array, _.identity);
});
places = sortUnique(places);
$.each(places, function(index, place) {
var placeAlreadySetInTable = false;
$.get(tgnURL, {q : place, georef : 'true'}).success(function(xml){
var elemId = 'tgn_' + place.replace(' ', '_');
var elem = '<div class="input-append">'
+ '<h4 style="margin-bottom:3px;">' + place + '</h4>'
+ '<p><select style="width:64%;" id="' + elemId + '"></select>'
+ '<button class="btn" style="width:18%;" id="pick_' + elemId + '" title="Show this place in the map selection the right."><i class="icon-eye-open"></i>&nbsp;Map</button>'
+ '<button class="btn" style="width:18%;" id="setAll_' + elemId + '" title="Sets all places with this name to the choosen coordinates."><i class="icon-pencil"></i>&nbsp;Set</button>'
+ '</p></div>';
console.log("elem " + elemId + ": ", elem);
$('#tgnList').append(elem);
// Bind function to change event.
$('#' + elemId).change(placeChanged);
$('#pick_' + elemId).bind('click', pickPlace);
$('#setAll_' + elemId).bind('click', setAllPlacesTGN);
$(xml).find('term').each(function (index, val) {
var id = $(this).attr('id');
id = id.substring(id.indexOf(':') + 1);
var path = $(this).find('path').text();
var name = $(this).find('name').text();
var variant = $(this).find('variant').text();
// Check for empty or not existing name tag, use match_name instead.
if (name == "") {
name = $(this).find('match_name').text();
}
var lat = $(this).find('latitude').text();
var long = $(this).find('longitude').text();
// Only add places with exact match or variant involved!
if (place === name || variant.includes(place)) {
$('#' + elemId).append('<option value="' + name + '|' + id + '|' + lat + '|' + long + '">' + name + ': ' + path + '</option>');
}
// Set coordinates of place to first returned entry with exact title match.
if (!placeAlreadySetInTable && (place === name || variant.includes(place))) {
updateCoordinates(name, lat, long, id, false, variant);
placeAlreadySetInTable = true;
}
});
});
});
}
function setOSMapCenter(lat, long, zoomLevel) {
$('#osmLat').val(lat);
......
/* function dealing with the handsontable widget
*
* TODO:
* - encapsulate handsontable requests
*
* TODO:
* - encapsulate handsontable requests
*/
function initTable() {
$("#dataTable").handsontable({
rows: 40,
cols: 10,
rowHeaders: true, // 123
colHeaders: true, // ABC
minSpareCols: 1, //always keep at least 1 spare row at the right
minSpareCols: 1, //always keep at least 1 spare row at the right
minSpareRows: 1, //always keep at least 1 spare row at the bottom
contextMenu: true, // menu for add rows or cols,
legend: [
......@@ -40,15 +40,15 @@ function initTable() {
}
],
onChange: function (change, source) {
console.log('onCHange called with source ' + source);
console.log('onCHange called with source ' + source);
//console.log('source' + source);
if (source === 'loadData') {
return; //don't save this change
}
autoSave(change);
}
});
}
......@@ -64,20 +64,20 @@ function checkColumnHeaders() {
var arr = $('#dataTable').handsontable('getDataReference');
var ready = true;
$('#missingCols').empty();
$(requiredColumns).each(function(index,val) {
ready = findOrAlertColumn(arr, val) >=0 && ready;
});
$(addableColumns).each(function(index, val) {
//findOrCreateColumn(arr, val);
ready = findOrAlertCreatableColumn(arr, val) >=0 && ready;
});
return ready;
}
function findColumn(arr, columnName) {
......@@ -95,7 +95,7 @@ function findOrAlertColumn(arr, columnName) {
function findOrAlertCreatableColumn(arr, columnName) {
var id = $.inArray(columnName, arr[0]);
if(id<0) {
if(id<0) {
var message = '<p>You could create missing column <strong>'+ columnName +'</strong> and try again.'
+ '&nbsp;<button class="btn btn-warning" onclick="createColumn(\''+columnName+'\');">Create</button></p>';
newAlert('error', 'Missing Column', message, 'columnAlert');
......@@ -106,7 +106,7 @@ function findOrAlertCreatableColumn(arr, columnName) {
function createColumn(columnName) {
var arr = $('#dataTable').handsontable('getDataReference');
var id = $.inArray(columnName, arr[0]);
// entry not existing, create
if(id<0) {
var colId;
......@@ -116,44 +116,51 @@ function createColumn(columnName) {
colId=index;
}
});
//console.log('empty col: ' + colId);
$('#dataTable').handsontable('selectCell', 0, colId-1);
$('#dataTable').handsontable('alter', 'insert_col', colId-1);
$('#dataTable').handsontable('setDataAtCell', 0, colId-1, columnName);
//console.log('tried:' + colId + ' ' + columnName);
}
return id;
}
function updateCoordinates(address, lat, long, gettyId, forceOverwrite) {
var arr = $('#dataTable').handsontable('getDataReference');
/**
* Table is filled with coords and Getty IDs only if address is contained in table's address field
* or address field is empty AND (if given) address field content is contained in variant string.
*
* Getty ID is only overwritten if also not existing!
*/
function updateCoordinates(address, lat, long, gettyId, forceOverwrite, variant) {
// In case variant is not existing or given.
if (!variant) {
variant = "";
}
var arr = $('#dataTable').handsontable('getDataReference');
var addressColumn = findColumn(arr, 'Address');
var longColumn = findColumn(arr, 'Longitude');
var latColumn = findColumn(arr, 'Latitude');
var gettyColumn = findColumn(arr, 'GettyID');
var save = false;
//console.log("trying to write" + address + " at " + long + "|" + lat );
$(arr).each(function(index, val){
if($.trim(val[addressColumn])===$.trim(address)) {
if(forceOverwrite || (isEmptyString(val[longColumn]) && isEmptyString(val[latColumn]))) {
//console.log('found ' + index );
if(forceOverwrite) console.log('forced overwrite at ' + index);
$(arr).each(function(index, val) {
if ($.trim(val[addressColumn]) === $.trim(address) || ($.trim(val[addressColumn]) !== "" && variant.includes($.trim(val[addressColumn])))) {
if (forceOverwrite || (isEmptyString(val[longColumn]) && isEmptyString(val[latColumn]) && isEmptyString(val[gettyColumn]))) {
$('#dataTable').handsontable('setDataAtCell', index, longColumn, long);
$('#dataTable').handsontable('setDataAtCell', index, latColumn, lat);
$('#dataTable').handsontable('setDataAtCell', index, gettyColumn, gettyId);
save = true;
} else {
//console.log('entry not overwritten at ' + index);
}
}
});
// trigger autosave functionality manually
if(save) autoSave();
if(save) {
autoSave();
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment