calculated-field icon indicating copy to clipboard operation
calculated-field copied to clipboard

other fieldtypes

Open Dontorpedo opened this issue 5 years ago • 17 comments

Hi,

It would be nice if other Fieldtypes had also a broadcast method.. something like.

Place::make()->broadcaster()

and so on... do you thin this is possible?

thanks

Dontorpedo avatar Aug 23 '19 21:08 Dontorpedo

I think this would be a bit difficult. The default Nova fields do not broadcast an event, and the only way to enable a ->broadcaster() feature would be to replace the built-in components, or extend Nova's primary repository to enable a hook on the value.

I will look into this once I get some time.

codebykyle avatar Oct 03 '19 05:10 codebykyle

@Dontorpedo

I followed @codebykyle instructions here, and created my own custom local package having other broadcaster and listener field types. Here's an example of the folder structure of my package:

├── resources
│   ├── js
│   │   ├── components
│   │   │   ├── broadcaster-belongs-to-field
│   │   │   │   └── FormField.vue
│   │   │   ├── broadcaster-boolean-field
│   │   │   │   └── FormField.vue
│   │   │   ├── broadcaster-text-field
│   │   │   │   └── FormField.vue
│   │   │   ├── listener-belongs-to-field
│   │   │   │   └── FormField.vue
│   │   │   └── listener-text-field
│   │   │       └── FormField.vue
│   │   ├── field.js
│   │   └── mixins
│   │       └── Listener.vue
│   └── sass
│       └── field.scss
├── routes
│   └── api.php
├── src
│   ├── Http
│   │   └── Controllers
│   │       └── CalculatedFieldController.php
│   ├── Traits
│   │   ├── Broadcaster.php
│   │   └── Listener.php
│   ├── BroadcasterBelongsTo.php
│   ├── BroadcasterBoolean.php
│   ├── BroadcasterNumber.php
│   ├── FieldServiceProvider.php
│   ├── ListenerBelongsTo.php
│   ├── ListenerNumber.php
│   └── ListenerText.php

pauldstar avatar Apr 05 '20 16:04 pauldstar

@pauldstar would you be so kind to share your nova-components code?

flatcapco avatar Apr 08 '20 13:04 flatcapco

@latwelve

Sure. I'll create a repo and share it shortly.

pauldstar avatar Apr 08 '20 14:04 pauldstar

@latwelve uploaded to this repo: https://github.com/pauldstar/calculated-field

pauldstar avatar Apr 08 '20 19:04 pauldstar

@latwelve uploaded to this repo: https://github.com/pauldstar/calculated-field

thank you - I've just had a quick look is it missing ListenerBoolean?

flatcapco avatar Apr 08 '20 20:04 flatcapco

@latwelve Yeah it's missing. I've only added field types that I've needed thus far. I could add it if you fancy.

pauldstar avatar Apr 08 '20 20:04 pauldstar

@latwelve Yeah it's missing. I've only added field types that I've needed thus far. I could add it if you fancy.

Ah ok no worries - I should be able to add extra fields in too, new to laravel and nova so it's a good exercise thanks for getting me started

flatcapco avatar Apr 09 '20 08:04 flatcapco

@latwelve Fantastic. Have fun.

pauldstar avatar Apr 09 '20 09:04 pauldstar

@pauldstar Hello, great extension you built there. It is not available on composer, so my question is how can i install your package? Can you give me some keywords so I can search for a tutorial? Thanks

marcusgabler avatar Aug 13 '20 08:08 marcusgabler

Hello @marcusgabler

Sorry for late reply. It used to be on composer, but i took it off, because I made so many modifications to it, and didn't have time to keep updating. Plus I've merged it with another custom package that I made for UI at work. So I didn't feel comfortable dishing out a half finished product.

So I've just left the repo as public, so others can study and add to their code as they see fit.

pauldstar avatar Sep 01 '20 11:09 pauldstar

Looking to use this for a Select. If anyone has experimented with this can you please let me know. Thank you.

keironwaites avatar Oct 16 '20 06:10 keironwaites

@keironwaites

I've updated my repo with a Select (ReactiveSelect.php, ReactiveSelect.vue).

pauldstar avatar Oct 16 '20 09:10 pauldstar

@pauldstar Wow! Nice one, thank you. I will try it out hopefully this afternoon.

keironwaites avatar Oct 16 '20 09:10 keironwaites

Apologies for my lack of knowledge but does anyone have any guides on how to manually install this package using composer? I assume this is the correct approach? Cheers.

keironwaites avatar Oct 23 '20 14:10 keironwaites

I managed to install the package. I am using Example.php's example on a cleanish Resource. I get the following JavaScript error when changing the Price Control drop down.

Screenshot 2020-10-23 at 16 36 08

What am I missing? Cheers

keironwaites avatar Oct 23 '20 15:10 keironwaites

@keironwaites

Sorry, my repo isn't a package (it was at some point, but i removed it...no time to maintain).

And Example.php is not really functional lol it's just to show how to use the custom fields you have created (or in this case copied).

The original intent for this code was to create custom fields which help people who had followed @codebykyle instructions on how to do just that. The instructions can be found here.

pauldstar avatar Oct 23 '20 16:10 pauldstar