Beispiel #1
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {

            OptionSelection result = new OptionSelection();
            result.OptionBvin = baseOption.Bvin;

            string val = string.Empty;

            foreach (OptionItem o in baseOption.Items)
            {
                
                if (!o.IsLabel)
                {
                    string checkId = "opt" + o.Bvin.Replace("-", "");
                    System.Web.UI.HtmlControls.HtmlInputCheckBox cb = (System.Web.UI.HtmlControls.HtmlInputCheckBox)ph.FindControl(checkId);
                    if (cb != null)
                    {
                        if (cb.Checked)
                        {                                                     
                                string temp = "";
                                if (val.Length > 0)
                                {
                                    temp += ",";
                                }
                                temp += o.Bvin;
                                val += temp;                         
                        }
                    }
                }
            }

            result.SelectionData = val;
     
            return result;
        }
Beispiel #2
0
        public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            string radioId = "opt" + val.SelectionData.Replace("-", "");

            System.Web.UI.HtmlControls.HtmlInputRadioButton rb = (System.Web.UI.HtmlControls.HtmlInputRadioButton)ph.FindControl(radioId);
            if (rb != null)
            {
                rb.Checked = true;
            }
        }
Beispiel #3
0
        public OptionSelection ParseFromPlaceholder(Option baseOption, PlaceHolder ph, string prefix = null)
        {
            var result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            foreach (var o in baseOption.Items)
            {
                if (!o.IsLabel)
                {
                    var radioId = "opt" + prefix + o.Bvin.Replace("-", string.Empty);
                    var rb      = (HtmlInputRadioButton)ph.FindControl(radioId);
                    if (rb != null)
                    {
                        if (rb.Checked)
                        {
                            result.SelectionData = o.Bvin;
                            return(result);
                        }
                    }
                }
            }

            return(result);
        }
        public OptionSelection ParseFromPlaceholder(Option baseOption, PlaceHolder ph, string prefix = null)
        {
            var result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            var optionBvins = new List <string>();

            foreach (var o in baseOption.Items)
            {
                if (!o.IsLabel)
                {
                    var checkId = "opt" + prefix + o.Bvin.Replace("-", string.Empty);
                    var cb      = (HtmlInputCheckBox)ph.FindControl(checkId);
                    if (cb != null && cb.Checked)
                    {
                        optionBvins.Add(o.Bvin);
                    }
                }
            }

            result.SelectionData = string.Join(",", optionBvins);

            return(result);
        }
        private void RenderVariants(Product p)
        {
            StringBuilder sb            = new StringBuilder();
            int           renderedCount = 0;

            List <OptionSelectionList> possibleVariants = MTApp.CatalogServices.VariantsGenerateAllPossibleSelections(p.Options);

            foreach (OptionSelectionList possible in possibleVariants)
            {
                string  possibleKey = OptionSelection.GenerateUniqueKeyForSelections(possible);
                Variant v           = p.Variants.FindByKey(possibleKey);
                if (v != null)
                {
                    RenderSingleVariant(sb, p.Options.VariantsOnly(), v, p);
                    renderedCount += 1;
                }
            }

            if ((renderedCount >= MerchantTribe.Commerce.WebAppSettings.MaxVariants))
            {
                this.litOutput.Text  = "<div class=\"flash-message-warning\">This product has " + renderedCount + " variants. The maximum allowed is " + WebAppSettings.MaxVariants + ". If you need more variants try creating separate products with fewer choices that affect Pictures, Sku and Price.</div>";
                this.litOutput.Text += sb.ToString();
            }
            else
            {
                this.litOutput.Text = sb.ToString();
            }
        }
Beispiel #6
0
        public void can_read_the_options_for_a_selection()
        {
            ProjectTemplate g       = theGraph.FindCategory("new").FindTemplate("Complex");
            OptionSelection select1 = g.Selections.First();

            select1.Options.Select(x => x.Name).ShouldHaveTheSameElementsAs("Chiefs", "Broncos");
        }
