// All material copyright ESRI, All Rights Reserved, unless otherwise specified.
// See http://@sbaseurl@/jsapi/jsapi/esri/copyright.txt and http://www.arcgis.com/apps/webappbuilder/copyright.txt for details.

//>>built
define("dojo/_base/declare dojo/_base/lang dojo/_base/html dojo/_base/array dojo/on dojo/query jimu/BaseWidgetSetting".split(" "),function(l,g,a,h,k,b,m){return l([m],{baseClass:"jimu-widget-dsc-setting",postCreate:function(){this.setConfig(this.config)},_createDataSourceNodes:function(){var e=this.appConfig.dataSource.dataSources;h.forEach(Object.keys(e),function(c){var f=a.create("div",{"class":"ds "+(c===this.config.dataSourceId?"selected":""),"data-ds-id":c,innerHTML:e[c].label},this.dataSourceListNode);
this.own(k(f,"click",g.hitch(this,this._onDataSourceClick,c)))},this)},_onDataSourceClick:function(e,c){b(".ds",this.domNode).removeClass("selected");a.addClass(c.target,"selected");a.empty(this.fieldListNode);var f=["esriFieldTypeSmallInteger","esriFieldTypeInteger","esriFieldTypeSingle","esriFieldTypeDouble"];h.filter(this.appConfig.dataSource.dataSources[e].dataSchema.fields,function(d){-1<f.indexOf(d.type)&&(d=a.create("div",{"class":"field "+(d.name===this.config.summaryField?"selected":""),
"data-field-name":d.name,innerHTML:d.alias},this.fieldListNode),this.own(k(d,"click",g.hitch(this,function(n){b(".field",this.domNode).removeClass("selected");a.addClass(n.target,"selected")}))))},this)},setConfig:function(){this._createDataSourceNodes()},getConfig:function(){if(0===b(".ds.selected").length||0===b(".field.selected").length)alert("Please select.");else return{dataSourceId:a.attr(b(".ds.selected")[0],"data-ds-id"),summaryField:a.attr(b(".field.selected")[0],"data-field-name")}}})});