nova-inline-relationship icon indicating copy to clipboard operation
nova-inline-relationship copied to clipboard

Use default Nova behaviour for index column for the fields

Open YarinceP opened this issue 5 years ago • 3 comments

YarinceP avatar Feb 05 '20 22:02 YarinceP

@YarinceP Would you mind giving us some context around exactly what you are wanting? Thanks!

brandonferens avatar Feb 12 '20 16:02 brandonferens

@brandonferens Why does BelongsTo (which is just MANY to one or ONE to one show up at index like "1 address" instead of that address? i guess that's what OP meant

genesiscz avatar Apr 09 '20 03:04 genesiscz

@YarinceP

Could you look up into this or is this project simply dead?

It's not so hard to fix this. I've been able to do these changes to make this half-work (without the link tho)

IndexField.vue

        indexLabel: function() {
            if (this.field.value instanceof String || typeof this.field.value == "string") {
                return this.field.value;
            }
            let count = Object.keys(this.field.value).length;
            let label = (count > 1) ? this.field.pluralLabel : this.field.singularLabel;
            return count == 1 ? `${this.field.value}` : `${count} ${label}`;
        }
    }

NovaInlineRelationship.php, function updateFieldValue, before the last $this->value = ...


        // Ajax request for ïndex page
        if (strpos($request->fullUrl(), "search=") !== false && $this->isSingularRelationship($resource, $attribute)) {
            if (! $resource instanceof \Laravel\Nova\Resource) {
                $this->value = Nova::newResourceFromModel($resource)->title();
            } else {
                $this->value = $resource->title();
            }
            return;
        }

genesiscz avatar Apr 09 '20 04:04 genesiscz