Skip to content

Commit

Permalink
New feature: relations - add new record in case of editor plugin and …
Browse files Browse the repository at this point in the history
…WFS published related layer
  • Loading branch information
uprel committed Jan 9, 2020
1 parent 15be8e0 commit eef6101
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 3 deletions.
23 changes: 23 additions & 0 deletions client/site/css/popup.css
Expand Up @@ -42,6 +42,29 @@
background: url(../gis_icons/mActionClear.png);
}

.i-add {
display: inline-block;
-moz-box-sizing: border-box;
box-sizing: border-box;
height: 16px;
width: 16px;
padding-top: 16px;
overflow: hidden;
background: url(../libs/ext/resources/images/default/dd/drop-add.gif);

}

.i-table {
display: inline-block;
-moz-box-sizing: border-box;
box-sizing: border-box;
height: 16px;
width: 16px;
padding-top: 16px;
overflow: hidden;
background: url(../gis_icons/contextmenu/table.png);
}


/*
a:link, a:visited
Expand Down
50 changes: 48 additions & 2 deletions client/site/js/FeatureInfoDisplay.js
Expand Up @@ -415,14 +415,20 @@ function parseFIResult(node) {
var layerName = Eqwc.common.getIdentifyLayerNameRevert(sourceLayerName);
var layerId = wmsLoader.layerTitleNameMapping[layerName];
var layer = wmsLoader.layerProperties[layerId];
var countRelations = 0;
var layerTitle = layer.title;
if (showFILayerTitle) {
htmlText += "<h2>" + layerTitle + "</h2>";
}

if(projectData.relations[layerName]) {
countRelations = projectData.relations[layerName].length;
}

while (layerChildNode) {

var fid = layerTitle+"."+layerChildNode.id;
var id = layerChildNode.id;
var fid = layerTitle+"."+id;

if (layerChildNode.hasChildNodes() && layerChildNode.nodeName === "Feature") {
var attributeNode = layerChildNode.firstChild;
Expand All @@ -446,6 +452,16 @@ function parseFIResult(node) {
}
htmlText += "<tr><td colspan='2'>" + select + edit + clear + "</td></tr>";
}

if (countRelations == 1) {
var show = '';
var table = projectData.relations[layerName][0].relate_layer;
var field = projectData.relations[layerName][0].join_field;
var rid = table+"."+id;
var add = '<a class="i-add" href="javascript:;" onclick="identifyAction(\'addRelation\',\'' + rid + '\',\'' + field + '\');"></a>';
htmlText += "<tr><td colspan='2'>" + show + add + "</td></tr>";
}

while (attributeNode) {
if (attributeNode.nodeName == "Attribute") {
var attName = attributeNode.getAttribute("name");
Expand Down Expand Up @@ -477,6 +493,16 @@ function parseFIResult(node) {
htmlText += "<td>" + attName + ":</td>";
}

//TODO finish this for layers with more than 1 relation
if(countRelations > 1) {
var search = projectData.relations[layerName].find(function(currentValue, index, arr) {
return currentValue.count_field.toUpperCase() === attNameCase;
});
if(search) {
attValue += ' ' + search.join_field+'='+id;
}
}

if (attNameCase == filesAlias){
if (attValue>'') {
var attArr = Ext.util.JSON.decode(attValue);
Expand Down Expand Up @@ -621,7 +647,7 @@ function updateAddress(data, location, field, template, templateMin, factor) {

}

function identifyAction(type,id) {
function identifyAction(type, id, extra) {

var layer = id.split('.')[0];
if (id.split('.')[1] == 'undefined') {
Expand All @@ -648,6 +674,26 @@ function identifyAction(type,id) {

break;

case 'addRelation' :

var check = checkEditorState(layerId);
if(check) {
var preparePass = prepareEdit(projectData.layers[layerId]);

var feat = new OpenLayers.Feature.Vector();
feat.state = OpenLayers.State.INSERT;

if (preparePass) {

feat.data[extra] = id.split('.')[1];

editor.editLayer.addFeatures([feat]);
editor.attributesForm.loadRecord(feat);
}
}

break;

case 'select' :

var hasGeom = false;
Expand Down
4 changes: 4 additions & 0 deletions client_common/load.php
Expand Up @@ -27,6 +27,9 @@
if (!property_exists($settings, "wsgi")) {
$settings->wsgi = null;
}
if (!property_exists($settings, "relations")) {
$settings->relations = null;
}
if (!property_exists($settings, "locationServices")) {
$settings->locationServices = null;
}
Expand Down Expand Up @@ -80,6 +83,7 @@
projectData.layerSpecifics = eval(<?php echo json_encode($settings->layerSpecifics) ?>);
projectData.geoCode = eval(<?php echo json_encode($settings->geoCode) ?>);
projectData.wsgi = eval(<?php echo json_encode($settings->wsgi) ?>);
projectData.relations = eval(<?php echo json_encode($settings->relations) ?>);
projectData.locationServices = eval(<?php echo json_encode($settings->locationServices) ?>);
projectData.defaultCoordinatesCrsCode = eval(<?php echo json_encode($settings->defaultCoordinatesCrsCode) ?>);
projectData.editor = eval(<?php echo json_encode($settings->editor) ?>);
Expand Down
2 changes: 1 addition & 1 deletion index.php
Expand Up @@ -245,7 +245,7 @@ function goMobile($lang, $scanner) {
<link rel="stylesheet" type="text/css" href="client/site/libs/ext/ux/css/ux-all.css?v=20180219"/>
<link rel="stylesheet" type="text/css" href="client/site/css/TriStateTreeAndCheckbox.css?v=20191026"/>
<link rel="stylesheet" type="text/css" href="client/site/css/ThemeSwitcherDataView.css"/>
<link rel="stylesheet" type="text/css" href="client/site/css/popup.css?v=20171108"/>
<link rel="stylesheet" type="text/css" href="client/site/css/popup.css?v=20200109"/>
<link rel="stylesheet" type="text/css" href="client/site/css/layerOrderTab.css"/>
<link rel="stylesheet" type="text/css" href="client/site/css/contextMenu.css?v=20191222"/>

Expand Down

0 comments on commit eef6101

Please sign in to comment.