Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude special fields from default infoTemplate for identify. #479

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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