Skip to content

Commit

Permalink
Merge branch 'master' into display-btn-on-form-59
Browse files Browse the repository at this point in the history
  • Loading branch information
dillingham authored Jan 5, 2021
2 parents a31626e + 50f1145 commit bdfdf08
Show file tree
Hide file tree
Showing 7 changed files with 5,990 additions and 10,445 deletions.
2 changes: 1 addition & 1 deletion dist/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"/js/field.js": "/js/field.js"
}
}
16,388 changes: 5,954 additions & 10,434 deletions package-lock.json

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
},
"devDependencies": {
"cross-env": "^5.0.0",
"laravel-mix": "^1.0",
"laravel-nova": "^1.0"
"laravel-mix": "^5.0.5",
"laravel-nova": "^1.4.1",
"vue-template-compiler": "^2.6.12"
},
"dependencies": {
"vue": "^2.5.0"
Expand Down
14 changes: 12 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
## Nova Button

[![Latest Version on Github](https://img.shields.io/github/release/dillingham/nova-button.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-button)
[![Total Downloads](https://img.shields.io/packagist/dt/dillingham/nova-button.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-button) [![Twitter Follow](https://img.shields.io/twitter/follow/dillinghammm?color=%231da1f1&label=Twitter&logo=%231da1f1&logoColor=%231da1f1&style=flat-square)](https://twitter.com/dillinghammm)
[![Total Downloads](https://img.shields.io/packagist/dt/dillingham/nova-button.svg?style=flat-square)](https://packagist.org/packages/dillingham/nova-button) [![Twitter Follow](https://img.shields.io/twitter/follow/im_brian_d?color=%231da1f1&label=Twitter&logo=%231da1f1&logoColor=%231da1f1&style=flat-square)](https://twitter.com/im_brian_d)

Nova package for rendering buttons on index, detail and lens views.

Expand Down Expand Up @@ -124,7 +124,7 @@ Button::make('Remind User')->loadingText('Sending..')->successText('Sent!')
| Event | Text | Style |
| -- | -- | -- |
| loading | `loadingText('Loading..')` | `loadingStyle('grey-outline')` |
| success | `successText('Done!')` | `successStyle('succes')` |
| success | `successText('Done!')` | `successStyle('success')` |
| error | `errorText('Failed')` | `errorStyle('danger')` |

Defaults defined in the `nova-button` config. Add methods when you want to change for specific resources
Expand Down Expand Up @@ -233,3 +233,13 @@ Button::make('Confirm')->event('App\Events\ConfirmClick')
# Telescope inspection

![event-triggered](https://user-images.githubusercontent.com/29180903/50742633-1a1b8800-11dc-11e9-8a2d-5ec70d3fcae4.png)

---

# Author

Hi 👋, Im Brian Dillingham, creator of this Nova package [and others](https://novapackages.com/collaborators/dillingham)

Hope you find it useful. Feel free to reach out with feedback.

Follow me on twitter: [@im_brian_d](https://twitter.com/im_brian_d)
4 changes: 3 additions & 1 deletion resources/js/components/NovaButton.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
@click="handleClick"
:class="buttonClasses"
:style="{'min-width': buttonWidth}"
:title="field.title"
:dusk="field.attribute"
></span>
</span>
</template>
Expand Down Expand Up @@ -128,4 +130,4 @@ export default {
}
}
};
</script>
</script>
20 changes: 16 additions & 4 deletions src/Button.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace NovaButton;

use Laravel\Nova\Fields\Field;
use Laravel\Nova\Resource;
use Illuminate\Support\Arr;
use Illuminate\Support\Str;
use Laravel\Nova\Fields\Field;
use Laravel\Nova\Resource;

class Button extends Field
{
Expand All @@ -31,6 +31,8 @@ class Button extends Field

public $label = null;

public $title = null;

public $indexName = null;

public $route = null;
Expand Down Expand Up @@ -58,6 +60,7 @@ public function __construct($name, $key = null)
$this->name = $name;
$this->text = $name;
$this->key = $key ?? Str::kebab($name);
$this->attribute = $this->key;
$this->config = config('nova-button');
$this->addDefaultSettings();
}
Expand Down Expand Up @@ -85,6 +88,7 @@ public function resolve($resource, $attribute = null)
'visible' => $this->visible,
'classes' => $this->classes,
'indexName' => $this->indexName,
'title' => $this->title,
'indexAlign' => $this->indexAlign,
'errorText' => $this->errorText,
'errorClasses' => $this->errorClasses,
Expand Down Expand Up @@ -205,6 +209,13 @@ public function label($label)
return $this;
}

public function title($title)
{
$this->title = $title;

return $this;
}

public function index($namespace)
{
$this->route('index', [
Expand Down Expand Up @@ -275,9 +286,10 @@ public function route($name, $params)
}

/**
* Add params to route
* Add params to route.
*
* @param array $params
*
* @param array $params
* @return $this
*/
public function withParams(array $params)
Expand Down
2 changes: 1 addition & 1 deletion src/Providers/FieldServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FieldServiceProvider extends ServiceProvider
public function boot()
{
$this->publishes([
__DIR__.'/../../config/nova-button.php' => config_path('nova-button.php'),
__DIR__.'/../../config/nova-button.php' => config_path('nova-button.php'),
], 'nova-button');

Nova::serving(function (ServingNova $event) {
Expand Down

0 comments on commit bdfdf08

Please sign in to comment.