Retour à la documentation
/**
* @class spw.widgets.SpwIdentifyResultRow
*/
define(["dojo/_base/declare", "spw/api/SpwBaseTemplatedWidget", "dojo/dom-construct", "dojo/_base/array", "dojo/_base/lang",
"dojo/dom-style","dojo/query","dojo/on",
"spw/api/CollapserItem", "dojo/i18n!./nls/SpwIdentifyResultRow", "dojo/text!./templates/SpwIdentifyResultRow.html"],
function(declare, SpwBaseTemplatedWidget, domConstruct, array, lang,
Style,Query,on,
CollapserItem,labels, template) {
return declare("spw.widgets.SpwIdentifyResultRow", [SpwBaseTemplatedWidget], /** @lends spw.widgets.SpwIdentifyResultRow.prototype */{
templateString: template,
labels: labels,
_result: null,
_spwLayer: null,
_spwIdentifyResultTable: null,
_cbSelectResult: null,
_rowValues: null,
postMixInProperties: function() {
this.inherited(arguments);
this._name = this._spwLayer.get('name');
},
postCreate: function() {
this.inherited(arguments);
//properties
this._rowValues = new Array();
//TODO : check if needed in the new object layer
if(this._spwLayer.fields && this._spwLayer.fields.length > 0) {
for(var j=0; j<this._spwLayer.fields.length; j++) {
var td = null;
if(this._spwLayer.fields[j].isHyperlink) {
var linkLabel = this._result.feature.attributes[this._spwLayer.fields[j].alias];
if(this._spwLayer.fields[j].hyperlinkLabel != null && this._spwLayer.fields[j].hyperlinkLabel != ""){
linkLabel = this._spwLayer.fields[j].hyperlinkLabel;
}
this._rowValues.push(this._result.feature.attributes[this._spwLayer.fields[j].alias]);
td = domConstruct.create("td", {
innerHTML: "<a href='"+this._result.feature.attributes[this._spwLayer.fields[j].alias]+"' target='_blank'>"+linkLabel+"</a>"
}, this.domNode);
td.feature = this._result.feature;
}
else {
this._rowValues.push(this._result.feature.attributes[this._spwLayer.fields[j].alias]);
td = domConstruct.create("td", {
innerHTML: this.nvl(this._result.feature.attributes[this._spwLayer.fields[j].alias],"")
}, this.domNode);
td.feature = this._result.feature;
}
on(td, "click", lang.hitch(this, function(e){
this.spwViewer.spwMap.zoomToFeature(td.feature);
}));
}
} else {
for (key in this._result.feature.attributes) {
if( key.toUpperCase().indexOf("SHAPE") != 0
&& key.toUpperCase().indexOf("SE_ANNO_CAD_DATA" ) != 0
&& key.toUpperCase().indexOf("OBJECTID") != 0) {
this._rowValues.push(this.nvl(this._result.feature.attributes[key],""));
var td = domConstruct.create("td", {innerHTML: this.nvl(this._result.feature.attributes[key],"")}, this.domNode);
td.feature = this._result.feature;
on(td, "click", lang.hitch(this,this.onRowClick));
}
}
}
},
onRowClick:function(e){
if(e && e.target && e.target.feature && e.target.feature.geometry){
e.target.feature.geometry.spatialReference = this.spwViewer.get('spatialReference');
}
this.spwViewer.get('spwMap').zoomToFeature(e.target.feature);
},
nvl: function(val,rep) {
try {
if(val && val != null && typeof val != "undefined" && val.toLowerCase() != "null") {
return val;
}
else {
return rep;
}
}
catch(Error) {
return rep;
}
},
onMouseOver: function() {
this.spwViewer.get('spwMap').showFeature(this._result.feature);
},
onMouseOut: function() {
this.spwViewer.get('spwMap').removeFeature(this._result.feature);
},
isSelected: function() {
return this._cbSelectResult && this._cbSelectResult.checked;
},
setSelected: function(selected) {
if(this._cbSelectResult) {
this._cbSelectResult.set('checked', selected);
}
},
destroy: function() {
this.onMouseOut();
this.inherited(arguments);
},
onClickImgDeleteResult: function() {
this._spwIdentifyResultTable.deleteRow(this);
},
onChangeCbSelectResult: function(checked) {
this._spwIdentifyResultTable.onRowSelected(checked);
},
getGeometry: function() {
return this._result.feature.geometry;
},
getFeatureFieldValue: function(fieldName) {
return this._result.feature.attributes[fieldName];
},
getRowValues: function() {
return this._rowValues;
}
});
});