Beispiel #1
0
        public static MvcHtmlString LightEntityLine(this HtmlHelper helper, Lite <IEntity> lite, bool isSearch, bool targetBlank = true, string innerText = null)
        {
            if (lite == null)
            {
                return(MvcHtmlString.Empty);
            }

            if (lite.ToString() == null)
            {
                Database.FillToString(lite);
            }

            if (!Navigator.IsNavigable(lite.EntityType, null, isSearch))
            {
                return((innerText ?? lite.ToString()).EncodeHtml());
            }

            Dictionary <string, object> htmlAtributes = new Dictionary <string, object>();

            if (targetBlank)
            {
                htmlAtributes.Add("target", "_blank");
            }

            if (!Navigator.EntitySettings(lite.EntityType).AvoidPopup)
            {
                htmlAtributes.Add("data-entity-link", lite.Key());
            }

            return(helper.Href("",
                               innerText ?? lite.ToString(),
                               Navigator.NavigateRoute(lite),
                               HttpUtility.HtmlEncode(lite.ToString()),
                               "sf-light-entity-line", htmlAtributes));
        }
Beispiel #2
0
        private static MvcHtmlString InternalRepeaterElement <T>(this HtmlHelper helper, TypeElementContext <T> itemTC, EntityListCheckbox entityListCheckBox, bool isChecked, Lite <IEntity> lite)
        {
            HtmlStringBuilder sb = new HtmlStringBuilder();

            var label = new HtmlTag("label", itemTC.Compose(EntityRepeaterKeys.RepeaterElement)).Class("sf-checkbox-element");

            entityListCheckBox.CustomizeLabel?.Invoke(label, lite);

            using (sb.SurroundLine(label))
            {
                if (EntityBaseHelper.EmbeddedOrNew((Modifiable)(object)itemTC.Value))
                {
                    sb.AddLine(EntityBaseHelper.RenderPopup(helper, itemTC, RenderPopupMode.PopupInDiv, entityListCheckBox));
                }
                else if (itemTC.Value != null)
                {
                    sb.Add(helper.Div(itemTC.Compose(EntityBaseKeys.Entity), null, "",
                                      new Dictionary <string, object> {
                        { "style", "display:none" }, { "class", "sf-entity-list" }
                    }));
                }

                var cb = new HtmlTag("input")
                         .Attr("type", "checkbox")
                         .Attr("name", itemTC.Compose(EntityBaseKeys.RuntimeInfo))
                         .Attr("value", itemTC.RuntimeInfo()?.ToString());

                if (isChecked)
                {
                    cb.Attr("checked", "checked");
                }

                if (entityListCheckBox.ReadOnly)
                {
                    cb.Attr("disabled", "disabled");
                }

                entityListCheckBox.CustomizeCheckBox?.Invoke(cb, lite);

                sb.AddLine(cb);

                if (lite != null && (entityListCheckBox.Navigate || entityListCheckBox.View))
                {
                    var dic = new Dictionary <string, object>
                    {
                        { "target", "_blank" }
                    };

                    sb.AddLine(
                        helper.Href(itemTC.Compose(EntityBaseKeys.Link),
                                    lite.ToString(),
                                    lite.IdOrNull == null ? null : Navigator.NavigateRoute(lite),
                                    lite.ToString(), "sf-entitStrip-link", dic));
                }
                else
                {
                    sb.AddLine(
                        helper.Span(itemTC.Compose(EntityBaseKeys.Link),
                                    itemTC.UntypedValue.ToString() ?? " ", "sf-entitStrip-link"));
                }
            }

            return(sb.ToHtml());
        }
 public override MvcHtmlString Execute()
 {
     return(new HtmlTag("a").Attr("href", Navigator.NavigateRoute(lite)).InnerHtml(TextAndIcon()));
 }