Esempio n. 1
0
        public static MvcHtmlString UmaButton(this HtmlHelper htmlHelper, string id, string label, UmaButtonType buttonType, FontAwesomeIcon fontAwesomeIcon, object htmlAttributes)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentNullException(id);
            }

            if (htmlHelper == null)
            {
                throw new ArgumentNullException("htmlHelper");
            }

            TagBuilder button = new TagBuilder("button");

            button.GenerateId(id);
            button.Attributes.Add("name", id);

            string localizedLabel = label;
            // TO DO: Andrejs
            // GetTranslation(label, htmlHelper.ViewBag.FeatureName);

            if (fontAwesomeIcon != null && fontAwesomeIcon.Justification == IconJustification.Right)
            {
                button.InnerHtml = string.Concat(localizedLabel, " ", fontAwesomeIcon.Html);
            }
            else
            {
                button.InnerHtml = string.Concat(fontAwesomeIcon == null ? string.Empty : fontAwesomeIcon.Html + " ", localizedLabel);
            }

            button.AddCssClass(GetButtonCssClass(buttonType));
            button.AddCssClass("btn");
            button.Attributes.Add("type",
                buttonType == UmaButtonType.FormSubmit ? "submit" : "button");
            AddAdditionalAttributes(htmlAttributes, button);
            return MvcHtmlString.Create(button.ToString(TagRenderMode.Normal));
        }
Esempio n. 2
0
 /// <summary>
 /// Creates the HTML markup for button in UI with necessary specified styling classes and icon
 /// </summary>
 /// <param name="htmlHelper">The HTML helper.</param>
 /// <param name="id">The identifier of a button. Also becomes a name</param>
 /// <param name="label">The label to display on button. It is automatically localized in current UI Culture</param>
 /// <param name="buttonType">Semantic type of the button.</param>
 /// <param name="fontAwesomeIconName">Specify font awesome icon full name (like "fa-check-square-o"). Refer to http://fontawesome.io/icons/ for names.</param>
 public static MvcHtmlString UmaButton(this HtmlHelper htmlHelper, string id, string label, UmaButtonType buttonType, string fontAwesomeIconName)
 {
     FontAwesomeIcon iconDef = new FontAwesomeIcon(fontAwesomeIconName) { Size = IconSize.Larger };
     return UmaButton(htmlHelper, id, label, buttonType, iconDef, null);
 }
Esempio n. 3
0
 /// <summary>
 /// Creates the HTML markup for button in UI with necessary specified styling classes
 /// </summary>
 /// <param name="htmlHelper">The HTML helper.</param>
 /// <param name="id">The identifier of a button. Also becomes a name</param>
 /// <param name="label">The label to display on button. It is automatically localized in current UI Culture</param>
 /// <param name="buttonType">Semantic type of the button.</param>
 /// <param name="htmlAttributes">The HTML attributes you might want to add to element.</param>
 public static MvcHtmlString UmaButton(this HtmlHelper htmlHelper, string id, string label, UmaButtonType buttonType, object htmlAttributes = null)
 {
     return UmaButton(htmlHelper, id, label, buttonType, null, htmlAttributes);
 }
Esempio n. 4
0
        /// <summary>
        /// Common method around HTML helper classes that return button css class name
        /// </summary>
        /// <param name="buttonType">UmaButtonType enum value</param>
        /// <returns>Returns css class name</returns>
        private static string GetButtonCssClass(UmaButtonType buttonType)
        {
            string returnValue = string.Empty;

            switch (buttonType)
            {
                case UmaButtonType.Back:
                case UmaButtonType.Operation:
                case UmaButtonType.Redirect:
                case UmaButtonType.ViewOperation:
                    returnValue = "btn-info";
                    break;
                case UmaButtonType.DeleteOperation:
                    returnValue = "btn-danger";
                    break;
                case UmaButtonType.CreateOperation:
                case UmaButtonType.EditOperation:
                    returnValue = "btn-success";
                    break;
                case UmaButtonType.FormSubmit:
                    returnValue = "btn-primary";
                    break;
                default:
                    returnValue = "btn-default";
                    break;
            }
            return returnValue;
        }
Esempio n. 5
0
 public static MvcHtmlString UmaButtonLink(this HtmlHelper htmlHelper, string label, string redirectUri, UmaButtonType type, object htmlAttributes)
 {
     return UmaButtonLink(htmlHelper, label, redirectUri, null, htmlAttributes, type);
 }
Esempio n. 6
0
        public static MvcHtmlString UmaButtonLink(this HtmlHelper htmlHelper, string label, string redirectUri, FontAwesomeIcon fontAwesomeIcon, object htmlAttributes, UmaButtonType type = UmaButtonType.ViewOperation)
        {
            if (string.IsNullOrEmpty(redirectUri))
            {
                throw new ArgumentNullException("redirectUri");
            }

            if (htmlHelper == null)
            {
                throw new ArgumentNullException("htmlHelper");
            }

            TagBuilder link = new TagBuilder("a");
            link.Attributes.Add("href", redirectUri);
            // TODO :  Andrejs
            string localizedLabel = label;
            // GetTranslation(label, htmlHelper.ViewBag.FeatureName);

            if (fontAwesomeIcon != null && fontAwesomeIcon.Justification == IconJustification.Right)
            {
                link.InnerHtml = string.Concat(localizedLabel, " ", fontAwesomeIcon.Html);
            }
            else
            {
                link.InnerHtml = string.Concat(fontAwesomeIcon == null ? string.Empty : fontAwesomeIcon.Html + " ", localizedLabel);
            }

            link.AddCssClass(GetButtonCssClass(type));
            link.AddCssClass("btn");
            AddAdditionalAttributes(htmlAttributes, link);
            return MvcHtmlString.Create(link.ToString(TagRenderMode.Normal));
        }