コード例 #1
0
 public static ButtonConfig AddAttributes(this ButtonConfig button, object htmlAttributes)
 {
     if (htmlAttributes != null)
     {
         foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(htmlAttributes))
         {
             button.HtmlAttribute.Add(property.Name.Replace('\u005F', '-'), Convert.ToString(property.GetValue(htmlAttributes), CultureInfo.InvariantCulture));
         }
     }
     return(button);
 }
コード例 #2
0
 public static ButtonConfig AddIconCssClass(this ButtonConfig button, string parameter, params string[] parameters)
 {
     button.IconCssClass += " " + parameter;
     if (parameters != null)
     {
         foreach (var item in parameters)
         {
             button.IconCssClass += " " + item;
         }
     }
     return(button);
 }
コード例 #3
0
        public static ButtonConfig GridCommand(string name, string title, string url, string iconCssClass = "", TextColor iconColor = TextColor.None, string condition = null, params VSMParameter[] param)
        {
            var lnk = new ButtonConfig(name);

            lnk.Title        = title;
            lnk.Url          = url;
            lnk.IconCssClass = iconCssClass;
            lnk.IconColor    = iconColor;
            lnk.Condition    = condition;
            lnk.Tooltip      = true;
            if (param != null)
            {
                lnk.AddParameter(param);
            }
            return(lnk);
        }
