Skip to content

Commit

Permalink
Exclude special fields from default infoTemplate for identify.
Browse files Browse the repository at this point in the history
  • Loading branch information
tmcgee committed Nov 7, 2015
1 parent 711693a commit 8ebacf8
Showing 1 changed file with 23 additions and 9 deletions.
32 changes: 23 additions & 9 deletions viewer/js/gis/dijit/Identify.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ define([
draggable: false,
layerSeparator: '||',
allLayersId: '***',
excludedFields: [
'objectid', 'esri_oid', 'shape',
'shape.len', 'shape_length',
'shape_len', 'shape.stlength()',
'shape.area', 'shape_area', 'shape.starea()'
],

postCreate: function () {
this.inherited(arguments);
Expand Down Expand Up @@ -339,13 +345,13 @@ define([

// if no Popup config found, create one with all attributes or layer fields
if (!popup) {
popup = this.createInfoTemplate(layer, layerId, result);
popup = this.createDefaultInfoTemplate(layer, layerId, result);
}

return popup;
},

createInfoTemplate: function (layer, layerId, result) {
createDefaultInfoTemplate: function (layer, layerId, result) {
var popup = null, fieldInfos = [];

var layerName = this.getLayerName(layer);
Expand All @@ -359,8 +365,9 @@ define([
if (attributes) {
for (var prop in attributes) {
if (attributes.hasOwnProperty(prop)) {
fieldInfos.push({
this.addDefaultFieldInfo(fieldInfos, {
fieldName: prop,
label: prop.replace(/_/g, ' '),
visible: true
});
}
Expand All @@ -371,29 +378,29 @@ define([
} else if (layer._outFields && (layer._outFields.length) && (layer._outFields[0] !== '*')) {

var fields = layer.fields;
array.forEach(layer._outFields, function (fieldName) {
array.forEach(layer._outFields, lang.hitch(this, function (fieldName) {
var foundField = array.filter(fields, function (field) {
return (field.name === fieldName);
});
if (foundField.length > 0) {
fieldInfos.push({
this.addDefaultFieldInfo(fieldInfos, {
fieldName: foundField[0].name,
label: foundField[0].alias,
visible: true
});
}
});
}));

// from the fields layer
} else if (layer.fields) {

array.forEach(layer.fields, function (field) {
fieldInfos.push({
array.forEach(layer.fields, lang.hitch(this, function (field) {
this.addDefaultFieldInfo(fieldInfos, {
fieldName: field.name,
label: field.alias,
visible: true
});
});
}));
}

if (fieldInfos.length > 0) {
Expand All @@ -411,6 +418,13 @@ define([
return popup;
},

addDefaultFieldInfo: function (fieldInfos, field) {
var nameLC = field.fieldName.toLowerCase();
if (array.indexOf(this.excludedFields, nameLC) < 0) {
fieldInfos.push(field);
}
},

createIdentifyLayerList: function () {
var id = null;
var identifyItems = [];
Expand Down

0 comments on commit 8ebacf8

Please sign in to comment.