Blueq-world / laravel-nova-inlineIndex

Inline update resource field, support text and number update
6 stars 4 forks source link

Just a couple of suggestions #1

Open stuartcusackie opened 3 years ago

stuartcusackie commented 3 years ago

This is exactly what I need and it works well, thank you!

Just a few features that I would ideally like:

manyasone commented 3 years ago

I've made handling numbers myself a little easier by extending the InlineIndex class:

<?php

namespace App\Nova\Fields;

use Ncus\InlineIndex\InlineIndex;

class InlineNumber extends InlineIndex
{
    public function __construct($name, $attribute = null, callable $resolveCallback = null)
    {
        parent::__construct($name, $attribute, $resolveCallback);

        $this->withMeta(
            [
                'type' => 'number',
            ]
        );
    }

    /**
     * The minimum value that can be assigned to the field.
     *
     * @param  mixed  $min
     * @return $this
     */
    public function min($min)
    {
        return $this->withMeta(['min' => $min]);
    }

    /**
     * The maximum value that can be assigned to the field.
     *
     * @param  mixed  $max
     * @return $this
     */
    public function max($max)
    {
        return $this->withMeta(['max' => $max]);
    }

    /**
     * The step size the field will increment and decrement by.
     *
     * @param  mixed  $step
     * @return $this
     */
    public function step($step)
    {
        return $this->withMeta(['step' => $step]);
    }

    /**
     * The step size the field will increment and decrement by.
     *
     * @param  mixed  $refreshOnSaving
     * @return $this
     */
    public function refreshOnSaving($refreshOnSaving = true)
    {
        return $this->withMeta(['refreshOnSaving' => $refreshOnSaving]);
    }
}

edit: Whoops, I hadn't noticed, that min and max are not being set in the vue index component. :[


It would be great, if unsaved changes were temporarily saved optionally, so that you could modify multiple inputs and then save all the changes by pressing enter once.