예제 #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: "+ CCHtmlConventionsKO.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("href", "mailto:" + request.StringValue());
     root.Attr("name", request.Accessor.FieldName + "Link");
     root.Append(new HtmlTag("span").Text(request.StringValue()));
     return root;
 }
예제 #4
0
 public override HtmlTag Build(ElementRequest request)
 {
     var ul = new HtmlTag("ul").Attr("data-bind", "foreach:" + CCHtmlConventionsKO.DeriveElementName(request));
     var li = new HtmlTag("li");
     li.Children.Add(new HtmlTag("span").Attr("data-bind", "text:$data"));
     ul.Children.Add(li);
     return ul;
 }
예제 #5
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)
 {
     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 = CCHtmlConventionsKO.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;
        }
예제 #8
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;
        }
        public override HtmlTag Build(ElementRequest request)
        {
            Action<SelectTag> action = x =>
                                           {
            //                                               var value = request.RawValue is Entity ? ((Entity)request.RawValue).EntityId : request.RawValue;
                                               var value = 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("fixedWidthDropdown");
                                           };
            return new SelectTag(action);
        }
예제 #10
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("SelectItem","");
                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);
        }
 public static void AddElementName(ElementRequest request, HtmlTag tag)
 {
     if (!tag.IsInputElement())
         return;
     tag.Attr("name", request.ElementId);
 }
예제 #12
0
 public override HtmlTag Build(ElementRequest request)
 {
     var date = request.StringValue().IsNotEmpty() ? DateTime.Parse(request.StringValue()).ToShortTimeString() : "";
     return new TextboxTag().Attr("value", date).AddClass("timePicker");
 }
예제 #13
0
 public override HtmlTag Build(ElementRequest request)
 {
     return new HtmlTag("img").Attr("src", request.StringValue()).Attr("alt",request.Accessor.FieldName);
 }
예제 #14
0
 public override HtmlTag Build(ElementRequest request)
 {
     var isChecked =request.RawValue!=null && (bool) request.RawValue;
     return new CheckboxTag(isChecked);
 }
예제 #15
0
 public abstract HtmlTag Build(ElementRequest request);
예제 #16
0
 public HtmlTag Build(ElementRequest request)
 {
     return _creators[request.ToAccessorDef()](request);
 }
예제 #17
0
 public override HtmlTag Build(ElementRequest request)
 {
     return new HtmlTag("textarea").Attr("data-bind", "value:" + CCHtmlConventionsKO.DeriveElementName(request)).AddClass("textArea").Attr("name", request.ElementId);
 }
 public override HtmlTag Build(ElementRequest request)
 {
     var date = request.StringValue().IsNotEmpty() ? DateTime.Parse(request.StringValue()).ToShortTimeString() : "";
     return new HtmlTag("span").Text(date);
 }
 public override HtmlTag Build(ElementRequest request)
 {
     return new HtmlTag("span").Attr("data-bind", "timeString:" + CCHtmlConventionsKO.DeriveElementName(request));
 }
예제 #20
0
 public abstract HtmlTag Build(ElementRequest request);
예제 #21
0
 public static HtmlTag BuildTextbox(ElementRequest request)
 {
     return new TextboxTag().Attr("value", request.StringValue());
 }
예제 #22
0
 public static HtmlTag BuildCheckbox(ElementRequest request)
 {
     return new CheckboxTag((bool) request.RawValue);
 }
 public static HtmlTag BuildTextboxKO(ElementRequest request)
 {
     var date = DateTime.Parse(request.StringValue()).ToShortDateString();
     return new TextboxTag().Attr("value", date).AddClass("datePicker");
 }