public static HtmlString GetMagicSelect(int projectId, bool showCharacters, ShowImplicitGroups showGroups, MagicControlStrategy strategy, string propertyName, IEnumerable <string> elements, bool showSpecial) { var implicitGroupsString = GetImplicitGroupString(showGroups); var strategyString = GetStrategyString(strategy); //TODO: convert to verbatim var magicSelectFor = new HtmlString(string.Format(@" <div id=""{0}_control_{6}"" style=""max-width: 700px;width:100%""></div> <script type=""text/javascript""> $(function() {{ var options = {{ url: '/' + {1} + '/roles/{7}', multiselect: true, showcharacters: {2}, hiddenselect: {{ id: '{0}', name: '{0}' }}, implicitgroups: {3}, strategy: {{ type: '{4}', elements: [{5}] }}, }}; $('#{0}_control_{6}').multicontrol(options); }}); </script>", propertyName, projectId, showCharacters ? "true" : "false", implicitGroupsString, strategyString, elements.JoinStrings(", "), Random.Next(), showSpecial ? "json_full" : "json_real")); return(magicSelectFor); }
private static string GetImplicitGroupString(ShowImplicitGroups showGroups) { string implicitGroupsString; switch (showGroups) { case ShowImplicitGroups.None: implicitGroupsString = "'none'"; break; case ShowImplicitGroups.Children: implicitGroupsString = "'children'"; break; case ShowImplicitGroups.Parents: implicitGroupsString = "'parents'"; break; default: throw new ArgumentOutOfRangeException(nameof(showGroups), showGroups, null); } return(implicitGroupsString); }