Beispiel #7
0
        /// <summary>
        /// Adds the possible product variant.
        /// </summary>
        //[TestMethod]
        public void AddPossibleProductVariant()
        {
            //Arrange
            var prj = GetRootProduct();

            _application.CatalogServices.VariantsGenerateAllPossible(prj);
            var count = _irepoproductvariant.GetTotalProductVariantCount();

            //Act
            var possibleVariants = _application.CatalogServices.VariantsGenerateAllPossibleSelections(prj.Options);
            var lstv             = new List <Variant>();
            var prj1             = GetRootProduct();

            foreach (var possible in possibleVariants)
            {
                var possibleKey = OptionSelection.GenerateUniqueKeyForSelections(possible);
                var v           = prj1.Variants.FindByKey(possibleKey);
                if (v != null)
                {
                    lstv.Add(v);
                }
            }


            //Assert
            Assert.AreEqual(count, lstv.Count);
        }
Beispiel #8
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            string val = string.Empty;

            foreach (OptionItem o in baseOption.Items)
            {
                if (!o.IsLabel)
                {
                    string checkId = "opt" + o.Bvin.Replace("-", "");
                    System.Web.UI.HtmlControls.HtmlInputCheckBox cb = (System.Web.UI.HtmlControls.HtmlInputCheckBox)ph.FindControl(checkId);
                    if (cb != null)
                    {
                        if (cb.Checked)
                        {
                            string temp = "";
                            if (val.Length > 0)
                            {
                                temp += ",";
                            }
                            temp += o.Bvin;
                            val  += temp;
                        }
                    }
                }
            }

            result.SelectionData = val;

            return(result);
        }
Beispiel #9
0
        public void can_read_the_description_for_a_selection()
        {
            ProjectTemplate g       = theGraph.FindCategory("new").FindTemplate("Complex");
            OptionSelection select1 = g.Selections.First();

            select1.Description.ShouldEqual("the selection");
        }
Beispiel #10
0
        private bool IsSelected(OptionItem item, OptionSelectionList selections)
        {
            bool result = false;

            if (selections == null)
            {
                return(false);
            }

            OptionSelection val = selections.FindByOptionId(item.OptionBvin);

            if (val == null)
            {
                return(result);
            }

            string[] vals = val.SelectionData.Split(',');
            foreach (string s in vals)
            {
                if (s == item.Bvin.Replace("-", ""))
                {
                    return(true);
                }
            }
            return(result);
        }
Beispiel #11
0
        public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            string[] vals = val.SelectionData.Split(',');
            foreach (string s in vals)
            {
                string checkId = "opt" + s.Replace("-", "");
                System.Web.UI.HtmlControls.HtmlInputCheckBox cb = (System.Web.UI.HtmlControls.HtmlInputCheckBox)ph.FindControl(checkId);
                if (cb != null)
                {
                    cb.Checked = true;
                }
            }
        }
Beispiel #12
0
        public void CanGenerateCorrectSelectionData()
        {
            OptionList options = GetSampleOptions();

            VariantList target             = new VariantList();
            MerchantTribeApplication mtapp = MerchantTribeApplication.InstantiateForMemory(new RequestContext());

            List <OptionSelectionList> data = mtapp.CatalogServices.VariantsGenerateAllPossibleSelections(options);

            Assert.IsNotNull(data, "Data should not be null");
            Assert.AreEqual(6, data.Count, "There should be six possible combinations");

            List <string> keys = new List <string>();

            foreach (OptionSelectionList o in data)
            {
                string k = OptionSelection.GenerateUniqueKeyForSelections(o);
                keys.Add(k);
            }
            Assert.AreEqual(6, keys.Count, "Key Count should be six.");
            Assert.IsTrue(keys.Contains("1-101|2-201|"), "Keys should contain 1-101|2-201|");
            Assert.IsTrue(keys.Contains("1-101|2-202|"), "Keys should contain 1-101|2-202|");
            Assert.IsTrue(keys.Contains("1-101|2-203|"), "Keys should contain 1-101|2-203|");
            Assert.IsTrue(keys.Contains("1-102|2-201|"), "Keys should contain 1-102|2-201|");
            Assert.IsTrue(keys.Contains("1-102|2-202|"), "Keys should contain 1-102|2-202|");
            Assert.IsTrue(keys.Contains("1-102|2-203|"), "Keys should contain 1-102|2-203|");
        }
