Skip to content

Commit 5f1a9e1

Browse files
committed
Allow rendering button list only
1 parent 165d216 commit 5f1a9e1

File tree

1 file changed

+31
-16
lines changed

1 file changed

+31
-16
lines changed

Griddly/Views/Shared/Griddly/BootstrapButton.cshtml

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
@*
22
* GriddlyButton renderer using Bootstrap html and styles
33
* http://griddly.com
4-
* Copyright 2013-2017 Chris Hynes and Data Research Group, Inc.
4+
* Copyright 2013-2018 Chris Hynes and Data Research Group, Inc.
55
* Licensed under MIT (https://github.com/programcsharp/griddly/blob/master/LICENSE)
66
*
77
* WARNING: Don't edit this file -- it'll be overwitten when you upgrade.
@@ -10,6 +10,9 @@
1010
*@
1111

1212
@model GriddlyButton
13+
@{
14+
bool isListOnly = ViewBag.IsListOnly == true;
15+
}
1316
@if (Model is GriddlyHtmlButton)
1417
{
1518
@(((GriddlyHtmlButton)Model).HtmlTemplate(Model))
@@ -20,6 +23,8 @@ else if (!Model.Buttons.Any())
2023
}
2124
else
2225
{
26+
if (!isListOnly)
27+
{
2328
<div class="btn-group">
2429
@RenderLink(Model, true, false)
2530
@if (Model.DropdownCaret == GriddlyDropdownCaret.Split)
@@ -29,23 +34,14 @@ else
2934
</button>
3035
}
3136
<ul class="dropdown-menu @(Model.AlignRight ? "pull-right" : "")">
32-
@foreach (GriddlyButton button in Model.Buttons)
33-
{
34-
if (button is GriddlyHtmlButton)
35-
{
36-
<li class="@(!button.Enabled || button.EnableOnSelection == true ? "disabled" : null)" @Html.AttributeIf("data-enable-on-selection", button.EnableOnSelection, button.EnableOnSelection.ToString().ToLower())>@(((GriddlyHtmlButton)button).HtmlTemplate(button))</li>
37-
}
38-
else if (!button.IsSeparator)
39-
{
40-
<li class="@(!button.Enabled || button.EnableOnSelection == true ? "disabled" : null)" @Html.AttributeIf("data-enable-on-selection", button.EnableOnSelection, button.EnableOnSelection.ToString().ToLower())>@RenderLink(button, false, true)</li>
41-
}
42-
else
43-
{
44-
<li class="divider"></li>
45-
}
46-
}
37+
@RenderList()
4738
</ul>
4839
</div>
40+
}
41+
else
42+
{
43+
@RenderList()
44+
}
4945
}
5046

5147
@helper RenderLink(GriddlyButton button, bool isDropdown, bool isMenuItem)
@@ -111,4 +107,23 @@ else
111107
<span class="caret"></span>
112108
}
113109
</a>
110+
}
111+
112+
@helper RenderList()
113+
{
114+
foreach (GriddlyButton button in Model.Buttons)
115+
{
116+
if (button is GriddlyHtmlButton)
117+
{
118+
<li class="@(!button.Enabled || button.EnableOnSelection == true ? "disabled" : null)" @Html.AttributeIf("data-enable-on-selection", button.EnableOnSelection, button.EnableOnSelection.ToString().ToLower())>@(((GriddlyHtmlButton)button).HtmlTemplate(button))</li>
119+
}
120+
else if (!button.IsSeparator)
121+
{
122+
<li class="@(!button.Enabled || button.EnableOnSelection == true ? "disabled" : null)" @Html.AttributeIf("data-enable-on-selection", button.EnableOnSelection, button.EnableOnSelection.ToString().ToLower())>@RenderLink(button, false, true)</li>
123+
}
124+
else
125+
{
126+
<li class="divider"></li>
127+
}
128+
}
114129
}

0 commit comments

Comments
 (0)