Пример #1
0
 public static void AddElementName(ElementRequest request, HtmlTag tag)
 {
     if (tag.IsInputElement())
     {
         tag.Attr("name", DeriveElementName(request));
     }
 }
Пример #2
0
 public override HtmlTag Build(ElementRequest request)
 {
     HtmlTag root = new HtmlTag("div").Attr("data-bind", "foreach: "+ CCHtmlConventions2.DeriveElementName(request));
     var child = new HtmlTag("div").Attr("data-bind", "text: $data" );
     root.Append(child);
     return root;
 }
Пример #3
0
 public override HtmlTag Build(ElementRequest request)
 {
     HtmlTag root = new HtmlTag("a");
     root.Attr("data-bind", "attr: { href: mailto:" + CCHtmlConventionsKO.DeriveElementName(request)+"}");
     root.Children.Add(new HtmlTag("span").Attr("data-bind", "text:" + CCHtmlConventionsKO.DeriveElementName(request)));
     return root;
 }
        public override HtmlTag Build(ElementRequest request)
        {
            Action<SelectTag> action = x =>
            {
                var value = request.RawValue;
                Enumeration enumeration = request.Accessor.InnerProperty.GetEnumeration("");
                if (enumeration == null) return;

                IEnumerable<Enumeration> enumerations = Enumeration.GetAllActive(enumeration);
                if (enumerations == null) return;

                foreach (Enumeration option in enumerations)
                {
                    x.Option(option.Key,
                             option.Value.IsEmpty() || option.OnlyUseKeyForSelector ? option.Key : option.Value);
                }
                if (value != null && value.ToString().IsNotEmpty())
                {
                    x.SelectByValue(value);
                }
                else
                {
                    Enumeration defaultOption = enumerations.FirstOrDefault(o => o.IsDefault);
                    if (defaultOption != null)
                    {
                        x.SelectByValue(defaultOption.Value.IsEmpty() ? defaultOption.Key : defaultOption.Value);
                    }
                }
                x.AddClass("mf_fixedWidthDropdown");
                x.AddClass("fixedWidthDropdown");
            };
            return new SelectTag(action);
        }
Пример #5
0
 public override HtmlTag Build(ElementRequest request)
 {
     HtmlTag root = new HtmlTag("a");
     root.Attr("href", "mailto:" + request.StringValue());
     root.Attr("name", request.Accessor.FieldName + "Link");
     root.Append(new HtmlTag("span").Text(request.StringValue()));
     return root;
 }
Пример #6
0
 public override HtmlTag Build(ElementRequest request)
 {
     var ul = new HtmlTag("ul").Attr("data-bind", "foreach:" + CCHtmlConventions2.DeriveElementName(request));
     var li = new HtmlTag("li");
     li.Children.Add(new HtmlTag("span").Attr("data-bind", "text:$data"));
     ul.Children.Add(li);
     return ul;
 }
Пример #7
0
 public override HtmlTag Build(ElementRequest request)
 {
     var value = request.StringValue().IsNotEmpty() ? request.StringValue() : "";
     return new HtmlTag("textarea")
     .AddClasses("textArea")
         .Attr("name", request.ElementId)
         .Text(value);
 }
 public override HtmlTag Build(ElementRequest request)
 {
     var selectTag = new SelectTag();
     var elementName = CCHtmlConventions2.DeriveElementName(request);
     selectTag.Attr("data-bind", "options:_" + elementName + "List," +
                                 "optionsText:'Text'," +
                                 "optionsValue:'Value'," +
                                 "value:" + elementName );
     return selectTag;
 }
 public override HtmlTag Build(ElementRequest request)
 {
     HtmlTag root = new HtmlTag("a");
     root.Attr("href", request.RawValue);
     root.Attr("target", "_blank");
     root.Id(request.Accessor.FieldName);
     var img = new HtmlTag("img");
     img.Attr("src", request.RawValue);
     root.Append(img);
     return root;
 }
        public override HtmlTag Build(ElementRequest request)
        {
            var selectTag = new SelectTag();
            var elementName = CCHtmlConventions2.DeriveElementName(request);
            var elementRoot = elementName.Contains("EntityId") ? elementName.Replace(".EntityId", "") : elementName;
            selectTag.Attr("data-bind", "options:_" + elementRoot +"List," +
                                        "optionsValue:'Value'," +
                                        "optionsText:'Text'," +
                                        "value:" + elementName);

            return selectTag;
        }
