Retour à la documentation
/**
* @class spw.widgets.SpwIdentifyResult
*/
define(["dojo/_base/declare", "spw/api/SpwBaseTemplatedWidget", "dojo/dom-construct", "dojo/_base/array", "dojo/_base/lang",
"dojo/dom-style","dojo/dom-construct",
"spw/api/CollapserItem", "dojo/i18n!./nls/SpwIdentifyResult", "dojo/text!./templates/SpwIdentifyResult.html", "dojo/NodeList-traverse"],
function(declare, SpwBaseTemplatedWidget, domConstruct, array, lang,
Style,Construct,
CollapserItem,labels, template) {
return declare("spw.widgets.SpwIdentifyResult", [SpwBaseTemplatedWidget], /** @lends spw.widgets.SpwIdentifyResult.prototype */{
templateString: template,
labels: labels,
_layersCollapserItems: null,
_resultTableWidgetClass: null,
_resultTableWidgetConfig: null,
allowUseSelectionIdentify: false,
exportCsvServerUrl: false,
/**
* @constructs
* @param config
*/
constructor: function(){
this._layersCollapserItems = new Array();
},
postMixInProperties: function() {
this.inherited(arguments);
array.forEach(this.widgets, lang.hitch(this, function(widget){
if(widget.className == "spw/widgets/SpwIdentifyResultTable"){
require([widget.className], lang.hitch(this, function(widgetClass){
lang.mixin(widget.config, {spwViewer: this.spwViewer});
this._resultTableWidgetConfig = widget.config;
this._resultTableWidgetClass = widgetClass;
}));
}
}));
},
postCreate: function() {
this.inherited(arguments);
this._reportButton.on('click', lang.hitch(this, function() {
this._spwAdvancedIdentify.downloadReport(this._spwAdvancedIdentify._reportResults);
}));
},
addResults: function(results, spwLayer) {
var resultCollapserItem = null;
for(var i=0;i<this._layersCollapserItems.length;i++) {
if(this._layersCollapserItems[i]._data.get('id') == spwLayer.get('id')) {
resultCollapserItem = this._layersCollapserItems[i];
break;
}
}
if(resultCollapserItem) {
resultCollapserItem.spwIdentifyResultTable.addResults(results);
}
else {
resultCollapserItem = new CollapserItem({
_label: spwLayer.get('displayLabel') || spwLayer.get('name'),
_data: spwLayer
});
Style.set(resultCollapserItem.itemContentBlock, "paddingLeft", "0px");
Construct.place(resultCollapserItem.domNode,this.domNode,"last");
lang.mixin(this._resultTableWidgetConfig, {
_spwAdvancedIdentify: this._spwAdvancedIdentify,
_results: results,
_spwLayer: spwLayer,
_spwIdentifyResultWidget: this
});
var spwIdentifyResultTable = new this._resultTableWidgetClass(this._resultTableWidgetConfig);
resultCollapserItem.addContent(spwIdentifyResultTable.domNode);
resultCollapserItem.spwIdentifyResultTable = spwIdentifyResultTable;
this._layersCollapserItems.push(resultCollapserItem);
}
},
clearResults: function() {
for(var i=this._layersCollapserItems.length - 1; i>=0; i--) {
this._layersCollapserItems[i].spwIdentifyResultTable.destroy();
this._layersCollapserItems[i].destroy();
}
this._layersCollapserItems = new Array();
},
displayLoadingImage: function() {
Style.set(this.loadingImage, "display", "");
},
hideLoadingImage: function() {
Style.set(this.loadingImage, "display", "none");
},
removeResult: function(spwIdentifyResultTable) {
for(var i=this._layersCollapserItems.length - 1; i>=0; i--) {
if(this._layersCollapserItems[i].spwIdentifyResultTable == spwIdentifyResultTable) {
this._layersCollapserItems[i].spwIdentifyResultTable.destroy();
this._layersCollapserItems[i].destroy();
this._layersCollapserItems.splice(i, 1);
break;
}
}
}
});
});