Skip to content

Commit 6f38fdb

Browse files
committed
fix issue where type label would render incorrectly when used with nova-mega-filter
1 parent a3fc4b8 commit 6f38fdb

10 files changed

+46
-32
lines changed

dist/js/field.js

+2-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/js/field.js.LICENSE.txt

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/*!
2+
* Determine if an object is a Buffer
3+
*
4+
* @author Feross Aboukhadijeh <https://feross.org>
5+
* @license MIT
6+
*/
7+
8+
/**
9+
* @license
10+
* Lodash <https://lodash.com/>
11+
* Copyright JS Foundation and other contributors <https://js.foundation/>
12+
* Released under MIT license <https://lodash.com/license>
13+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
14+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
15+
*/

dist/mix-manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
22
"/js/field.js": "/js/field.js"
3-
}
3+
}

package.json

+5-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
"production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
1111
},
1212
"devDependencies": {
13-
"cross-env": "^5.0.0",
14-
"laravel-mix": "^1.0",
15-
"laravel-nova": "^1.0"
13+
"cross-env": "^7.0.2",
14+
"laravel-mix": "^5.0.4",
15+
"laravel-nova": "^1.2.0",
16+
"vue-template-compiler": "^2.6.11"
1617
},
1718
"dependencies": {
18-
"vue": "^2.5.0"
19+
"vue": "^2.6.11"
1920
}
2021
}

resources/js/ReplaceValueWithLabel.js

+4-6
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ export default {
44
originalValue: this.field.value
55
}
66
},
7-
created() {
8-
9-
const resource = this.field.resources.find(resource => resource.className === this.field.value)
10-
11-
this.field.value = resource.label
12-
7+
computed: {
8+
label() {
9+
return this.field.resources.find(resource => resource.className === this.field.value).label
10+
}
1311
}
1412
}

resources/js/components/DetailField.vue

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<div>
44

5-
<panel :panel="{ name: field.value, fields: standardFields }"/>
5+
<panel :panel="{ name: label, fields: standardFields }"/>
66

77
<template v-for="({type, fields}) of relationalFields">
88

@@ -28,8 +28,8 @@
2828
import ReplaceValueWithLabel from '../ReplaceValueWithLabel'
2929
3030
export default {
31-
props: ['resource', 'resourceName', 'resourceId', 'field'],
32-
mixins: [ReplaceValueWithLabel],
31+
props: [ 'resource', 'resourceName', 'resourceId', 'field' ],
32+
mixins: [ ReplaceValueWithLabel ],
3333
computed: {
3434
relationalFields() {
3535
@@ -51,7 +51,7 @@
5151
},
5252
standardFields() {
5353
54-
return this.fields.filter(field => !['has-one-field', 'has-many-field', 'belongs-to-many-field'].includes(field.component))
54+
return this.fields.filter(field => ![ 'has-one-field', 'has-many-field', 'belongs-to-many-field' ].includes(field.component))
5555
5656
},
5757
fields() {

resources/js/components/FormField.vue

+4-9
Original file line numberDiff line numberDiff line change
@@ -53,27 +53,22 @@
5353

5454
<script>
5555
56-
import {FormField, HandlesValidationErrors} from 'laravel-nova'
56+
import { FormField, HandlesValidationErrors } from 'laravel-nova'
5757
5858
export default {
59-
mixins: [FormField, HandlesValidationErrors],
60-
61-
props: ['resourceName', 'resourceId', 'field'],
62-
59+
mixins: [ FormField, HandlesValidationErrors ],
60+
props: [ 'resourceName', 'resourceId', 'field' ],
6361
computed: {
64-
6562
shouldDisableTypeSelect() {
6663
return this.resourceId
6764
}
68-
6965
},
70-
7166
methods: {
7267
/*
7368
* Set the initial, internal value for the field.
7469
*/
7570
setInitialValue() {
76-
this.value = this.field.value || this.field.default
71+
this.value = this.field.value || this.field.default || null
7772
},
7873
7974
/**
+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
<template>
2-
<span>{{ field.value }}</span>
2+
<span>{{ label }}</span>
33
</template>
44

55
<script>
66
77
import ReplaceValueWithLabel from '../ReplaceValueWithLabel'
88
99
export default {
10-
props: ['resourceName', 'field'],
11-
mixins: [ReplaceValueWithLabel]
10+
props: [ 'resourceName', 'field' ],
11+
mixins: [ ReplaceValueWithLabel ]
1212
}
1313
1414
</script>

resources/js/field.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
import IndexField from './components/IndexField'
2+
import DetailField from './components/DetailField'
3+
import FormField from './components/FormField'
4+
15
Nova.booting((Vue, router, store) => {
2-
Vue.component('index-inline-morph-to', require('./components/IndexField'))
3-
Vue.component('detail-inline-morph-to', require('./components/DetailField'))
4-
Vue.component('form-inline-morph-to', require('./components/FormField'))
6+
Vue.component('index-inline-morph-to', IndexField)
7+
Vue.component('detail-inline-morph-to', DetailField)
8+
Vue.component('form-inline-morph-to', FormField)
59
})

webpack.mix.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
const mix = require('laravel-mix')
22

33
mix.setPublicPath('dist')
4-
.js('resources/js/field.js', 'js')
4+
.js('resources/js/field.js', 'js')

0 commit comments

Comments
 (0)