public static HtmlTag ActionAjax(this IHtmlHelper helper, string url, int minHeight, string placeholderText) { var placeholderTag = new DivTag(); placeholderTag.Append(new HtmlTag("h6").Text(placeholderText)); var spinnerTag = new DivTag(); spinnerTag.Append(new HtmlTag("i").AddClasses("fa", "fa-spinner", "fa-pulse", "fa-fw")); var errorMessage = "Restarting the ODS / API is known to solve issues with first time setup or previously cached information, and may help resolve this issue on its own." + " Please try restarting the ODS / API now and reload this to see if this same error occurs." + " If the error persists, please check the application logs and then feel to schedule a ticket via <a href='https://tracker.ed-fi.org/projects/EDFI/issues'>Ed-Fi Tracker</a>" + " or visit <a href='https://techdocs.ed-fi.org/display/ADMIN'>Admin App documentation</a> for more information."; var contentLoadingArea = new DivTag().Data("source-url", url).Data("error-message", errorMessage).AddClass("load-action-async"); if (minHeight > 0) { //adding a minimum height is optional, but can help prevent the page scrollbar from jumping around while content loads contentLoadingArea.Attr("style", $"min-height: {minHeight}px"); } contentLoadingArea.Append(placeholderTag); contentLoadingArea.Append(spinnerTag); return(contentLoadingArea); }
private static HtmlTag FormBlock(HtmlTag label, HtmlTag input, HtmlTag toolTip) { var formRow = new DivTag().AddClasses("row", "form-group"); formRow.Append(label); formRow.Append(input); formRow.Append(toolTip); var wrapper = new DivTag().AddClass("form-horizontal"); wrapper.Append(formRow); return(wrapper); }
private static HtmlTag MakeRadioButton(string display, object value, string name) { DivTag divTag = new DivTag(display); HtmlTag radioButton = new RadioButtonTag(false).Attr("value", value).Attr("name", name); HtmlTag label = new HtmlTag("label").Text(display); label.Append(radioButton); divTag.Append(label); return(divTag); }
// public static IHtmlString FildsFor<TModel> (TModel model, FormType formType) // { // var form = GenerateForm (model, formType, new FormTag()); // return new NonEncodedHtmlString (form == null ? "" : form.ToString()) ; // } static HtmlTag GenerateFields <TModel> (TModel model, FormType formType) { var tag = new DivTag(); foreach (var prop in model.GetType().GetProperties()) { //var value = prop.GetValue (model, null); var visibility = (ScaffoldVisibilityType)model.GetAttributeValue(prop, typeof(ScaffoldVisibilityAttribute), formType.ToString()); if (visibility == ScaffoldVisibilityType.None) { continue; } if (visibility == ScaffoldVisibilityType.Show) { var type = prop.PropertyType; if (type == typeof(string)) { tag.Append(GenerateInputText <TModel> (model, prop)); } else if (type == typeof(bool)) { tag.Append(GenerateInputCheck <TModel> (model, prop)); } else if (typeof(IEnumerable).IsAssignableFrom(type)) { tag.Append(GenerateSelect <TModel> (model, prop)); } else if (type.IsEnum) { tag.Append(GenerateSelect <TModel> (model, prop)); } } else { tag.Append(GenerateInputHidden <TModel> (model, prop)); } } if (tag.Children.Count == 0) { return(null); } return(tag); }
public static HtmlTag ActionAjax(this IHtmlHelper helper, string url, int minHeight, string placeholderText) { var placeholderTag = new DivTag(); placeholderTag.Append(new HtmlTag("h6").Text(placeholderText)); var spinnerTag = new DivTag(); spinnerTag.Append(new HtmlTag("i").AddClasses("fa", "fa-spinner", "fa-pulse", "fa-fw")); var contentLoadingArea = new DivTag().Data("source-url", url).AddClass("load-action-async"); if (minHeight > 0) { //adding a minimum height is optional, but can help prevent the page scrollbar from jumping around while content loads contentLoadingArea.Attr("style", $"min-height: {minHeight}px"); } contentLoadingArea.Append(placeholderTag); contentLoadingArea.Append(spinnerTag); return(contentLoadingArea); }
static HtmlTag GenerateCalendar <TModel> (TModel model, PropertyInfo member) { var modelValue = member.GetValue(model, null); if (modelValue == null) { return(null); } //http://www.eyecon.ro/bootstrap-datepicker/ //<div class="control-group"> // <label class="control-label" for="Email">Email:</label> // <div class="controls"> //<div class="input-append date" id="dp3" data-date="12-02-2012" data-date-format="dd-mm-yyyy"> //<input class="span2" size="16" type="text" value="12-02-2012"> //<span class="add-on"><i class="icon-th"></i></span> //</div> // <span class="field-validation-valid error" data-valmsg-for="Email" // data-valmsg-replace="true"></span> // <p class="help-block">Ex.: [email protected]</p> // </div> //</div> var cg = CreateControlGroup(model, member); var div = new DivTag().AddClass("datepicker"); var input = new TextboxTag(member.Name, modelValue.ToString()) .Id(member.Name); var span = new LiteralTag("span").AddClass("add-on"); div.Append(input); div.Append(span); FillValidation <TModel>(input, member); cg.Children[1].InsertFirst(input); return(cg); }
public static HtmlTag ActionAjax(this HtmlHelper helper, string actionName, string controllerName, object routeValues, int minHeight = 0, string placeholderText = "") { var url = new UrlHelper(helper.ViewContext.RequestContext).Action(actionName, controllerName, routeValues); var placeholderTag = new DivTag(); placeholderTag.Append(new HtmlTag("h6").Text(placeholderText)); var spinnerTag = new DivTag(); spinnerTag.Append(new HtmlTag("i").AddClasses("fa", "fa-spinner", "fa-pulse", "fa-fw")); var contentLoadingArea = new DivTag().Data("source-url", url).AddClass("load-action-async"); if (minHeight > 0) { //adding a minimum height is optional, but can help prevent the page scrollbar from jumping around while content loads contentLoadingArea.Attr("style", $"min-height: {minHeight}px"); } contentLoadingArea.Append(placeholderTag); contentLoadingArea.Append(spinnerTag); return(contentLoadingArea); }
private HtmlTag ColumnSetRender(AdaptiveColumnSet columnSet, AdaptiveRenderContext context) { var container = new DivTag() .AddClass("container") .Attr("hidden", !columnSet.IsVisible); var row = new DivTag() .AddClass("row"); container.Append(row); AddContainerElements(row, columnSet.Columns, context); return(container); }
public static HtmlTag ButtonGroup(this IHtmlHelper helper, params HtmlTag[] buttons) { var outer = new DivTag() .AddClass("form-group"); var inner = new DivTag() .AddClass("col-md-offset-2") .AddClass("col-md-10"); inner.Append(buttons); outer.Append(inner); return(outer); }
protected override HtmlTag CreateTag() { var vertical = _values.Count > 2; var radioClass = vertical ? "radio radio-block" : "radio radio-inline"; var container = new DivTag().AddClasses(radioClass); var modelValue = RenderValue(); foreach (var value in _values) { var label = CreateLabel(value, modelValue); container.Append(label); } return(container); }
public static LiteralTag ValidationSummary(this HtmlHelper htmlHelper, bool excludePropertyErrors) { var val = ValidationExtensions.ValidationSummary(htmlHelper, excludePropertyErrors); if (val != null) { return(new LiteralTag(val.ToHtmlString())); } var valtag = new DivTag().AddClass(HtmlHelper.ValidationSummaryCssClassName); valtag.Append(new HtmlTag("ul").Append(new HtmlTag("li").Style("display", "none"))); if (!excludePropertyErrors) { valtag.Data("valmsg-summary", "true"); } return(new LiteralTag(valtag.ToHtmlString())); }
public static HtmlTag FormButton <T>(this HtmlHelper <T> helper, string name, string value, string label, ButtonType buttonType = ButtonType.Primary) { // Could use a DescriptionAttribute on the enum but this will do for now... string className = String.Format("button--{0}", Enum.GetName(typeof(ButtonType), buttonType).ToLower()); var div = new DivTag().AddClasses("form-group"); var button = new HtmlTag("button").AddClasses("button", className).Text(label); if (!string.IsNullOrWhiteSpace(name)) { button.Name(name); } if (!string.IsNullOrWhiteSpace(value)) { button.Value(value); } return(div.Append(button)); }
protected override HtmlTag CreateTag(bool inlineMandatory = false) { var container = new DivTag().AddClasses("confirm-check-box"); if (_emphasise) { container.AddClass("emphasise"); } var modelValue = RenderValue(); var input = new HtmlTag("input").Attr("type", "checkbox").Name(ControlContext.Name).Value("True"); if (_disabled) { input.Attr("disabled", "disabled"); } if (modelValue != null && modelValue.ToLower() == "true") { input.Attr("checked", "checked"); } var labelText = _labelText ?? ControlContext.Metadata.DisplayName ?? ControlContext.Metadata.PropertyName; var text = new HtmlTag("span"); if (inlineMandatory) { text.Append(NewMandatory()); } text.Append(new HtmlTag("span").Text(labelText)); var label = new HtmlTag("label").Append(input).Append(text); return(container.Append(label)); }