@model PantheonRA.BackOffice.Models.GridButtonsViewModel

@if (Model.GridActionsGroup != null && Model.GridActionsGroup.Buttons != null)
{
    @ButtonGroup(Model.GridActionsGroup.Buttons, Loc.Action, "actionsButton", "fa fa-check", "btn btn-primary btn-outline " + (Model.GridActionsGroup.IsActive == false ? "disabled" : string.Empty))
}

@if (Model.AddButton != null)
{
    <a href="@(string.IsNullOrEmpty(Model.AddButton.Url) ? "#" : Model.AddButton.Url)" onclick="@Model.AddButton.OnClick"
       class="btn btn-success btn-outline pull-right @Model.AddButton.Class" title="@Model.AddButton.Text">
        <i class="@Model.AddButton.Icon" title="@Model.AddButton.Text"></i><span class="bold hidden-xs hidden-sm m-l-xs">@Model.AddButton.Text</span>
    </a>
}

@*<a href="#" onclick="gridPrint()" class="btn btn-default btn-outline pull-right m-l-sm">
        <i class="far fa-print" title="@Loc.Print"></i><span class="bold hidden-xs m-l-xs">@Loc.Print</span>
    </a>

    <a href="#" onclick="gridDelete()" class="btn btn-danger pull-right m-l-sm">
        <i class="fa fa-times" title="@Loc.Delete"></i><span class="bold hidden-xs m-l-xs">@Loc.Delete</span>
    </a>*@

@helper ButtonGroup(List<PantheonRA.BackOffice.Models.FormButton> buttons, string text, string buttonId, string icon, string buttonClass)
{
    if (buttons.Count > 1)
    {
        <div class="btn-group pull-right">
            <div class="dropdown btn-group">
                <button type="button" onclick="@buttons.First().OnClick" class="@buttonClass" id="@buttonId" title="@text">
                    <i class="@buttons.First().Icon"></i><span class="visible-lg-inline visible-md-inline m-l-xs">@text</span>
                </button>
                <button type="button" class="@buttonClass dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                    <span class="caret"></span>
                </button>
                <ul class="dropdown-menu">
                    @foreach (var button in buttons)
                    {
                        <li>
                            <a href="@(string.IsNullOrEmpty(button.Url) ? "#" : button.Url)" onclick="@button.OnClick">
                                <i class="@button.Icon"></i><span class="m-l-xs">@button.Text</span>
                            </a>
                        </li>
                    }
                </ul>
            </div>
        </div>
    }
    else
    {
        <a href="@(string.IsNullOrEmpty(buttons.First().Url) ? "#" : buttons.First().Url)" onclick="@buttons.First().OnClick" class="@buttonClass pull-right" id="@buttonId" title="@buttons.First().Text">
            <i class="@buttons.First().Icon"></i><span class="visible-lg-inline visible-md-inline m-l-xs">@buttons.First().Text</span>
        </a>
    }
}