Skip to content

Commit 4c55a9d

Browse files
committed
Move graphqlFormGenerator defaults into v-defaults-provider
1 parent fe20bc2 commit 4c55a9d

File tree

5 files changed

+42
-28
lines changed

5 files changed

+42
-28
lines changed

src/components/cylc/Mutation.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ import {
138138
} from '@/utils/aotf'
139139
import { mdiClose } from '@mdi/js'
140140
import { useDynamicVuetifyDefaults } from '@/plugins/vuetify'
141+
import { inputDefaults } from '@/components/graphqlFormGenerator/components/vuetify'
141142
142143
export default {
143144
name: 'mutation',
@@ -177,7 +178,7 @@ export default {
177178
},
178179
179180
setup () {
180-
const vuetifyDefaults = useDynamicVuetifyDefaults()
181+
const vuetifyDefaults = useDynamicVuetifyDefaults(inputDefaults)
181182
182183
return {
183184
vuetifyDefaults,

src/components/graphqlFormGenerator/EditRuntimeForm.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ export default {
223223
getInputProps (fieldName) {
224224
const gqlType = findByName(this.type.fields, fieldName).type
225225
return {
226-
...VuetifyConfig.defaultProps,
227226
gqlType,
228227
...getComponentProps(gqlType, NamedTypes, VuetifyConfig.kinds)
229228
}

src/components/graphqlFormGenerator/FormInput.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ export default {
9696
9797
// merge this in with default and override props
9898
const propGroups = [
99-
VuetifyConfig.defaultProps,
10099
componentProps,
101100
this.propOverrides || {}
102101
]

src/components/graphqlFormGenerator/components/vuetify.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import GList from '@/components/graphqlFormGenerator/components/List.vue'
2424
import GObject from '@/components/graphqlFormGenerator/components/Object.vue'
2525
import GBroadcastSetting from '@/components/graphqlFormGenerator/components/BroadcastSetting.vue'
2626
import GMapItem from '@/components/graphqlFormGenerator/components/MapItem.vue'
27+
import { inputComponents } from '@/plugins/vuetify'
2728

2829
const NumberFieldProps = {
2930
is: VTextField,
@@ -55,14 +56,18 @@ export const RULES = {
5556

5657
export const RUNTIME_SETTING = 'RuntimeSetting'
5758

58-
export default {
59-
defaultProps: {
60-
// default props for all form inputs
61-
variant: 'filled',
62-
density: 'compact',
63-
hideDetails: false,
64-
},
59+
/** Defaults for all form inputs */
60+
export const inputDefaults = Object.fromEntries(
61+
inputComponents.map((name) => [
62+
name,
63+
{
64+
variant: 'filled',
65+
hideDetails: false,
66+
}
67+
])
68+
)
6569

70+
export default {
6671
namedTypes: {
6772
// registry of GraphQL "named types" (e.g. String)
6873
// {namedType: {is: ComponentClass, prop1: value, ...}}

src/plugins/vuetify.js

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,27 @@ import { VTextField } from 'vuetify/components/VTextField'
2525
import colors from 'vuetify/util/colors'
2626
import { mdiClose } from '@mdi/js'
2727
import { useReducedAnimation } from '@/composables/localStorage'
28+
import { merge } from 'lodash-es'
2829

29-
const inputDefaults = Object.fromEntries([
30+
export const inputComponents = [
3031
VAutocomplete,
3132
VCombobox,
3233
VSelect,
3334
VTextarea,
34-
VTextField
35-
].map(({ name }) => [
36-
name,
37-
{
38-
density: 'compact',
39-
variant: 'outlined',
40-
clearIcon: mdiClose,
41-
hideDetails: true,
42-
}
43-
]))
35+
VTextField,
36+
].map(({ name }) => name)
37+
38+
const inputDefaults = Object.fromEntries(
39+
inputComponents.map((name) => [
40+
name,
41+
{
42+
density: 'compact',
43+
variant: 'outlined',
44+
clearIcon: mdiClose,
45+
hideDetails: true,
46+
}
47+
])
48+
)
4449

4550
/**
4651
* @type {import('vuetify').VuetifyOptions}
@@ -84,14 +89,19 @@ export const vuetifyOptions = {
8489
* the static defaults provided in `createVuetify(vuetifyOptions)`.
8590
*
8691
* For use with a v-defaults-provider.
92+
*
93+
* @param {Object=} other - Additional defaults to provide.
8794
*/
88-
export function useDynamicVuetifyDefaults () {
95+
export function useDynamicVuetifyDefaults (other = {}) {
8996
const reducedAnimation = useReducedAnimation()
9097

91-
return computed(() => ({
92-
global: {
93-
transition: reducedAnimation.value ? 'no' : undefined,
94-
ripple: reducedAnimation.value ? false : undefined,
95-
}
96-
}))
98+
return computed(() => merge(
99+
{
100+
global: {
101+
transition: reducedAnimation.value ? 'no' : undefined,
102+
ripple: reducedAnimation.value ? false : undefined,
103+
},
104+
},
105+
other
106+
))
97107
}

0 commit comments

Comments
 (0)