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

Hide tabs in index #6

Closed salierg closed 4 years ago

salierg commented 4 years ago

Is it possible to add the option to not show tabs on the index and replace it with the first language value ?

Also, swith from "TAB TRANSLATABLE" on the index to a select field name ? It's a little weird to display "tab translatable" on the "title" or "name" column of our resource.

Big thx for this package

kongulov commented 4 years ago

@salierg Thanks for the suggestion

To change the title, I added the method setTitle

NovaTabTranslatable::make([
    Text::make('Title')->rules('required'),
])->setTitle('Own Title'),
salierg commented 4 years ago

@kongulov Thx for your time, seems to work fine for the "only one column on index". Nothing to do, only the first field is display now. You can also use ->hideFromIndex() on a field now.

->setTitle() is not working on my code, but it's not a problem anymore if each field has is own column on the index with it's own name.

->hideFromIndex() on a NovaTabTranslatable seems broken, I had to apply ->onlyOnForms() on each column, not ideal.

Also, maybe you could set a ->onlyIndexFields(array $fields) for TabGroup ? Better solution than ->onlyOnForms() if you have a lot of fields in a group. Example:

return [
            NovaTabTranslatable::make([
                Text::make('Name','name'),
                Text::make('Message','cta_body'),
                Text::make('Lien','cta_link'),
            ])->onlyIndexFields(['cta_link'])
        ];
kongulov commented 4 years ago

@salierg What version of nova do you have? It works for both NovaTabTranslatable and internal fields.

->setTitle() not work with TranslatableTabToRowTrait trait. Because there is no longer needed in the field name, there will be the name of the internal fields

It will be necessary to make not only "onlyIndexFields", but also all other options. I'll leave this as a future feature, but for now, use fields hiding