outl1ne / nova-notes-field

This Laravel Nova package adds a notes field to Nova's arsenal of fields.
MIT License
51 stars 36 forks source link

Button currently unclickable #2

Closed LorenzoSapora closed 5 years ago

LorenzoSapora commented 5 years ago

Hey Tarvo,

Following your readme instructions, and when viewing, the submit button is unclickable.

image

Assumed maybe a character limit, that's why I copy pasted 'test' so many times.

Attempted to remove the disabled=disabled from the button itself, but still doesn't allow me to click

Nova: 2.5.0 Laravel: 5.8~ This package: 1.0.2

Tarpsvo commented 5 years ago

Hey! The button becomes disabled when the field is in the middle of a request (ie fetching notes or submitting a note). I think either fetching notes or submitting a note failed.

Did you run the migrations and add the HasNotes trait to the model?

LorenzoSapora commented 5 years ago

Aha, could it possibly be actions that's causing this issue? I have actions on this resource, and that's refreshing every 10s

Tarpsvo commented 5 years ago

I don't think so. Can you check for any errors in the console?

LorenzoSapora commented 5 years ago

Yep, all migrated. I've added it to a very basic resource, without actions, and it's exhibiting the same issue. The only error I have in my console is a 404. but it's inside my nova js, so I'll have to uncompile that to see what's failing.

My current code block (truncated)

[..]
use OptimistDigital\NovaNotesField\Traits\HasNotes;
use OptimistDigital\NovaNotesField\NotesField;

class GameFeatured extends Resource
{

    use HasNotes;

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make()->sortable(),
[..]
            NotesField::make('Notes')
                ->placeholder('Add note'), // Optional
        ];
    }
Tarpsvo commented 5 years ago

Hey. You added HasNotes to the resource, it should be on the Model.

LorenzoSapora commented 5 years ago

Idiota! Apologies. I'll write up a pull request for the docs, to make it a little more clearer. Thanks for your time.

Tarpsvo commented 5 years ago

Cheers, glad it worked!

LorenzoSapora commented 5 years ago

Aha, reopening because it's still unclickable.

Resource:

<?php

namespace App\Nova;

use Laravel\Nova\Fields\{ID, BelongsTo, DateTime};
use Illuminate\Http\Request;
use Laravel\Nova\Http\Requests\NovaRequest;

use OptimistDigital\NovaNotesField\NotesField;

class GameFeatured extends Resource
{
    /**
     * The model the resource corresponds to.
     *
     * @var string
     */
    public static $model = 'App\Models\GameFeatured';

    /**
     * The single value that should be used to represent the resource when being displayed.
     *
     * @var string
     */
    public static $title = 'id';

    /**
     * The columns that should be searched.
     *
     * @var array
     */
    public static $search = [
        'id',
    ];

    public static function label() {
        return 'Featured';
    }

    public static function uriKey() {
        return 'featured';
    }

    /**
     * Get the fields displayed by the resource.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array
     */
    public function fields(Request $request)
    {
        return [
            ID::make()
                ->sortable(),

            NotesField::make('Notes')
                ->placeholder('Add note'), // Optional
        ];
    }
[...]

Model:

<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;
use OptimistDigital\NovaNotesField\Traits\HasNotes;

class GameFeatured extends Model
{
    use HasNotes;

    /**
     * The database table used by the model.
     *
     * @var string
     */
    protected $table = 'game_featured';

    protected $casts = [
        'start' => 'date',
        'end' => 'date',
    ];
[...]

image

Tarpsvo commented 5 years ago

Now that I think about it, I believe I made it so it's also disabled when the field is empty, did you try entering anything?

LorenzoSapora commented 5 years ago

I did, sorry the screenshot doesn't reflect this.

image

Tarpsvo commented 5 years ago

What Laravel Nova version are you using?

LorenzoSapora commented 5 years ago

2.5.0

LorenzoSapora commented 5 years ago

Definitely relating to the 404 error I'm getting. Give me a minute and I'll get the block of JS it's 404ing on

Tarpsvo commented 5 years ago

That's really weird. The only thing I can imagine would cause this is if /nova-vendor/nova-notes/notes request failed for some reason.

Tarpsvo commented 5 years ago

Maybe your routes are cached and the nova-vendor routes are not loaded? 🤷‍♂

LorenzoSapora commented 5 years ago

Hmm. It seems you're right, although I'm not entirely sure why. But for future explorers, running

php artisan cache:clear;php artisan config:clear;php artisan route:clear;php artisan view:clear;php artisan optimize;php artisan clear-compiled;composer dump-autoload;php artisan config:cache;php artisan route:cache;php artisan view:cache;

Cleared everything out for me. Sorry for wasting so much of your time.

Tarpsvo commented 5 years ago

Awesome, I think the routes were cached and it wasn't loading the new ones. Running php artisan route:clear would've probably been enough.