var UCDashboardForEditor,WidgetType={Object:"Object",Filter:"Filter",TextBlock:"TextBlock",Button:"Button",Image:"Image",Blank:"Blank"},ControlType={Editbox:"Edit",Checkbox:"Check box",RadioButton:"Radio button",ComboBox:"Combo box",Slider:"Slider",Range:"Range",DropDownList:"Drop-down list",Switch:"Switch"},DataType={Integer:"Numeric (without decimals)",Real:"Numeric (with decimals)",Character:"Character",Boolean:"Boolean",Date:"Date",DateTime:"DateTime",GUID:"GUID"},FilterType={Value:"Value",Range:"Range",
Collection:"Collection"},ParameterType={Value:"Value",Collection:"Collection"},ControlOrientation={Horizontal:"Horizontal",Vertical:"Vertical"},ChartType={Column:"Column",Column3D:"Column3D",StackedColumn:"StackedColumn",StackedColumn3D:"StackedColumn3D",StackedColumn100:"StackedColumn100",Bar:"Bar",StackedBar:"StackedBar",StackedBar100:"StackedBar100",Area:"Area",StackedArea:"StackedArea",StackedArea100:"StackedArea100",SmoothArea:"SmoothArea",StepArea:"StepArea",Line:"Line",StackedLine:"StackedLine",
StackedLine100:"StackedLine100",SmoothLine:"SmoothLine",StepLine:"StepLine",Timeline:"Timeline",SmoothTimeline:"SmoothTimeline",StepTimeline:"StepTimeline",Sparkline:"Sparkline",Pie:"Pie",Pie3D:"Pie3D",Doughnut:"Doughnut",Doughnut3D:"Doughnut3D",LinearGauge:"LinearGauge",CircularGauge:"CircularGauge",Radar:"Radar",FilledRadar:"FilledRadar",PolarArea:"PolarArea",Funnel:"Funnel",Pyramid:"Pyramid",ColumnLine:"ColumnLine",Column3DLine:"Column3DLine"},PlotSeries={InTheSameChart:"InTheSameChart",InSeparateCharts:"InSeparateCharts"},
XAxisLabels={Horizontally:"Horizontally",Rotated30:"Rotated 30º",Rotated45:"Rotated 45º",Rotated60:"Rotated 60º",Vertically:"Vertically"},ShowDataAs={Values:"Values",Percentages:"Percentages",ValuesAndPercentages:"ValuesAndPercentages"},TrendPeriod={SinceTheBeginning:"SinceTheBeginning",LastYear:"LastYear",LastSemester:"LastSemester",LastQuarter:"LastQuarter",LastMonth:"LastMonth",LastWeek:"LastWeek",LastDay:"LastDay",LastHour:"LastHour",LastMinute:"LastMinute",LastSecond:"LastSecond"},Orientation=
{Horizontal:"Horizontal",Vertical:"Vertical"},ShowDataLabelsIn={Columns:"Columns",Rows:"Rows"},ObjectType={Query:"Query",DataProvider:"DataProvider"},OnItemClick={DoNothing:"Do nothing",RaiseItemClick:"Raise ItemClick event",ApplyFilters:"Apply filters",HighlightValues:"Highlight values"},FiltersPosition={Left:"Left",Right:"Right",Top:"Top"},MainTableLayout={Free:"Free",TwoColumns:"Two columns",ThreeColumns:"Three columns",HeaderTwoColumns:"Header + two columns",HeaderThreeColumns:"Header + three columns",
HeaderTwoColumnsFooter:"Header + two columns + footer",HeaderThreeColumnsFooter:"Header + three columns + footer"},QueryViewerAxisType={Rows:"Row",Columns:"Column",Pages:"Page",Data:"Data",Hidden:"NotShow"},QueryViewerFilterType={ShowAllValues:"ShowAllValues",HideAllValues:"HideAllValues",ShowSomeValues:"ShowSomeValues"},QueryViewerAxisOrderType={None:"None",Ascending:"Ascending",Descending:"Descending",Custom:"Custom"},QueryViewerExpandCollapseType={ExpandAllValues:"ExpandAllValues",CollapseAllValues:"CollapseAllValues",
ExpandSomeValues:"ExpandSomeValues"},MAIN_TABLE_ID="1",FILTERS_TABLE_ID="2",ChildType=JSON.parse(JSON.stringify(WidgetType));ChildType.Table=ElementType.Table;function UpdateDashboardEditorElement(n,a,b,c){n=UCDashboardForEditor.editor.GetElement(n);null!=n&&(""!=c&&UCDashboardForEditor.InsertCssRules(c),b=JSON.parse(b),UCDashboardForEditor.UpdateElement(n,b,a))}
function UpdateDashboardEditorParameters(n){var a=UCDashboardForEditor.DashboardObject;a.Parameters=JSON.parse(n);UCDashboardForEditor.LoadParametersDefaults(a);UCDashboardForEditor.UpdateParameterVariables(a)}function SelectAllDashboardElements(){UCDashboardForEditor.editor.SelectAll()}function MouseOverElement(n){UCDashboardForEditor.editor.MouseOver(null,n)}function MouseOutElement(n){UCDashboardForEditor.editor.MouseOut(null,n)}
function MouseClickElement(n){UCDashboardForEditor.editor.SelectElement(null,n,!1,!0)}
function DashboardViewer(n){this.WidgetsExpanded=!0;this.SetItemClickData=function(a){this.ItemClickData=a};this.GetItemClickData=function(){return this.ItemClickData};this.SetFiltersChangedData=function(a){this.FiltersChangedData=a};this.GetFiltersChangedData=function(){return this.FiltersChangedData};this.SetValuesHighlightedData=function(a){this.ValuesHighlightedData=a};this.GetValuesHighlightedData=function(){return this.ValuesHighlightedData};this.show=function(){qv.services.GetDashboardSpecIfNeeded(this,
function(a,b){b.UpdateDashboardObject(a);var c=b.DashboardObject;if(null!=c){var d={dashboard:c,widgetsExpanded:function(){return b.WidgetsExpanded},callbacks:{selectElements:function(a){window.external.SelectElements(a)},selectObjectItem:function(a,b){window.external.SelectObjectItem(a,b)},addElement:function(a,b,c){window.external.AddElement(a,b,c)},moveElement:function(a,b,c){window.external.MoveElement(a,b,c)},moveElements:function(a,b,c){window.external.MoveElements(a,b,c)},addKBObjects:function(a,
b,c){window.external.AddKBObjects(a,b,c)}},layoutDefaults:function(a){b.LayoutDefaults(a)},tableDefaults:function(a){b.TableDefaults(a)},rowDefaults:function(a){b.RowDefaults(a)},cellDefaults:function(a){b.CellDefaults(a)},widgetDefaults:function(a,c,d){b.WidgetDefaults(a,c,d)},getWidgetContentHTML:function(a,c){return b.GetWidgetContentHTML(a,c)},addExtraRow:function(a,c){return 0==c.Rows.length||c.ElementId==FILTERS_TABLE_ID||c.ElementId==MAIN_TABLE_ID&&a.MainTableLayout==MainTableLayout.Free||
b.IsMainTableLayoutTable(c)},widgetOverflowStr:function(){return""},cellHasVisibleContent:function(a,b){return b.ChildType==ChildType.Filter?b.Filter.Visible||a:!0},isMainTableLayoutTable:function(a){return b.IsMainTableLayoutTable(a)},isHeight100Percent:function(a,c,d){return b.IsHeight100Percent(a,c,d)},getElementIcon:function(a){switch(a.WidgetType){case WidgetType.Object:return"Object.ico";case WidgetType.Filter:return"Filter.ico";case WidgetType.TextBlock:return"TextBlock.ico";case WidgetType.Image:return"Image.ico";
case WidgetType.Button:return"Button.ico";default:return""}},getUpperMostAncestorElementId:function(a){do var b=a.ElementId,a=a.ParentElement;while(b!=MAIN_TABLE_ID&&b!=FILTERS_TABLE_ID);return b},onAddElement:function(a,c){b.OnAddElement(a,c)},onRemoveElement:function(a,c){b.OnRemoveElement(a,c)},isEditor:function(){return b.IsDashboardEdit()},dependsOnElement:function(a,c){return b.DependsOnElement(a,c)},impactsElement:function(a,c){return b.ImpactsElement(a,c)},getContainerControlId:function(){return b.getContainerControl().id},
getMe:function(){return b.me()+".editor"},getMessage:function(a){return gx.getMessage(a)},get:function(a){return n(a)},startsWith:function(a,b){return qv.util.startsWith(a,b)},endsWith:function(a,b){return qv.util.endsWith(a,b)},replaceVariablesValuesInText:function(a,c){return b.ReplaceVariablesValuesInText(a,c)},getHamburgerMenuHTML:function(a){return b.GetObjectMenuHTML(a)},getElementReferences:function(a){return b.GetElementReferences(a)}};b.LoadParameterVariables(c);b.editor=new BrowserLayout(d);
b.LoadFilterVariables(c);b.SetContainerSize();b.RenderDashboard();c=b.ReplaceVariableValue(c.Layout.RefreshPeriod,[DataType.Integer,DataType.Real],!1,c.Variables.Filters);b.SetRefreshPeriod(b,c)}else b.RenderError(gx.getMessage("GX_Dashboard_NotAssigned"))})};this.Refresh=function(){this.RefreshDashboard()};this.GetFilterValue=function(a){var b=this.GetFilterByAnyName(a);return null!=b&&b.Type!=FilterType.Collection?b.Type==FilterType.Value?b.SerializedValue:b.NameLowerValue==a?b.SerializedLowerValue:
b.SerializedUpperValue:""};this.GetFilterValues=function(a){a=this.GetFilterByName(a);if(null!=a&&a.Type==FilterType.Collection)for(var b=[],c=0;c<a.Values.length;c++)b.push(this.ValueToString(a.Values[c],a.DataType,a.Picture,a.PictureProperties));return b};this.SetFilterValue=function(a,b){var c=this.GetFilterByName(a);if(null!=c&&c.Type==FilterType.Value&&!c.IsHidden){var d=this.UpdateFilter1(null,a,b);d&&this.RefreshWidget(c)}else if(c=this.GetObjectElementForFilter(a),null!=c){var d=this.DefaultPicture(c.Element.DataType),
e=this.GetPictureProperties(c.Element.DataType,d),d=this.CheckFilterValue(b,c.Element.DataType,FilterType.Value,d,e,null,null,!1);if(d.Success&&(d=this.AddHiddenFilter(c.Object,a,d.ParsedValue,c.Element.DataType)))this.RefreshDashboard([a]),c.Object.QueryViewer.Select([{Name:a,Value:b}])}};this.SetFilterRange=function(a,b,c,d){var e;e=""==a?this.GetFilterByAnyName(c):this.GetFilterByAnyName(a);null!=e&&e.Type==FilterType.Range&&(""==a?this.UpdateFilter2(null,e.NameLowerValue,c,e.SerializedLowerValue,
d):""==c?this.UpdateFilter2(null,a,e.NameUpperValue,b,e.SerializedUpperValue):this.UpdateFilter2(null,a,c,b,d))&&this.RefreshWidget(e)};this.SetFilterValues=function(a,b){var c=this.GetFilterByName(a);null!=c&&c.Type==FilterType.Collection&&this.UpdateFilter1(null,a,JSON.stringify(b))&&this.RefreshWidget(c)};this.GetObjectElementForFilter=function(a){for(var b=this.DashboardObject,c=0;c<b.Objects.length;c++){var d=b.Objects[c];if(d.OnItemClick==OnItemClick.ApplyFilters)for(var e=0;e<d.Elements.length;e++){var g=
d.Elements[e];if(g.Name.toLowerCase()==a.toLowerCase())return{Object:d,Element:g}}}return null};this.SetRefreshPeriod=function(a,b){this._refreshInterval&&clearInterval(this._refreshInterval);!isNaN(b)&&0!=b&&(this._refreshInterval=setInterval(a.me()+".RefreshDashboard();",1E3*b))};this.RenderError=function(a){this.setHtml('<div style="height: '+this.Height+"; width: "+this.Width+'; border: silver thin solid">'+this.CenteredTextHTML("","",gx.getMessage("GX_Dashboard_Error")+": "+a)+"</div>")};this.CenteredTextHTML=
function(a,b,c){return"<div"+(""==b?"":' class="'+b+'"')+' style="display:table;width:100%;height:100%"><div style="display:table-cell;vertical-align:middle;text-align:center"><span'+(""==a?"":' id="'+a+'"')+">"+c+"</span></div></div>"};this.LoadParametersDefaults=function(a){this._ValidParametersCalculated=!1;for(var b=0;b<a.Parameters.length;b++)this.ParameterDefaults(a.Parameters[b])};this.UpdateDashboardObject=function(a){function b(a,b){if(a.Object)for(var e=eval(a.Object),g=0;g<b.Parameters.length;g++){var f=
b.Parameters[g];if(g+2<=e.length-1){var h=a.ParseValue(e[g+2],f.DataType,f.Type==ParameterType.Collection);h.Success&&(f.Value=h.ParsedValue,a.SerializeParameterValue(f))}}}a!=this.DashboardSpec&&(this.DashboardSpec=a);""!=this.DashboardSpec?(this.DashboardObject=JSON.parse(this.DashboardSpec),this.LoadParametersDefaults(this.DashboardObject),b(this,this.DashboardObject),this.DashboardDefaults(this.DashboardObject),this.IsDashboardEdit()&&(UCDashboardForEditor=this)):this.DashboardObject=null};this.GetDashboardSpec=
qv.services.createAsyncServerCallFn(this,qv.services.url.getDashboardSpecURL,qv.services.postInfo.DashboardSpec);this.IsRelated=function(a,b){return b.WidgetType==WidgetType.Filter?this.IsFilterRelated(a,b):b.WidgetType==WidgetType.Object?this.IsObjectRelated(a,b):!1};this.IsFilterRelated=function(a,b){return b.IsHidden?!1:b.Type==FilterType.Range?0<=this.CaseInsensitiveIndexOf(a.Parameters,b.NameLowerValue)||0<=this.CaseInsensitiveIndexOf(a.Parameters,b.NameUpperValue):0<=this.CaseInsensitiveIndexOf(a.Parameters,
b.Name)};this.IsObjectRelated=function(a,b){if(b.OnItemClick==OnItemClick.ApplyFilters)for(var c=0;c<b.Elements.length;c++)if(0<=this.CaseInsensitiveIndexOf(a.Parameters,b.Elements[c].Name))return!0;return!1};this.DependsOnElement=function(a,b){return a.ElementType!=ElementType.Widget&&a.ElementType!=ElementType.Layout?!1:b.WidgetType==WidgetType.Filter||b.WidgetType==WidgetType.Object?this.IsRelated(a,b):!1};this.ImpactsElement=function(a,b){return a.ElementType!=ElementType.Widget&&a.ElementType!=
ElementType.Layout?!1:a.WidgetType==WidgetType.Filter||a.WidgetType==WidgetType.Object?this.IsRelated(b,a):!1};this.SetContainerSize=function(){var a=document.getElementById(this.ContainerName);""!=this.Width&&(a.style.width=gx.dom.addUnits(this.Width));""!=this.Height&&(a.style.height=gx.dom.addUnits(this.Height))};this.IsDashboardEdit=function(){this._IsDashboardEdit||(this._IsDashboardEdit=void 0!=window.external&&void 0!=window.external.SelectElements&&void 0!=window.external.DeleteSelectedElements&&
void 0!=window.external.SelectObjectItem&&void 0!=window.external.AddElement&&void 0!=window.external.MoveElement&&void 0!=window.external.MoveElements&&void 0!=window.external.AddKBObjects&&void 0!=window.external.SetFilterValue&&void 0!=window.external.SetFilterValues&&void 0!=window.external.SetFrameCollapsed&&void 0!=window.external.SendText);return this._IsDashboardEdit};this.ProcessResponsiveSizes=function(a){function b(a,b,c){for(var a=a.Rows[b],d=0,e=0,b=0;b<a.Cells.length;b++){var f=a.Cells[b];
f.ResponsiveSizes.Width[c]&&(d+=f.ResponsiveSizes.Width[c],e+=1)}d=12-d;e=a.Cells.length-e;for(b=0;b<a.Cells.length;b++)if(f=a.Cells[b],!f.ResponsiveSizes.Width[c]){var g=Math.ceil(d/e);f.ResponsiveSizes.Width[c]=g;d-=g;e-=1}}function c(a,b,c,d){function e(a,b){for(var c=0,d=0;d<a.length&&a[d].OldPos!=b;d++)a[d].Visible&&(c+=a[d].Width);return c}function f(a,b){if(a.NewPos<b.NewPos)return-1;if(a.NewPos>b.NewPos)return 1;var c;c=a.OldPos<b.OldPos?-1:a.OldPos>b.OldPos?1:0;return c}for(var g=[],h=!1,
a=a.Rows[b],b=0;b<a.Cells.length;b++){var t=a.Cells[b],u=t.ResponsiveSizes.Width[d]||parseInt(12/a.Cells.length),r=t.ResponsiveSizes.Move[d]||0;g.push({OldPos:b,NewPos:0!=r?r:a.Cells.length,Width:u+(t.ResponsiveSizes.Offset[d]||0),Visible:void 0!=t.ResponsiveSizes.Visible[d]?t.ResponsiveSizes.Visible[d]:!0});0!=r&&(h=!0)}h&&(h=e(g,c),g.sort(f),r=e(g,c)-h,0<r?a.Cells[c].ResponsiveSizes.Push[d]=r:0>r?a.Cells[c].ResponsiveSizes.Pull[d]=-r:(g=Object.values(ResponsiveScale)[Object.values(ResponsiveScale).indexOf(d)-
1],void 0!=g&&(h=a.Cells[c].ResponsiveSizes.Pull[g],0<a.Cells[c].ResponsiveSizes.Push[g]&&(a.Cells[c].ResponsiveSizes.Push[d]=0),0<h&&(a.Cells[c].ResponsiveSizes.Pull[d]=0))))}for(var d=0;d<a.Rows.length;d++){row=a.Rows[d];for(var e={},g=0;g<row.Cells.length;g++){for(var f=row.Cells[g],h={Width:{},Offset:{},Visible:{},Move:{},Push:{},Pull:{}},j=0;j<a.ResponsiveSizes.length;j++){var k=a.ResponsiveSizes[j];if(d<k.rows.length){var m=k.rows[d];if(g<m.length&&(m=m[g],void 0!=m.width&&(h.Width[k.scale]=
Math.round(12*m.width/100),e[k.scale]=!0),void 0!=m.offset&&(h.Offset[k.scale]=Math.round(12*m.offset/100)),void 0!=m.visible&&(h.Visible[k.scale]=m.visible),void 0!=m.move))h.Move[k.scale]=m.move}}f.ResponsiveSizes=h}for(j=0;j<a.ResponsiveSizes.length;j++)g=a.ResponsiveSizes[j].scale,e[g]&&b(a,d,g);for(g=0;g<row.Cells.length;g++)for(j=0;j<a.ResponsiveSizes.length;j++)c(a,d,g,a.ResponsiveSizes[j].scale)}};this.DashboardDefaults=function(a){a.Name=a.Name||"";a.Description=a.Description||"";a.Objects=
[];a.Filters=[];a.Buttons=[];a.Images=[];a.TextBlocks=[]};this.LayoutDefaults=function(a){a.Title=a.Title||"";a.RefreshPeriod=a.RefreshPeriod||0;a.MainTableLayout=a.MainTableLayout||MainTableLayout.Free;a.FiltersPosition=a.FiltersPosition||FiltersPosition.Right;a.ElementId=a.ElementId||"";a.Parameters=a.Parameters||[]};this.ParameterDefaults=function(a){a.Name=a.Name||"";a.DataType=a.DataType||DataType.Integer;a.Type=a.Type||ParameterType.Value;a.Picture=a.Picture||this.DefaultPicture(a.DataType);
var b=this.GetPictureProperties(a.DataType,a.Picture);null!=b&&(a.PictureProperties=b);a.Value||(a.Value=this.GetEmptyValue(a.DataType,a.Type==ParameterType.Collection),this.SerializeParameterValue(a))};this.TableDefaults=function(a){a.ControlName=a.ControlName||"";a.ElementId=a.ElementId||"";a.Class=a.Class||"";a.Rows=a.Rows||[];a.Mode=TableMode.Bootstrap;a.ResponsiveSizes=a.ResponsiveSizes||[];this.ProcessResponsiveSizes(a)};this.RowDefaults=function(a){a.ElementId=a.ElementId||"";a.RowClass=a.RowClass||
"";a.Cells=a.Cells||[]};this.CellDefaults=function(a){a.ElementId=a.ElementId||"";a.CellClass=a.CellClass||"";a.ChildType=a.ChildType||"";a.IsEmpty=a.IsEmpty||""==a.ChildType;a.HasTable=a.ChildType==ChildType.Table};this.BasicWidgetDefaults=function(a,b,c){a.ElementId=a.ElementId||"";a.ControlName=a.ControlName||"";a.WidgetType=c;a.FrameVisible=a.FrameVisible||!1;a.FrameTitle=a.FrameTitle||"";a.FrameAllowCollapsing=a.FrameAllowCollapsing||!1;a.FrameCollapsed=a.FrameCollapsed||!1;a.Parameters=a.Parameters||
[]};this.ObjectElementDefaults=function(a){a.Name=a.Name||"";a.DataType=a.DataType||DataType.Integer;a.Title=a.Title||"";a.DataField=a.DataField||"";a.Visible=void 0!=a.Visible?a.Visible:!0;a.Type=a.Type||"";a.Aggregation=a.Aggregation||"";a.Format=a.Format||{};a.Format.Picture=a.Format.Picture||"";a.Format.Subtotals=a.Format.Subtotals||"";a.Format.CanDragToPages=void 0!=a.Format.CanDragToPages?a.Format.CanDragToPages:!0;a.Format.Style=a.Format.Style||"";a.Format.TargetValue=a.Format.TargetValue||
0;a.Format.MaximumValue=a.Format.MaximumValue||0;a.Format.ValueStyles=a.Format.ValueStyles||[];a.Format.ConditionalStyles=a.Format.ConditionalStyles||[];a.Filter=a.Filter||{};a.Filter.Type=a.Filter.Type||"";a.Filter.Values=a.Filter.Values||[];a.ExpandCollapse=a.ExpandCollapse||{};a.ExpandCollapse.Type=a.ExpandCollapse.Type||"";a.ExpandCollapse.Values=a.ExpandCollapse.Values||[];a.AxisOrder=a.AxisOrder||{};a.AxisOrder.Type=a.AxisOrder.Type||"";a.AxisOrder.Values=a.AxisOrder.Values||[];a.Grouping=a.Grouping||
{};a.Grouping.GroupByYear=a.Grouping.GroupByYear||!1;a.Grouping.YearTitle=a.Grouping.YearTitle||"";a.Grouping.GroupBySemester=a.Grouping.GroupBySemester||!1;a.Grouping.SemesterTitle=a.Grouping.SemesterTitle||"";a.Grouping.GroupByQuarter=a.Grouping.GroupByQuarter||!1;a.Grouping.QuarterTitle=a.Grouping.QuarterTitle||"";a.Grouping.GroupByMonth=a.Grouping.GroupByMonth||!1;a.Grouping.MonthTitle=a.Grouping.MonthTitle||"";a.Grouping.GroupByDayOfWeek=a.Grouping.GroupByDayOfWeek||!1;a.Grouping.DayOfWeekTitle=
a.Grouping.DayOfWeekTitle||"";a.Grouping.HideValue=a.Grouping.HideValue||!1;a.RaiseItemClick=void 0!=a.RaiseItemClick?a.RaiseItemClick:!0};this.ObjectElementsDefaults=function(a,b){for(var c=0;c<a.length;c++)this.ObjectElementDefaults(a[c],b)};this.ObjectDefaults=function(a,b){this.BasicWidgetDefaults(a,b,WidgetType.Object);a.Name=a.Name||"";a.Type=a.Type||ObjectType.Query;a.Elements=a.Elements||[];this.ObjectElementsDefaults(a.Elements,b);a.Class=a.Class||"";a.ContainerClass=a.ContainerClass||"";
a.FrameClass=a.FrameClass||"";a.FrameTitleClass=a.FrameTitleClass||"";a.FrameBodyClass=a.FrameBodyClass||"";a.Output=a.Output||{};a.Output.Title=a.Output.Title||"";a.Output.Type=a.Output.Type||OutputType.Chart;a.Output.ChartType=a.Output.ChartType||ChartType.Column;a.Output.PlotSeries=a.Output.PlotSeries||PlotSeries.InTheSameChart;a.Output.XAxisLabels=a.Output.XAxisLabels||XAxisLabels.Horizontally;a.Output.XAxisIntersectionAtZero=a.Output.XAxisIntersectionAtZero||!1;a.Output.ShowValues=void 0!=a.Output.ShowValues?
a.Output.ShowValues:!0;a.Output.XAxisTitle=a.Output.XAxisTitle||"";a.Output.YAxisTitle=a.Output.YAxisTitle||"";a.Output.ShowDataAs=a.Output.ShowDataAs||ShowDataAs.Values;a.Output.Orientation=a.Output.Orientation||Orientation.Horizontal;a.Output.IncludeTrend=a.Output.IncludeTrend||!1;a.Output.TrendPeriod=a.Output.TrendPeriod||TrendPeriod.SinceTheBeginning;a.Output.IncludeSparkline=a.Output.IncludeSparkline||!1;a.Output.IncludeMaxAndMin=a.Output.IncludeMaxAndMin||!1;a.Output.Paging=void 0!=a.Output.Paging?
a.Output.Paging:!0;a.Output.PageSize=a.Output.PageSize||20;a.Output.ShowDataLabelsIn=a.Output.ShowDataLabelsIn||ShowDataLabelsIn.Columns;a.OnItemClick=a.OnItemClick||OnItemClick.DoNothing};this.FilterDefaults=function(a,b){this.BasicWidgetDefaults(a,b,WidgetType.Filter);a.Type=a.Type||FilterType.Value;a.Name=a.Name||"";a.NameLowerValue=a.NameLowerValue||"";a.NameUpperValue=a.NameUpperValue||"";a.Visible=void 0!=a.Visible?a.Visible:!0;a.CaptionClass=a.CaptionClass||"";a.ValueClass=a.ValueClass||"";
a.ContainerClass=a.ContainerClass||"";a.FrameClass=a.FrameClass||"";a.FrameTitleClass=a.FrameTitleClass||"";a.FrameBodyClass=a.FrameBodyClass||"";a.Caption=a.Caption||a.Name;a.Value=a.Value||"";a.LowerValue=a.LowerValue||"";a.UpperValue=a.UpperValue||"";a.Values=a.Values||[];a.MinValue=a.MinValue||"";a.MaxValue=a.MaxValue||"";a.DataType=a.DataType||DataType.Integer;a.Picture=a.Picture||"";a.Control=a.Control||{};a.Control.Type=a.Control.Type||ControlType.Editbox;a.Control.Dynamic=a.Control.Dynamic||
!1;a.Control.Dynamic?a.Control.RefreshValues=a.Control.RefreshValues||!1:(a.Control.Values=a.Control.Values||[],a.Control.Descriptions=a.Control.Descriptions||[]);a.Control.EmptyItem=a.Control.EmptyItem||!1;a.Control.EmptyItemText=a.Control.EmptyItemText||"GX_EmptyItemText";a.Control.Orientation=a.Control.Orientation||ControlOrientation.Horizontal;a.Control.InviteMessage=a.Control.InviteMessage||"";a.IsHidden=!1};this.ButtonDefaults=function(a,b){this.BasicWidgetDefaults(a,b,WidgetType.Button);a.Caption=
a.Caption||"";a.Class=a.Class||"";a.ContainerClass=a.ContainerClass||"";a.FrameClass=a.FrameClass||"";a.FrameTitleClass=a.FrameTitleClass||"";a.FrameBodyClass=a.FrameBodyClass||""};this.ImageDefaults=function(a,b){this.BasicWidgetDefaults(a,b,WidgetType.Image);a.Guid=a.Guid||"";a.AlternateText=a.AlternateText||"";a.Class=a.Class||"";a.ContainerClass=a.ContainerClass||"";a.FrameClass=a.FrameClass||"";a.FrameTitleClass=a.FrameTitleClass||"";a.FrameBodyClass=a.FrameBodyClass||""};this.TextBlockDefaults=
function(a,b){this.BasicWidgetDefaults(a,b,WidgetType.TextBlock);a.Caption=a.Caption||"";a.Class=a.Class||"";a.ContainerClass=a.ContainerClass||"";a.FrameClass=a.FrameClass||"";a.FrameTitleClass=a.FrameTitleClass||"";a.FrameBodyClass=a.FrameBodyClass||""};this.WidgetDefaults=function(a,b,c){switch(c){case WidgetType.Object:this.ObjectDefaults(a,b);break;case WidgetType.Filter:this.FilterDefaults(a,b);this.ProcessFilter(a);break;case WidgetType.Image:this.ImageDefaults(a,b);break;case WidgetType.Button:this.ButtonDefaults(a,
b);break;case WidgetType.TextBlock:this.TextBlockDefaults(a,b)}};this.ReplaceVariables=function(a,b){a.VariablesReplaced||(b(this,a),a.VariablesReplaced=!0)};this.ReplaceDashboardParametersInLayout=function(a){this.ReplaceVariables(a,function(a,c){var d=a.DashboardObject,d=d.Variables.ValidParameters.concat(d.Variables.Standard);c.Title=a.ReplaceVariablesValuesInText(c.Title,d);c.RefreshPeriod=a.ReplaceVariableValue(c.RefreshPeriod,[DataType.Integer],!1,d)})};this.ReplaceDashboardParametersInWidget=
function(a){this.ReplaceVariables(a,function(a,c){var d=a.DashboardObject,d=d.Variables.ValidParameters.concat(d.Variables.Standard);c.FrameTitle=a.ReplaceVariablesValuesInText(c.FrameTitle,d);switch(c.WidgetType){case WidgetType.Object:a.ReplaceVariablesInObject(c,d);for(var e=0;e<c.Elements.length;e++)a.ReplaceVariablesInObjectElement(c.Elements[e],d);break;case WidgetType.Filter:a.ReplaceVariablesInFilter(c,d);break;case WidgetType.TextBlock:a.ReplaceVariablesInTextBlock(c,d);break;case WidgetType.Button:a.ReplaceVariablesInButton(c,
d);break;case WidgetType.Image:a.ReplaceVariablesInImage(c,d)}})};this.ReplaceVariablesInObject=function(a,b){switch(a.Output.Type){case OutputType.Chart:a.Output.Title=this.ReplaceVariablesValuesInText(a.Output.Title,b);a.Output.XAxisTitle=this.ReplaceVariablesValuesInText(a.Output.XAxisTitle,b);a.Output.YAxisTitle=this.ReplaceVariablesValuesInText(a.Output.YAxisTitle,b);break;case OutputType.Table:case OutputType.PivotTable:a.Output.PageSize=this.ReplaceVariableValue(a.Output.PageSize,[DataType.Integer],
!1,b)}};this.ReplaceVariablesInObjectElement=function(a,b){a.Type!=QueryViewerAxisType.Hidden&&(a.Title=this.ReplaceVariablesValuesInText(a.Title,b));if((a.Type==QueryViewerAxisType.Rows||a.Type==QueryViewerAxisType.Columns)&&(a.DataType==DataType.Date||a.DataType==DataType.DateTime))if(a.Grouping.GroupByYear&&(a.Grouping.YearTitle=this.ReplaceVariablesValuesInText(a.Grouping.YearTitle,b)),a.Grouping.GroupBySemester&&(a.Grouping.SemesterTitle=this.ReplaceVariablesValuesInText(a.Grouping.SemesterTitle,
b)),a.Grouping.GroupByQuarter&&(a.Grouping.QuarterTitle=this.ReplaceVariablesValuesInText(a.Grouping.QuarterTitle,b)),a.Grouping.GroupByMonth&&(a.Grouping.MonthTitle=this.ReplaceVariablesValuesInText(a.Grouping.MonthTitle,b)),a.Grouping.GroupByDayOfWeek)a.Grouping.DayOfWeekTitle=this.ReplaceVariablesValuesInText(a.Grouping.DayOfWeekTitle,b);a.Type==QueryViewerAxisType.Data&&(a.Format.TargetValue=this.ReplaceVariableValue(a.Format.TargetValue,[DataType.Integer,DataType.Real],!1,b),a.Format.MaximumValue=
this.ReplaceVariableValue(a.Format.MaximumValue,[DataType.Integer,DataType.Real],!1,b));if(a.Type==QueryViewerAxisType.Rows||a.Type==QueryViewerAxisType.Columns){var c=[a.DataType];a.DataType==DataType.Real&&c.push(DataType.Integer);a.Filter.Type==QueryViewerFilterType.ShowSomeValues&&(a.Filter.Values=this.ReplaceVariableValue(a.Filter.Values,c,!0,b));a.ExpandCollapse.Type==QueryViewerExpandCollapseType.ExpandSomeValues&&(a.ExpandCollapse.Values=this.ReplaceVariableValue(a.ExpandCollapse.Values,c,
!0,b));a.AxisOrder.Type==QueryViewerAxisOrderType.Custom&&(a.AxisOrder.Values=this.ReplaceVariableValue(a.AxisOrder.Values,c,!0,b))}};this.ReplaceVariablesInFilter=function(a,b){a.Caption=this.ReplaceVariablesValuesInText(a.Caption,b);a.Control.Type==ControlType.Editbox&&(a.Control.InviteMessage=this.ReplaceVariablesValuesInText(a.Control.InviteMessage,b))};this.ReplaceVariablesInFilterOnlyParameters=function(a,b){a.Type!=FilterType.Collection?(a.Type==FilterType.Value?this.ReplaceVariableValueInFilter(a.Value,
"Value","SerializedValue",a,b):(this.ReplaceVariableValueInFilter(a.LowerValue,"LowerValue","SerializedLowerValue",a,b),this.ReplaceVariableValueInFilter(a.UpperValue,"UpperValue","SerializedUpperValue",a,b)),this.ReplaceVariableValueInFilter(a.MinValue,"MinValue","",a,b),this.ReplaceVariableValueInFilter(a.MaxValue,"MaxValue","",a,b)):this.ReplaceVariableValueInFilter(a.Values,"Values","SerializedValue",a,b)};this.ReplaceVariablesInButton=function(a,b){a.Caption=this.ReplaceVariablesValuesInText(a.Caption,
b)};this.ReplaceVariablesInImage=function(a,b){a.AlternateText=this.ReplaceVariablesValuesInText(a.AlternateText,b)};this.ReplaceVariablesInTextBlock=function(a,b){a.Caption=this.ReplaceVariablesValuesInText(a.Caption,b)};this.GetQueryViewerElementId=function(a){return this.editor.GetDOMElementId(a)+"_QueryViewer"};this.GetRangeElementId=function(a){return this.editor.GetDOMElementId(a)+"_Range"};this.IsMainTable=function(a){return a.ElementId==MAIN_TABLE_ID||a.ElementId==FILTERS_TABLE_ID};this.IsMainTableLayoutTable=
function(a){return this.IsMainTable(a)?!1:this.DashboardObject.Layout.MainTableLayout!=MainTableLayout.Free&&a.ParentElement.ParentElement.ParentElement.ElementId==MAIN_TABLE_ID};this.IsHeight100Percent=function(a,b,c){if(c.ElementId==MAIN_TABLE_ID)switch(a){case MainTableLayout.TwoColumns:case MainTableLayout.ThreeColumns:return!0;case MainTableLayout.HeaderTwoColumns:case MainTableLayout.HeaderThreeColumns:case MainTableLayout.HeaderTwoColumnsFooter:case MainTableLayout.HeaderThreeColumnsFooter:return 1==
b;default:return b==c.Rows.length-1}else return b==c.Rows.length-1};this.GetPictureProperties=function(a,b){return a==DataType.Integer||a==DataType.Real?qv.util.ParseNumericPicture(a==DataType.Integer?"integer":"",b):a==DataType.Date||a==DataType.DateTime?qv.util.ParseDateTimePicture(a==DataType.DateTime?"datetime":"",b):null};this.MakeFilterItem=function(a,b){var c={};c.Name=a;c.Values=[];if(null!=b)switch(b.Type){case FilterType.Value:c.Values.push(b.SerializedValue);break;case FilterType.Range:b.NameLowerValue==
a?c.Values.push(b.SerializedLowerValue):c.Values.push(b.SerializedUpperValue);break;case FilterType.Collection:for(var d=0;d<b.Values.length;d++)c.Values.push(this.ValueToString(b.Values[d],b.DataType,b.Picture,b.PictureProperties))}return c};this.LoadOtherFilterValues=function(a){a.AllFilters=[];for(var b=this.DashboardObject,c=0;c<b.Filters.length;c++){var d=b.Filters[c];d.Type!=FilterType.Range?a.AllFilters.push(this.MakeFilterItem(d.Name,d)):(a.AllFilters.push(this.MakeFilterItem(d.NameLowerValue,
d)),a.AllFilters.push(this.MakeFilterItem(d.NameUpperValue,d)))}};this.LoadFiltersChangedData=function(a){this.FiltersChangedData={};this.FiltersChangedData.ChangedFilters=[];for(var b=0;b<a.length;b++){var c=this.GetFilterByAnyName(a[b]),d=this.MakeFilterItem(a[b],c);d.Enabled=null!=c;this.FiltersChangedData.ChangedFilters.push(d)}this.LoadOtherFilterValues(this.FiltersChangedData)};this.LoadItemClickData=function(a,b){this.ItemClickData={};this.ItemClickData.Object=a.Name;this.ItemClickData.Element=
b.ItemClickData.Name;this.ItemClickData.Value=b.ItemClickData.Value;this.ItemClickData.Context=JSON.parse(JSON.stringify(b.ItemClickData.Context));this.LoadOtherFilterValues(this.ItemClickData)};this.LoadValuesHighlightedData=function(a){this.ValuesHighlightedData={};this.ValuesHighlightedData.Elements=a;this.LoadOtherFilterValues(this.ValuesHighlightedData)};this.RefreshDashboard=function(a){a&&this.FiltersChanged&&(this.LoadFiltersChangedData(a),this.FiltersChanged());var b=this.DashboardObject;
this.UpdateFilterVariables(b,a);for(var c=0;c<b.AllWidgets.length;c++)this.RefreshElementIfNeeded(b.AllWidgets[c],a);this.RefreshElementIfNeeded(b.Layout,a)};this.CaseInsensitiveIndexOf=function(a,b){for(var c=0;c<a.length;c++)if(a[c].toLowerCase()==b.toLowerCase())return c;return-1};this.RefreshElementIfNeeded=function(a,b){var c;a:if(b){for(c=0;c<b.length;c++)if(0<=this.CaseInsensitiveIndexOf(a.Parameters,b[c])){c=!0;break a}c=!1}else c=!0;c&&(a.ElementType==ElementType.Layout?this.RefreshLayout():
a.ElementType==ElementType.Widget&&(a.WidgetType==WidgetType.Filter&&a.Control.Dynamic&&(a.Control.RefreshValues=!0),this.RefreshWidget(a)))};this.GetThemeStyleSheet=function(){if(!this._themeStyleSheet){for(var a=gx.theme+".css",b,c=0;c<document.styleSheets.length;c++)if(null!=document.styleSheets[c].href&&0<=document.styleSheets[c].href.indexOf(a)){b=document.styleSheets[c];break}this._themeStyleSheet=b}return this._themeStyleSheet};this.InsertCssRules=function(a){for(var b=this.GetThemeStyleSheet(),
a=a.split("}"),c=0;c<a.length;c++)""!=a[c]&&b.insertRule(a[c]+"}")};this.UpdateElement=function(a,b,c){switch(c){case ElementType.Table:this.UpdateTable(a,b);break;case ElementType.Row:this.UpdateRow(a,b,!1);break;case ElementType.Cell:this.UpdateCell(a,b);break;case ElementType.Widget:this.UpdateWidget(a,b)}this.editor.UpdateSelectedElementPath(a)};this.UpdateCell=function(a,b){var c=this.DashboardObject,d=this.GetElementContainer(a.ElementId);this.CellDefaults(b);if(!b.IsEmpty||a.IsEmpty)if(!b.IsEmpty&&
a.IsEmpty){var e=b[b.ChildType];this.editor.ParentInitialize(e,a);b.HasTable?this.editor.TableDefaults(e,c,""):(this.editor.WidgetDefaults(e,c,b.ChildType),this.editor.AddElement(c,e));var g=e,f=b.ChildType;a.ChildType=f;a[f]=g;a.IsEmpty=!1;var f=document.createElement("DIV"),h=[],e=e.ElementType==ElementType.Table?this.editor.GetTableHTML(c,g,!0,h,!1):this.editor.GetWidgetHTML(c,a.ParentElement.ParentElement,a,g,h);this.RemoveDomElements(h);f.innerHTML=e;e=this.GetElementContainer(a.ElementId);e.childNodes[0]&&
e.removeChild(e.childNodes[0]);e.appendChild(f.firstChild);e.classList.remove("gx-db-cell-empty")}else!a.IsEmpty&&!b.IsEmpty&&(f=a[a.ChildType],e=b[b.ChildType],a.HasTable?this.UpdateTable(f,e):this.UpdateWidget(f,e));a.CellClass!=b.CellClass&&(a.CellClass=b.CellClass,this.UpdateDOMElementClass(d,b.CellClass,"gx-db-cell"))};this.UpdateRow=function(a,b,c){function d(a,b,c,d,e,f){var g=a.GetElementContainer(e.ElementId);d.id==g.parentNode.id&&d.removeChild(g);c.Cells.splice(f,1);a.editor.RemoveElement(b,
e);e.IsEmpty||(c=e[e.ChildType],a.editor.SelectedElementIds.splice(a.editor.SelectedElementIds.indexOf(c.ElementId),1),a.editor.RemoveElement(b,c))}function e(a,b,c,d,e,f){var g;f<c.Cells.length&&(g=a.GetElementContainer(c.Cells[f].ElementId));c.Cells.splice(f,0,e);var h=document.createElement("DIV"),j=[],b=a.editor.GetCellHTML(b,c.ParentElement,c,d,e,f,"",j);a.RemoveDomElements(j);h.innerHTML=b;a=a.GetElementContainer(c.ElementId);g?a.insertBefore(h.firstChild,g):a.appendChild(h.firstChild)}function g(a,
b,c,d,e){var f=a.GetElementContainer(b.Cells[s].ElementId),a=a.GetElementContainer(b.Cells[l].ElementId);b.Cells.splice(e,0,b.Cells.splice(d,1)[0]);c.insertBefore(f,a)}function f(a,b,c,d,e){var f=c.Cells[e],b=a.editor.CellClass2(b,c,d,f,e);a.GetElementContainer(f.ElementId).className=b}function h(a,b){var c=a.Cells[b];if(!c.IsEmpty&&(c=c[c.ChildType],c.WidgetType==WidgetType.Object&&c.Output.Type==OutputType.Chart&&(c=c.QueryViewer)))c.ForceChartRendering=!0,code="try { qv.chart.checkChartSize("+
c.me()+") } catch (e) {}",c.IntervalCheckChartSize=setInterval(code,0)}var j=this.DashboardObject,k=a.Cells.length!=b.Cells.length,m=this.GetElementContainer(a.ElementId);this.RowDefaults(b);for(var o=[],l=a.Cells.length-1;0<=l;l--){var q=a.Cells[l];0>this.GetCellIndex(b,q.ElementId)&&d(this,j,a,m,q,l)}q=this.GetRowIndex(a.ParentElement,a.ElementId);for(l=0;l<b.Cells.length;l++){var p=b.Cells[l],s=this.GetCellIndex(a,p.ElementId);0>s&&!p.IsEmpty&&(o.push(p.ElementId),this.editor.ParentInitialize(p,
a),this.editor.CellDefaults(p,j),e(this,j,a,q,p,l))}for(l=0;l<a.Cells.length;l++)p=b.Cells[l],s=this.GetCellIndex(a,b.Cells[l].ElementId),s!=l&&g(this,a,m,s,l);for(l=0;l<b.Cells.length;l++)0>o.indexOf(a.Cells[l].ElementId)&&this.UpdateCell(a.Cells[l],b.Cells[l]);if(k||c)for(l=0;l<a.Cells.length;l++)f(this,a.ParentElement,a,q,l);if(k)for(l=0;l<a.Cells.length;l++)h(a,l);a.RowClass!=b.RowClass&&(a.RowClass=b.RowClass,this.UpdateDOMElementClass(m,b.RowClass,"gx-db-row"))};this.UpdateTable=function(a,
b){function c(a,b,c,d,e,f){var g=a.GetElementContainer(e.ElementId);(d.id=g.parentNode.id)&&d.removeChild(g);c.Rows.splice(f,1);for(c=0;c<e.Cells.length;c++)d=e.Cells[c],a.editor.RemoveElement(b,d),d.IsEmpty||a.editor.RemoveElement(b,d[d.ChildType]);a.editor.RemoveElement(b,e)}function d(a,b,c,d,e){var f;e<c.Rows.length&&(f=a.GetElementContainer(c.Rows[e].ElementId));c.Rows.splice(e,0,d);var g=document.createElement("DIV"),h=[],b=a.editor.GetRowHTML(b,c,d,e,h);a.RemoveDomElements(h);g.innerHTML=b;
a=a.GetElementContainer(c.ElementId);f?a.insertBefore(g.firstChild,f):a.appendChild(g.firstChild)}var e=this.DashboardObject,g=!1,f=this.GetElementContainer(a.ElementId);this.TableDefaults(b);for(var h=[],j=a.ElementId==MAIN_TABLE_ID||a.ElementId==FILTERS_TABLE_ID||this.IsMainTableLayoutTable(a)?a.Rows.length-2:a.Rows.length-1;0<=j;j--){var k=a.Rows[j];0>this.GetRowIndex(b,k.ElementId)&&(g=!0,c(this,e,a,f,k,j))}for(j=0;j<b.Rows.length;j++)k=b.Rows[j],0>this.GetRowIndex(a,k.ElementId)&&(h.push(k.ElementId),
g=!0,this.editor.ParentInitialize(k,a),this.editor.RowDefaults(k,e),d(this,e,a,k,j));0==a.Rows.length&&(k={ElementId:a.ElementId+"_NEWROW",Cells:[{ElementId:a.ElementId+"_NEWROW_NEWCELL",IsEmpty:!0}]},this.editor.ParentInitialize(k,a),this.editor.RowDefaults(k,e),d(this,e,a,k,0));for(j=0;j<b.Rows.length;j++)0>h.indexOf(a.Rows[j].ElementId)&&this.UpdateRow(a.Rows[j],b.Rows[j],g);a.Class!=b.Class&&(a.Class=b.Class,this.UpdateDOMElementClass(f,b.Class,"gx-db-table"))};this.UpdateWidget=function(a,b){var c=
this.DashboardObject,d=this.GetElementContainer(a.ElementId);this.WidgetDefaults(b,c,a.WidgetType);c=a.ContainerClass!=b.ContainerClass;this.CopyObjectProperties(b,a);this.RefreshWidget(a);c&&this.UpdateDOMElementClass(d,a.ContainerClass,"gx-db-widget")};this.CopyObjectProperties=function(a,b){for(var c in a)"Selected"!=c&&(b[c]instanceof Object&&!(b[c]instanceof Array)&&!(b[c]instanceof gx.date.gxdate)&&"ParentElement"!=c?this.CopyObjectProperties(a[c],b[c]):b[c]=a[c])};this.GetRowIndex=function(a,
b){for(var c=0;c<a.Rows.length;c++)if(a.Rows[c].ElementId==b)return c;return-1};this.GetCellIndex=function(a,b){for(var c=0;c<a.Cells.length;c++)if(a.Cells[c].ElementId==b)return c;return-1};this.GetElementContainer=function(a){a=this.editor.GetDOMElementId(a);return document.getElementById(a)};this.RemoveDomElements=function(a){for(var b=0;b<a.length;b++){var c=document.getElementById(a[b]);null!=c&&c.parentNode.removeChild(c)}};this.OnAddElement=function(a,b){switch(b.WidgetType){case WidgetType.Object:a.Objects.push(b);
break;case WidgetType.Filter:a.Filters.push(b);break;case WidgetType.Button:a.Buttons.push(b);break;case WidgetType.Image:a.Images.push(b);break;case WidgetType.TextBlock:a.TextBlocks.push(b)}};this.OnRemoveElement=function(a,b){switch(b.WidgetType){case WidgetType.Object:this.editor.RemoveElementById(a.Objects,b.ElementId);break;case WidgetType.Filter:this.editor.RemoveElementById(a.Filters,b.ElementId);break;case WidgetType.Button:this.editor.RemoveElementById(a.Buttons,b.ElementId);break;case WidgetType.Image:this.editor.RemoveElementById(a.Images,
b.ElementId);break;case WidgetType.TextBlock:this.editor.RemoveElementById(a.TextBlocks,b.ElementId)}};this.ValuesIndexOf=function(a,b,c){if((c==DataType.Date||c==DataType.DateTime)&&b instanceof gx.date.gxdate){c=!1;for(i=0;i<a.length;i++)if(0==b.compare(a[i])){c=!0;break}return c?i:-1}return a.indexOf(b)};this.SameValue=function(a,b,c){return c==DataType.Date||c==DataType.DateTime?0==a.compare(b):a===b};this.CompareValues=function(a,b,c){return c==DataType.Date||c==DataType.DateTime?a.compare(b):
a===b?0:a<b?-1:1};this.ParseValue=function(a,b,c){return this.ParseValueMain(a,b,c,!1)};this.ParseInternalValue=function(a,b,c){return this.ParseValueMain(a,b,c,!0)};this.ParseValueMain=function(a,b,c,d){var e,g;if(c)try{var f=JSON.parse(a);e=[];g=!0;for(a=0;a<f.length;a++){var h=this.ParseValueMain(f[a],b,!1,!0);h.Success&&e.push(h.ParsedValue)}}catch(j){g=!1}else switch(b){case DataType.Integer:e=parseInt(a);g=!isNaN(e);break;case DataType.Real:e=parseFloat(a);g=!isNaN(e);break;case DataType.Character:e=
a.toString();g=!0;break;case DataType.Boolean:e="true"==a.toString().toLowerCase();g=!0;break;case DataType.Date:case DataType.DateTime:e=d?new gx.date.gxdate(a,"Y4MD"):new gx.date.gxdate(a);g=!0;break;case DataType.GUID:e=36>=a.length?a:a.substr(0,36);e=e.toLowerCase().replace(/-/g,"");e=e.replace(/([0-f]{8})([0-f]{4})([0-f]{4})([0-f]{4})([0-f]{12})/,"$1-$2-$3-$4-$5");g=/([0-f]{8})-([0-f]{4})-([0-f]{4})-([0-f]{4})-([0-f]{12})/.test(e);break;default:g=!1}return{Success:g,ParsedValue:e}};this.ValueToString=
function(a,b,c,d){return this.ValueToStringMain(a,b,c,d,!1)};this.ValueToInternalString=function(a,b,c,d){return this.ValueToStringMain(a,b,c,d,!0)};this.ValueToStringMain=function(a,b,c,d,e){if(null==a)return"";switch(b){case DataType.Integer:case DataType.Real:return gx.num.formatNumber(a,d.DecimalPrecision,c,0,!0,!1);case DataType.Character:return"@!"==c?a.toUpperCase():a;case DataType.Date:case DataType.DateTime:e?(c=a.getStringWithFmt("Y4MD"),c=c==a.emptyDateString("Y4MD")?"0000-00-00":c.replace(/\//g,
"-")):c=a.getStringWithFmt(d.DateFormat);if(b==DataType.DateTime){b=a.TimeFmt;e&&(a.TimeFmt=24);var g=e||d.IncludeHours,f=e||d.IncludeMinutes,d=e||d.IncludeSeconds,d=g?a.getTimeString(f,d,g):"";"::"==d&&(d="00:00:00");""!=d&&(c+=" "+d);e&&(a.TimeFmt=b)}return c;case DataType.GUID:return a;default:return a.toString()}};this.ValuesToString=function(a,b,c,d){if(b==DataType.Date||b==DataType.DateTime){for(var e=[],g=0;g<a.length;g++){var f=this.ValueToInternalString(a[g],b,c,d);e.push(f)}return JSON.stringify(e)}return JSON.stringify(a)};
this.DefaultPicture=function(a){switch(a){case DataType.Integer:return"ZZZZZZZZZZZZZZ9";case DataType.Real:return"ZZZZZZZZZZZZZZ9.99";case DataType.Date:return"99/99/9999";case DataType.DateTime:return"99/99/9999 99:99:99";case DataType.GUID:return"XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX";default:return""}};this.ProcessFilter=function(a){function b(a,b,c,d){return a.CheckVariable(b,[c],d==FilterType.Collection,a.DashboardObject.Variables.AllParameters.concat(a.DashboardObject.Variables.Standard))}function c(a,
b,d,h,j){if(""==b&&j)return null;b=""==b?a.GetEmptyValueStr(d,h==FilterType.Collection):b;b=a.ParseInternalValue(b,d,h==FilterType.Collection);if(b.Success)return b.ParsedValue;if(j)return null;j=a.GetEmptyValueStr(d,h==FilterType.Collection);return c(a,j,d,h,!1)}""==a.Picture&&(a.Picture=this.DefaultPicture(a.DataType));var d=this.GetPictureProperties(a.DataType,a.Picture);null!=d&&(a.PictureProperties=d);if(a.Type!=FilterType.Collection){if(a.Type==FilterType.Value?(d=b(this,a.Value,a.DataType,
a.Type),d.IsVariable?a.SerializedValue=d.SerializedValue:(a.Value=c(this,a.Value,a.DataType,a.Type,!1),a.SerializedValue=this.ValueToString(a.Value,a.DataType,a.Picture,a.PictureProperties))):(d=b(this,a.LowerValue,a.DataType,a.Type),d.IsVariable?a.SerializedLowerValue=d.SerializedValue:(a.LowerValue=c(this,a.LowerValue,a.DataType,a.Type,!1),a.SerializedLowerValue=this.ValueToString(a.LowerValue,a.DataType,a.Picture,a.PictureProperties)),d=b(this,a.UpperValue,a.DataType,a.Type),d.IsVariable)?a.SerializedUpperValue=
d.SerializedValue:(a.UpperValue=c(this,a.UpperValue,a.DataType,a.Type,!1),a.SerializedUpperValue=this.ValueToString(a.UpperValue,a.DataType,a.Picture,a.PictureProperties)),d=b(this,a.MinValue,a.DataType,a.Type),d.IsVariable||(a.MinValue=c(this,a.MinValue,a.DataType,a.Type,!0)),d=b(this,a.MaxValue,a.DataType,a.Type),!d.IsVariable)a.MaxValue=c(this,a.MaxValue,a.DataType,a.Type,!0)}else if(d=b(this,a.Values,a.DataType,a.Type),d.IsVariable)a.SerializedValue=d.SerializedValue;else{for(d=0;d<a.Values.length;d++)a.Values[d]=
c(this,a.Values[d],a.DataType,FilterType.Value,!1);a.SerializedValue=this.ValuesToString(a.Values,a.DataType,a.Picture,a.PictureProperties)}if(!a.Control.Dynamic&&(a.Control.Type==ControlType.Checkbox||a.Control.Type==ControlType.ComboBox||a.Control.Type==ControlType.RadioButton||a.Control.Type==ControlType.DropDownList))if(a.DataType==DataType.Boolean)a.Control.Values=[!0,!1],a.Control.Descriptions=["true","false"];else for(d=0;d<a.Control.Values.length;d++)a.Control.Values[d]=c(this,a.Control.Values[d],
a.DataType,!1,!1),a.Control.Descriptions[d]=c(this,a.Control.Descriptions[d],DataType.Character,!1,!1)};this.RenderDashboard=function(){qv.util.SetUserControlClass(this,"gx-db"+(""!=this.Class?" ":"")+this.Class);this.InsertCssRules(this.CSSRules);var a=this.DashboardObject,b="";a.Layout&&(b=this.GetLayoutHTML(a),b=this.IsDashboardEdit()?this.TwoRowsTableHTML(null,"","100%","100%",this.editor.GetElementSelectorHTML(a.Layout),b):b,b+='<div id ="gx-dashboard-error-placeholder" class="gx-db-error" style="position:fixed;z-index:100;display:none"></div>',
this.IsDashboardEdit()&&(b+='<div id ="gx-dashboard-references-placeholder" style="position:fixed;z-index:100;display:none"></div>'));this.setHtml(b)};this.UpdateDOMElementClass=function(a,b,c){for(var d=a.classList.length-1;0<=d;d--){var e=a.classList.item(d);(e==c||!qv.util.startsWith(e,"gx-db-"))&&a.classList.remove(e)}a.classList.add(""==b?c:b)};this.RefreshLayout=function(){var a=this.DashboardObject,b=a.Variables.Filters,c=document.getElementById("gx-db-title-text");null!=c&&(c.innerText=this.ReplaceVariablesValuesInText(a.Layout.Title,
b));this.SetRefreshPeriod(this,this.ReplaceVariableValue(a.Layout.RefreshPeriod,[DataType.Integer,DataType.Real],!1,b))};this.RefreshWidget=function(a){if(a.WidgetType==WidgetType.Filter&&a.Control.Type==ControlType.Editbox&&(a.DataType==DataType.Date||a.DataType==DataType.DateTime)){var b=n("#"+this.GetRangeElementId(a.ElementId)).data("daterangepicker");null!=b&&b.hide()}var b=this.GetElementContainer(a.ElementId),c=this.editor.GetWidgetContentHTML(this.DashboardObject,a,null);a.WidgetType!=WidgetType.Object&&
(b.innerHTML=c);a.WidgetType==WidgetType.Filter&&a.Control.Type==ControlType.DropDownList&&n("#"+this.editor.GetDOMElementId(a.ElementId)+" > .selectpicker").selectpicker("refresh")};this.SerializeParameterValue=function(a){a.SerializedValue=this.IsDashboardEdit()?"&"+a.Name:a.Type==ParameterType.Value?this.ValueToString(a.Value,a.DataType,a.Picture,a.PictureProperties):this.ValuesToString(a.Value,a.DataType,a.Picture,a.PictureProperties)};this.MakeVariable=function(a,b,c,d,e){return{Name:a,Value:b,
SerializedValue:c,DataType:d,IsCollection:e}};this.LoadParameterVariables=function(a){a.Variables={};a.Variables.Standard=function(a){var c=[];c.push(function(a){var b=gx.date.today(),c=DataType.Date,f=qv.util.ParseDateTimePicture("","99/99/9999"),f=a.IsDashboardEdit()?"&Today":a.ValueToString(b,c,"99/99/9999",f);return a.MakeVariable("Today",b,f,c,!1)}(a));c.push(function(a){var b=gx.date.today();b.HasTimePart=!0;var b=b.getTimeString(!0,!0,!0),c=a.IsDashboardEdit()?"&Time":b;return a.MakeVariable("Time",
b,c,DataType.Character,!1)}(a));c.push(function(a){var b=a.DashboardObject.Name,c=a.IsDashboardEdit()?"&Pgmname":b;return a.MakeVariable("Pgmname",b,c,DataType.Character,!1)}(a));c.push(function(a){var b=a.DashboardObject.Description,c=a.IsDashboardEdit()?"&Pgmdesc":b;return a.MakeVariable("Pgmdesc",b,c,DataType.Character,!1)}(a));return c}(this);a.Variables.AllParameters=this.ParametersToVariables(a.Parameters)};this.LoadFilterVariables=function(a){a.Variables.ValidParameters=this.ParametersToVariables(this.ValidParameters());
for(var b=0;b<a.Filters.length;b++){var c=a.Filters[b];this.IsDashboardEdit()||this.ReplaceVariablesInFilterOnlyParameters(c,a.Variables.AllParameters.concat(a.Variables.Standard))}a.Variables.Filters=this.FiltersToVariables(a.Filters)};this.UpdateParameterVariables=function(a){a.Variables.AllParameters=this.ParametersToVariables(a.Parameters);a.Variables.ValidParameters=this.ParametersToVariables(this.ValidParameters())};this.UpdateFilterVariables=function(a,b){function c(a,b,c){for(var d=!1,e={},
f=0;f<b.Filters.length;f++){filter=b.Filters[f];switch(filter.Type){case FilterType.Value:filter.Name.toLowerCase()==c.toLowerCase()&&(d=!0,e=a.MakeVariable(filter.Name,filter.Value,filter.SerializedValue,filter.DataType,!1));break;case FilterType.Range:filter.NameLowerValue.toLowerCase()==c.toLowerCase()?(d=!0,e=a.MakeVariable(filter.NameLowerValue,filter.LowerValue,filter.SerializedLowerValue,filter.DataType,!1)):filter.NameUpperValue.toLowerCase()==c.toLowerCase()&&(d=!0,e=a.MakeVariable(filter.NameUpperValue,
filter.UpperValue,filter.SerializedUpperValue,filter.DataType,!1));break;case FilterType.Collection:filter.Name.toLowerCase()==c.toLowerCase()&&(d=!0,e=a.MakeVariable(filter.Name,filter.Values,filter.SerializedValue,filter.DataType,!0))}if(d)break}return{Found:d,Variable:e}}function d(a,b){for(var c=0;c<a.length;c++)if(a[c].Name.toLowerCase()==b.toLowerCase())return c;return-1}if(b)for(var e=0;e<b.length;e++){var g=d(a.Variables.Filters,b[e]),f=c(this,a,b[e]),h=f.Found,f=f.Variable;!h&&0<=g?a.Variables.Filters.splice(g,
1):h&&0>g?a.Variables.Filters.push(f):h&&0<=g&&(a.Variables.Filters[g]=f)}else a.Variables.Filters=this.FiltersToVariables(a.Filters)};this.FiltersToVariables=function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];switch(d.Type){case FilterType.Value:b.push(this.MakeVariable(d.Name,d.Value,d.SerializedValue,d.DataType,!1));break;case FilterType.Range:b.push(this.MakeVariable(d.NameLowerValue,d.LowerValue,d.SerializedLowerValue,d.DataType,!1));b.push(this.MakeVariable(d.NameUpperValue,d.UpperValue,
d.SerializedUpperValue,d.DataType,!1));break;case FilterType.Collection:b.push(this.MakeVariable(d.Name,d.Values,d.SerializedValue,d.DataType,!0))}}return b};this.ParametersToVariables=function(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];b.push(this.MakeVariable(d.Name,d.Value,d.SerializedValue,d.DataType,d.Type==ParameterType.Collection))}return b};this.ReplaceVariablesValuesInText=function(a,b){return 0<=a.indexOf("&")?this.ReplaceValuesInTextMain(b,a):a};this.ReplaceValuesInTextMain=function(a,
b){function c(a,b,c,d){if(0<=a.indexOf("&"))for(var e=!1,g=-1;!e;)if(g=a.toLowerCase().indexOf("&"+b.toLowerCase(),g+1),0<=g){var l=a.substr(g+b.length+1,1);"a"<=l&&"z">=l||("A"<=l&&"Z">=l||"0"<=l&&"9">=l||"_"==l)||d.push({Pos:g,Name:b,SerializedValue:c})}else e=!0}for(var d=[],e=0;e<a.length;e++){var g=a[e];c(b,g.Name,g.SerializedValue,d)}d.sort(function(a,b){return a.Pos<b.Pos?-1:a.Pos>b.Pos?1:0});g=b;for(e=d.length-1;0<=e;e--)g=g.substr(0,d[e].Pos)+d[e].SerializedValue+g.substr(d[e].Pos+d[e].Name.length+
1);return g};this.ReplaceVariableValue=function(a,b,c,d){b=this.CheckVariable(a,b,c,d);return b.IsVariable?b.Value:a};this.ReplaceVariableValueInFilter=function(a,b,c,d,e){a=this.CheckVariable(a,[d.DataType],d.Type==FilterType.Collection,e);a.IsVariable&&(d[b]=a.Value,c&&(d[c]=a.SerializedValue))};this.CheckVariable=function(a,b,c,d){var e=!1,g="",f=null,h=null;if("string"===typeof a&&a.startsWith("&"))for(var a=a.substr(1,a.length-1).toLowerCase(),j=0;j<d.length;j++){var k=d[j];if(k.Name.toLowerCase()==
a&&0<=b.indexOf(k.DataType)&&k.IsCollection==c){e=!0;g="&"+k.Name;f=k.Value;h=k.SerializedValue;break}}return{IsVariable:e,Name:g,Value:f,SerializedValue:h}};this.CheckVariableInEditMode=function(a,b,c){if(this.IsDashboardEdit()){var d=this.DashboardObject,e=[b];b==DataType.Real&&e.push(DataType.Integer);a=this.CheckVariable(a,e,c,d.Variables.AllParameters.concat(d.Variables.Standard))}else a={IsVariable:!1};return a};this.ResolveVariable=function(a,b,c){return null!=a?this.CheckVariableInEditMode(a,
b,c).IsVariable?this.GetEmptyValue(b,!1):a:a};this.ValidParameters=function(){if(!this._ValidParametersCalculated){var a=this.DashboardObject;this._ValidParameters=[];for(var b=0;b<a.Parameters.length;b++){var c=a.Parameters[b],d;a:{d=a;for(var e=c.Name,g=0;g<d.Filters.length;g++){var f=d.Filters[g];if(!f.IsHidden){var h=f.Type==FilterType.Range;if(!h&&f.Name.toLowerCase()==e.toLowerCase()||h&&(f.NameLowerValue.toLowerCase()==e.toLowerCase()||f.NameUpperValue.toLowerCase()==e.toLowerCase())){d=!0;
break a}}}d=!1}!d&&null==this.GetObjectElementForFilter(c.Name)&&this._ValidParameters.push(c)}this._ValidParametersCalculated=!0}return this._ValidParameters};this.GetElementReferences=function(a){function b(a,b){for(var c="",d=0;d<a.Filters.length;d++){var e=a.Filters[d];if(!e.IsHidden)if(e.Type==FilterType.Range)if(e.NameLowerValue.toLowerCase()==b.toLowerCase()){c=e.NameLowerValue;break}else{if(e.NameUpperValue.toLowerCase()==b.toLowerCase()){c=e.NameUpperValue;break}}else if(e.Name.toLowerCase()==
b.toLowerCase()){c=e.Name;break}}return c}function c(a,b){var c=a.GetObjectElementForFilter(b);return null==c?"":c.Element.Name}function d(a,b){for(var c="",d=0;d<a.Parameters.length;d++){var e=a.Parameters[d];if(e.Name.toLowerCase()==b.toLowerCase()){c=e.Name;break}}return c}for(var e=this.DashboardObject,g="",f="",h="",j="",k="",m=0;m<a.Parameters.length;m++){var o=a.Parameters[m],l=b(e,o);""!=l?f+=(""==f?"":", ")+l:(l=c(this,o),""!=l?h+=(""==h?"":", ")+l:(l=d(e,o),""!=l?j+=(""==j?"":", ")+l:k+=
(""==k?"":", ")+o))}if(""!=f||""!=j||""!=h)g+='<span class="gx-db-dependencies-title">'+gx.getMessage("GX_Dashboard_DependsOn")+":</span>",""!=f&&(g+='<br><span class="gx-db-dependencies-subtitle">'+gx.getMessage("GX_Dashboard_Filters")+":</span>&nbsp"+f),""!=h&&(g+='<br><span class="gx-db-dependencies-subtitle">'+gx.getMessage("GX_Dashboard_ObjectElements")+":</span>&nbsp"+h),""!=j&&(g+='<br><span class="gx-db-dependencies-subtitle">'+gx.getMessage("GX_Dashboard_Parameters")+":</span>&nbsp"+j);""!=
k&&(""!=g&&(g+="<br>"),g+='<span class="gx-db-not-resolved-dependencies-title">'+gx.getMessage("GX_Dashboard_UnknownValues")+":</span><br>"+k);h=f="";if(a.ElementType==ElementType.Widget&&(a.WidgetType==WidgetType.Filter&&!a.IsHidden||a.WidgetType==WidgetType.Object&&a.OnItemClick==OnItemClick.ApplyFilters)){for(m=0;m<e.AllElements.length;m++)if(j=e.AllElements[m],a!=j&&(j.ElementType==ElementType.Widget||j.ElementType==ElementType.Layout)){var q;a.WidgetType==WidgetType.Filter?q=this.IsFilterRelated(j,
a):a.WidgetType==WidgetType.Object&&(q=this.IsObjectRelated(j,a));q&&(h+=(""==h?"":", ")+(j.ElementType==ElementType.Layout?j.ElementType:j.ControlName))}""!=h&&(f+='<span class="gx-db-impact-title">'+gx.getMessage("GX_Dashboard_ImpactedElements")+":</span><br>"+h)}return{DependenciesHTML:g,ImpactHTML:f}};this.GetWidget=function(a){for(var b=this.DashboardObject,c=0;c<b.AllWidgets.length;c++)if(widget=b.AllWidgets[c],widget.ElementId==a)return widget;return null};this.OldRadioButton=function(){return 0>
gx.plugdesign.definition.templates.indexOf("radio-button")};this.TwoRowsTableHTML=function(a,b,c,d,e,g){return this.editor.TwoRowsTableHTML(a,b,c,d,e,g)};this.TwoCellsTableHTML=function(a,b,c,d,e,g,f){var h=this.editor.TableClass(null==a,!1,""),j=this.editor.RowClass(""),k;this.IsDashboardEdit()?(k="gx-db-flex-cell gx-db-flex-cell-3"+(f?" gx-db-flex-cell-order-2":""),f="gx-db-flex-cell gx-db-flex-cell-9"+(f?" gx-db-flex-cell-order-1":"")):(k="col-xs-12 col-sm-3"+(f?" col-sm-push-9":""),f="col-xs-12 col-sm-9"+
(f?" col-sm-pull-3":""));k=this.editor.CellClass(k,!1,!1,"");f=this.editor.CellClass(f,!1,!1,"");a=this.editor.DIVStart(a,b,h,"height:"+c+";width:"+d,!1,!0,!1);return a+('<div class="'+j+'" style="height:100%">')+('<div class="'+k+'" style="height:100%">'+e+"</div>")+('<div class="'+f+'" style="height:100%">'+g+"</div>")+"</div></div>"};this.GetLayoutHTML=function(a){function b(a,b,c,d,e,m,o){if(b||a.IsDashboardEdit())switch(c){case FiltersPosition.Top:return a.TwoRowsTableHTML(d,e,"100%","100%",
m,o);case FiltersPosition.Right:return a.TwoCellsTableHTML(d,e,"100%","100%",m,o,!0);case FiltersPosition.Left:return a.TwoCellsTableHTML(d,e,"100%","100%",m,o,!1)}else return o}var c=this.editor.GetDOMElementId(a.Layout.ElementId),d=this.editor.GetTableHTML(a,a.Layout.MainTable,!1,[],!0),e=this.editor.GetTableHTML(a,a.Layout.FiltersTable,!1,[],!0);this.ReplaceDashboardParametersInLayout(a.Layout);""!=a.Layout.Title?(d=b(this,0<a.Filters.length,a.Layout.FiltersPosition,null,"",e,d),e=this.CenteredTextHTML("gx-db-title-text",
"gx-db-title",this.ReplaceVariablesValuesInText(a.Layout.Title,a.Variables.Filters)),a=this.TwoRowsTableHTML(a.Layout,c,"100%","100%",e,d)):a=b(this,0<a.Filters.length,a.Layout.FiltersPosition,a.Layout,c,e,d);return a};this.GetWidgetContentHTML=function(a,b){var c;this.ReplaceDashboardParametersInWidget(b);switch(b.WidgetType){case WidgetType.Object:c=this.GetObjectWidgetHTML(b);break;case WidgetType.Filter:c=this.GetFilterWidgetHTML(b,a.Variables.Filters);break;case WidgetType.TextBlock:c=this.GetTextBlockWidgetHTML(b,
a.Variables.Filters);break;case WidgetType.Button:c=this.GetButtonWidgetHTML(b,a.Variables.Filters);break;case WidgetType.Image:c=this.GetImageWidgetHTML(b,a.Variables.Filters);break;case WidgetType.Blank:c="";break;default:c="Not implemented"}return c};this.GetObjectMenuHTML=function(a){var b="";if(a.WidgetType==WidgetType.Object){for(var c=this.DashboardObject,b=b+('<div style="position:absolute;right:2px;top:'+(!this.WidgetsExpanded?"calc((100% - 33px) / 2)":"2px")+'" class="dropdown"><button class="gx-db-object-menu btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><span class="gx-db-object-menu-icon glyphicon glyphicon-menu-hamburger"></span></button>'),
b=b+('<ul class="dropdown-menu'+(c.Layout.FiltersPosition==FiltersPosition.Right?"":" dropdown-menu-right")+'">'),c=0;c<a.Elements.length;c++)var d=a.Elements[c].Name,b=b+('<li><a href="#" onclick="'+this.me()+".editor.SelectObjectItem(event, '"+a.ElementId+"', '"+d+"')\">"+d+"</a></li>");b+="</ul></div>"}return b};this.GetObjectWidgetHTML=function(a){var b=this.me()+".RenderQueryViewer('"+a.ElementId+"');";setTimeout(b,0);b=""+('<div id="'+this.GetQueryViewerElementId(a.ElementId)+'"></div>');this.IsDashboardEdit()&&
(b+=this.GetObjectMenuHTML(a));return b};this.GetTextBlockWidgetHTML=function(a,b){var c=this.ReplaceVariablesValuesInText(a.Caption,b);return'<span class="'+(""==a.Class?"gx-db-textblock":a.Class)+'">'+c+"</span>"};this.GetButtonWidgetHTML=function(a,b){var c=this.ReplaceVariablesValuesInText(a.Caption,b);return'<input type="button" class="btn btn-default '+(""==a.Class?"gx-db-button":a.Class)+'" value="'+c+'"></button>'};this.GetImageWidgetHTML=function(a,b){var c=this.ReplaceVariablesValuesInText(a.AlternateText,
b),d=gx.ajax.imageGuidToUrl(a.Guid);this.IsDashboardEdit()&&(d="Resources/TempImages/"+d);return'<img class="'+(""==a.Class?"gx-db-image":a.Class)+'" src="'+d+'"'+(""!=c?' alt="'+c+'"':"")+">"};this.GetFilterWidgetHTML=function(a,b){function c(a,b,c,d,e){if(""!=b.Caption){var f=""==b.CaptionClass?"gx-db-filter-caption":b.CaptionClass;""!=d&&(f+=" "+d);return'<label class="'+f+'"'+(""==e?"":' for="'+e+'"')+">"+a.ReplaceVariablesValuesInText(b.Caption,c)+"</label>"}return""}function d(a){return a.Control.Dynamic&&
(a.Control.RefreshValues||!a.Control.ValuesLoaded)}function e(a,b,d){var e;e=""+c(a,b,d,"","");var f=""==b.ValueClass?"gx-db-filter-value":b.ValueClass,d=a.ReplaceVariablesValuesInText(b.Control.InviteMessage,d),d=""!=d?' placeholder="'+d+'"':"",g;switch(b.Type){case FilterType.Value:g=b.SerializedValue;break;case FilterType.Range:g=b.SerializedLowerValue+" - "+b.SerializedUpperValue;break;case FilterType.Collection:g=b.SerializedValue.replace(/"/g,"&quot;")}var h="";a.IsDashboardEdit()&&(h=' onfocus="'+
a.me()+".editor.RemoveDraggableAttributes('"+b.ElementId+'\')" onblur="'+a.me()+'.editor.RestoreDraggableAttributes()"');b=b.Type==FilterType.Range?"SplitAndUpdateFilter2(this, '"+b.NameLowerValue+"', '"+b.NameUpperValue+"', this.value)\"":"UpdateFilter1(this, '"+b.Name+"', this.value)\"";return e+='<input type="text" class="'+f+' form-control" value="'+g+'"'+d+' onchange="'+a.me()+"."+b+h+">"}function g(a,b,d){d=""+c(a,b,d,"","");d+='<div id="'+a.GetRangeElementId(b.ElementId)+'"></div><div style="height:20px"></div>';
a=a.me()+".CreateSlider('"+b.ElementId+"');";setTimeout(a,0);return d}function f(a,b,c){return a.OldRadioButton()?m(a,b,c):h(a,b,c)}function h(a,b,e){function f(a,b,c,d,e,g,u){return'<div class="btn-group"><button type="button" class="'+u+" btn btn-default"+(d?" active":"")+'"'+(e?' style="text-align:center"':"")+' onclick="'+a.me()+".UpdateFilter1(this, '"+g.Name+"', '"+b+"')\">"+c+"</button></div>"}var g=""==b.ValueClass?"gx-db-filter-value":b.ValueClass,e=""+c(a,b,e,"",""),h=b.Control.Orientation==
ControlOrientation.Vertical,e=b.Control.Orientation==ControlOrientation.Horizontal?e+'<div class="btn-group btn-group-justified">':e+'<div class="btn-group-vertical" style="width:100%">';if(d(b))var j=gx.getMessage("GX_Dashboard_Loading"),e=e+f(a,j,j,!1,h,b,g);else{b.Control.EmptyItem&&(j=a.GetEmptyValue(b.DataType,!1),e+=f(a,a.ValueToString(j,b.DataType,b.Picture,b.PictureProperties),gx.getMessage(b.Control.EmptyItemText),a.SameValue(j,b.Value,b.DataType),h,b,g));for(var l=0;l<b.Control.Values.length;l++)var j=
b.Control.Values[l],k=b.Control.Descriptions[l],e=e+f(a,a.ValueToString(j,b.DataType,b.Picture,b.PictureProperties),k,a.SameValue(j,b.Value,b.DataType),h,b,g)}return e+"</div>"}function j(a,b,e){function f(a,b,c,d){return'<option value="'+b+'"'+(d?" selected":"")+">"+c+"</option>"}var e=""+c(a,b,e,"",""),g=""==b.ValueClass?"gx-db-filter-value":b.ValueClass,h=d(b),e=e+('<select class="'+g+' form-control" onchange="'+a.me()+".UpdateFilter1(this, '"+b.Name+"', this.value)\">");if(h)g=gx.getMessage("GX_Dashboard_Loading"),
e+=f(a,g,g,!1,b);else{b.Control.EmptyItem&&(g=a.GetEmptyValue(b.DataType,!1),e+=f(a,a.ValueToString(g,b.DataType,b.Picture,b.PictureProperties),gx.getMessage(b.Control.EmptyItemText),a.SameValue(g,b.Value,b.DataType),b));for(h=0;h<b.Control.Values.length;h++)var g=b.Control.Values[h],j=b.Control.Descriptions[h],e=e+f(a,a.ValueToString(g,b.DataType,b.Picture,b.PictureProperties),j,a.SameValue(g,b.Value,b.DataType),b)}return e+"</select>"}function k(a,b,e){function f(a,b,c,d,e,g){return'<option class="'+
g+'" value="'+b+'"'+(d?" selected":"")+">"+c+"</option>"}var e=""+c(a,b,e,"",""),g=""==b.ValueClass?"gx-db-filter-value":b.ValueClass,h=d(b),j=h?' title="'+gx.getMessage("GX_Dashboard_Loading")+'"':"",l=' data-select-all-text="'+gx.getMessage("GX_Dashboard_SelectAll")+'" data-deselect-all-text="'+gx.getMessage("GX_Dashboard_DeselectAll")+'" data-none-selected-text="'+gx.getMessage("GX_Dashboard_NothingSelected")+'" data-count-selected-text="'+gx.getMessage("GX_Dashboard_ItemsSelectedQuantity")+'" data-none-results-text="'+
gx.getMessage("GX_Dashboard_NoResultsMatch")+'" data-multiple-separator=", "',k=gx.util.browser.isSmartDevice()?' data-mobile="true"':"",e=e+('<select data-style="'+g+'" class="selectpicker form-control" multiple'+k+' data-icon-base = "material-icons" data-tick-icon = "" data-selected-text-format="count > 3" data-actions-box="true" data-live-search="true" data-live-search-placeholder="'+gx.getMessage("GX_Dashboard_SearchFilter")+'" onchange="'+a.me()+".UpdateDropDownListFilter(this, '"+b.Name+"')\""+
j+l+">");if(!h){b.Control.EmptyItem&&(h=a.GetEmptyValue(b.DataType,!1),e+=f(a,a.ValueToString(h,b.DataType,b.Picture,b.PictureProperties),gx.getMessage(b.Control.EmptyItemText),0<=a.ValuesIndexOf(b.Values,h,b.DataType),b,g));j=gx.util.browser.isSmartDevice()?" gx-db-sd":"";for(l=0;l<b.Control.Values.length;l++)h=b.Control.Values[l],k=b.Control.Descriptions[l],e+=f(a,a.ValueToString(h,b.DataType,b.Picture,b.PictureProperties),k,0<=a.ValuesIndexOf(b.Values,h,b.DataType),b,g+j)}e+="</select>";a=a.me()+
".CreateDropDownList('"+b.ElementId+"');";setTimeout(a,0);return e}function m(a,b,e){function f(a,b,c,d,e,g){var h="",a='<input type="radio" name="optradio_'+e.ControlName+'" onclick="'+a.me()+".UpdateFilter1(this, '"+e.Name+"', '"+b+"')\""+(d?"checked ":"")+">";return h=e.Control.Orientation==ControlOrientation.Horizontal?'<label class="'+g+' radio-inline">'+a+c+"</label>":'<div class="radio"><label class="'+g+'">'+a+c+"</label></div>"}var e=""+c(a,b,e,"",""),g=""==b.ValueClass?"gx-db-filter-value":
b.ValueClass;""!=b.Caption&&b.Control.Orientation==ControlOrientation.Horizontal&&(e+="<p>");if(d(b))var h=gx.getMessage("GX_Dashboard_Loading"),e=e+f(a,h,h,!1,b,g);else{b.Control.EmptyItem&&(h=a.GetEmptyValue(b.DataType,!1),e+=f(a,a.ValueToString(h,b.DataType,b.Picture,b.PictureProperties),gx.getMessage(b.Control.EmptyItemText),a.SameValue(h,b.Value,b.DataType),b,g));for(var j=0;j<b.Control.Values.length;j++)var h=b.Control.Values[j],l=b.Control.Descriptions[j],e=e+f(a,a.ValueToString(h,b.DataType,
b.Picture,b.PictureProperties),l,a.SameValue(h,b.Value,b.DataType),b,g)}""!=b.Caption&&b.Control.Orientation==ControlOrientation.Horizontal&&(e+="</p>");return e}function o(a,b,e){function f(a,b,c,d,e,g){var h="",j=d?"checked ":"",u=gx.util.browser.isSmartDevice()?'class="gx-db-sd" ':"",h=a.GetRangeElementId(e.ElementId)+"_"+b,j='<input id="'+h+'" type="checkbox" '+u+j+'onchange="'+a.me()+".UpdateFilterValue(this, '"+e.Name+"', '"+b+"', this.checked)\">",a='<i class="material-icons" onclick="document.getElementById(\''+
h+"').checked = this.textContent == 'check_box_outline_blank';"+a.me()+".UpdateFilterValue(this, '"+e.Name+"', '"+b+"', this.textContent == 'check_box_outline_blank')\">"+(d?"check_box":"check_box_outline_blank")+"</i>";return h=e.Control.Orientation==ControlOrientation.Horizontal?j+a+'<label class="'+g+' checkbox-inline" for="'+h+'">'+c+"</label>":'<div class="checkbox">'+j+a+'<label class="'+g+'" for="'+h+'">'+c+"</label></div>"}var e=""+c(a,b,e,"",""),g=""==b.ValueClass?"gx-db-filter-value":b.ValueClass;
""!=b.Caption&&b.Control.Orientation==ControlOrientation.Horizontal&&(e+="<p>");if(d(b))var h=gx.getMessage("GX_Dashboard_Loading"),e=e+f(a,h,h,!1,b,g);else{b.Control.EmptyItem&&(h=a.GetEmptyValue(b.DataType,!1),e+=f(a,a.ValueToString(h,b.DataType,b.Picture,b.PictureProperties),gx.getMessage(b.Control.EmptyItemText),0<=a.ValuesIndexOf(b.Values,h,b.DataType),b,g));for(var j=0;j<b.Control.Values.length;j++)var h=b.Control.Values[j],l=b.Control.Descriptions[j],e=e+f(a,a.ValueToString(h,b.DataType,b.Picture,
b.PictureProperties),l,0<=a.ValuesIndexOf(b.Values,h,b.DataType),b,g)}""!=b.Caption&&b.Control.Orientation==ControlOrientation.Horizontal&&(e+="</p>");return e}function l(a,b,d){var e="",f=b.Value?"checked ":"",g=gx.util.browser.isSmartDevice()?'class="gx-db-sd" ':"",h=a.GetRangeElementId(b.ElementId),f='<input id="'+h+'" type="checkbox" '+g+f+'onchange="'+a.me()+".UpdateFilter1(this, '"+b.Name+"', this.checked.toString())\">",e=e+f,f='<i class="material-icons" onclick="document.getElementById(\''+
h+"').checked = this.textContent == 'check_box_outline_blank';"+a.me()+".UpdateFilter1(this, '"+b.Name+"', this.textContent == 'check_box_outline_blank')\">"+(b.Value?"check_box":"check_box_outline_blank")+"</i>";return e=e+f+c(a,b,d,"checkbox-inline",h)}function q(a,b,c){switch(b.Control.Type){case ControlType.Editbox:return e(a,b,c);case ControlType.RadioButton:return f(a,b,c);case ControlType.ComboBox:return j(a,b,c);case ControlType.Slider:return g(a,b,c);default:return e(a,b,c)}}function n(a,
b,c){switch(b.Control.Type){case ControlType.Editbox:return e(a,b,c);case ControlType.RadioButton:return f(a,b,c);case ControlType.ComboBox:return j(a,b,c);default:return e(a,b,c)}}function s(a,b,d){switch(b.Control.Type){case ControlType.Editbox:return e(a,b,d);case ControlType.Checkbox:return l(a,b,d);case ControlType.RadioButton:return f(a,b,d);case ControlType.ComboBox:return j(a,b,d);case ControlType.Switch:return d=""+c(a,b,d,"gx-db-switch-label",""),d+='<input type="checkbox" id="'+a.GetRangeElementId(b.ElementId)+
'">',a=a.me()+".CreateSwitch('"+b.ElementId+"');",setTimeout(a,0),d;default:return l(a,b,d)}}function v(a,b,d){switch(b.Control.Type){case ControlType.Editbox:var h=!(b.Type==FilterType.Value&&gx.util.browser.isSmartDevice()),d=""+c(a,b,d,"",""),l=""==b.ValueClass?"gx-db-filter-value":b.ValueClass,k;if(b.Type==FilterType.Range){k="";var m=a.CheckVariableInEditMode(b.LowerValue,b.DataType,!1),o=a.CheckVariableInEditMode(b.UpperValue,b.DataType,!1);if(m.IsVariable||o.IsVariable||!gx.date.isNullDate(b.LowerValue)||
!gx.date.isNullDate(b.UpperValue))k=m.IsVariable?k+m.SerializedValue:k+(gx.date.isNullDate(b.LowerValue)?"":a.ValueToString(b.LowerValue,b.DataType,b.Picture,b.PictureProperties)),k+=" - ",k=o.IsVariable?k+o.SerializedValue:k+(gx.date.isNullDate(b.UpperValue)?"":a.ValueToString(b.UpperValue,b.DataType,b.Picture,b.PictureProperties)),k=' value="'+k+'"'}else k=a.CheckVariableInEditMode(b.Value,b.DataType,!1),k=k.IsVariable?' value="'+k.SerializedValue+'"':gx.date.isNullDate(b.Value)?"":' value="'+(h?
a.ValueToString(b.Value,b.DataType,b.Picture,b.PictureProperties):a.ValueToInternalString(b.Value,b.DataType,b.Picture,b.PictureProperties).replace(" ","T"))+'"';m=b.Type==FilterType.Range?"SplitAndUpdateFilter2(this, '"+b.NameLowerValue+"', '"+b.NameUpperValue+"', this.value)\"":h?"UpdateFilter1(this, '"+b.Name+"', this.value)\"":"UpdateFilter1Internal(this, '"+b.Name+"', this.value)\"";h?(h=gx.util.browser.isSmartDevice()?' onfocus="blur()"':"",d+='<input id="'+a.GetRangeElementId(b.ElementId)+
'" type="text" class="'+l+' form-control"'+k+' onchange="'+a.me()+"."+m+h+">",a=a.me()+".CreateDatePicker('"+b.ElementId+"');",setTimeout(a,0)):(h=null!=b.MinValue?' min="'+a.ValueToInternalString(b.MinValue,b.DataType,b.Picture,b.PictureProperties).replace(" ","T")+'"':"",o=null!=b.MaxValue?' max="'+a.ValueToInternalString(b.MaxValue,b.DataType,b.Picture,b.PictureProperties).replace(" ","T")+'"':"",d+='<input type="'+(b.DataType==DataType.Date?"date":"datetime-local")+'" class="'+l+' form-control"'+
k+h+o+' onchange="'+a.me()+"."+m+">");return d;case ControlType.RadioButton:return f(a,b,d);case ControlType.ComboBox:return j(a,b,d);case ControlType.Slider:return g(a,b,d);default:return e(a,b,d)}}if(a.Visible){if(d(a)){var w=this,x=this.QueryFilterName(a);qv.services.createAsyncServerCallFn(this.FakeQueryViewer(x),qv.services.url.getDataURL,qv.services.postInfo.Data,"GetData")(function(b){w.ControlValuesLoaded(a,b)})}if(a.Type==FilterType.Collection)switch(a.Control.Type){case ControlType.Editbox:return e(this,
a,b);case ControlType.Checkbox:return o(this,a,b);case ControlType.DropDownList:return k(this,a,b);default:return o(this,a,b)}else switch(a.DataType){case DataType.Integer:return q(this,a,b);case DataType.Real:return q(this,a,b);case DataType.Character:return n(this,a,b);case DataType.Boolean:return s(this,a,b);case DataType.Date:return v(this,a,b);case DataType.DateTime:return v(this,a,b);case DataType.GUID:return n(this,a,b);default:return"Not implemented"}}else return a.Type==FilterType.Range?
a.NameLowerValue+" = "+a.SerializedLowerValue+"; "+a.NameUpperValue+" = "+a.SerializedUpperValue:a.Name+" = "+a.SerializedValue};this.ControlValuesLoaded=function(a,b){var c={xml:{data:b}};if(qv.util.anyError(b)){c.Data={Rows:[]};var d=qv.util.getErrorFromText(b);this.ShowError(a.ElementId,d,!1)}else qv.services.parseDataXML(c);a.Control.RefreshValues=!1;a.Control.ValuesLoaded=!0;a.Control.Values=[];a.Control.Descriptions=[];for(d=0;d<c.Data.Rows.length;d++){var e=c.Data.Rows[d],g=qv.util.trim(e.F1),
e=qv.util.trim(e.F2),g=this.ParseInternalValue(g,a.DataType,!1),e=this.ParseInternalValue(e,DataType.Character,!1);g.Success&&e.Success&&(a.Control.Values.push(g.ParsedValue),a.Control.Descriptions.push(e.ParsedValue))}0>this.ValuesIndexOf(a.Control.Values,a.Value,a.DataType)&&0<a.Control.Values.length&&(a.Value=a.Control.EmptyItem?this.GetEmptyValue(a.DataType,!1):a.Control.Values[0]);this.RefreshWidget(a)};this.CreateDatePicker=function(a){function b(a){var b;b=0<=a.DateFormat.indexOf("4")?a.DateFormat.replace("D",
"DD/").replace("M","MM/").replace("Y4","YYYY/").substr(0,10):a.DateFormat.replace("D","DD/").replace("M","MM/").replace("Y","YY/").substr(0,8);a.IncludeHours&&(b+=12==gx.timeFormat?" hh":" HH");a.IncludeMinutes&&(b+=":mm");a.IncludeSeconds&&(b+=":ss");12==gx.timeFormat&&(b+=" A");return b}var c=this.DashboardObject,d=this.GetWidget(a);if(null!=d){a={parentEl:"#"+this.editor.GetDOMElementId(1),autoApply:!1,linkedCalendars:!1,opens:c.Layout.FiltersPosition==FiltersPosition.Right?"left":"right",singleDatePicker:d.Type!=
FilterType.Range,autoUpdateInput:!1,showDropdowns:!0,locale:{format:b(d.PictureProperties),monthNames:[gx.getMessage("GX_Dashboard_January"),gx.getMessage("GX_Dashboard_February"),gx.getMessage("GX_Dashboard_March"),gx.getMessage("GX_Dashboard_April"),gx.getMessage("GX_Dashboard_May"),gx.getMessage("GX_Dashboard_June"),gx.getMessage("GX_Dashboard_July"),gx.getMessage("GX_Dashboard_August"),gx.getMessage("GX_Dashboard_September"),gx.getMessage("GX_Dashboard_October"),gx.getMessage("GX_Dashboard_November"),
gx.getMessage("GX_Dashboard_December")],daysOfWeek:[gx.getMessage("GX_Dashboard_Sunday"),gx.getMessage("GX_Dashboard_Monday"),gx.getMessage("GX_Dashboard_Tuesday"),gx.getMessage("GX_Dashboard_Wednesday"),gx.getMessage("GX_Dashboard_Thursday"),gx.getMessage("GX_Dashboard_Friday"),gx.getMessage("GX_Dashboard_Saturday")],applyLabel:gx.getMessage("GX_Dashboard_Apply"),cancelLabel:gx.getMessage("GX_Dashboard_Cancel")}};null!=d.MinValue&&(c=this.CheckVariable(d.MinValue,[d.DataType],d.Type==FilterType.IsCollection,
this.DashboardObject.Variables.AllParameters),c.IsVariable||(a.minDate=d.MinValue.getStringWithFmt(d.PictureProperties.DateFormat)));null!=d.MaxValue&&(c=this.CheckVariable(d.MaxValue,[d.DataType],d.Type==FilterType.IsCollection,this.DashboardObject.Variables.AllParameters),c.IsVariable||(a.maxDate=d.MaxValue.getStringWithFmt(d.PictureProperties.DateFormat)));d.DataType==DataType.DateTime&&d.PictureProperties.IncludeHours&&(a.timePicker=!0,a.timePicker24Hour=24==gx.timeFormat,a.timePickerSeconds=
d.PictureProperties.IncludeSeconds);c=n("#"+this.GetRangeElementId(d.ElementId));c.daterangepicker(a);var e=this;c.on("apply.daterangepicker",function(a,b){function c(a,b,d){d=new gx.date.gxdate(d);d.HasTimePart=b.DataType==DataType.DateTime;return a.ValueToString(d,b.DataType,b.Picture,b.PictureProperties)}if(d.Type==FilterType.Range){var j=c(e,d,b.startDate._d),k=c(e,d,b.endDate._d);n(this).val(j+" - "+k);e.UpdateFilter2(this,d.NameLowerValue,d.NameUpperValue,j,k)}else{j=c(e,d,b.startDate._d);n(this).val(j);
e.UpdateFilter1(this,d.Name,j)}})}};this.CreateSlider=function(a){var b=this.GetWidget(a);if(null!=b){var c,d,e,g,f,h,j,k,a=this.ResolveVariable(b.MaxValue,b.DataType,b.Type==FilterType.Collection),m=this.ResolveVariable(b.MinValue,b.DataType,b.Type==FilterType.Collection);b.Type==FilterType.Value?h=this.ResolveVariable(b.Value,b.DataType,b.Type==FilterType.Collection):(j=this.ResolveVariable(b.LowerValue,b.DataType,b.Type==FilterType.Collection),k=this.ResolveVariable(b.UpperValue,b.DataType,b.Type==
FilterType.Collection));b._noUiSliderSlideExecuted=!1;b.Type==FilterType.Range&&(b._noUiSliderIsLowerValue=!0);switch(b.DataType){case DataType.Integer:case DataType.Real:b.Type==FilterType.Value?d=c=h:(c=j,d=k);e=null!=m?m:c-50;g=null!=a?a:d+50;f=b.DataType==DataType.Integer?1:1/Math.pow(10,b.PictureProperties.DecimalPrecision);break;case DataType.Date:b.Type==FilterType.Value?(b.MinValueResolved=null!=m?m:gx.date.dtadd(h,-432E4),b.MaxValueResolved=null!=a?a:gx.date.dtadd(h,432E4)):(b.MinValueResolved=
null!=m?m:gx.date.dtadd(j,-432E4),b.MaxValueResolved=null!=a?a:gx.date.dtadd(k,432E4));e=0;g=gx.date.daysDiff(b.MaxValueResolved,b.MinValueResolved);b.Type==FilterType.Value?d=c=gx.date.daysDiff(h,b.MinValueResolved):(c=gx.date.daysDiff(j,b.MinValueResolved),d=gx.date.daysDiff(k,b.MinValueResolved));f=1;break;case DataType.DateTime:b.Type==FilterType.Value?(b.MinValueResolved=null!=m?m:gx.date.dtadd(h,-432E4),b.MaxValueResolved=null!=a?a:gx.date.dtadd(h,432E4)):(b.MinValueResolved=null!=m?m:gx.date.dtadd(j,
-432E4),b.MaxValueResolved=null!=a?a:gx.date.dtadd(k,432E4)),e=0,g=gx.date.dtdiff(b.MaxValueResolved,b.MinValueResolved),b.Type==FilterType.Value?d=c=gx.date.dtdiff(h,b.MinValueResolved):(c=gx.date.dtdiff(j,b.MinValueResolved),d=gx.date.dtdiff(k,b.MinValueResolved)),f=1}var o=this;h=document.getElementById(this.GetRangeElementId(b.ElementId));f={start:b.Type==FilterType.Value?[c]:[c,d],step:f,tooltips:!0,connect:b.Type==FilterType.Range,behaviour:"drag-tap",format:{to:function(a){var c=false;if(!b._noUiSliderSlideExecuted){if(b.Type==
FilterType.Value)c=b.Value;else{c=b._noUiSliderIsLowerValue?b.LowerValue:b.UpperValue;b._noUiSliderIsLowerValue=!b._noUiSliderIsLowerValue}var d=o.CheckVariableInEditMode(c,b.DataType,b.Type==FilterType.Collection),c=d.IsVariable}if(c)return d.SerializedValue;var e;switch(b.DataType){case DataType.Integer:e=a;break;case DataType.Real:e=a;break;case DataType.Date:e=gx.date.dtadd(b.MinValueResolved,Math.round(a)*86400);break;case DataType.DateTime:e=gx.date.dtadd(b.MinValueResolved,Math.round(a))}return o.ValueToString(e,
b.DataType,b.Picture,b.PictureProperties)},from:function(a){return parseFloat(a)}}};e!=g?f.range={min:e,max:g}:(f.range={min:c-1,max:d+1},f.disabled=!0);noUiSlider.create(h,f);h.noUiSlider.on("slide",function(){b._noUiSliderSlideExecuted=true});h.noUiSlider.on("set",function(){if(b.Type!=FilterType.Range)o.UpdateFilter1(null,b.Name,this.get());else{var a=this.get();o.UpdateFilter2(null,b.NameLowerValue,b.NameUpperValue,a[0],a[1])}});c=""==b.ValueClass?"gx-db-filter-value":b.ValueClass;n("#"+this.GetRangeElementId(b.ElementId)+
" .noUi-tooltip").addClass(c)}};this.CreateSwitch=function(a){var b=this.GetWidget(a);if(null!=b){var a={size:"small",state:b.Value,handleWidth:0,labelWidth:10,onText:"",offText:"",onColor:"primary",offColor:"default"},c=this,d=n("#"+this.GetRangeElementId(b.ElementId));d.bootstrapSwitch(a);d.on("switchChange.bootstrapSwitch",function(a,g){c.UpdateFilter1(null,b.Name,g.toString());g?(d.bootstrapSwitch("onColor","primary"),d.bootstrapSwitch("offColor","primary")):(d.bootstrapSwitch("onColor","default"),
d.bootstrapSwitch("offColor","default"))})}};this.CreateDropDownList=function(a){null!=this.GetWidget(a)&&n("#"+this.editor.GetDOMElementId(widget.ElementId)+" > .selectpicker").selectpicker()};this.GetQueryViewerAxes=function(a,b){for(var c=JSON.parse(JSON.stringify(a.Elements)),d=0;d<c.length;d++)this.ReplaceVariablesInObjectElement(c[d],b);return c};this.GetQueryViewerParameters=function(a){function b(a,b,c,d,e){c=d==DataType.Real?c.replace(",","."):c;return{Name:b,Value:a.ResolveVariable(c,d,
e)}}for(var c=[],d=0;d<a.Filters.length;d++){var e=a.Filters[d],g;e.Type!=FilterType.Range?g=b(this,e.Name,e.SerializedValue,e.DataType,e.Type==FilterType.Collection):(g=b(this,e.NameLowerValue,e.SerializedLowerValue,e.DataType,e.Type==FilterType.Collection),c.push(g),g=b(this,e.NameUpperValue,e.SerializedUpperValue,e.DataType,e.Type==FilterType.Collection));c.push(g)}for(d=0;d<a.Parameters.length;d++)e=a.Parameters[d],g=b(this,e.Name,e.SerializedValue,e.DataType,e.Type==ParameterType.Collection),
c.push(g);return c};this.GetEmptyValueStr=function(a,b){if(b)return"[]";switch(a){case DataType.Integer:case DataType.Real:return"0";case DataType.Character:return"";case DataType.Boolean:return"false";case DataType.Date:return"0000-00-00";case DataType.DateTime:return"0000-00-00 00:00:00";case DataType.GUID:return"00000000-0000-0000-0000-000000000000";default:return""}};this.GetEmptyValue=function(a,b){if(b)return[];switch(a){case DataType.Integer:case DataType.Real:return 0;case DataType.Character:return"";
case DataType.Boolean:return!1;case DataType.Date:case DataType.DateTime:return new gx.date.gxdate;case DataType.GUID:return"00000000-0000-0000-0000-000000000000";default:return null}};this.NextControlId=function(){this._queryViewerId?this._queryViewerId++:this._queryViewerId=1;return this.ParentObject.GXLastCtrlId+this._queryViewerId+1};this.QueryFilterName=function(a){return this.DashboardObject.Name+"_"+a.ControlName};this.RenderQueryViewer=function(a){var b=this.GetWidget(a);if(null!=b){var a=
this.GetQueryViewerElementId(b.ElementId),c;if(!b.QueryViewer||b.QueryViewer.ContainerName!=a){var d=this.ParentObject,e=this.NextControlId(),g="QueryViewer"+b.ElementId,f=g.toUpperCase();c=gx.uc.getNew(d,e,0,"QueryViewer",a,g,f);d.setUserControl(c);b.QueryViewer=c}else c=b.QueryViewer;a=this.DashboardObject.Variables.Filters;d=this.GetQueryViewerParameters(this.DashboardObject);e=this.GetQueryViewerAxes(b,a);this.InitializeQueryViewer(c);c.Class=""==b.Class?"gx-db-object":b.Class;c.Visible=!0;c.Enabled=
!0;c.SetParameters(d);c.SetAxes(e);c.ReturnSampleData=b.Type==ObjectType.DataProvider&&this.IsDashboardEdit()?!0:this.ReturnSampleData;c.ObjectName=b.Name;c.ObjectType=b.Type;c.Title=this.ReplaceVariablesValuesInText(b.Output.Title,a);c.Type=b.Output.Type;c.ChartType=b.Output.ChartType;c.PlotSeries=b.Output.PlotSeries;c.XAxisLabels=b.Output.XAxisLabels;c.XAxisIntersectionAtZero=b.Output.XAxisIntersectionAtZero;c.XAxisTitle=this.ReplaceVariablesValuesInText(b.Output.XAxisTitle,a);c.YAxisTitle=this.ReplaceVariablesValuesInText(b.Output.YAxisTitle,
a);c.ShowValues=b.Output.ShowValues;c.ShowDataAs=b.Output.ShowDataAs;c.Orientation=b.Output.Orientation;c.IncludeTrend=b.Output.IncludeTrend;c.TrendPeriod=b.Output.TrendPeriod;c.IncludeSparkline=b.Output.IncludeSparkline;c.IncludeMaxAndMin=b.Output.IncludeMaxAndMin;c.Paging=b.Output.Paging;c.PageSize=this.ReplaceVariableValue(b.Output.PageSize,[DataType.Integer],!1,a);c.ShowDataLabelsIn=b.Output.ShowDataLabelsIn;if(b.OnItemClick==OnItemClick.ApplyFilters||b.OnItemClick==OnItemClick.HighlightValues||
b.OnItemClick==OnItemClick.RaiseItemClick&&this.ItemClick){c.AllowSelection=b.OnItemClick==OnItemClick.ApplyFilters||b.OnItemClick==OnItemClick.HighlightValues;var h=this;c.ItemClick=function(){h.ProcessItemClick(b,c)}}else c.ItemClick&&delete c.ItemClick;if(b.OnItemClick!=OnItemClick.ApplyFilters&&b.HiddenFilters&&0<b.HiddenFilters.length){a=[];for(d=0;d<c.Metadata.Axes.length;d++)e=c.Metadata.Axes[d],this.RemoveHiddenFilter(b,e.Name),a.push(e.Name);0<a.length&&this.RefreshDashboard(a)}c.show()}};
this.ProcessItemClick=function(a,b){switch(a.OnItemClick){case OnItemClick.ApplyFilters:this.ApplyHiddenFilters(a,b);break;case OnItemClick.HighlightValues:var c=this.HighlightValues(a,b);this.ValuesHighlighted&&(this.LoadValuesHighlightedData(c),this.ValuesHighlighted());break;case OnItemClick.RaiseItemClick:this.LoadItemClickData(a,b),this.ItemClick()}};this.FakeQueryViewer=function(a){var b=this.GetQueryViewerParameters(this.DashboardObject),c={RealType:"Table",Axes:[]};c.Parameters=b;c.ParentObject=
{PackageName:this.ParentObject.PackageName};c.ObjectName=a;c.ObjectType=ObjectType.Query;c.ObjectId=0;c.QueryInfo="";c.AppSettings=[];c.AllowChangeAxesOrder=!1;c.UseRecordsetCache=!1;c.ReturnSampleData=this.ReturnSampleData;return c};this.InitializeQueryViewer=function(a){a.AutoRefreshGroup="";a.SetDragAndDropData({});a.SetItemExpandData({});a.SetItemCollapseData({});a.SetFilterChangedData({});a.SetItemClickData({});a.SetItemDoubleClickData({});a.ObjectId=0;a.ObjectType="";a.QueryInfo="";a.AppSettings=
"";a.IsExternalQuery=!1;a.ExternalQueryResult="";a.AvoidAutomaticShow=!1;a.ExecuteShow=!1;a.ObjectInfo="";a.SetAxes([]);a.SetParameters([]);a.ObjectName="";a.Class="";a.AutoResize=!1;a.Width="100%";a.Height="100%";a.ShowAxesSelectors="BothSelectors";a.AllowChangeAxesOrder=!1;a.DisableColumnSort=!1;a.FontFamily="";a.FontSize=0;a.FontColor=gx.color.fromRGB(0,0,0);a.ExportToXML=!0;a.ExportToHTML=!0;a.ExportToXLS=!0;a.ExportToXLSX=!0;a.ExportToPDF=!0;a.Title="";a.Type=OutputType.Chart;a.ChartType=ChartType.Column;
a.Paging=!0;a.PageSize=20;a.CurrentPage=0;a.ShowDataLabelsIn=ShowDataLabelsIn.Columns;a.PlotSeries=PlotSeries.InTheSameChart;a.XAxisLabels=XAxisLabels.Horizontally;a.XAxisIntersectionAtZero=!1;a.ShowValues=!0;a.XAxisTitle="";a.YAxisTitle="";a.ShowDataAs=ShowDataAs.Values;a.Orientation=Orientation.Horizontal;a.IncludeTrend=!1;a.TrendPeriod=TrendPeriod.SinceTheBeginning;a.IncludeSparkline=!1;a.IncludeMaxAndMin=!1;a.RememberLayout=!0};this.HighlightValues=function(a,b){var c=[],d=b.ItemClickData;if(d.Selected)for(var e=
0;e<d.Context.length;e++){var g=d.Context[e],f=this.GetAxisInMetadata(b.Metadata,g.Name);null!=f&&1==g.Values.length&&c.push({Name:f.Name,Value:g.Values[0]})}d=this.DashboardObject;for(e=0;e<d.Objects.length;e++)d.Objects[e].ElementId!=a.ElementId&&(g=d.Objects[e].QueryViewer,g.AllowSelection=!0,g.Select(c));return c};this.CheckFilterValue=function(a,b,c,d,e,g,f,h){function j(a,b){if(b==FilterType.Collection)return gx.getMessage("GX_Dashboard_NotAValidJSON");switch(a){case DataType.Integer:case DataType.Real:return gx.getMessage("GX_Dashboard_NotAValidNumber");
case DataType.Boolean:return gx.getMessage("GX_Dashboard_NotAValidBoolean");case DataType.Date:return gx.getMessage("GX_Dashboard_NotAValidDate");case DataType.DateTime:return gx.getMessage("GX_Dashboard_NotAValidDateTime");case DataType.GUID:return gx.getMessage("GX_Dashboard_NotAValidGUID");default:return""}}function k(a,b,c,d,e){return null!=d&&b!=DataType.Boolean&&c!=FilterType.Collection?b==DataType.Date||b==DataType.DateTime?e?0<=a.compare(d):0>=a.compare(d):e?a>=d:a<=d:!0}var m=null,o="",l=
"",a=""==a?this.GetEmptyValueStr(b,c==FilterType.Collection):a,n=this.CheckVariableInEditMode(a,b,c==FilterType.Collection),p={};n.IsVariable?(p.Success=!0,p.ParsedValue=n.Value,o=n.SerializedValue):p=h?this.ParseInternalValue(a,b,c==FilterType.Collection):this.ParseValue(a,b,c==FilterType.Collection);p.Success?k(p.ParsedValue,b,c,g,!0)?k(p.ParsedValue,b,c,f,!1)?(m=p.ParsedValue,n.IsVariable||(o=c==FilterType.Collection?this.ValuesToString(m,b,d,e):this.ValueToString(m,b,d,e))):l=gx.getMessage("GX_Dashboard_MaximumExceeded"):
l=gx.getMessage("GX_Dashboard_MinimumExceeded"):l=j(b,c);return{Success:""==l,IsVariable:n.IsVariable,ParsedValue:m,ParsedSerializedValue:o,Message:l}};this.UpdateFilterLayout=function(a,b,c){function d(a,b){if(!a.OldRadioButton()){for(var c=0;c<b.parentNode.parentNode.childNodes.length;c++)b.parentNode.parentNode.childNodes[c].childNodes[0].classList.remove("active");b.classList.add("active")}}function e(a,b){for(var c="INPUT"==b.tagName?b:b.previousSibling,d=!1,e=0;e<b.parentNode.childNodes.length;e++){var g=
b.parentNode.childNodes[e];g.id==c.id&&(d=!0);if(g.classList.contains("material-icons")&&d){g.textContent="check_box_outline_blank"==g.textContent?"check_box":"check_box_outline_blank";break}}}if(null!=a)switch(b.Control.Type){case ControlType.Editbox:var g;switch(b.Type){case FilterType.Value:g=c?this.ValueToInternalString(b.Value,b.DataType,b.Picture,b.PictureProperties).replace(" ","T"):b.SerializedValue;break;case FilterType.Range:g=b.SerializedLowerValue+" - "+b.SerializedUpperValue;break;case FilterType.Collection:g=
b.SerializedValue}a.value=g;break;case ControlType.RadioButton:d(this,a);break;case ControlType.Checkbox:e(this,a)}};this.UpdateFilter1=function(a,b,c){return this.UpdateFilterMain(a,b,null,c,null,!1)};this.UpdateFilter2=function(a,b,c,d,e){return this.UpdateFilterMain(a,b,c,d,e,!1)};this.UpdateFilter1Internal=function(a,b,c){return this.UpdateFilterMain(a,b,null,c,null,!0)};this.SplitAndUpdateFilter2=function(a,b,c,d){var e=d.split(" - ");1==e.length&&(e=d.split("-"));var g=d="";1<=e.length&&(d=
e[0]);2<=e.length&&(g=e[1]);this.UpdateFilter2(a,b,c,d,g)};this.UpdateFilterMain=function(a,b,c,d,e,g){var f=this.GetFilterByNames([b,c]),h=!1,j=!1;if(null!=f){d=this.CheckFilterValue(d,f.DataType,f.Type,f.Picture,f.PictureProperties,f.MinValue,f.MaxValue,g);e=f.Type==FilterType.Range?this.CheckFilterValue(e,f.DataType,f.Type,f.Picture,f.PictureProperties,f.MinValue,f.MaxValue,g):{Success:!0,Message:""};d.Success&&(e.Success&&f.Type==FilterType.Range&&1==this.CompareValues(d.ParsedValue,e.ParsedValue,
f.DataType))&&(d.Success=!1,d.Message=gx.getMessage("GX_Dashboard_LowerValueGreaterThanUpperValue"));if(d.Success&&e.Success){if(f.Type==FilterType.Collection){if(h=f.SerializedValue!=d.ParsedSerializedValue)f.Values=d.ParsedValue,f.SerializedValue=d.ParsedSerializedValue}else if(f.Type!=FilterType.Range?h=f.SerializedValue!==d.ParsedSerializedValue:(h=f.SerializedLowerValue!==d.ParsedSerializedValue,j=f.SerializedUpperValue!==e.ParsedSerializedValue),h||j)f.Type!=FilterType.Range?(f.Value=d.ParsedValue,
f.SerializedValue=d.ParsedSerializedValue):(f.LowerValue=d.ParsedValue,f.UpperValue=e.ParsedValue,f.SerializedLowerValue=d.ParsedSerializedValue,f.SerializedUpperValue=e.ParsedSerializedValue);this.HideError()}else this.ShowError(f.ElementId,d.Message+(""==e.Message?"":" ")+e.Message,!0);(h||j||f.Control.Type==ControlType.Editbox)&&this.UpdateFilterLayout(a,f,g);if(h||j)a=[],null!=b&&h&&a.push(b),null!=c&&j&&a.push(c),this.RefreshDashboard(a),this.IsDashboardEdit()&&(f.Type!=FilterType.Range?(b=d.IsVariable?
d.ParsedSerializedValue:f.Type==FilterType.Collection?f.SerializedValue:this.ValueToInternalString(f.Value,f.DataType,f.Picture,f.PictureProperties),window.external.SetFilterValue(f.ElementId,b)):(b=d.IsVariable?d.ParsedSerializedValue:this.ValueToInternalString(f.LowerValue,f.DataType,f.Picture,f.PictureProperties),c=e.IsVariable?e.ParsedSerializedValue:this.ValueToInternalString(f.UpperValue,f.DataType,f.Picture,f.PictureProperties),window.external.SetFilterValues(f.ElementId,b,c)))}return h||j};
this.ShowError=function(a,b,c){var d=this.editor.GetErrorDiv(),e=n("#"+this.editor.GetDOMElementId(a)),g=e.offset(),f=window.getComputedStyle(document.getElementById(this.editor.GetDOMElementId(a))),a=parseInt(f.getPropertyValue("padding-bottom")),f=parseInt(f.getPropertyValue("padding-left"));d.style.left=gx.dom.addUnits(parseInt(g.left+f));d.style.top=gx.dom.addUnits(parseInt(g.top+e.height()+a));d.style.width=gx.dom.addUnits(e.width());d.innerText=b;d.style.display="block";d.classList.remove("gx-db-fade");
this._errorFadeTimeout&&clearTimeout(this._errorFadeTimeout);c&&(b=this.me()+".FadeError();",this._errorFadeTimeout=setTimeout(b,5E3))};this.HideError=function(){this.editor.GetErrorDiv().style.display="none"};this.FadeError=function(){this.editor.GetErrorDiv().classList.add("gx-db-fade")};this.UpdateFilterValue=function(a,b,c,d){for(var e=this.DashboardObject,g=!1,f=0;f<e.Filters.length;f++){var h=e.Filters[f];if(h.Name==b){c=this.CheckFilterValue(c,h.DataType,FilterType.Value,h.Picture,h.PictureProperties,
null,null,!1);if(c.Success){if(e=this.ValuesIndexOf(h.Values,c.ParsedValue,h.DataType),0>e&&d&&(h.Values.push(c.ParsedValue),h.SerializedValue=this.ValuesToString(h.Values,h.DataType,h.Picture,h.PictureProperties),g=!0),0<=e&&!d)h.Values.splice(e,1),h.SerializedValue=this.ValuesToString(h.Values,h.DataType,h.Picture,h.PictureProperties),g=!0}else this.ShowError(h.ElementId,c.Message,!0);g&&(this.UpdateFilterLayout(a,h,!1),this.RefreshDashboard([b]),this.IsDashboardEdit()&&window.external.SetFilterValue(h.ElementId,
h.SerializedValue));break}}};this.UpdateDropDownListFilter=function(a,b){var c=this.GetFilterByName(b);if(null!=c){var d;d=c.DataType==DataType.Character||c.DataType==DataType.Date||c.DataType==DataType.DateTime||c.DataType==DataType.GUID?'"':"";for(var e="",g=0;g<a.options.length;g++)if(a.options[g].selected){var f=this.CheckFilterValue(a.options[g].value,c.DataType,FilterType.Value,c.Picture,c.PictureProperties,null,null,!1);f.Success&&(f=d+this.ValueToInternalString(f.ParsedValue,c.DataType,c.Picture,
c.PictureProperties)+d,e+=(""==e?"":", ")+f)}this.UpdateFilter1(a,b,"["+e+"]")}};this.ApplyHiddenFilters=function(a,b){for(var c=b.ItemClickData,d=[],e=0;e<c.Context.length;e++){var g=c.Context[e],f=this.GetAxisInMetadata(b.Metadata,g.Name);if(null!=f&&1==g.Values.length)if(c.Selected){var h=this.GetHiddenFilterDataType(f),g=this.ParseValue(g.Values[0],h,!1);g.Success&&this.AddHiddenFilter(a,f.Name,g.ParsedValue,h)&&d.push(f.Name)}else this.RemoveHiddenFilter(a,f.Name),d.push(f.Name)}0<d.length&&
this.RefreshDashboard(d)};this.RemoveHiddenFilter=function(a,b){for(var c=this.DashboardObject,d=0;d<c.Filters.length;d++)if(filter=c.Filters[d],filter.Name==b&&filter.IsHidden){c.Filters.splice(d,1);break}c=a.HiddenFilters.indexOf(b);0<=c&&a.HiddenFilters.splice(c,1)};this.GetFilterByName=function(a){return this.GetFilterByNames([a])};this.GetFilterByNames=function(a){for(var b=this.DashboardObject,c=0;c<b.Filters.length;c++){filter=b.Filters[c];var d=filter.Type==FilterType.Range;if(!d&&filter.Name==
a[0]||d&&filter.NameLowerValue==a[0]&&filter.NameUpperValue==a[1])return filter}return null};this.GetFilterByAnyName=function(a){for(var b=this.DashboardObject,c=0;c<b.Filters.length;c++)if(filter=b.Filters[c],filter.Type==FilterType.Range){if(filter.NameLowerValue.toLowerCase()==a.toLowerCase()||filter.NameUpperValue.toLowerCase()==a.toLowerCase())return filter}else if(filter.Name.toLowerCase()==a.toLowerCase())return filter;return null};this.AddHiddenFilter=function(a,b,c,d){for(var e=this.DashboardObject,
g=!1,f,h=!1,h=0;h<e.Filters.length;h++)if(f=e.Filters[h],f.Name==b){g=!0;break}if(g){if(h=f.Value!==c)f.Value=c,f.SerializedValue=this.ValueToString(f.Value,f.DataType,f.Picture,f.PictureProperties)}else f={},this.FilterDefaults(f,e),f.IsHidden=!0,f.Name=b,f.DataType=d,f.Type=FilterType.Value,f.MinValue="",f.MaxValue="",e.Filters.push(f),a.HiddenFilters=a.HiddenFilters||[],a.HiddenFilters.push(b),f.Value=c,this.ProcessFilter(f),h=!0;return h};this.GetAxisInMetadata=function(a,b){for(var c=0;c<a.Axes.length;c++){var d=
a.Axes[c];if(d.Name==b)return d}return null};this.GetHiddenFilterDataType=function(a){if(null!=a)switch(a.DataType){case "integer":return DataType.Integer;case "real":return DataType.Real;case "character":return DataType.Character;case "boolean":return DataType.Boolean;case "date":return DataType.Date;case "datetime":return DataType.DateTime;case "guid":return DataType.GUID;default:return DataType.Integer}else return DataType.Integer}};