Пример #11
0
 public static void AddElementName(ElementRequest request, HtmlTag tag)
 {
     if (tag.IsInputElement())
     {
         var name = request.Accessor.Name;
         if (request.Accessor is PropertyChain)
         {
             name = ((PropertyChain)(request.Accessor)).PropertyNames.Aggregate((current, next) => current + "." + next);
             if (new InheritsFromDomainEntity().execute(request.Accessor.PropertyType))
                 name += ".EntityId";
         }
         //var name = request.Accessor.Name.Substring(0, request.Accessor.Name.IndexOf(request.Accessor.FieldName)) + "." + request.Accessor.FieldName;
         //tag.Attr("name", name);
         tag.Attr("name", name);
     }
 }
Пример #12
0
        public static string DeriveElementName(ElementRequest request)
        {
            var name = request.Accessor.Name;
            if (request.Accessor is PropertyChain)
            {
                name = ((PropertyChain)(request.Accessor)).PropertyNames.Aggregate((current, next) => current + "." + next);
                var isDomainEntity = false;
                var de = request.Accessor.PropertyType.BaseType;
                while (de.Name != "Object")
                {
                    if (de.Name == "DomainEntity") isDomainEntity = true;
                    de = de.BaseType;
                }
                if (isDomainEntity) name += ".EntityId";

            }
            return name;
        }
Пример #13
0
        public override HtmlTag Build(ElementRequest request)
        {
            Action<SelectTag> action = x =>
                                           {
                                               var elementName = CCHtmlConventions2.DeriveElementName(request);
                                               x.Attr("data-bind", "groupedSelect:_" + elementName + "List," +
                                                                    "optionsText:'Text'," +
                                                                    "optionsValue:'Value'," +
                                                                    "optionsCaption:'" + CCCoreLocalizationKeys.SELECT_ITEM.ToString() + "'," +
                                                                    "value:" + elementName);

            //                                               var elementName = CCHtmlConventions.DeriveElementName(request);
            //                                               x.Attr("data-bind", "foreach: _" + elementName + "List.Groups, value:" + elementName);
            //                                               var optGroup = new HtmlTag("optgroup").Attr("data-bind","attr: {label: Label}, foreach: Children");
            //                                               var opt = new HtmlTag("option").Attr("data-bind","text: Text, value: Value");
            //                                               optGroup.Children.Add(opt);
            //                                               x.Children.Add(optGroup);
                                           };
            return new SelectTag(action);
        }
Пример #14
0
        public override HtmlTag Build(ElementRequest request)
        {
            var container = new HtmlTag("div").AddClass("imageInputContainer");
            var imageContainer = new HtmlTag("div").AddClass("imageContainer");
            var name = CCHtmlConventionsKO.DeriveElementName(request);
            var thumb = new HtmlTag("img").Attr("data-bind", "attr: { src: " + name + " }").Id("image").Attr("alt", request.Accessor.FieldName);
            var linkImage = new HtmlTag("img").Attr("src",@"/content/images/document.png").Attr("alt", request.Accessor.FieldName);
            var link = new HtmlTag("a").Attr("data-bind", "attr: { href: " + name + "} ").Id("link").Attr("target", "_blank");
            link.Children.Add(linkImage);
            var delete = new HtmlTag("input").Attr("type", "button").AddClass("deleteImage").Attr("value", "Delete");

            var inputContainer = new HtmlTag("div").AddClass("inputContainer");
            var file = new HtmlTag("input").Attr("type", "file").Attr("size", 45).Attr("id", name).Attr("name", name);
            imageContainer.Children.Add(thumb);
            imageContainer.Children.Add(link);
            imageContainer.Children.Add(delete);
            inputContainer.Children.Add(file);
            container.Children.Add(imageContainer);
            container.Children.Add(inputContainer);
            return container;
        }
        public override HtmlTag Build(ElementRequest request)
        {
            Action<SelectTag> action = x =>
                                           {
                                               var value = request.RawValue is Entity ? ((Entity)request.RawValue).EntityId : request.RawValue;

                                                var propertyName = request.ToAccessorDef().Accessor.FieldName;
                                                var listPropertyInfo = request.ToAccessorDef().ModelType.GetProperty(propertyName+"List");
                                               var selectListItems = listPropertyInfo.GetValue(request.Model, null) as IEnumerable<SelectListItem>;
                                               if (selectListItems == null) return;

                                               selectListItems.ForEachItem(option=> x.Option(option.Text, option.Value.IsNotEmpty() ? option.Value: ""));

                                               if ( value != null && value.ToString().IsNotEmpty())
                                               {
                                                   x.SelectByValue(value.ToString());
                                               }
                                               x.AddClass("mf_fixedWidthDropdown");
                                               x.AddClass("fixedWidthDropdown");
                                           };
            return new SelectTag(action);
        }
