Skip to content

Commit

Permalink
Merge pull request #99 from DissNik/сonfirm_mass_delete
Browse files Browse the repository at this point in the history
  • Loading branch information
lee-to committed Feb 12, 2023
2 parents a834cff + 34e3591 commit ce61396
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 24 deletions.
74 changes: 52 additions & 22 deletions resources/views/base/index/foot.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,30 +25,60 @@
</form>
@endforeach

<form action="{{ $resource->route("destroy", 1) }}" method="POST">
@csrf

@if($resource->isRelatable())
<input type="hidden" name="relatable_mode" value="1">
@endif

@if(request()->routeIs('*.query-tag'))
<input type="hidden" name="redirect_back" value="1">
@endif

@method("delete")

<input name="ids" type="hidden" value="" class="actionBarIds">

@if($resource->can('massDelete') && in_array('delete', $resource->getActiveActions()))
<button class="text-pink inline-block">
@include("moonshine::shared.icons.delete", ["size" => 6, "class" => "mr-2", "color" => "pink"])
</button>
@endif
</form>
@if($resource->can('massDelete') && in_array('delete', $resource->getActiveActions()))
<x-moonshine::modal>
{{ trans('moonshine::ui.confirm_delete') }}

<x-slot name="icon">
<svg class="h-6 w-6 text-red-600" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"
stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"/>
</svg>
</x-slot>

<x-slot name="title">{{ trans('moonshine::ui.deleting') }}</x-slot>

<x-slot name="buttons">
<div class="flex w-full rounded-md shadow-sm sm:ml-3 sm:w-auto">
<form action="{{ $resource->route("destroy", 1) }}" method="POST">
@csrf

@if($resource->isRelatable())
<input type="hidden" name="relatable_mode" value="1">
@endif

@if(request()->routeIs('*.query-tag'))
<input type="hidden" name="redirect_back" value="1">
@endif

@method("delete")

<input name="ids" type="hidden" value="" class="actionBarIds">

<button type="submit"
class="inline-flex justify-center w-full rounded-md border border-transparent px-4 py-2 bg-red-600 text-base leading-6 font-medium text-white shadow-sm hover:bg-red-500 focus:outline-none focus:border-red-700 focus:shadow-outline-red transition ease-in-out duration-150 sm:text-sm sm:leading-5">
{{ trans('moonshine::ui.confirm') }}
</button>
</form>
</div>
<div class="mt-3 flex w-full rounded-md shadow-sm sm:mt-0 sm:w-auto">
<button x-on:click="isOpen = false" type="button"
class="inline-flex justify-center w-full rounded-md border border-gray-300 px-4 py-2 bg-white text-base leading-6 font-medium text-gray-700 shadow-sm hover:text-gray-500 focus:outline-none focus:border-purple focus:shadow-outline-purple transition ease-in-out duration-150 sm:text-sm sm:leading-5">
{{ trans('moonshine::ui.cancel') }}
</button>
</div>
</x-slot>

<x-slot name="outerHtml">
<button x-on:click="isOpen = !isOpen" type="button" class="text-pink inline-block">
@include("moonshine::shared.icons.delete", ["size" => 6, "class" => "mr-2", "color" => "pink"])
</button>
</x-slot>
</x-moonshine::modal>
@endif
</div>


<script>
function actionBarHandler() {
return {
Expand Down
4 changes: 2 additions & 2 deletions resources/views/base/index/table.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
@if(!$resource->isPreviewMode())
<tfoot x-ref="foot"
class="hidden bg-whiteblue dark:bg-purple"
:class="actionBarOpen ? 'translate-y-0 ease-out' : '-translate-y-full ease-in hidden'">

:class="actionBarOpen ? 'translate-y-none ease-out' : '-translate-y-full ease-in hidden'"
>
@include("moonshine::base.index.foot", [$resource])
</tfoot>
@endif
Expand Down

0 comments on commit ce61396

Please sign in to comment.