Skip to content

Commit

Permalink
Fix double delete button on index view (#5)
Browse files Browse the repository at this point in the history
  • Loading branch information
milewski authored Oct 25, 2023
1 parent 0d0c053 commit b42720c
Show file tree
Hide file tree
Showing 12 changed files with 91 additions and 73 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ composer require digital-creative/icon-action-toolbar

## Basic Usage

All you need to do is append an `->icon()` to all your actions, it accepts either an icon name from heroicons v1 or inlined svg string.
All you need to do is append an `->icon()` to all your actions, it accepts either an icon name from [heroicons](https://heroicons.com/) or inlined svg string.

```php
class UserResource extends Resource
Expand Down Expand Up @@ -49,8 +49,8 @@ You can customize the icons by adding the following to your nova config file:
'vendors' => [
'icon_action_toolbar' => [
'icons' => [
'replicate' => 'duplicate',
'preview' => 'document-search',
'replicate' => 'square-2-stack',
'preview' => 'viewfinder-circle',
'impersonate' => 'finger-print',
'delete_resource' => '<svg>...</svg>',
],
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"license": "MIT",
"require": {
"php": ">=8.1",
"laravel/nova": "^4.0"
"laravel/nova": "^4.28.0"
},
"autoload": {
"psr-4": {
Expand Down
4 changes: 2 additions & 2 deletions config/nova.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

return [
'icons' => [
'replicate' => 'duplicate',
'preview' => 'document-search',
'replicate' => 'square-2-stack',
'preview' => 'viewfinder-circle',
'impersonate' => 'finger-print',
'delete_resource' => 'trash',
],
Expand Down
2 changes: 1 addition & 1 deletion dist/css/tool.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/js/tool.js

Large diffs are not rendered by default.

9 changes: 9 additions & 0 deletions dist/js/tool.js.LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,16 @@
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <http://feross.org>
* @license MIT
*/

/*!
* vuex v4.1.0
* (c) 2022 Evan You
* @license MIT
*/

/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */

/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
1 change: 1 addition & 0 deletions nova.mix.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class NovaExtension {
webpackConfig.resolve.alias = {
...(webpackConfig.resolve.alias || {}),
'laravel-nova': path.join(__dirname, '../../vendor/laravel/nova/resources/js/mixins/packages.js'),
'laravel-nova-ui': path.join(__dirname, '../../vendor/laravel/nova/node_modules/laravel-nova-ui'),
'@': path.resolve(__dirname, '../../vendor/laravel/nova/resources/js/'),
}

Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
"nova:install": "npm --prefix='../../vendor/laravel/nova' ci"
},
"devDependencies": {
"@vue/compiler-sfc": "^3.3.6",
"@vue/compiler-sfc": "^3.3.7",
"laravel-mix": "^6.0.41",
"mix-tailwindcss": "^1.3.0",
"sass": "^1.69.4",
"sass-loader": "^13.3.2",
"tailwindcss": "^3.3.3",
"tailwindcss": "^3.3.5",
"vue-loader": "^17.3.0"
}
}
2 changes: 1 addition & 1 deletion resources/js/components/ActionDropdown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@
}
if (resource.authorizedToDelete && !resource.softDeleted) {
if (resource.authorizedToDelete && !resource.softDeleted && Nova.$router.page.component !== 'Nova.Index') {
actions.push({
name: __('Delete Resource'),
Expand Down
6 changes: 5 additions & 1 deletion resources/js/components/ActionSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

<div class="icon-action-toolbar w-full">

<IconActionToolbar :actions="actionsForSelect" @click="handleSelectionChange" :standalone="false"/>
<IconActionToolbar
:actions="actionsForSelect"
@click="handleSelectionChange"
:standalone="false"
parent-type="ActionSelector"/>

<!-- Confirm Action Modal -->
<component
Expand Down
10 changes: 7 additions & 3 deletions resources/js/components/IconActionToolbar.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>

<div v-if="actions.length > 0"
:class="{ 'rounded': standalone, 'rounded-lg bg-gray-100 dark:bg-gray-700': !standalone }"
:class="{ 'rounded': standalone, 'rounded-lg bg-gray-700/5 dark:bg-gray-700': !standalone }"
class="flex dark:focus:ring-gray-600 justify-evenly">

<div v-for="{ iconActionToolbar, destructive, uriKey, name } of actions">
Expand All @@ -12,20 +12,21 @@
type="button"
@click.stop="() => $emit('click', uriKey)"
:class="{
'dark:text-gray-400 dark:hover:text-primary-500': parentType === 'ActionSelector',
'h-9 w-9': !isDetailView && !standalone,
'hover:text-red-500': destructive && !isDetailView,
'hover:text-primary-500': !destructive && !isDetailView,
'rounded hover:bg-gray-200 dark:hover:bg-gray-800 focus:outline-none focus:ring px-3 hover:text-gray-400': standalone && isDetailView
}"
class="toolbar-button px-2 disabled:opacity-50 disabled:pointer-events-none">

<Icon v-if="typeof iconActionToolbar.icon !== 'string'" type="cube-transparent"/>
<Icon v-if="typeof iconActionToolbar.icon !== 'string'" name="cube-transparent"/>

<template v-else-if="iconActionToolbar.icon?.trim()?.startsWith('<svg')">
<div v-html="iconActionToolbar.icon"/>
</template>
<Icon v-else-if="iconActionToolbar.icon" :type="iconActionToolbar.icon"/>
<Icon v-else-if="iconActionToolbar.icon" :name="iconActionToolbar.icon"/>
<div class="ml-1" v-if="iconActionToolbar.label">
{{ iconActionToolbar.label }}
Expand All @@ -41,7 +42,10 @@
<script>
import { Icon, Button } from 'laravel-nova-ui'
export default {
components: { Icon, Button },
emits: [ 'click' ],
props: [ 'actions', 'standalone', 'parentType' ],
computed: {
Expand Down
Loading

0 comments on commit b42720c

Please sign in to comment.