示例#1
0
            public MvcHtmlString ToHtml(HtmlHelper helper)
            {
                HtmlStringBuilder sb = new HtmlStringBuilder();

                using (sb.SurroundLine("li"))
                {
                    sb.Add(helper.ScriptCss("~/Help/Content/helpWidget.css"));

                    var id = TypeContextUtilities.Compose(Prefix, "helpButton");

                    sb.Add(new HtmlTag("button").Id(id)
                           .Class("btn btn-xs btn-help btn-help-widget")
                           .Class(HelpLogic.GetEntityHelp(RootType).HasEntity ? "hasItems" : null)
                           .Attr("type", "button")
                           .SetInnerText("?"));

                    var type = HelpLogic.GetEntityHelpService(this.RootType);

                    var jsType = new
                    {
                        Type       = TypeLogic.GetCleanName(type.Type),
                        Info       = type.Info,
                        Operations = type.Operations.ToDictionary(a => a.Key.Key, a => a.Value),
                        Properties = type.Properties.ToDictionary(a => a.Key.ToString(), a => a.Value),
                    };

                    sb.Add(MvcHtmlString.Create("<script>$('#" + id + "').on('mouseup', function(event){ if(event.which == 3) return; " +
                                                HelpClient.WidgetModule["entityClick"](JsFunction.This, this.Prefix, jsType, helper.UrlHelper().Action((HelpController c) => c.PropertyRoutes())).ToString() +
                                                " })</script>"));
                }

                return(sb.ToHtml());
            }
            MvcHtmlString IWidget.ToHtml(HtmlHelper helper)
            {
                if (Isolation == null)
                    return MvcHtmlString.Empty;

                HtmlStringBuilder sb = new HtmlStringBuilder();
                sb.Add(helper.HiddenLite(TypeContextUtilities.Compose(Prefix, "Isolation"), Isolation));
                sb.Add(new HtmlTag("span").Class("sf-quicklinks badge").SetInnerText(Isolation.ToString()));
                //sb.Add(new MvcHtmlString("<script>" + IsolationClient.Module["addIsolationPrefilter"](Isolation.Key()) + "</script>"));
                return sb.ToHtml();
            }
示例#3
0
            MvcHtmlString IWidget.ToHtml(HtmlHelper helper)
            {
                if (Isolation == null)
                {
                    return(MvcHtmlString.Empty);
                }

                HtmlStringBuilder sb = new HtmlStringBuilder();

                sb.Add(helper.HiddenLite(TypeContextUtilities.Compose(Prefix, "Isolation"), Isolation));
                sb.Add(new HtmlTag("span").Class("sf-quicklinks badge").SetInnerText(Isolation.ToString()));
                //sb.Add(new MvcHtmlString("<script>" + IsolationClient.Module["addIsolationPrefilter"](Isolation.Key()) + "</script>"));
                return(sb.ToHtml());
            }
 public static MvcHtmlString QueryTokenDNBuilder(this HtmlHelper helper, TypeContext<QueryTokenEntity> ctx, QueryTokenBuilderSettings settings)
 {
     if (ctx.Value.Try(qt => qt.ParseException) != null)
     {
         HtmlStringBuilder sb = new HtmlStringBuilder();
         sb.Add(new HtmlTag("div").Class("ui-state-error").SetInnerText(ctx.Value.ParseException.Message).ToHtml());
         sb.Add(new HtmlTag("pre").SetInnerText(ctx.Value.TokenString).ToHtml());
         sb.Add(helper.QueryTokenBuilder(null, ctx, settings));
         return sb.ToHtml();
     }
     else
     {
         return helper.QueryTokenBuilder(ctx.Value.Try(ct => ct.Token), ctx, settings);
     }
 }
