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()); }
internal static MvcHtmlString InternalFileLine(this HtmlHelper helper, FileLine fileLine) { if (!fileLine.Visible) { return(MvcHtmlString.Empty); } IFile value = fileLine.GetFileValue(); HtmlStringBuilder sbg = new HtmlStringBuilder(); using (sbg.SurroundLine(new HtmlTag("div").Id(fileLine.Prefix).Class("sf-field SF-control-container"))) { sbg.AddLine(new HtmlTag("link").Attrs(new { rel = "stylesheet", type = "text/css", href = RouteHelper.New().Content("~/Files/Content/Files.css") }).ToHtmlSelf()); if (value != null) { sbg.AddLine(helper.Div(fileLine.Compose(EntityBaseKeys.Entity), null, "", new Dictionary <string, object> { { "style", "display:none" } })); } fileLine.ValueHtmlProps.AddCssClass("form-control"); bool hasEntity = value != null && value.FileName.HasText(); using (sbg.SurroundLine(new HtmlTag("div", fileLine.Compose("DivOld")).Attr("style", "display:" + (hasEntity ? "block" : "none")))) { HtmlStringBuilder sb = new HtmlStringBuilder(); using (sb.SurroundLine(new HtmlTag("div", fileLine.Compose("inputGroup")).Class("input-group"))) { if (fileLine.Download != DownloadBehaviour.None) { sb.AddLine(helper.Href(fileLine.Compose(EntityBaseKeys.Link), value?.FileName, hasEntity ? FilesClient.GetDownloadUrl(value) : null, value?.FileName, "form-control file-control", fileLine.Download == DownloadBehaviour.View ? null : new Dictionary <string, object> { { "download", value?.FileName } })); } else { sb.AddLine(helper.Span(fileLine.Compose(EntityBaseKeys.ToStr), value?.FileName ?? "", "form-control file-control", null)); } if (fileLine.Type.IsEmbeddedEntity()) { sb.AddLine(helper.Hidden(fileLine.Compose(EntityBaseKeys.EntityState), value?.Let(f => Navigator.Manager.SerializeEntity((ModifiableEntity)f)))); } using (sb.SurroundLine(new HtmlTag("span", fileLine.Compose("shownButton")).Class("input-group-btn"))) { sb.AddLine(EntityButtonHelper.Remove(helper, fileLine, btn: true)); } } sbg.AddLine(helper.FormGroup(fileLine, fileLine.Download == DownloadBehaviour.None ? fileLine.Compose(EntityBaseKeys.Link) : fileLine.Compose(EntityBaseKeys.ToStr), fileLine.LabelHtml ?? fileLine.LabelText.FormatHtml(), sb.ToHtml())); } using (sbg.SurroundLine(new HtmlTag("div", fileLine.Compose("DivNew")) .Class("sf-file-line-new") .Attr("style", "display:" + (hasEntity ? "none" : "block")))) { HtmlStringBuilder sb = new HtmlStringBuilder(); sb.AddLine(helper.HiddenRuntimeInfo(fileLine)); if (!fileLine.ReadOnly) { sb.AddLine(MvcHtmlString.Create("<input type='file' id='{0}' name='{0}' class='form-control'/>".FormatWith(fileLine.Compose(FileLineKeys.File)))); sb.AddLine(MvcHtmlString.Create("<img src='{0}' id='{1}_loading' alt='loading' style='display:none'/>".FormatWith(RouteHelper.New().Content("~/Files/Images/loading.gif"), fileLine.Prefix))); } sbg.AddLine(helper.FormGroup(fileLine, fileLine.Compose(FileLineKeys.File), fileLine.LabelHtml ?? fileLine.LabelText.FormatHtml(), sb.ToHtml())); } if (!fileLine.ReadOnly) { sbg.AddLine(fileLine.ConstructorScript(FilesClient.Module, "FileLine")); } } return(sbg.ToHtml()); }