Skip to content

Added variable for change command bar position #2989

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bald-cat
Copy link
Contributor

@bald-cat bald-cat commented Apr 7, 2025

Fixes #

Proposed Changes

I suggest adding the ability to change the position of the command bar in the Layout::block(). This can be useful in some cases where commands need to be displayed at the table level or to display commands above the form they belong to.

top-commands-table

Code example:

Layout::block([
                Layout::table('table', [
                    TD::make('id', 'ID')
                        ->width('100')
                        ->render(fn (Repository $model) => // Please use view('path')
                        "<img src='https://loremflickr.com/500/300?random={$model->get('id')}'
                              alt='sample'
                              class='mw-100 d-block img-fluid rounded-1 w-100'>
                            <span class='small text-muted mt-1 mb-0'># {$model->get('id')}</span>"),

                    TD::make('name', 'Name')
                        ->width('450')
                        ->render(fn (Repository $model) => Str::limit($model->get('name'), 200)),

                    TD::make('price', 'Price')
                        ->width('100')
                        ->usingComponent(Currency::class, before: '$')
                        ->align(TD::ALIGN_RIGHT),

                    TD::make('created_at', 'Created')
                        ->width('100')
                        ->usingComponent(DateTimeSplit::class)
                        ->align(TD::ALIGN_RIGHT),
                ]),
            ])
                ->vertical()
                ->commands([
                    Button::make('Add')->icon('bs.plus'),
                    Button::make('Delete')->icon('bs.trash'),
                    Button::make('Send')->icon('bs.send'),
                ], top: true),

At first I wanted to add a whole system of constants, but I decided to simplify everything and just added one more optional parameter to the method.

First variant example: )))

    public const COMMAND_TOP = 'top';

    public const COMMAND_BOTTOM = 'bottom';

    public const BAR_TABLE_CLASSES = [
        self::COMMAND_TOP => 'rounded-bottom',
        self::COMMAND_BOTTOM => 'rounded-top',
    ];

    /**
     * @var string
     */
    protected $template = 'platform::layouts.block';

    public $commandBarPosition = self::COMMAND_BOTTOM;
    ```

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

Successfully merging this pull request may close these issues.

1 participant