Beispiel #13
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            foreach (OptionItem o in baseOption.Items)
            {
                if (!o.IsLabel)
                {
                    string radioId = "opt" + o.Bvin.Replace("-", "");
                    System.Web.UI.HtmlControls.HtmlInputRadioButton rb = (System.Web.UI.HtmlControls.HtmlInputRadioButton)ph.FindControl(radioId);
                    if (rb != null)
                    {
                        if (rb.Checked)
                        {
                            result.SelectionData = o.Bvin;
                            return(result);
                        }
                    }
                }
            }

            return(result);
        }
Beispiel #14
0
        public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (ddl != null)
            {
                if (ddl.Items.FindByValue(val.SelectionData) != null)
                {
                    ddl.ClearSelection();
                    ddl.Items.FindByValue(val.SelectionData).Selected = true;
                }
            }
        }
        public void SetUp()
        {
            theSelection = new OptionSelection {
                Name = "select"
            };
            theSelection.Options.Add(new Option("a", "a1", "a2"));
            theSelection.Options.Add(new Option("b", "b1", "b2"));
            theSelection.Options.Add(new Option("c", "c1", "c2"));

            theChoices = new TemplateChoices();
            theRequest = new ProjectRequest("MyFoo", "baseline");
        }
        public Catalog.OptionSelection ParseFromForm(Option baseOption, System.Collections.Specialized.NameValueCollection form)
        {
            OptionSelection result = new OptionSelection();
            result.OptionBvin = baseOption.Bvin;

            string formid = "opt" + baseOption.Bvin.Replace("-", "");
            string value = form[formid];
            if (value != null)
            {
                result.SelectionData = value;
            }
            return result;
        }
Beispiel #17
0
        public Catalog.OptionSelection ParseFromForm(Option baseOption, System.Collections.Specialized.NameValueCollection form)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;
            string formid = "opt" + baseOption.Bvin.Replace("-", "");
            string value  = form[formid];

            if (value != null)
            {
                result.SelectionData = value.Trim();
            }
            return(result);
        }
Beispiel #18
0
        public OptionSelection ParseFromForm(Option baseOption, NameValueCollection form, string prefix = null)
        {
            var result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;
            var formid = "opt" + prefix + baseOption.Bvin.Replace("-", string.Empty);
            var value  = form[formid];

            if (value != null)
            {
                result.SelectionData = value;
            }
            return(result);
        }
Beispiel #19
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (tb != null)
            {
                result.SelectionData = tb.Text.Trim();
            }

            return(result);
        }
Beispiel #20
0
        private OptionSelectionList ParseSelections(Product p)
        {
            OptionSelectionList result = new OptionSelectionList();

            foreach (Option opt in p.Options)
            {
                OptionSelection selected = opt.ParseFromPlaceholder(this.phChoices);
                if (selected != null)
                {
                    result.Add(selected);
                }
            }

            return(result);
        }
        public OptionSelection ParseFromPlaceholder(Option baseOption, PlaceHolder ph, string prefix = null)
        {
            var result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            var tb = (TextBox)ph.FindControl(string.Concat("opt", prefix, baseOption.Bvin.Replace("-", string.Empty)));

            if (tb != null)
            {
                result.SelectionData = tb.Text.Trim();
            }

            return(result);
        }
Beispiel #22
0
        private void ParseSelections(ProductPageViewModel model)
        {
            OptionSelectionList result = new OptionSelectionList();

            foreach (Option opt in model.LocalProduct.Options)
            {
                OptionSelection selected = opt.ParseFromForm(Request.Form);
                if (selected != null)
                {
                    result.Add(selected);
                }
            }

            model.Selections = result;
        }