Пример #16
0
        public override HtmlTag Build(ElementRequest request)
        {
            Action<SelectTag> action = x =>
            {
                var value = request.RawValue;

                var propertyName = request.ToAccessorDef().Accessor.FieldName;
                var listPropertyInfo = request.ToAccessorDef().ModelType.GetProperty(propertyName + "List");
                var dictionary = listPropertyInfo.GetValue(request.Model, null) as IDictionary<string, IEnumerable<SelectListItem>>;
                if (dictionary == null) return;
                x.Option(CCCoreLocalizationKeys.SELECT_ITEM.ToString(),"");
                dictionary.Keys.ForEachItem(key =>
                {
                    x.OptionGroup(key);
                    dictionary[key].ForEachItem(l => x.Option(l.Text, l.Value+"_"+key));
                });
                if (value != null && value.ToString().IsNotEmpty())
                {
                    x.SelectByValue(value.ToString());
                }
            };
            return new SelectTag(action);
        }
Пример #17
0
 public override HtmlTag Build(ElementRequest request)
 {
     return new TextboxTag().Attr("data-bind", "value:" + CCHtmlConventionsKO.DeriveElementName(request));
 }
Пример #18
0
 public abstract HtmlTag Build(ElementRequest request);
Пример #19
0
 public static HtmlTag BuildCheckbox(ElementRequest request)
 {
     return new CheckboxTag((bool) request.RawValue);
 }
Пример #20
0
 public override HtmlTag Build(ElementRequest request)
 {
     return new HtmlTag("textarea").Attr("data-bind", "value:" + CCHtmlConventionsKO.DeriveElementName(request)).AddClass("textArea").Attr("name", request.ElementId);
 }
Пример #21
0
 public override HtmlTag Build(ElementRequest request)
 {
     var div = new HtmlTag("div").AddClass("gallery").Attr("data-bind", "foreach:" + CCHtmlConventionsKO.DeriveElementName(request));
     var a = new HtmlTag("a").Attr("data-bind", "attr:{href:FileUrl_Thumb}");
     a.Children.Add(new HtmlTag("image").Attr("data-bind", "attr:{src:FileUrl_Large,imageId:ImageId}"));
     div.Children.Add(a);
     return div;
 }
Пример #22
0
 public override HtmlTag Build(ElementRequest request)
 {
     return new TextboxTag().Id(request.Accessor.Name).AddClass("multiSelect").Attr("data-bind", "MultiSelect:" + CCHtmlConventionsKO.DeriveElementName(request));
 }
Пример #23
0
 public override HtmlTag Build(ElementRequest request)
 {
     return new HtmlTag("img").Attr("data-bind",
         " attr: { src: " + CCHtmlConventionsKO.DeriveElementName(request) + " }")
         .Attr("alt", request.Accessor.FieldName);
 }
 public override HtmlTag Build(ElementRequest request)
 {
     var date = request.StringValue().IsNotEmpty() ? DateTime.Parse(request.StringValue()).ToShortTimeString() : "";
     return new HtmlTag("span").Text(date);
 }
Пример #25
0
 public static HtmlTag BuildTextbox(ElementRequest request)
 {
     return new TextboxTag().Attr("value", request.StringValue());
 }
Пример #26
0
 public override HtmlTag Build(ElementRequest request)
 {
     return new TextboxTag().Attr("data-bind", "dateString:" + CCHtmlConventionsKO.DeriveElementName(request)).AddClass("datePicker");
 }
 public override HtmlTag Build(ElementRequest request)
 {
     return new HtmlTag("span").Attr("data-bind", "timeString:" + CCHtmlConventions2.DeriveElementName(request));
 }
 public static HtmlTag BuildTextbox2(ElementRequest request)
 {
     var date = DateTime.Parse(request.StringValue()).ToShortDateString();
     return new TextboxTag().Attr("value", date).AddClass("datePicker");
 }
Пример #29
0
 public override HtmlTag Build(ElementRequest request)
 {
     return new CheckboxTag(false).Attr("data-bind",
                                   "checked:" + CCHtmlConventionsKO.DeriveElementName(request));
 }
Пример #30
0
 public HtmlTag Build(ElementRequest request)
 {
     return _creators[request.ToAccessorDef()](request);
 }