Skip to content
This repository has been archived by the owner on Aug 26, 2019. It is now read-only.

Commit

Permalink
added possibility to customize buttons in config
Browse files Browse the repository at this point in the history
  • Loading branch information
Arthur LORENT committed Oct 26, 2017
1 parent 9978361 commit 703b009
Show file tree
Hide file tree
Showing 10 changed files with 86 additions and 59 deletions.
28 changes: 19 additions & 9 deletions config/tablelist.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,23 @@
'rows_number' => 20,
],
'template' => [
'edit' => [
'class' => 'btn btn-primary btn-rounded spin-on-click',
'icon' => '<i class="fa fa-pencil" aria-hidden="true"></i>',
],
'destroy' => [
'class' => 'btn btn-danger btn-rounded spin-on-click',
'icon' => '<i class="fa fa-times" aria-hidden="true"></i>',
],
'button' => [
'edit' => [
'class' => 'btn btn-primary btn-rounded spin-on-click',
'icon' => '<i class="fa fa-pencil" aria-hidden="true"></i>',
],
'destroy' => [
'class' => 'btn btn-danger btn-rounded',
'icon' => '<i class="fa fa-times" aria-hidden="true"></i>',
],
'confirm' => [
'class' => 'btn btn-success spin-on-click',
'icon' => '<i class="fa fa-check" aria-hidden="true"></i>',
],
'cancel' => [
'class' => 'btn btn-danger',
'icon' => '<i class="fa fa-ban" aria-hidden="true"></i>',
],
]
],
];
];
6 changes: 6 additions & 0 deletions views/components/buttons/cancel.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<button type="button"
class="{!! config('tablelist.template.button.cancel.class') !!}"
data-dismiss="modal">
{!! config('tablelist.template.button.cancel.icon') !!}
{{ trans('tablelist::tablelist.modal.cancel') }}
</button>
5 changes: 5 additions & 0 deletions views/components/buttons/confirm.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<button type="submit"
class="{!! config('tablelist.template.button.confirm.class') !!}">
{!! config('tablelist.template.button.confirm.icon') !!}
{{ trans('tablelist::tablelist.modal.confirm') }}
</button>
7 changes: 7 additions & 0 deletions views/components/buttons/destroy.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<button type="button"
class="{!! config('tablelist.template.button.destroy.class') !!}"
data-toggle="modal"
data-target=".destroy-confirm-modal-{{ $entity->id }}"
title="{{ trans('tablelist::tablelist.tbody.action.destroy') }}">
{!! config('tablelist.template.button.destroy.icon') !!}
</button>
5 changes: 5 additions & 0 deletions views/components/buttons/edit.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<button class="{!! config('tablelist.template.button.edit.class') !!}"
type="submit"
title="{{ trans('tablelist::tablelist.tbody.action.edit') }}">
{!! config('tablelist.template.button.edit.icon') !!}
</button>
14 changes: 0 additions & 14 deletions views/components/destroy-button.blade.php

This file was deleted.

25 changes: 0 additions & 25 deletions views/components/destroy-confirm-modal.blade.php

This file was deleted.

9 changes: 0 additions & 9 deletions views/components/edit-button.blade.php

This file was deleted.

31 changes: 31 additions & 0 deletions views/components/modals/destroy-confirmation.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<div class="modal fade destroy-confirm-modal-{{ $entity->id }}"
tabindex="-1"
role="dialog"
aria-labelledby="myLargeModalLabel"
style="display: none;">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header text-danger">
<button type="button"
class="close"
data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title text-left" id="modal-title">
<i class="fa fa-exclamation-triangle"></i>
{{ trans('tablelist::tablelist.modal.title') }}
</h4>
</div>
<div class="modal-body text-left">
{!! trans('tablelist::tablelist.modal.question', [
'entity' => $entity->{$table->destroyAttribute}
]) !!}
</div>
<div class="modal-footer">
@include('tablelist::components.buttons.cancel')
@include('tablelist::components.buttons.confirm')
</div>
</div>
</div>
</div>
15 changes: 13 additions & 2 deletions views/tbody.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,22 @@
<td class="actions">
{{-- edit button --}}
@if($table->isRouteDefined('edit'))
@include('tablelist::components.edit-button')
<form role="form"
method="GET"
action="{{ $table->getRoute('edit', ['id' => $entity->id]) }}">
@include('tablelist::components.buttons.edit')
</form>
@endif
{{-- destroy button --}}
@if($table->isRouteDefined('destroy'))
@include('tablelist::components.destroy-button')
<form role="form"
method="POST"
action="{{ $table->getRoute('destroy', ['id' => $entity->id]) }}">
{!! csrf_field() !!}
<input type="hidden" name="_method" value="DELETE">
@include('tablelist::components.buttons.destroy')
@include('tablelist::components.modals.destroy-confirmation')
</form>
@endif
</td>
@endif
Expand Down

0 comments on commit 703b009

Please sign in to comment.