epartment / nova-dependency-container

A Laravel Nova field container allowing to depend on other fields values
MIT License
382 stars 163 forks source link

Nova 4 support #206

Open jaros93 opened 2 years ago

jaros93 commented 2 years ago

Added Nova 4 compatibility.

GarethSomers commented 2 years ago

Hi @jaros93 are you asking for the developers to "Add Nova 4 compatibility"?

"Added" is past tense and implies you've done this already.


In any case Nova 4 adds native support for Dependant Fields.

I wonder if anyone can comment on the native functionality vs that of this package? And whether this package is still required.

wamesro commented 2 years ago

It's not exactly the same

This convenient notation is not possible

NovaDependencyContainer::make([
    Text::make('First Name', 'first_name')
])->dependsOn('name_format', 0),

It is not possible to use it

It is necessary to set a condition for each field

And it is not possible to use either hideWhenCreating() hideWhenCreating() https://nova.laravel.com/docs/4.0/resources/fields.html#showing-hiding-fields only e.g. readonly() required() default()

NoahNxT commented 2 years ago

@GarethSomers The new dependent functionality works very well in Nova 4, but there are some main issues which made me choose for this package still:

  1. Not all fields are supported for the dependent functionality, for example the Markdown field (which isn't even mentioned in the docs) https://nova.laravel.com/docs/4.0/resources/fields.html#dependent-fields

  2. Also the key difference is that the default dependsOn from Nova 4 itself does not check on all events/changes of your dependent field, for example one of the big ones is a boolean field, when you set a default value as 'true' on it it will not detect it on your Edit page, which makes it not yet reliable.

  3. and last but not least, this package makes it possible to use the dependent functionality on a quick and easy way without having to write any difficult logics.

NoahNxT commented 2 years ago

Nova 4 support will be there in the future, but not yet. But surely feel free to open a PR and we'll check it as fast as possible!

meyer59 commented 2 years ago

Also (it seems ridiculous) but Laravel nova dependent functionality doesnt work on Action. check this https://github.com/laravel/nova-issues/issues/3897

internetbug256 commented 2 years ago

Hi from Argentina. Also suffering from Nova 4.0 "enhancements" and plugins compatibility. I have some projects where I had to leave them at Nova 3 due to the amount of plugins not working in the new version. Piece of advice: let's start learning how to build our own plugins. Can't depend on this kind of issues.

mehrancodes commented 2 years ago

Just tried to find a solution this weekend and got failed. in the first step we need to upgrade to Vue 3. since it is trying to get all of the components list via this.$root.$children which doesn't exists in Vue 3. this is where the issue happens

NoahNxT commented 2 years ago

@mehrancodes indeed, we'll have to upgrade to Vue 3. Haven't got the time yet to take a look at it but feel free to open a PR 😇

mehrancodes commented 2 years ago

@NoahNxT Yes true, and UNF it needs a deep understanding of Vue 3. I believe the easier way would be to start the frontend side from zero since in Vue 3 we have composition API and the things can be done different than Vue 2

dmason30 commented 2 years ago

There is a Nova 4 compatible fork here, not sure why they never created a PR for you guys but perhaps someone could take inspiration from it:

https://github.com/alexwenzel/nova-dependency-container

NoahNxT commented 2 years ago

@dmason30 thanks for the info! We will try to take a look ASAP.

mehrancodes commented 2 years ago

@NoahNxT I also did a deep look at the Nova source code just noticed we can get rid of most of the complex parts by using events! for example the watchers registration, etc... Also tested it out quickly and it did work!

For now I would go with the above PR since we need it on prod but would make a PR soon for the event driven solution

jaxramus commented 2 years ago

+1 im still reaching for this package over nova 4 dependsOn a lot of the time

will use the fork posted in the replies for now.

samdharris commented 2 years ago

Hi There

I'm looking at upgrading this to Nova 4 and the main issue is the retirement of the $children property in Vue 3 so without direct access the child component instances, it's kinda difficult for this package to function :(

dmason30 commented 2 years ago

@samdharris You can see how this fork got around this here

https://github.com/alexwenzel/nova-dependency-container/blob/4f4d3756f6d3f6d37ae577841c919d8576340f28/resources/js/components/FormField.vue#L46

dmason30 commented 2 years ago

Also (it seems ridiculous) but Laravel nova dependent functionality doesnt work on Action. check this laravel/nova-issues#3897

Nova 4 now supports dependent fields in actions!

NoahNxT commented 2 years ago

@mehrancodes Did you finished your PR?

BobbyBorisov commented 1 year ago

ping @mehrancodes