コード例 #4
0
        public static GridColumn GridColumnCommand <TModel>(this HtmlHelper <TModel> html, ButtonConfig command, params ButtonConfig[] commands)
        {
            var prgConfig = (DataAccess.SEC.MenuModel)html.ViewContext.HttpContext.Session[SessionSystemName.SYS_CurrentPrgConfig];

            if (prgConfig == null)
            {
                prgConfig = new DataAccess.SEC.MenuModel();
            }
            bool existsCommand = false;
            var  col           = new GridColumn();

            col.width          = "3%";
            col.orderable      = false;
            col.IsButtonColumn = true;
            col.className      = ColumnsTextAlign.Center.GetDescription();
            var sb = new StringBuilder();

            sb.AppendLine("function (data, type, full, meta) {");
            sb.AppendLine("var tag = '';");
            bool genScript = true;

            if ((command.Name == StandardButtonName.Edit && !prgConfig.IsROLE_EDIT) ||
                (command.Name == StandardButtonName.Info && !prgConfig.IsROLE_PRINT))
            {
                genScript = false;
            }
            if (genScript)
            {
                existsCommand = true;
                if (!command.Condition.IsNullOrEmpty())
                {
                    sb.Append("if(");
                    sb.Append(command.Condition);
                    sb.AppendLine("){");
                }
                sb.Append("tag += '<p class=\"no-margin\"><a name=\"");
                sb.Append(command.Name);
                sb.Append("\"");
                if (command.Tooltip)
                {
                    sb.Append(" data-toggle=\"tooltip\" data-placement=\"right\"");
                }
                if (!command.Title.IsNullOrEmpty())
                {
                    sb.Append(" title=\"");
                    sb.Append(command.Title);
                    sb.Append("\"");
                }
                if (command.HtmlAttribute.Count > 0)
                {
                    foreach (var item in command.HtmlAttribute)
                    {
                        sb.Append(" ");
                        sb.Append(item.Key);
                        sb.Append("=\"");
                        sb.Append(item.Value);
                        sb.Append("\"");
                    }
                }
                sb.AppendLine("';");
                sb.Append("tag +=' href=\"");
                sb.Append(command.Url);
                if (command.Parameters != null && command.Parameters.Count > 0)
                {
                    sb.AppendLine("?';");
                    var i = 0;
                    foreach (var cmd in command.Parameters)
                    {
                        sb.Append("tag += '");
                        if (i != 0)
                        {
                            sb.Append("&");
                        }
                        sb.Append(cmd.Name);
                        sb.Append("='+ toUrlString(");
                        if (cmd.Type == VSMParameterType.ByGridDate)
                        {
                            sb.Append("$.gridDateToISOString(full." + (cmd.Value.IsNullOrEmpty() ? cmd.Name : cmd.Value) + ")");
                        }
                        else if (cmd.Type == VSMParameterType.ByModelData)
                        {
                            sb.Append("'");
                            sb.Append(cmd.Value);
                            sb.Append("'");
                        }
                        else if (cmd.Type == VSMParameterType.ByControlId)
                        {
                            sb.Append("$('#");
                            sb.Append(cmd.Value);
                            sb.Append("').val()");
                        }
                        else
                        {
                            sb.Append("full." + (cmd.Value.IsNullOrEmpty() ? cmd.Name : cmd.Value));
                        }
                        sb.AppendLine(");");
                        i++;
                    }
                    sb.AppendLine("tag +='\"';");
                }
                else
                {
                    sb.AppendLine("\"';");
                }
                sb.Append("tag +='>");
                if (!command.IconCssClass.IsNullOrEmpty())
                {
                    sb.Append("<i class=\"ace-icon fa");
                    sb.Append(" " + command.IconCssClass);
                    sb.Append(" bigger-130");
                    if (command.IconColor != TextColor.None)
                    {
                        sb.Append(" " + command.IconColor.GetDescription());
                    }
                    sb.Append("\"></i>");
                }
                if (!command.Text.IsNullOrEmpty())
                {
                    sb.Append(command.Text);
                }
                sb.AppendLine("</a></p>';");
                if (!command.Condition.IsNullOrEmpty())
                {
                    sb.AppendLine("}");
                }
            }
            if (commands != null)
            {
                foreach (var item in commands)
                {
                    genScript = true;
                    if ((item.Name == StandardButtonName.Edit && !prgConfig.IsROLE_EDIT) ||
                        (item.Name == StandardButtonName.Info && !prgConfig.IsROLE_PRINT))
                    {
                        genScript = false;
                    }
                    if (genScript)
                    {
                        existsCommand = true;
                        if (!item.Condition.IsNullOrEmpty())
                        {
                            sb.Append("if(");
                            sb.Append(item.Condition);
                            sb.AppendLine("){");
                        }
                        sb.Append("tag += '<p class=\"no-margin\"><a name=\"");
                        sb.Append(item.Name);
                        sb.Append("\"");
                        if (command.Tooltip)
                        {
                            sb.Append(" data-toggle=\"tooltip\" data-placement=\"right\"");
                        }
                        if (!item.Title.IsNullOrEmpty())
                        {
                            sb.Append("title=\"" + item.Title + "\"");
                        }

                        sb.AppendLine("';");
                        sb.Append("tag +=' href=\"");
                        sb.Append(item.Url);
                        if (item.Parameters != null && item.Parameters.Count > 0)
                        {
                            sb.AppendLine("?';");
                            var i = 0;
                            foreach (var cmd in item.Parameters)
                            {
                                sb.Append("tag += '");
                                if (i != 0)
                                {
                                    sb.Append("&");
                                }
                                sb.Append(cmd.Name);
                                sb.Append("='+ toUrlString(");
                                if (cmd.Type == VSMParameterType.ByGridDate)
                                {
                                    sb.Append("$.gridDateToISOString(full." + (cmd.Value.IsNullOrEmpty() ? cmd.Name : cmd.Value) + ")");
                                }
                                else if (cmd.Type == VSMParameterType.ByModelData)
                                {
                                    sb.Append(cmd.Value);
                                }
                                else if (cmd.Type == VSMParameterType.ByControlId)
                                {
                                    sb.Append("$('#");
                                    sb.Append(cmd.Value);
                                    sb.Append("').val()");
                                }
                                else
                                {
                                    sb.Append("full." + (cmd.Value.IsNullOrEmpty() ? cmd.Name : cmd.Value));
                                }
                                sb.AppendLine(");");
                                i++;
                            }
                            sb.AppendLine("tag +='\"';");
                        }
                        else
                        {
                            sb.AppendLine("\"';");
                        }
                        sb.Append("tag +='>");
                        if (!item.IconCssClass.IsNullOrEmpty())
                        {
                            sb.Append("<i class=\"ace-icon fa");
                            sb.Append(" " + item.IconCssClass);
                            sb.Append(" bigger-130");
                            if (item.IconColor != TextColor.None)
                            {
                                sb.Append(" " + item.IconColor.GetDescription());
                            }
                            sb.Append("\"></i>");
                        }
                        if (!item.Text.IsNullOrEmpty())
                        {
                            sb.Append(item.Text);
                        }
                        sb.AppendLine("</a></p>';");
                        if (!item.Condition.IsNullOrEmpty())
                        {
                            sb.AppendLine("}");
                        }
                    }
                }
            }

            sb.AppendLine("return tag;");
            sb.Append("}");
            col.render = sb.ToString();
            if (!existsCommand)
            {
                col = null;
            }
            return(col);
        }
コード例 #5
0
 public static ButtonConfig AddAttribute(this ButtonConfig button, string key, object value)
 {
     button.HtmlAttribute.Add(key, value);
     return(button);
 }
コード例 #6
0
 public static ButtonConfig AddParameter(this ButtonConfig button, params VSMParameter[] param)
 {
     button.Parameters.AddRange(param);
     return(button);
 }