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

Nova hideWhenCreating() not working #11

Closed blomdahldaniel closed 3 years ago

blomdahldaniel commented 3 years ago

Hi!

Thanks for a great package. I like it a lot and it really fills a need. Thank you for your contribution!

I found out that calling the ->hideWhenCreating() does not work.

For example the code below does not hide the slug field. When I place it outside of the NovaTabTranslatable::make([]) wrapper it works fine.

return [
    NovaTabTranslatable::make([
        Text::make('Slug', 'slug')
        ->hideWhenCreating()
        ->updateRules('required', 'string'),

        Text::make('Title', 'title'),
    ]),
];

Status check (checked works):

Methods from nova docs https://nova.laravel.com/docs/3.0/resources/fields.html#showing-hiding-fields

I wish that I could suggest a pull request for this but I have too limited knowledge of the nova internals for that. But I wanted to contribute a bit and it looks like you maybe are missing some functions in this section: https://github.com/kongulov/nova-tab-translatable/blob/master/src/NovaTabTranslatable.php#L90

Maybe this could be a potential fix?

// src/NovaTabTranslatable.php#L90
$translatedField->withMeta([
    'locale' => $locale,
    'showOnIndex'       => $translatedField->showOnIndex,
    'showOnDetail'      => $translatedField->showOnDetail,
    'showOnCreating'    => $translatedField->showOnCreating,
    'showOnUpdating'    => $translatedField->showOnUpdating,
    'hideFromIndex'     => $translatedField->hideFromIndex,
    'hideFromDetail'    => $translatedField->hideFromDetail,
    'hideWhenCreating'  => $translatedField->hideWhenCreating,
    'hideWhenUpdating'  => $translatedField->hideWhenUpdating,
    'onlyOnIndex'       => $translatedField->onlyOnIndex,
    'onlyOnDetail'      => $translatedField->onlyOnDetail,
    'onlyOnForms'       => $translatedField->onlyOnForms,
    'exceptOnForms'     => $translatedField->exceptOnForms,
]);

Thank you!

kongulov commented 3 years ago

Hi @blomdahldaniel, Thanks for checking all the options. But then the problem turned out to be in the VUEjs

You can see the fix here: https://github.com/kongulov/nova-tab-translatable/commit/c20354c6013b907a4e2c1a9b5f827d111599b45d

Please update the package to version 1.0.14 and let me know if everything worked for you

blomdahldaniel commented 3 years ago

Hi @kongulov

Great stuff and a very quick fix! Thank you for that! Everything seems to be working as expected with the new update.

Thanks!

Side note, I saw that you left a few "console.log()" rows in the new release. And maybe you dont want to have that inside your released versions...?

Cheers!