File tree Expand file tree Collapse file tree 4 files changed +23
-7
lines changed
Expand file tree Collapse file tree 4 files changed +23
-7
lines changed Original file line number Diff line number Diff line change 66
77<picture >
88 <source media =" (prefers-color-scheme: dark) " srcset =" https://raw.githubusercontent.com/dcasia/custom-relationship-field/main/screenshots/dark.png " >
9- <img alt =" Laravel Nova Filepond in action" src =" https://raw.githubusercontent.com/dcasia/custom-relationship-field/main/screenshots/light.png " >
9+ <img alt =" Custom Relationship Field in action" src =" https://raw.githubusercontent.com/dcasia/custom-relationship-field/main/screenshots/light.png " >
1010</picture >
1111
1212This field works just like as the default HasMany relationship field from nova but ** without requiring a real relation** with the resource.
Original file line number Diff line number Diff line change 66 :via-resource =" resourceName"
77 :via-resource-id =" resourceId"
88 :via-relationship =" null"
9- :relationship-type =" `CustomRelationshipField:${ encodedAttribute }` "
9+ :relationship-type =" relationshipType "
1010 @actionExecuted =" actionExecuted"
1111 :load-cards =" false"
1212 :initial-per-page =" field.perPage || 5"
2727 this .$emit (' actionExecuted' )
2828 },
2929 },
30+ data () {
31+ return {
32+ eventCallback: null ,
33+ }
34+ },
35+ mounted () {
36+ Nova .$on (' custom-relationship-field:request-extra-params' , this .eventCallback = () => {
37+ Nova .$emit (' custom-relationship-field:extra-params' , { relationshipType: this .relationshipType })
38+ })
39+ },
40+ unmounted () {
41+ Nova .$off (' custom-relationship-field:request-extra-params' , this .eventCallback )
42+ },
3043 computed: {
3144 encodedAttribute () {
3245 return btoa (` ${ this .field .attribute } |_::_|${ this .field .name } ` )
3346 },
34- }
47+ relationshipType () {
48+ return ` CustomRelationshipField:${ this .encodedAttribute } `
49+ },
50+ },
3551 }
3652
3753 </script >
Original file line number Diff line number Diff line change 12271227 integrity sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==
12281228
12291229" @types/node@* " :
1230- version "20.7.2 "
1231- resolved "https://registry.yarnpkg.com/@types/node/-/node-20.7.2 .tgz#0bdc211f8c2438cfadad26dc8c040a874d478aed "
1232- integrity sha512-RcdC3hOBOauLP+r/kRt27NrByYtDjsXyAuSbR87O6xpsvi763WI+5fbSIvYJrXnt9w4RuxhV6eAXfIs7aaf/FQ ==
1230+ version "20.8.0 "
1231+ resolved "https://registry.yarnpkg.com/@types/node/-/node-20.8.0 .tgz#10ddf0119cf20028781c06d7115562934e53f745 "
1232+ integrity sha512-LzcWltT83s1bthcvjBmiBvGJiiUe84NWRHkw+ZV6Fr41z2FbIzvc815dk2nQ3RAKMuN2fkenM/z3Xv2QzEpYxQ ==
12331233
12341234" @types/parse-json@^4.0.0 " :
12351235 version "4.0.0"
You can’t perform that action at this time.
0 commit comments