Beispiel #1
0
        public static IDisposable RenderEmbeddedWidget(this HtmlHelper helper, WidgetContext ctx)
        {
            if (GetEmbeddedWidget == null)
            {
                return(null);
            }

            List <IEmbeddedWidget> widgets = GetEmbeddedWidget.GetInvocationListTyped()
                                             .Select(d => d(ctx))
                                             .NotNull()
                                             .ToList();

            if (widgets.IsNullOrEmpty())
            {
                return(null);
            }


            foreach (var item in widgets.Where(a => a.Position == EmbeddedWidgetPostion.Top))
            {
                helper.ViewContext.Writer.Write(item.ToHtml(helper).ToString());
            }


            return(new Disposable(() =>
            {
                foreach (var item in widgets.Where(a => a.Position == EmbeddedWidgetPostion.Bottom))
                {
                    helper.ViewContext.Writer.Write(item.ToHtml(helper).ToString());
                }
            }));
        }
        internal static IWidget CreateWidget(WidgetContext ctx)
        {
            var ident = ctx.Entity as Entity;

            if (ident == null || ident.IsNew)
            {
                return(null);
            }

            List <QuickLink> quicklinks = LinksClient.GetForEntity(ident.ToLiteFat(), ctx.PartialViewName, ctx.Prefix, null, ctx.Url);

            if (quicklinks == null || quicklinks.Count == 0)
            {
                return(null);
            }

            return(new Widget
            {
                Id = TypeContextUtilities.Compose(ctx.Prefix, "quicklinksWidget"),
                Class = "sf-quicklinks",
                Title = QuickLinkMessage.Quicklinks.NiceToString(),
                IconClass = "glyphicon glyphicon-star",
                Text = quicklinks.Count.ToString(),
                Items = quicklinks.OrderBy(a => a.Order).Cast <IMenuItem>().ToList(),
                Active = true,
            });
        }
Beispiel #3
0
        public static MvcHtmlString RenderWidgets(this HtmlHelper helper, WidgetContext ctx)
        {
            if (GetWidget == null)
            {
                return(MvcHtmlString.Empty);
            }

            List <IWidget> widgets = GetWidget.GetInvocationListTyped()
                                     .Select(d => d(ctx))
                                     .NotNull()
                                     .ToList();

            if (widgets.IsNullOrEmpty())
            {
                return(MvcHtmlString.Empty);
            }

            HtmlStringBuilder sb = new HtmlStringBuilder();

            using (sb.SurroundLine(new HtmlTag("ul").Class("sf-widgets")))
            {
                foreach (IWidget widget in widgets)
                {
                    sb.AddLine(widget.ToHtml(helper));
                }
            }
            return(sb.ToHtml());
        }
Beispiel #4
0
        public static MvcHtmlString RenderWidgetsForEntity(this HtmlHelper helper, WidgetContext ctx)
        {
            if (GetWidget == null)
                return MvcHtmlString.Empty;

            List<IWidget> widgets = GetWidget.GetInvocationList()
                .Cast<Func<WidgetContext, IWidget>>()
                .Select(d => d(ctx))
                .NotNull()
                .ToList();

            if (widgets.IsNullOrEmpty())
                return MvcHtmlString.Empty;

            HtmlStringBuilder sb = new HtmlStringBuilder();
            using (sb.Surround(new HtmlTag("ul").Class("sf-widgets")))
            {
                foreach (Widget widget in widgets)
                {
                    sb.AddLine(widget.ToHTml(helper));
                }
            }
            return sb.ToHtml();
        }
Beispiel #5
0
        public static IDisposable RenderEmbeddedWidget(this HtmlHelper helper, WidgetContext ctx)
        {
            if (GetEmbeddedWidget == null)
                return null;

            List<IEmbeddedWidget> widgets = GetEmbeddedWidget.GetInvocationListTyped()
                .Select(d => d(ctx))
                .NotNull()
                .ToList();

            if (widgets.IsNullOrEmpty())
                return null;


            foreach (var item in widgets.Where(a=>a.Position == EmbeddedWidgetPostion.Top))
            {
                helper.ViewContext.Writer.Write(item.ToHtml(helper).ToString());
            }


            return new Disposable(() =>
            {
                foreach (var item in widgets.Where(a => a.Position == EmbeddedWidgetPostion.Bottom))
                {
                    helper.ViewContext.Writer.Write(item.ToHtml(helper).ToString());
                }
            }); 
        }