Beispiel #1
0
        /// <summary>
        /// Writes the <see cref="T:System.Web.UI.WebControls.CompositeControl" /> content to the specified <see cref="T:System.Web.UI.HtmlTextWriter" /> object, for display on the client.
        /// </summary>
        /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter" /> that represents the output stream to render HTML content on the client.</param>
        public override void RenderControl(HtmlTextWriter writer)
        {
            DataFilterComponent component = null;
            string clientFormatString     = string.Empty;

            if (!string.IsNullOrWhiteSpace(FilterEntityTypeName))
            {
                component = Rock.Reporting.DataFilterContainer.GetComponent(FilterEntityTypeName);
                if (component != null)
                {
                    clientFormatString =
                        string.Format("if ($(this).find('.filter-view-state').children('i').attr('class') == 'fa-chevron-up') {{ var $article = $(this).parents('article:first'); var $content = $article.children('div.panel-body'); $article.find('div.filter-item-description:first').html({0}); }}", component.GetClientFormatSelection(FilteredEntityType));
                }
            }

            if (component == null)
            {
                hfExpanded.Value = "True";
            }

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel panel-widget filter-item");
            writer.RenderBeginTag("article");

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel-heading clearfix");
            if (!string.IsNullOrEmpty(clientFormatString))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Onclick, clientFormatString);
            }
            writer.RenderBeginTag("header");

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-expanded");
            hfExpanded.RenderControl(writer);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "pull-left");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-item-description");
            if (Expanded)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.Write(component != null ? component.FormatSelection(FilteredEntityType, Selection) : "Select Filter");
            writer.RenderEndTag();

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-item-select");
            if (!Expanded)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.RenderBeginTag(HtmlTextWriterTag.Span);
            writer.Write("Filter Type ");
            writer.RenderEndTag();

            ddlFilterType.RenderControl(writer);
            writer.RenderEndTag();

            writer.RenderEndTag();


            writer.AddAttribute(HtmlTextWriterAttribute.Class, "pull-right");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "btn btn-xs filter-view-state");
            writer.RenderBeginTag(HtmlTextWriterTag.A);
            writer.AddAttribute(HtmlTextWriterAttribute.Class, Expanded ? "fa fa-chevron-up" : "fa fa-chevron-down");
            writer.RenderBeginTag(HtmlTextWriterTag.I);
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.Write(" ");
            lbDelete.RenderControl(writer);
            writer.RenderEndTag();

            writer.RenderEndTag();

            writer.AddAttribute("class", "panel-body");
            if (!Expanded)
            {
                writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
            }
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            if (component != null)
            {
                component.RenderControls(FilteredEntityType, this, writer, filterControls);
            }
            writer.RenderEndTag();

            writer.RenderEndTag();
        }
Beispiel #2
0
        /// <summary>
        /// Writes the <see cref="T:System.Web.UI.WebControls.CompositeControl" /> content to the specified <see cref="T:System.Web.UI.HtmlTextWriter" /> object, for display on the client.
        /// </summary>
        /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter" /> that represents the output stream to render HTML content on the client.</param>
        public override void RenderControl(HtmlTextWriter writer)
        {
            DataFilterComponent component = null;
            string clientFormatString     = string.Empty;

            if (!string.IsNullOrWhiteSpace(FilterEntityTypeName))
            {
                component = Rock.Reporting.DataFilterContainer.GetComponent(FilterEntityTypeName);
                if (component != null)
                {
                    clientFormatString =
                        string.Format("if ($(this).find('.filter-view-state').children('i').hasClass('fa-chevron-up')) {{ var $article = $(this).parents('article:first'); var $content = $article.children('div.panel-body'); $article.find('div.filter-item-description:first').html({0}); }}", component.GetClientFormatSelection(FilteredEntityType));
                }
            }

            if (component == null)
            {
                hfExpanded.Value = "True";
            }

            bool showFilterTypePicker = this.FilterMode == FilterMode.AdvancedFilter;

            if (showFilterTypePicker)
            {
                // only render this stuff if the filter type picker is shown
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel panel-widget filter-item");

                writer.RenderBeginTag("article");

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel-heading clearfix");
                if (!string.IsNullOrEmpty(clientFormatString))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Onclick, clientFormatString);
                }

                writer.RenderBeginTag("header");

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-expanded");
                hfExpanded.RenderControl(writer);

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "pull-left");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-item-description");
                if (Expanded)
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
                writer.Write(component != null ? component.FormatSelection(FilteredEntityType, this.GetSelection()) : "Select Filter");
                writer.RenderEndTag();

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-item-select");
                if (!Expanded)
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.RenderBeginTag(HtmlTextWriterTag.Span);
                writer.Write("Filter Type ");
                writer.RenderEndTag();

                ddlFilterType.RenderControl(writer);
                writer.RenderEndTag();

                writer.RenderEndTag();

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "pull-right");
                writer.RenderBeginTag(HtmlTextWriterTag.Div);

                writer.AddAttribute(HtmlTextWriterAttribute.Class, "btn btn-link btn-xs filter-view-state");
                writer.RenderBeginTag(HtmlTextWriterTag.A);
                writer.AddAttribute(HtmlTextWriterAttribute.Class, Expanded ? "fa fa-chevron-up" : "fa fa-chevron-down");
                writer.RenderBeginTag(HtmlTextWriterTag.I);
                writer.RenderEndTag();
                writer.RenderEndTag();
                writer.Write(" ");
                lbDelete.Visible = (this.DeleteClick != null);
                lbDelete.RenderControl(writer);
                writer.RenderEndTag();

                writer.RenderEndTag();

                writer.AddAttribute("class", "panel-body");
                if (!Expanded)
                {
                    writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none");
                }
                writer.RenderBeginTag(HtmlTextWriterTag.Div);
            }

            writer.AddAttribute("class", "row js-filter-row filterfield");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);
            writer.AddAttribute("class", "col-md-12");
            writer.RenderBeginTag(HtmlTextWriterTag.Div);

            if (ShowCheckbox)
            {
                //// EntityFieldFilter renders the checkbox itself (see EntityFieldFilter.cs),
                //// so only render the checkbox if we are hiding filter criteria and it isn't an entity field filter
                if (!(component is Rock.Reporting.DataFilter.EntityFieldFilter) || HideFilterCriteria)
                {
                    cbIncludeFilter.Text = this.Label;
                    cbIncludeFilter.RenderControl(writer);
                }
            }
            else if (!string.IsNullOrWhiteSpace(this.Label))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "control-label");
                writer.AddAttribute(HtmlTextWriterAttribute.For, this.ClientID);
                writer.RenderBeginTag(HtmlTextWriterTag.Label);
                writer.Write(Label);
                writer.RenderEndTag();  // label
            }

            if (component != null && !HideFilterCriteria)
            {
                component.RenderControls(FilteredEntityType, this, writer, filterControls, this.FilterMode);
            }

            writer.RenderEndTag(); // "col-md-12"
            writer.RenderEndTag(); // "row js-filter-row filter-row"

            if (showFilterTypePicker)
            {
                writer.RenderEndTag();

                writer.RenderEndTag();
            }
        }