Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use default Nova behaviour for index column for the fields #53

Open
YarinceP opened this issue Feb 5, 2020 · 3 comments
Open

Use default Nova behaviour for index column for the fields #53

YarinceP opened this issue Feb 5, 2020 · 3 comments

Comments

@YarinceP
Copy link

YarinceP commented Feb 5, 2020

No description provided.

@brandonferens
Copy link
Member

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

@genesiscz
Copy link
Contributor

@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
Copy link
Contributor

@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;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants