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

Confirm mass delete #99

Merged
merged 1 commit into from
Feb 12, 2023
Merged
Show file tree
Hide file tree
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
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