示例#5
0
 public static MvcHtmlString QueryTokenDNBuilder(this HtmlHelper helper, TypeContext <QueryTokenEmbedded> ctx, QueryTokenBuilderSettings settings)
 {
     if (ctx.Value?.ParseException != null)
     {
         HtmlStringBuilder sb = new HtmlStringBuilder();
         sb.Add(new HtmlTag("div").Class("ui-state-error").SetInnerText(ctx.Value.ParseException.Message).ToHtml());
         sb.Add(new HtmlTag("pre").SetInnerText(ctx.Value.TokenString).ToHtml());
         sb.Add(helper.QueryTokenBuilder(null, ctx, settings));
         return(sb.ToHtml());
     }
     else
     {
         return(helper.QueryTokenBuilder(ctx.Value?.Token, ctx, settings));
     }
 }
        public ContentResult SelectedItemsContextMenu(string webQueryName, string implementationsKey, string prefix)
        {
            var lites = this.ParseLiteKeys <Entity>();

            if (lites.IsEmpty())
            {
                return(Content(""));
            }

            object          queryName       = Finder.ResolveQueryName(webQueryName);
            Implementations implementations = implementationsKey == "[All]" ? Implementations.ByAll :
                                              Implementations.By(implementationsKey.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(t => Navigator.ResolveType(t)).ToArray());

            var items = ContextualItemsHelper.GetContextualItemListForLites(new SelectedItemsMenuContext
            {
                Url = RouteHelper.New(),
                ControllerContext = this.ControllerContext,
                Lites             = lites,
                QueryName         = queryName,
                Implementations   = implementations,
                Prefix            = prefix,
            });

            if (items.IsNullOrEmpty())
            {
                return(Content(""));
            }

            var sb = new HtmlStringBuilder(items.Select(mi => mi.ToHtml()));

            sb.Add(new MvcHtmlString(@"<script>$(function(){ $('[data-toggle=""tooltip""]').tooltip({}); });</script>"));
            return(Content(sb.ToHtml().ToString()));
        }
示例#7
0
        private static void DiffLine(HtmlStringBuilder sb, IEnumerable <StringDistance.DiffPair <string> > list)
        {
            foreach (var gr in list.GroupWhenChange(a => a.Action))
            {
                string text = gr.Select(a => a.Value).ToString("");

                if (gr.Key == StringDistance.DiffAction.Equal)
                {
                    sb.Add(HtmlTag.Encode(text));
                }
                else
                {
                    var color =
                        gr.Key == StringDistance.DiffAction.Added ? "#72F272" :
                        gr.Key == StringDistance.DiffAction.Removed ? "#FF8B8B" :
                        throw new InvalidOperationException();

                    sb.Add(new HtmlTag("span").Attr("style", "background:" + color).SetInnerText(text));
                }
            }

            sb.AddLine();
        }
示例#8
0
        public ContentResult SelectedItemsContextMenu(string webQueryName, string implementationsKey, string prefix)
        {
            var lites = this.ParseLiteKeys<Entity>();
            if (lites.IsEmpty())
                return Content("");

            object queryName = Finder.ResolveQueryName(webQueryName);
            Implementations implementations = implementationsKey == "[All]" ? Implementations.ByAll :
                Implementations.By(implementationsKey.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries).Select(t => Navigator.ResolveType(t)).ToArray());

            var items = ContextualItemsHelper.GetContextualItemListForLites(new SelectedItemsMenuContext
            {
                Url = RouteHelper.New(),
                ControllerContext = this.ControllerContext,
                Lites = lites,
                QueryName = queryName,
                Implementations = implementations,
                Prefix = prefix,
            });

            if (items.IsNullOrEmpty())
                return Content("");

            var sb = new HtmlStringBuilder(items.Select(mi => mi.ToHtml()));
            sb.Add(new MvcHtmlString(@"<script>$(function(){ $('[data-toggle=""tooltip""]').tooltip({}); });</script>"));
            return Content(sb.ToHtml().ToString());
        }
        public static Widget CreateWidget(WidgetContext ctx)
        {
            var ident = (Entity)ctx.Entity;

            var url = RouteHelper.New().Action((AlertController ac) => ac.AlertsCount());

            var alertList = new[]
            {
                new { Count = CountAlerts(ident.ToLite(), "Attended"), Property = "Attended", AlertClass = "sf-alert-attended", Title = AlertMessage.Alerts_Attended.NiceToString() },
                new { Count = CountAlerts(ident.ToLite(), "Alerted"), Property = "Alerted", AlertClass = "sf-alert-alerted", Title = AlertMessage.Alerts_NotAttended.NiceToString() },
                new { Count = CountAlerts(ident.ToLite(), "Future"), Property = "Future", AlertClass = "sf-alert-future", Title = AlertMessage.Alerts_Future.NiceToString() },
            };

            var items = alertList.Select(a => new MenuItem(ctx.Prefix, "sfAlertExplore_" + a.Property)
            {
                OnClick = AlertClient.Module["exploreAlerts"](ctx.Prefix, GetFindOptions(ident, a.Property).ToJS(ctx.Prefix, "alerts"), url),
                CssClass = "sf-alert-view",
                Html = 
                new HtmlTag("span").Class("sf-alert-count-label").Class(a.AlertClass).Class(a.Count > 0 ? "sf-alert-active" : null).InnerHtml((a.Title + ": ").EncodeHtml()).ToHtml().Concat(
                new HtmlTag("span").Class(a.AlertClass).Class(a.Count > 0 ? "sf-alert-active" : null).SetInnerText(a.Count.ToString()))
            }).Cast<IMenuItem>().ToList();

            items.Add(new MenuItemSeparator());

            items.Add(new MenuItem(ctx.Prefix, "sfAlertCreate")
            {
                CssClass = "sf-alert-create",
                OnClick = AlertClient.Module["createAlert"](JsFunction.Event, ctx.Prefix, AlertOperation.CreateAlertFromEntity.Symbol.Key, url),
                Text = AlertMessage.CreateAlert.NiceToString(),
            }); 

            HtmlStringBuilder label = new HtmlStringBuilder();
            int count = alertList.Length;
            for(int i = 0; i < count; i++)
            {
                var a = alertList[i];
                    
                label.Add(new HtmlTag("span")
                    .Class("sf-widget-count")
                    .Class(a.AlertClass)
                    .Class(a.Count > 0 ? "sf-alert-active" : null)
                    .SetInnerText(a.Count.ToString())
                    .Attr("title", a.Title)
                    .ToHtml());

                if (i < count - 1)
                {
                    label.Add(new HtmlTag("span")
                        .Class("sf-alerts-count-separator")
                        .SetInnerText(" - ")
                        .ToHtml());
                }
            }

            return new Widget
            {
                Title = AlertMessage.Alerts.NiceToString(),
                IconClass = "glyphicon glyphicon-bell",
                Class = "sf-alerts-toggler",
                Id = TypeContextUtilities.Compose(ctx.Prefix, "alertsWidget"),
                Active = alertList.Any(a => a.Count > 0),
                Html = label.ToHtml(),
                Items = items,
            };
        }
