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

Collapsed Preview Attribute #406

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

fedeisas
Copy link

@fedeisas fedeisas commented Oct 13, 2022

This implements the preview attribute for the collapsed view as suggested on #378

image

Usage

use Whitecube\NovaFlexibleContent\Layouts\Layout;
use Laravel\Nova\Fields\Text;


class MyLayout extends Layout
{
    protected $name = 'checkbox';

    protected $title = 'Checkbox';

    // You can define which attribute will be bind for the collapsed preview here
    public $collapsedPreviewAttribute = 'label';

    public function fields(): array
    {
        return [
            Text::make('Label', 'label'),
            Text::make('Label', 'title'),
        ];
    }

    // ...or here
    public function collapsedPreviewAttribute()
    {
        return 'title';
    }
}

Usage

This is an optional feature. It improves the UI by allowing differentiation between layouts by marking some attribute (probably the key or something unique) to be displayed on the collapsable header for hints.

@voidgraphics
Copy link
Member

Hello, thanks for the PR. What field types does this work with? Just textfields, or do selects work as well?

@fedeisas
Copy link
Author

Yes, I guess Booleans can be casted to Yes/No and from Selects we could use "selection.name" not sure though. What are your ideas on it @voidgraphics?

@fedeisas
Copy link
Author

fedeisas commented Oct 13, 2022

@voidgraphics just did a quick check, as it displays field.value:

  • for BooleanGroups it shows a JSON encoded representation
  • for Select it shows the option key
  • for Boolean it shows true|false as string

@LorenzoAlu
Copy link

I'll try this branch but doesn't works.

Maybe you have to versioned dist folder?

@fedeisas
Copy link
Author

Yes, you need to build the dist files

@LorenzoAlu
Copy link

@fedeisas thanks ;)

Maybe you can commit dist folder on this branch?

@fedeisas
Copy link
Author

@LorenzoAlu I think a PR with a committed dist/ folder has even fewer chances to get merged. I'm hoping @voidgraphics will merge this someday.

I'm using this branch in the meantime.

@LorenzoAlu
Copy link

@fedeisas thank you 💣

@fedeisas
Copy link
Author

@voidgraphics ping

@fedeisas fedeisas force-pushed the collapsed_preview branch from 15138ea to e639b4e Compare May 15, 2024 23:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants