Skip to content
This repository has been archived by the owner on Jan 9, 2020. It is now read-only.

Commit

Permalink
Layout the table templates and fix geojson props
Browse files Browse the repository at this point in the history
  • Loading branch information
doruk.ozturk committed Dec 1, 2016
1 parent 8fc98de commit 423574e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 48 deletions.
59 changes: 12 additions & 47 deletions web_external/js/views/widgets/WMSFeatureInfoWidget.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,34 @@
minerva.views.WmsFeatureInfoWidget = minerva.View.extend({

callInfo: function (event) {
var that = this;

var that = this

function getActiveWmsLayers () {
function getActiveWmsLayers() {
return _.chain(that.parentView.collection.models)
.filter(function (set) { return set.get('displayed') && set.getDatasetType() !== 'geojson'; })
.map(function (dataset) { return dataset.get('_id'); })
.value();
}

function getActiveGeojsonLayers () {
function getActiveGeojsonLayers() {
var geojsonLayers = [];
_.chain(that.parentView.collection.models)
.filter(function (set) { return set.get('displayed') && set.getDatasetType() === 'geojson'; })
.map(function (dataset) {
var layer = {};
var features = dataset.geoJsLayer.features();
var props = [];
_.each(features, function (feature) {
var hits = feature.pointSearch(event.geo);
if (hits && hits.found) {
props.push.apply(props, _.pluck(hits.found, 'properties'));
if (hits && hits.found.length !== 0) {
layer['properties'] = hits.found[0].properties;
}
});
layer['id'] = dataset.get('name');
layer['properties'] = props;
geojsonLayers.push(layer);
return geojsonLayers;
});

return geojsonLayers
return geojsonLayers;
}

function getInspectMapParams(event) {
Expand Down Expand Up @@ -72,39 +70,6 @@ minerva.views.WmsFeatureInfoWidget = minerva.View.extend({
var activeGeojsonLayers = getActiveGeojsonLayers();
var inspectResp = obj.features.concat(activeGeojsonLayers);
that.renderContents(inspectResp);

/*
var layer_div = document.createElement('div');
layer_div.className = 'accordion';
var tbl_div = document.createElement('div');
var tbl_body = document.createElement('table');
var odd_even = false;
var header = false;
var obj = JSON.parse(data);
$.each(obj.features, function () {
var tbl_row;
if (!header) {
tbl_row = tbl_body.insertRow();
tbl_row.className = 'header';
$.each(this.properties, function (k) {
var cell = tbl_row.insertCell();
cell.appendChild(document.createTextNode(k ? k.toString() : ''));
});
header = true;
}
tbl_row = tbl_body.insertRow();
tbl_row.className = odd_even ? 'odd' : 'even';
$.each(this.properties, function (k, v) {
var cell = tbl_row.insertCell();
cell.appendChild(document.createTextNode(v ? v.toString() : ''));
});
odd_even = !odd_even;
});
tbl_div.appendChild(tbl_body);
layer_div.appendChild(tbl_div);
that.content = that.content + layer_div.outerHTML;
$('#m-wms-info-dialog').html(that.content);
*/
});
} else {
var activeGeojsonLayers = getActiveGeojsonLayers();
Expand All @@ -127,12 +92,12 @@ minerva.views.WmsFeatureInfoWidget = minerva.View.extend({
},

renderContents: function (inspectResp) {
$('#m-wms-info-dialog').html(
minerva.templates.wmsFeatureInfoContent({
layersInfo: inspectResp
})
);
if (inspectResp.length !== 0) {
$('#m-wms-info-dialog').html(
minerva.templates.wmsFeatureInfoContent({
layersInfo: inspectResp
})
);
$('#m-wms-info-dialog').dialog('open');
}
},
Expand Down
14 changes: 13 additions & 1 deletion web_external/templates/widgets/wmsFeatureInfoContent.jade
Original file line number Diff line number Diff line change
@@ -1 +1,13 @@
h4 #{layersInfo}
if layersInfo
each layer in layersInfo
h4= layer.id
.accordion
div
table
tbody
tr(class="header")
each value, key in layer.properties
td= key
tr(class="even")
each value, key in layer.properties
td= value

0 comments on commit 423574e

Please sign in to comment.