Skip to content

Commit 174577c

Browse files
OwenMelbztabacitu
authored andcommitted
fixes hiding/showing buttons when the min/max are reached (#198)
1 parent 79fa248 commit 174577c

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/resources/views/fields/table.blade.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<!-- array input -->
22

33
<?php
4-
$max = isset($field['max']) ? $field['max'] : -1;
5-
$min = isset($field['min']) ? $field['min'] : -1;
4+
$max = isset($field['max']) && (int) $field['max'] > 0 ? $field['max'] : -1;
5+
$min = isset($field['min']) && (int) $field['min'] > 0 ? $field['min'] : -1;
66
$item_name = strtolower( isset($field['entity_singular']) && !empty($field['entity_singular']) ? $field['entity_singular'] : $field['label']);
77
88
$items = old($field['name']) ? (old($field['name'])) : (isset($field['value']) ? ($field['value']) : (isset($field['default']) ? ($field['default']) : '' ));
@@ -40,8 +40,8 @@
4040
{{ $prop }}
4141
</th>
4242
@endforeach
43-
<th class="text-center"> {{-- <i class="fa fa-sort"></i> --}} </th>
44-
<th class="text-center"> {{-- <i class="fa fa-trash"></i> --}} </th>
43+
<th class="text-center" ng-if="max == -1 || max > 1"> {{-- <i class="fa fa-sort"></i> --}} </th>
44+
<th class="text-center" ng-if="max == -1 || max > 1"> {{-- <i class="fa fa-trash"></i> --}} </th>
4545
</tr>
4646
</thead>
4747

@@ -54,10 +54,10 @@
5454
<input class="form-control input-sm" type="text" ng-model="item.{{ $prop }}">
5555
</td>
5656
@endforeach
57-
<td>
57+
<td ng-if="max == -1 || max > 1">
5858
<span class="btn btn-sm btn-default sort-handle"><span class="sr-only">sort item</span><i class="fa fa-sort" role="presentation" aria-hidden="true"></i></span>
5959
</td>
60-
<td>
60+
<td ng-if="max == -1 || max > 1">
6161
<button ng-hide="min > -1 && $index < min" class="btn btn-sm btn-default" type="button" ng-click="removeItem(item);"><span class="sr-only">delete item</span><i class="fa fa-trash" role="presentation" aria-hidden="true"></i></button>
6262
</td>
6363
</tr>
@@ -67,7 +67,7 @@
6767
</table>
6868

6969
<div class="array-controls btn-group m-t-10">
70-
<button class="btn btn-sm btn-default" type="button" ng-click="addItem()"><i class="fa fa-plus"></i> Add {{ $item_name }}</button>
70+
<button ng-if="max == -1 || items.length < max" class="btn btn-sm btn-default" type="button" ng-click="addItem()"><i class="fa fa-plus"></i> Add {{ $item_name }}</button>
7171
</div>
7272

7373
</div>

0 commit comments

Comments
 (0)