Beispiel #23
0
        public OptionSelection ParseFromPlaceholder(Option baseOption, PlaceHolder ph, string prefix = null)
        {
            var result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            var li = (LiteralControl)ph.FindControl("opt" + prefix + baseOption.Bvin.Replace("-", string.Empty));

            if (li != null)
            {
                result.SelectionData = li.Text.Trim();
            }

            return(result);
        }
Beispiel #24
0
        public OptionSelection ParseFromPlaceholder(Option baseOption, PlaceHolder ph, string prefix = null)
        {
            var result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            var ddl =
                (System.Web.UI.WebControls.DropDownList)
                ph.FindControl("opt" + prefix + baseOption.Bvin.Replace("-", string.Empty));

            if (ddl != null && !string.IsNullOrEmpty(ddl.SelectedValue))
            {
                result.SelectionData = ddl.SelectedValue;
            }

            return(result);
        }
Beispiel #25
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
        {
            string selected = string.Empty;

            if (selections != null)
            {
                OptionSelection sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            StringBuilder sb = new StringBuilder();
            string        c  = this.GetColumns(baseOption);

            if (c == "")
            {
                c = "20";
            }
            string r = this.GetRows(baseOption);

            if (r == "")
            {
                r = "1";
            }

            if (r != "1")
            {
                sb.Append("<textarea id=\"opt" + baseOption.Bvin.Replace("-", "") + "\" cols=\"" + c + "\" rows=\"" + r + "\" ");
                sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
                sb.Append(">");
                sb.Append(selected);
                sb.Append("</textarea>");
            }
            else
            {
                sb.Append("<input type=\"text\" id=\"opt" + baseOption.Bvin.Replace("-", "") + "\" cols=\"" + c + "\" maxlength=\"" + this.GetMaxLength(baseOption) + "\"");
                sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
                sb.Append(" value=\"" + selected + "\"");
                sb.Append("/>");
            }

            return(sb.ToString());
        }
        public OptionSelection ParseFromForm(Option baseOption, NameValueCollection form, string prefix = null)
        {
            var result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;
            var formid = string.Concat("opt", prefix, baseOption.Bvin.Replace("-", string.Empty));
            var value  = form[formid];

            if (value != null)
            {
                //TODO:
                //Setter of OptionSelection.SelectionData cleans BVIN which also replaces all '-' (dash) from rest of string
                //As temporary fix replace the '-' (dash) with invalid file character (?) and reaplce it in CartDescription function
                var uploadedFiles = value.Trim().Replace('-', '?');
                result.SelectionData = uploadedFiles;
            }
            return(result);
        }
Beispiel #27
0
        public string CartDescription(Option baseOption, Catalog.OptionSelectionList selections)
        {
            if (selections == null)
            {
                return(string.Empty);
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return(string.Empty);
            }

            if (val.SelectionData.Trim().Length > 0)
            {
                return(baseOption.Name + ": " + System.Web.HttpUtility.HtmlEncode(val.SelectionData));
            }

            return(string.Empty);
        }
    public void CanActivate(Vector2 position, Vector2 windowSize)
    {
        print("can activate panel");
        playerCamera      = transform.Find("Background").Find("Camera").GetComponent <Camera>();
        playerCamera.rect = new Rect(position, windowSize);
        playerCamera.transform.localPosition = cameraPosition;

        optionSelection = transform.Find("Background").Find("Options").GetComponent <OptionSelection>();

        //Transform imageChild = transform.Find("image");
        //if (imageChild != null)
        //{
        //    image = imageChild.GetComponent<Image>();
        //    image.enabled = true;
        //    image.color = Color.white;
        //    image.sprite = unactivedSprite;
        //    playerCamera.gameObject.SetActive(false);
        DeactivatePanel();
        playerActivated = false;
    }
Beispiel #29
0
        public string RenderWithSelection(Option baseOption, OptionSelectionList selections)
        {
            string selected = string.Empty;

            if (selections != null)
            {
                OptionSelection sel = selections.FindByOptionId(baseOption.Bvin);
                if (sel != null)
                {
                    selected = sel.SelectionData;
                }
            }

            StringBuilder sb = new StringBuilder();

            sb.Append("<select id=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
            sb.Append(" name=\"opt" + baseOption.Bvin.Replace("-", "") + "\" ");
            sb.Append(" class=\"isoption\" >");

            foreach (OptionItem o in baseOption.Items)
            {
                if (o.IsLabel)
                {
                    sb.Append("<option value=\"systemlabel\">" + o.Name + "</option>");
                }
                else
                {
                    sb.Append("<option value=\"" + o.Bvin.Replace("-", "") + "\"");
                    if (o.Bvin.Replace("-", "") == selected)
                    {
                        sb.Append(" selected ");
                    }
                    sb.Append(">" + o.Name + "</option>");
                }
            }
            sb.Append("</select>");

            return(sb.ToString());
        }
Beispiel #30
0
        private bool IsSelected(OptionItem item, OptionSelectionList selections)
        {
            bool result = false;

            if (selections == null)
            {
                return(false);
            }

            OptionSelection val = selections.FindByOptionId(item.OptionBvin);

            if (val == null)
            {
                return(result);
            }

            if (val.SelectionData == item.Bvin.Replace("-", ""))
            {
                return(true);
            }

            return(result);
        }
Beispiel #31
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();
            result.OptionBvin = baseOption.Bvin;

            System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (ddl != null)
            {
                if (ddl.SelectedItem != null)
                {
                    // Why was I parsing Guid only to return as string?
                    // Safety check maybe?
                    //result.SelectionData = new System.Guid(ddl.SelectedItem.Value).ToString();

                    // Removed GUID requirement for BVC2004 migration compatibility
                    string temp = ddl.SelectedItem.Value;
                    result.SelectionData = temp;
                    
                }
            }

            return result;
        }
Beispiel #32
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();

            result.OptionBvin = baseOption.Bvin;

            System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (ddl != null)
            {
                if (ddl.SelectedItem != null)
                {
                    // Why was I parsing Guid only to return as string?
                    // Safety check maybe?
                    //result.SelectionData = new System.Guid(ddl.SelectedItem.Value).ToString();

                    // Removed GUID requirement for BVC2004 migration compatibility
                    string temp = ddl.SelectedItem.Value;
                    result.SelectionData = temp;
                }
            }

            return(result);
        }
Beispiel #33
0
        public void SetSelectionsInPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph, Catalog.OptionSelectionList selections)
        {
            if (ph == null)
            {
                return;
            }
            if (selections == null)
            {
                return;
            }
            OptionSelection val = selections.FindByOptionId(baseOption.Bvin);

            if (val == null)
            {
                return;
            }

            System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (tb != null)
            {
                tb.Text = val.SelectionData;
            }
        }
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();
            result.OptionBvin = baseOption.Bvin;

            foreach (OptionItem o in baseOption.Items)
            {
                if (!o.IsLabel)
                {
                    string radioId = "opt" + o.Bvin.Replace("-", "");
                    System.Web.UI.HtmlControls.HtmlInputRadioButton rb = (System.Web.UI.HtmlControls.HtmlInputRadioButton)ph.FindControl(radioId);
                    if (rb != null)
                    {
                        if (rb.Checked)
                        {
                            result.SelectionData = o.Bvin;
                            return result;
                        }
                    }
                }
            }

            return result;
        }
Beispiel #35
0
        public Catalog.OptionSelection ParseFromPlaceholder(Option baseOption, System.Web.UI.WebControls.PlaceHolder ph)
        {
            OptionSelection result = new OptionSelection();
            result.OptionBvin = baseOption.Bvin;

            System.Web.UI.WebControls.TextBox tb = (System.Web.UI.WebControls.TextBox)ph.FindControl("opt" + baseOption.Bvin.Replace("-", ""));
            if (tb != null)
            {
                result.SelectionData = tb.Text.Trim();
            }

            return result;
        }