// 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
require({cache:{"url:widgets/CostAnalysis/setting/ReportSettings.html":'\x3cdiv class\x3d"esriCTMainConfigurationContainer"\x3e\r\n  \x3cdiv style\x3d"margin-bottom: 10px"\x3e\r\n      \x3cdiv class\x3d"esriCTReportNameLabel esriCTEllipsis"\x3e ${nls.generalSettings.reportSettings.reportNameLabel}\x3c/div\x3e\r\n      \x3cdiv style\x3d"width:70%" data-dojo-attach-point\x3d"reportNameNode" required\x3d"true" data-dojo-type\x3d"dijit/form/TextBox"\x3e\x3c/div\x3e\r\n  \x3c/div\x3e\r\n\r\n  \x3cdiv\x3e\r\n      \x3cdiv class\x3d"esriCTReportSettingsTable" data-dojo-attach-point\x3d"reportSettingsTableNode"\x3e\x3c/div\x3e\r\n  \x3c/div\x3e\r\n\r\n\x3c/div\x3e'}});
define("dojo/_base/declare jimu/dijit/Popup jimu/dijit/SimpleTable dijit/_WidgetBase dojo/Evented dijit/_TemplatedMixin dijit/_WidgetsInTemplateMixin dojo/text!./ReportSettings.html ../utils dojo/_base/array dojo/_base/lang jimu/dijit/Message dijit/form/TextBox".split(" "),function(l,m,n,p,q,r,t,u,k,g,e,v,w){return l([p,r,q,t],{templateString:u,popup:null,_reportSettingsTable:null,_tableTitleFields:{Layer:"layerName","Feature Template":"TEMPLATENAME",Geography:"GEOGRAPHY",Scenario:"SCENARIO",Count:"count",
Length:"Length",Area:"Area",Equation:"COSTEQUATION",Cost:"cost"},baseClass:"jimu-widget-cost-analysis-report-settings",constructor:function(a){e.mixin(this,a)},startup:function(){this._init()},postCreate:function(){this.popup=null;this.inherited(arguments)},_init:function(){this.isLoad?(this._addAbbreviationForTitle(),this._createDataForInitialLoad(),this.emit("onInitialLoad",this.previousReportSettings)):(this.previousReportSettings||(this._addAbbreviationForTitle(),this._createDataForInitialLoad()),
this._createReportSettingsTable(),this._createReportSettingsPopup())},_addAbbreviationForTitle:function(){var a;for(a in this._tableTitleFields)if("Length"===a){var b=k.units[this.config.generalSettings.measurementUnit].lengthAbbr;this._tableTitleFields[a+" ("+b+")"]=this._tableTitleFields[a];delete this._tableTitleFields[a]}else"Area"===a?(b=k.units[this.config.generalSettings.measurementUnit].areaAbbr,this._tableTitleFields[a+" ("+b+")"]=this._tableTitleFields[a],delete this._tableTitleFields[a]):
"Cost"===a&&(b=this.config.generalSettings.currency,this._tableTitleFields[a+" ("+b+")"]=this._tableTitleFields[a],delete this._tableTitleFields[a])},_createReportSettingsTable:function(){this.popup=new m({titleLabel:this.nls.generalSettings.reportSettings.reportSettingsPopupTitle,content:this.domNode,width:800,height:500,autoHeight:!0,"class":this.baseClass,buttons:[{label:this.nls.common.ok,onClick:e.hitch(this,function(){this.onOkButtonClicked()})},{label:this.nls.common.cancel}]})},onOkButtonClicked:function(){var a=
this._getReportSettings(),b=[];g.forEach(a.reportSettings,function(c){""!==c.columnLabel&&b.push(c.columnLabel)});var f=b.filter(e.hitch(this,function(c,h,d){return d.indexOf(c)!==h}));0<f.length?new v({message:this.nls.generalSettings.reportSettings.duplicateMsg+":"+f[0]}):(this.emit("okButtonClicked",a),this.popup.close())},_createReportSettingsPopup:function(){this._reportSettingsTable=new n({fields:[{name:"showColumn",title:this.nls.generalSettings.reportSettings.checkboxLabel,type:"checkbox",
editable:!1,width:"15%"},{name:"columnTitle",title:this.nls.generalSettings.reportSettings.layerTitle,type:"text",editable:!1,width:"35%"},{name:"columnLabel",title:this.nls.generalSettings.reportSettings.columnLabel,width:"35%",type:"empty"},{name:"actions",title:this.nls.common.actions,width:"15%",type:"actions",actions:["up","down"]}],selectable:!1});this._reportSettingsTable.placeAt(this.reportSettingsTableNode);this._reportSettingsTable.startup();this.previousReportSettings.hasOwnProperty("reportName")&&
this.reportNameNode.set("value",this.previousReportSettings.reportName);this._populateReportSettings()},_createDataForInitialLoad:function(){this.previousReportSettings={};this.previousReportSettings.reportSettings=[];for(var a in this._tableTitleFields)this.previousReportSettings.reportSettings.push({isVisible:!0,columnTitle:a,columnLabel:"",fieldToMap:this._tableTitleFields[a]});this.previousReportSettings.reportName=""},_populateReportSettings:function(){g.forEach(this.previousReportSettings.reportSettings,
e.hitch(this,function(a){this._addNewRow(a)}))},_addNewRow:function(a){this._createRow(a)},_createRow:function(a){var b=this._reportSettingsTable.addRow({showColumn:a.isVisible,columnTitle:a.columnTitle});b.tr.labelTextBox=new w;b.tr.labelTextBox.set("value",a.columnLabel);b.tr.labelTextBox.placeAt(b.tr.cells[2])},_getReportSettings:function(){var a={};var b=this._reportSettingsTable.getData();var f=this._reportSettingsTable.getRows();a.reportSettings=[];g.forEach(b,e.hitch(this,function(c,h){var d=
{};d.isVisible=c.showColumn;d.columnTitle=c.columnTitle;d.columnLabel=f[h].labelTextBox.get("value");d.fieldToMap=this._getFieldTitleAbbr(c.columnTitle);a.reportSettings.push(d)}));a.reportName=this.reportNameNode.get("value");return a},_getFieldTitleAbbr:function(a){return-1<a.indexOf("Length")?"Length":-1<a.indexOf("Area")?"Area":-1<a.indexOf("Cost")?"cost":this._tableTitleFields[a]}})});