Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Fixes the visibility of buttons when using max/min on table inputs #198

Merged
merged 1 commit into from
Oct 30, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions src/resources/views/fields/table.blade.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<!-- array input -->

<?php
$max = isset($field['max']) ? $field['max'] : -1;
$min = isset($field['min']) ? $field['min'] : -1;
$max = isset($field['max']) && (int) $field['max'] > 0 ? $field['max'] : -1;
$min = isset($field['min']) && (int) $field['min'] > 0 ? $field['min'] : -1;
$item_name = strtolower( isset($field['entity_singular']) && !empty($field['entity_singular']) ? $field['entity_singular'] : $field['label']);

$items = old($field['name']) ? (old($field['name'])) : (isset($field['value']) ? ($field['value']) : (isset($field['default']) ? ($field['default']) : '' ));
Expand Down Expand Up @@ -40,8 +40,8 @@
{{ $prop }}
</th>
@endforeach
<th class="text-center"> {{-- <i class="fa fa-sort"></i> --}} </th>
<th class="text-center"> {{-- <i class="fa fa-trash"></i> --}} </th>
<th class="text-center" ng-if="max == -1 || max > 1"> {{-- <i class="fa fa-sort"></i> --}} </th>
<th class="text-center" ng-if="max == -1 || max > 1"> {{-- <i class="fa fa-trash"></i> --}} </th>
</tr>
</thead>

Expand All @@ -54,10 +54,10 @@
<input class="form-control input-sm" type="text" ng-model="item.{{ $prop }}">
</td>
@endforeach
<td>
<td ng-if="max == -1 || max > 1">
<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>
</td>
<td>
<td ng-if="max == -1 || max > 1">
<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>
</td>
</tr>
Expand All @@ -67,7 +67,7 @@
</table>

<div class="array-controls btn-group m-t-10">
<button class="btn btn-sm btn-default" type="button" ng-click="addItem()"><i class="fa fa-plus"></i> Add {{ $item_name }}</button>
<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>
</div>

</div>
Expand Down