public static Boolean GenerateParametrizedAction(ref StringBuilder result, XafMenuItem menuItem, Boolean IsLeft, String style, String Callback, String ControlType = "button", String Click = "", String Glyphicon = "") { if (!(menuItem.ActionProcessor is MenuActionItemBase) || !((menuItem.ActionProcessor as MenuActionItemBase).Action is ParametrizedAction)) { return(false); } var parAction = (menuItem.ActionProcessor as MenuActionItemBase).Action as ParametrizedAction; bool usePostBack = (parAction as ActionBase).Model.GetValue <bool>("IsPostBackRequired"); result.AppendFormat(@" <div class='input-group parametrized-action'> <input type='text' class='form-control input-sm' placeholder='{0}' onkeydown=""if (event.keyCode == 13) $(this).parent().find('button').click();"" value='{3}' style='min-width:75px'> <span class='input-group-btn'> <button class='btn btn-default btn-sm' type='button' onclick='{1}'><span class='glyphicon {5}'></span> {2}</button> </span> </div>" , parAction.NullValuePrompt , Helpers.ContentHelper.GetScript(Callback, String.Format("\"Action={0},\" + $(this).parent().parent().find('input').val()", menuItem.Name), "", usePostBack).Replace("'", "\"") , parAction.ShortCaption , parAction.Value , style , Glyphicon); return(true); }
public string GetScript(String callbackName, String parameter, XafMenuItem menuItem, Boolean usePostBack) { if (Manager == null) { Manager = new XafCallbackManager(); } return(Manager.GetScript(callbackName, String.Format("\"Action={0}\"", menuItem.Name), "", usePostBack).Replace("'", "\"")); }
public static String GetFormattedActionString(XafMenuItem menuItem, String Callback, String style, String Type = "button", String defaultIcon = "glyphicon-star") { if (menuItem == null) { return(""); } String ClickScript = Callback; if (menuItem.ActionProcessor != null && menuItem.ActionProcessor is ActionBaseItem) { var processor = menuItem.ActionProcessor as ActionBaseItem; if (processor.Action != null && String.Concat(processor.Action.ConfirmationMessage) != "") { ClickScript = String.Format(@"var func = function(){{{1}}}; ShowXafMessage(""{2}"", ""{0}"", func, """", """");" , String.Concat(processor.Action.ConfirmationMessage).Replace("\r\n", "<br>").Replace("\n", "<br>") , Callback , XAF_Bootstrap.Templates.Helpers.GetLocalizedText(@"XAF Bootstrap\Dialogs", "ConfirmAction")).Replace("\"", """); } } var action = (menuItem.ActionProcessor as MenuActionItemBase).Action as ActionBase; SingleChoiceAction singleChoiceAction = action as SingleChoiceAction; if (singleChoiceAction != null) { if (singleChoiceAction.Items.Count == 1 && singleChoiceAction.ItemType == SingleChoiceActionItemType.ItemIsMode) { menuItem.Text = (action as SingleChoiceAction).Items[0].Caption; } else if (singleChoiceAction.Items.Count == 1 && singleChoiceAction.ItemType == SingleChoiceActionItemType.ItemIsOperation) { menuItem.Text = action.Caption; } } String FormatString = "<button type='button' class='{3}' onclick='{2}'>{4}{0}</button>"; if (Type == "a") { FormatString = "<a href='javascript:;' role='button' class='{3}' onclick='{2}'>{4}{0}</a>"; } return(String.Format(FormatString, (menuItem.Text == "" ? menuItem.AdaptiveText : menuItem.Text), menuItem.Name, ClickScript, style, (defaultIcon != "" ? String.Format(@"<span class='glyphicon {0}'></span> ", defaultIcon) : ""))); }
public static Boolean GenerateSingleChoiceAction(ref StringBuilder result, XafMenuItem menuItem, Boolean IsLeft, String style, String Callback, String ControlType = "button", String Click = "", String Glyphicon = "") { if (!(menuItem.ActionProcessor is MenuActionItemBase) || !((menuItem.ActionProcessor as MenuActionItemBase).Action is SingleChoiceAction)) { return(GenerateParametrizedAction(ref result, menuItem, IsLeft, style, Callback, ControlType, Click, Glyphicon)); } var choiceAction = (menuItem.ActionProcessor as MenuActionItemBase).Action as SingleChoiceAction; if (choiceAction.Items.Count <= 1) { return(false); } bool usePostBack = (choiceAction as ActionBase).Model.GetValue <bool>("IsPostBackRequired"); var dropdown = String.Format(@"<div class=""dropdown {4}""> <{3} href=""javascript:;"" class=""dropdown-toggle {0}"" type=""button"" id=""dropdownMenu1"" data-toggle=""dropdown"" aria-expanded=""true""> {2} <span class=""caret""></span> </{3}> <ul class=""dropdown-menu"" role=""menu"" aria-labelledby=""dropdownMenu1""> {1} </ul> </div>" , style , String.Join("", choiceAction.Items.Select(f => String.Format(@"<li role=""presentation""><a role=""menuitem"" tabindex=""-1"" href=""javascript:;"" onclick='{2}; {1}'>{0}</a></li>" , f.Caption , Helpers.ContentHelper.GetScript(Callback, String.Format("\"Action={0},{1}\"", menuItem.Name, f.Id), "", usePostBack).Replace("'", "\"") , Click) )) , choiceAction.SelectedItem != null && choiceAction.ItemType == SingleChoiceActionItemType.ItemIsMode ? choiceAction.SelectedItem.Caption : choiceAction.Caption , ControlType , IsLeft ? "pull-left" : "pull-right" ); result.Append(dropdown); return(true); }