示例#10
0
        public static Widget CreateWidget(WidgetContext ctx)
        {
            var ident = (Entity)ctx.Entity;

            var url = RouteHelper.New().Action((AlertController ac) => ac.AlertsCount());

            var alertList = new[]
            {
                new { Count = CountAlerts(ident.ToLite(), "Attended"), Property = "Attended", AlertClass = "sf-alert-attended", Title = AlertMessage.Alerts_Attended.NiceToString() },
                new { Count = CountAlerts(ident.ToLite(), "Alerted"), Property = "Alerted", AlertClass = "sf-alert-alerted", Title = AlertMessage.Alerts_NotAttended.NiceToString() },
                new { Count = CountAlerts(ident.ToLite(), "Future"), Property = "Future", AlertClass = "sf-alert-future", Title = AlertMessage.Alerts_Future.NiceToString() },
            };

            var items = alertList.Select(a => new MenuItem(ctx.Prefix, "sfAlertExplore_" + a.Property)
            {
                OnClick  = AlertClient.Module["exploreAlerts"](ctx.Prefix, GetFindOptions(ident, a.Property).ToJS(ctx.Prefix, "alerts"), url),
                CssClass = "sf-alert-view",
                Html     =
                    new HtmlTag("span").Class("sf-alert-count-label").Class(a.AlertClass).Class(a.Count > 0 ? "sf-alert-active" : null).InnerHtml((a.Title + ": ").EncodeHtml()).ToHtml().Concat(
                        new HtmlTag("span").Class(a.AlertClass).Class(a.Count > 0 ? "sf-alert-active" : null).SetInnerText(a.Count.ToString()))
            }).Cast <IMenuItem>().ToList();

            items.Add(new MenuItemSeparator());

            items.Add(new MenuItem(ctx.Prefix, "sfAlertCreate")
            {
                CssClass = "sf-alert-create",
                OnClick  = AlertClient.Module["createAlert"](JsFunction.Event, ctx.Prefix, AlertOperation.CreateAlertFromEntity.Symbol.Key, url),
                Text     = AlertMessage.CreateAlert.NiceToString(),
            });

            HtmlStringBuilder label = new HtmlStringBuilder();
            int count = alertList.Length;

            for (int i = 0; i < count; i++)
            {
                var a = alertList[i];

                label.Add(new HtmlTag("span")
                          .Class("sf-widget-count")
                          .Class(a.AlertClass)
                          .Class(a.Count > 0 ? "sf-alert-active" : null)
                          .SetInnerText(a.Count.ToString())
                          .Attr("title", a.Title)
                          .ToHtml());

                if (i < count - 1)
                {
                    label.Add(new HtmlTag("span")
                              .Class("sf-alerts-count-separator")
                              .SetInnerText(" - ")
                              .ToHtml());
                }
            }

            return(new Widget
            {
                Title = AlertMessage.Alerts.NiceToString(),
                IconClass = "glyphicon glyphicon-bell",
                Class = "sf-alerts-toggler",
                Id = TypeContextUtilities.Compose(ctx.Prefix, "alertsWidget"),
                Active = alertList.Any(a => a.Count > 0),
                Html = label.ToHtml(),
                Items = items,
            });
        }