/// <summary> /// Creates the control main element. /// </summary> /// <returns>The control IFWHtmlElement interface.</returns> protected override IFWHtmlElement CreateControl() { var input = new FWInputElement(Name, FWInputType.Hidden); input.MergeAttributes(Attributes); if (!string.IsNullOrWhiteSpace(CustomCss)) { input.AddCssClass(CustomCss); } input.Id = Id; input.DataType = "fw-hidden"; if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.VALUE); input.DataBind = DataBind.CreateBind(); } else if (Model != null) { input.Value = Model.ToString(); } else if (FWReflectionHelper.IsNumeric(ModelType)) { // If the property is a number, but the model is null, the value defaults to 0. input.Value = "0"; } return(input); }
private FWInputElement CreateDatepickerInput(FWDivElement element) { FWInputElement input = CreateInput(element); input.AddCssClass("form-control datetimepicker-input"); if (!string.IsNullOrWhiteSpace(_placeholder)) { input.Attributes.Add("placeholder", _placeholder); } input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName)); if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.DATEPICKER); input.DataBind = DataBind.CreateBind(); } else if (Model != null) { input.Value = (!_hasTimePicker) ? ((DateTime)Model).ToString("yyyy-MM-dd") : ((DateTime)Model).ToString("yyyy-MM-ddTHH:mm:ss"); } if (IsReadOnly) { input.Attributes.Add("readonly", "readonly"); } return(input); }
private FWInputElement CreateInput() { var input = new FWInputElement(Name, FWInputType.Textbox); input.AddCssClass("form-control"); input.Attributes.Add("data-thousands", CultureInfo.CurrentCulture.NumberFormat.NumberGroupSeparator); input.Attributes.Add("data-decimal", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); input.Attributes.Add("data-allownegative", _allowNegative ? "true" : "false"); input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName)); if (IsReadOnly) { input.Attributes.Add("readonly", "readonly"); } if (_displayCurrency) { input.Attributes.Add("data-prefix", CultureInfo.CurrentUICulture.NumberFormat.CurrencySymbol); } if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.CURRENCY); input.DataBind = DataBind.CreateBind(); } else if (Model != null) { input.Value = Model.ToString(); } return(input); }
/// <summary> /// Creates the control main element. /// </summary> /// <returns>The control IFWHtmlElement interface.</returns> protected override IFWHtmlElement CreateControl() { var element = new FWDivElement(); element.MergeAttributes(Attributes); if (!string.IsNullOrWhiteSpace(CustomCss)) { element.AddCssClass(CustomCss); } element.Id = Id; element.DataType = "fw-currency"; element.AddCssClass("m-form__group form-group"); if (DisplayLabel) { FWLabelControl label = new FWLabelControl(Name, DisplayName, IsRequired, Tooltip); label.AddCssClass("control-label"); element.Add(label.ToString()); } FWInputElement input = CreateInput(); if (_icon != null) { element.Add(_icon.Create(input).ToString()); } else { element.Add(input); } return(element); }
private FWInputElement CreateInput() { var input = new FWInputElement(Name, (!_isPassword) ? FWInputType.Textbox : FWInputType.Password); input.AddCssClass("form-control"); if (!string.IsNullOrWhiteSpace(_placeholder)) { input.Attributes.Add("placeholder", _placeholder); } input.Attributes.Add("data-rule-required", IsRequired.ToString().ToLower()); input.Attributes.Add("data-msg-required", string.Format(ViewResources.Validation_Required, DisplayName)); if (IsReadOnly) { input.Attributes.Add("readonly", "readonly"); } if (IsDisabled) { input.Attributes.Add("disabled", "disabled"); } if (_maxLength > 0) { input.Attributes.Add("maxlength", _maxLength.ToString()); } if (_minLength > 0) { input.Attributes.Add("data-rule-minlength", _minLength.ToString()); input.Attributes.Add("data-msg-minlength", string.Format(ViewResources.Validation_MinLength, DisplayName, _minLength)); } if (_regexPattern != null) { input.Attributes.Add("data-rule-pattern", _regexPattern); input.Attributes.Add("data-msg-pattern", string.Format(ViewResources.Validation_Regex, DisplayName)); } if (_targetValidationField != null) { input.Attributes.Add("data-rule-passwordmatch", _targetValidationField); input.Attributes.Add("data-msg-passwordmatch", ViewResources.Validation_PasswordMismatch); } if (DataBind) { DataBind.AddMainBind(FWBindConfiguration.VALUE); input.DataBind = DataBind.CreateBind(); } else if (Model != null) { input.Value = Model.ToString(); } return(input); }
/// <summary> /// Creates the control main element. /// </summary> /// <returns>The IFWHtmlElement object representation of the control.</returns> protected override IFWHtmlElement CreateControl() { CreateLineActions(); var detailControl = new FWPortletControl(Id, GetModelResource(OriginalId)); detailControl.AddCssClass("fw-detail-table"); detailControl.DataType("fw-detailcontrol"); detailControl.Attributes.Add("data-model", ListType.Name); detailControl.AddAction(FWDetailHelper.CreateUndoButton()); detailControl.Required(Metadata.IsRequired); detailControl.Footer(FWDetailHelper.CreateAddButton().ToString()); detailControl.Attributes.AddRange(Attributes); if (!string.IsNullOrWhiteSpace(CustomCss)) { detailControl.AddCssClass(CustomCss); } // Clears custom attributes and css to prevent adding to the base table control. Attributes.Clear(); ClearCss(); var grid = base.CreateControl() as FWTagBuilder; grid.DataType = "fw-detailcontrol-body"; grid.Attributes.Add("role", "grid"); detailControl.Add(grid); if (Metadata.IsRequired) { var validationDiv = new FWDivElement(); { validationDiv.DataType = "fw-detailvalidation"; validationDiv.AddCssClass("m-form__group form-group"); //Creates the validation input var validationInput = new FWInputElement("DetailValidation", FWInputType.Hidden); validationInput.Attributes.Add("data-rule-requireddetail", Metadata.IsRequired.ToString().ToLower()); validationInput.Attributes.Add("data-msg-requireddetail", string.Format(ViewResources.Validation_Required_Detail, GetModelResource(OriginalId))); validationInput.Attributes.Add("data-skipvalidation", "false"); validationDiv.Add(validationInput); detailControl.Add(validationDiv); } } detailControl.Add(RegisterTemplate()); return(detailControl); }
/// <summary> /// Creates the control main element. /// </summary> /// <returns>The control IFWHtmlElement interface.</returns> protected override IFWHtmlElement CreateControl() { FWDivElement container; var element = container = new FWDivElement(); element.MergeAttributes(Attributes); if (!string.IsNullOrWhiteSpace(CustomCss)) { element.AddCssClass(CustomCss); } element.Id = Id; element.DataType = "fw-textbox"; element.AddCssClass("m-form__group form-group"); if (DisplayLabel) { FWLabelControl label = new FWLabelControl(Name, DisplayName, IsRequired, Tooltip); label.AddCssClass("control-label"); element.Add(label.ToString()); } if (_autocompleteUrl != null) { ConfigureAutocomplete(element); // Adds a div wrapper to the control. container = element.Add(new FWDivElement()); container.AddCssClass("m-typeahead"); } FWInputElement input = CreateInput(); if (!string.IsNullOrWhiteSpace(_mask)) { ConfigureMask(input); } if (_icon != null) { container.Add(_icon.Create(input).ToString()); } else { container.Add(input); } return(element); }
private void ConfigureAutocomplete(FWDivElement element) { element.Attributes.Add("data-autocomplete-url", _autocompleteUrl); element.Attributes.Add("data-autocomplete-limit", _autocompleteLimit.ToString()); if (_autocompleteForceSelection) { element.Attributes.Add("data-autocomplete-force", "true"); } FWInputElement hidden = new FWInputElement($"{Id}Value", FWInputType.Hidden); element.Add(hidden); // TODO: Metronic 5 does not allow icons inside autocomplete combos yet //if (_icon == null) // Icon("fa fa-search"); }
public IFWCompositeElement Create(FWInputElement input) { var iconPlaceholder = new FWDivElement(); iconPlaceholder.AddCssClass("m-input-icon m-input-icon--left"); var span = new FWSpanElement(); span.AddCssClass("m-input-icon__icon m-input-icon__icon--left"); var innerSpan = new FWSpanElement(); var i = new FWTagBuilder("i"); i.AddCssClass(Icon); innerSpan.Add(i); span.Add(innerSpan); iconPlaceholder.Add(span); iconPlaceholder.Add(input); return(iconPlaceholder); }
private FWInputElement CreateInput(FWDivElement element) { var isMobile = RequestContext.HttpContext.Request.IsMobileDevice(); FWInputElement input; if (!isMobile) { // Format dates for Moment.js element.Attributes.Add("data-datelanguage", CultureInfo.CurrentUICulture.Name); element.Attributes.Add("data-date-format", (_hasTimePicker) ? "L LT" : "L"); input = new FWInputElement(Name, FWInputType.Textbox) { Id = $"{Id}_input" }; input.Attributes.Add("data-toggle", "datetimepicker"); input.Attributes.Add("data-target", $"#{input.Id}"); } else if (_hasTimePicker) { input = new FWInputElement(Name, FWInputType.Datetime) { Id = $"{Id}_input" }; } else { input = new FWInputElement(Name, FWInputType.Date) { Id = $"{Id}_input" }; } return(input); }
private void ConfigureMask(FWInputElement input) { input.Attributes.Add("data-mask", _mask); input.Attributes.Add("data-mask-reverse", _reversemask.ToString().ToLower()); }
/// <summary> /// Creates the control main element. /// </summary> /// <returns>The IFWHtmlElement object representation of the control.</returns> protected override IFWHtmlElement CreateControl() { var detailControl = new FWPortletControl(Id, GetModelResource()); detailControl.AddCssClass("fw-detail-grid"); detailControl.DataType("fw-detailcontrol"); detailControl.Attributes.Add("data-model", _listType.Name); detailControl.AddAction(FWDetailHelper.CreateUndoButton()); detailControl.Required(IsRequired); detailControl.Footer(FWDetailHelper.CreateAddButton().ToString()); detailControl.Attributes.AddRange(Attributes); if (!string.IsNullOrWhiteSpace(CustomCss)) { detailControl.AddCssClass(CustomCss); } var body = new FWDivElement() { DataType = "fw-detailcontrol-body" }; if (Model != null) { int i = 0; var list = Model as IEnumerable; foreach (var item in list) { body.Add(CreateBody(item, i.ToString())); i++; } } detailControl.Add(body); if (IsRequired) { var validationDiv = new FWDivElement(); { validationDiv.DataType = "fw-detailvalidation"; validationDiv.AddCssClass("m-form__group form-group"); //Creates the fileupload validation input var validationInput = new FWInputElement("DetailValidation", FWInputType.Hidden); validationInput.Attributes.Add("data-rule-requireddetail", "true"); validationInput.Attributes.Add("data-msg-requireddetail", string.Format(ViewResources.Validation_Required_Detail, GetModelResource())); validationInput.Attributes.Add("data-skipvalidation", "false"); validationDiv.Add(validationInput); detailControl.Add(validationDiv); } } detailControl.Add(RegisterTemplate()); return(detailControl); }