Skip to content

Commit d44d266

Browse files
authored
Add column toggler support (#21)
1 parent f4cc845 commit d44d266

File tree

4 files changed

+23
-7
lines changed

4 files changed

+23
-7
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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

1212
This field works just like as the default HasMany relationship field from nova but **without requiring a real relation** with the resource.

dist/js/field.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

resources/js/components/CustomRelationshipField.vue

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
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"
@@ -27,11 +27,27 @@
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>

yarn.lock

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,9 +1227,9 @@
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"

0 commit comments

Comments
 (0)