Skip to content

Commit ce8bf66

Browse files
committed
fix(Package): some readme fixes and additions
1 parent 7c33cae commit ce8bf66

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

README.md

+29-6
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function fields(Request $request)
3636

3737
// ... Nova default fields
3838

39-
ActionButton::make('') // Name in resource table column
39+
ActionButton::make('') // Name in resource table column
4040
->icon('<svg></svg>') // Svg icon (optional)
4141
->title('Refresh') // Title (optional)
4242
->styles([]) // Custom css styles (optional)
@@ -63,11 +63,11 @@ public function fields(Request $request)
6363

6464
// ... Nova default fields
6565

66-
ActionButtons::make()->collection([
67-
ActionButton::make('')->action(),
68-
ActionButton::make('')->action(),
69-
ActionButton::make('')->action(),
70-
])
66+
ActionButtons::make()->collection([
67+
ActionButton::make('')->action(),
68+
ActionButton::make('')->action(),
69+
ActionButton::make('')->action(),
70+
])
7171

7272
// ... Nova default fields
7373
];
@@ -123,6 +123,29 @@ class RefreshAction extends Action
123123

124124
```
125125

126+
> This field is available on index and detail (Thanks to [@CosminBd](https://github.com/CosminBd)) views
127+
128+
---
129+
To hide the action either on Index or Detail, you can add the methods in the action declaration as per:
130+
```php
131+
ActionButton::make('My action')
132+
->action((new RefreshAction)->onlyOnDetail(), $this->resource?->id)
133+
->icon('')
134+
->asToolbarButton(),
135+
```
136+
This is available for both action buttons and action button groups, and it works in individual actions which are part of the action group.
137+
138+
---
139+
140+
To run actions without confirmation, you can add the `$withoutConfirmation = true` property to the Laravel Nova action or provide it as a method when you declare the action button
141+
```php
142+
ActionButton::make('My action')
143+
->action((new RefreshAction)->withoutConfirmation(), $this->resource?->id)
144+
->icon('')
145+
->asToolbarButton(),
146+
```
147+
148+
126149
## License
127150

128151
This project is open-sourced software licensed under the [MIT license](LICENSE.md).

resources/js/components/DetailActionButtonsField.vue

+1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@
3333
queryString: props?.queryString,
3434
resourceName: props?.resourceName,
3535
})));
36+
3637
</script>

src/ActionButton.php

-8
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,6 @@ class ActionButton extends Field
2323
public $showOnUpdate = false;
2424

2525

26-
/**
27-
* Indicates if the element should be shown on the detail view.
28-
*
29-
* @var bool
30-
*/
31-
public $showOnDetail = true;
32-
33-
3426
/**
3527
* Indicates if the element should be shown on the creation view.
3628
*

src/ActionButtons.php

-8
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,6 @@ class ActionButtons extends Field
3030
public $showOnUpdate = false;
3131

3232

33-
/**
34-
* Indicates if the element should be shown on the detail view.
35-
*
36-
* @var bool
37-
*/
38-
public $showOnDetail = true;
39-
40-
4133
/**
4234
* Indicates if the element should be shown on the creation view.
4335
*

0 commit comments

Comments
 (0)