Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ronnytorresmtz/text-inline
Laravel Nova Text Inline Package
https://github.com/ronnytorresmtz/text-inline
Last synced: about 13 hours ago
JSON representation
Laravel Nova Text Inline Package
- Host: GitHub
- URL: https://github.com/ronnytorresmtz/text-inline
- Owner: ronnytorresmtz
- Created: 2020-08-02T17:56:56.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-01-01T19:53:27.000Z (about 4 years ago)
- Last Synced: 2024-04-17T19:47:24.865Z (9 months ago)
- Language: Vue
- Homepage:
- Size: 626 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Laravel Nova Text Inline Field with One Click
This package allow you to edit a text field in the index page with `one click`
## Installation
composer require ronnytorresmtz/text-inline
## Usage
### Make it editable
```php
use Ronnytorresmtz\TextInline\TextInline;public function fields()
{
return [
TextInline::make('Name')
->inlineOnIndex(),
];
}
```To edit the text field you need to click it on, and base on the `saveOn` event defined the text field value will be store in the database.
If you press the `Esc key` the field text will return to a not editable mode or if the text field lost the focus.
This method also accepts a closure with the current request if you want to make it editable dynamically:
```php
public function fields()
{
return [
InlineText::make('Name')
->inlineOnIndex(function (NovaRequest $request) {
return $request->user()->isAdmin();
}),
];
}
```### Updating field value
The default trigger to save the value is by pressing the `Enter` key (`keyup.enter`). If you wish to use a different event trigger to update the value you can use the `saveOn()` method that accepts an argument corresponding to a javascript event:
```php
public function fields()
{
return [
InlineText::make('Name')
->inlineOnIndex()
->saveOn('blur'),
];
}
```### Key event modifiers
You can also specify the key event modifier:
```php
public function fields()
{
return [
InlineText::make('Name')
->inlineOnIndex()
->saveOn('keyup.shift'),
];
}
```### Resoure Example
![Image](textInline_image.PNG)## Credits
The credit for this package belongs to `PDMFC` I just add the clickable functionality to enable the edit mode and add one listener for blur event to enable the readonly mode. Also I eliminate the refreshTable method.
This package was based on the package [pdmfc/nova-inline-text](https://github.com/pdmfc/nova-inline-text/)