kongulov / nova-tab-translatable

This package contains a NovaTabTranslatable class you can use to make any Nova field type translatable with tabs.
MIT License
79 stars 17 forks source link

Update TranslatableTabToRowTrait.php #13

Closed mgralikowski closed 2 years ago

mgralikowski commented 2 years ago

We use this plugin with another great plugin https://github.com/eminiarts/nova-tabs.

Screenshot_20210916_223557

After upgrade to 1.13 it stopped work.

Screenshot_20210916_223858

Console error:

TypeError: Cannot read property 'tabClass' of undefined at a.getTabClass (tabs:1) at tabs:1

This PR fixes it but I am sure there is a better option.

mgralikowski commented 2 years ago

Categories works because this field is outside the tabs module.

return [
    Tabs::make('Tabs', [
        Tab::make('Basic information', [
            ID::make(__('ID'), 'id'),
            Text::make('Title', 'title')
                ->sortable()
                ->exceptOnForms(),
            new Panel('Translatable elements', $this->translatableFields()), // here we put fields using NovaTabTranslatable
            new Panel('Basic information', $this->basicFields()),
            new Panel('Media', $this->mediaFields()),
        ]),
        Tab::make('SEO', SeoFields::getNovaFields()),
    ]),
    BelongsToMany::make('Categories', null, NewsCategory::class)
        ->sortable()
        ->onlyOnDetail(),
];
kongulov commented 2 years ago

@mgralikowski I made it so that they are also in the tab that you need, and not go beyond the tab https://github.com/kongulov/nova-tab-translatable/commit/c3bb55718ac927459d4b1ec60d7fd3eae09d188c

Your PR broke compatibility with: https://github.com/kongulov/nova-tab-translatable/issues/9

Please update package: https://github.com/kongulov/nova-tab-translatable/releases/tag/1.0.17

mgralikowski commented 2 years ago

Thanks. Update is working but it breaks the another function.

Before: Screenshot_20210918_000253

After: Screenshot_20210918_000607

Crucial is that actions button disappeared.

kongulov commented 2 years ago

@mgralikowski From the screenshot, I did not understand what the problem was. Can you describe in more detail?

mgralikowski commented 2 years ago

Whole "div" just disappeared. Both screen are the same "place" - above categories.

kongulov commented 2 years ago

@mgralikowski Previously, it just went beyond the tab, now it should be in the tab in which you added it

mgralikowski commented 2 years ago

I'm talking about these things:

They disappeared. When I try the previous version they are in the center of the details page like on the screenshot, maybe is not the best place, but better than none. Of course the proper place is top of page. For me, it is critical as we in custom actions have important actions.

This is how looks normal header (when we don't use tabs or panels): Screenshot_20210920_100121

When we use tabs and panel header is moved to the middle of the page (see my first screenshot https://github.com/kongulov/nova-tab-translatable/pull/13#issue-998622691 )

And in the last release:

Screenshot_20210920_100438

mgralikowski commented 2 years ago

Of course, generally, you fixed the issue with the wrong place to fields - it works.

kongulov commented 2 years ago

@mgralikowski I understood you. Due to the fact that you do not have any information, Nova herself does not display this tab.

You can solve this problem by adding ID::make() to the beginning.

return [
    ID::make(),
    Tabs::make('Tabs', [
        ...
    ]),
]

It's not because of the trait. if you use only Tabs, without our package return [ Tabs::make('Tabs', [ ... ]) ], then you will see that the buttons you need will not come out again. This property is Nova

kongulov commented 2 years ago

@mgralikowski But if you use only our package, then the buttons are shown normally.

return [
    NovaTabTranslatable::make([
        Text::make('Name1'),
    ]),
]

This is a Tabs package problem

mgralikowski commented 2 years ago

Screenshot_20210920_103037

Yea.. It works and looks ugly. Nova sucks :/

Your previous version "fixed" it by displaying separately this section.

Of course, the issue is closed, there is nothing we can do.

mgralikowski commented 2 years ago

It is not strictly connected with this library but for people who comes here, there is the solution to use ->withToolbar() on Tabs::make(); ;)