Example #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Ensure brand ID is specified
            int brandId = BrandId;

            // Ensure brand admin is accessing their own brand
            if (CurrentUser.UserRole.Equals(UserRole.BrandAdministrator) && !brandId.Equals(CurrentUser.PrimaryBrandId))
            {
                Response.Redirect("~/Admin/Default.aspx");
            }

            // Get the brand
            Brand brand = Brand.Get(brandId);

            // Set the page header
            PageHeaderDiv.InnerText = string.Format("Configure Metadata for {0}", brand.Name);

            if (!Page.IsPostBack)
            {
                // Ensure we have a brand
                if (brand.IsNull)
                {
                    Response.Redirect("ConfigureMetadata.aspx?redirect=search-filters", true);
                }

                // Get all of the metadata settings for this brand
                BindDataList();

                // load markup
                MarkupTextBox.Text = BrandManager.GetBrandFilterMarkup(brandId);

                // General brand options
                EnableFiltersCheckbox.Checked = !brand.HideFilterSearch;
            }
            else
            {
                //=======
                //make sure the preview state of preview list/drop down is preserved - otherwise they'll just load
                //what's stored in the database
                //load the other one as it should show - otherwise the meta setting stored in the database will kick in
                LoadPreviewState();

                //=======
                //we need to query the request this way because we are overriding the
                //asp.net radiobutton behaviour with a custom implementation that would allow
                //us to have many radio inputs with the same name rendered with via a datalist
                var eventArg = Request["__EVENTARGUMENT"];

                if (!string.IsNullOrEmpty(eventArg))
                {
                    SelectedGroup = int.Parse(eventArg.Replace("@@@@@", ""));
                    GroupChanged();
                    BindDataList();
                }
            }
        }
Example #2
0
 protected void LoadDefaultTemplateButton_Click(object sender, EventArgs e)
 {
     MarkupTextBox.Text = BrandManager.GetBrandFilterMarkup(BrandId);
     GeneralFeedbackLabel.SetSuccessMessage("template markup was reset. in order to apply the new template you will have to save the changes.");
 }
        /// <summary>
        /// loads the current brand filter template and inputs
        /// </summary>
        public void LoadFilter()
        {
            if (BrandId <= 0)
            {
                return;
            }

            //use preview template if set if not
            //then use the brand one,
            //if not then the system default
            Template = string.IsNullOrEmpty(Template) ? BrandManager.GetBrandFilterMarkup(BrandId) : Template;
            var parsedGroups = ParseTemplate();

            if (parsedGroups == null)
            {
                throw new Exception("template could not be parsed. examine whether you are supplying valid xml.");
            }

            //use preview selectables if available
            //if not query the database
            var all            = PreviewSelectables ?? BrandMetadataSettingManager.GetCustomMetadataSettings(BrandId);
            var enabledFilters = all
                                 .Where(s => s.UiControlType == (int)BrandMetadataUiControlType.Select)
                                 .ToList()
                                 .Where(s => s.SelectableSetting.FilterGroup > 0)
                                 .ToList();

            //reset controls so that other previous calls to this routine are not taken into account
            //and controls that are not required (for ex. the ones persisted from the previous postback)
            //are not stuffed in here with the rest
            TemporaryMetaControlsPlaceHolder.Controls.Clear();

            foreach (var f in enabledFilters)
            {
                var parsedGrp = parsedGroups.FirstOrDefault(g => g.num == f.SelectableSetting.FilterGroup);

                //no group defined in the template or set in the config - therefore we shouldn't
                //be bothered with it and continue to the next
                if (parsedGrp.num <= 0 || f.SelectableSetting.FilterGroup <= 0)
                {
                    continue;
                }

                var input = new MetadataInputWrapper();
                //visualise as its set to be seen on the catalogue and not as in admin
                //we are basically overriding the default brand meta setting values for the metadata input
                //this way
                f.SelectableSetting.SelectableType = f.SelectableSetting.FilterSelectableType;
                f.SelectableSetting.Depth          = f.SelectableSetting.FilterDepth;

                input.SetTempBrandMetaSetting(f);
                input.IncludeJqueryReference = false;
                input.GroupNumber            = f.GroupNumber;
                input.BrandId = BrandId;
                input.ResetState();
                input.InitInput(true);
                //apply the settings from the template
                input.ApplyCustomControlAttributes(parsedGrp.inputStyle, parsedGrp.inputTxt, parsedGrp.inputVal);
                input.RefreshFromBrandAndSelet(BrandId, new int[] { }, string.Empty);

                TemporaryMetaControlsPlaceHolder.Controls.Add(input);
            }
        }