Skip to content

Commit 962cbe1

Browse files
authored
Merge pull request #2007 from MetRonnie/reduced-animation
Fix reduced animation mode not working inside mutation form
2 parents 7ee8528 + 4c55a9d commit 962cbe1

File tree

6 files changed

+69
-29
lines changed

6 files changed

+69
-29
lines changed

src/App.vue

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
2828
<script setup>
2929
import { computed, onMounted } from 'vue'
3030
import { useRoute } from 'vue-router'
31-
import { useJobTheme, useReducedAnimation } from '@/composables/localStorage'
31+
import { useJobTheme } from '@/composables/localStorage'
32+
import { useDynamicVuetifyDefaults } from '@/plugins/vuetify'
3233
3334
const DEFAULT_LAYOUT = 'empty'
3435
const route = useRoute()
@@ -39,14 +40,7 @@ const showSidebar = computed(() => route.meta.showSidebar ?? true)
3940
4041
const jobTheme = useJobTheme()
4142
42-
const reducedAnimation = useReducedAnimation()
43-
44-
const vuetifyDefaults = computed(() => ({
45-
global: {
46-
transition: reducedAnimation.value ? 'no' : undefined,
47-
ripple: reducedAnimation.value ? false : undefined,
48-
}
49-
}))
43+
const vuetifyDefaults = useDynamicVuetifyDefaults()
5044
5145
onMounted(() => {
5246
// apply stored application font-size

src/components/cylc/Mutation.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
-->
1717

1818
<template>
19+
<!-- Have to repeat these defaults as the ones set in App.vue don't make it through
20+
the parent v-dialog - see https://github.com/vuetifyjs/vuetify/issues/18123 -->
21+
<v-defaults-provider :defaults="vuetifyDefaults">
1922
<v-card>
2023
<!-- the mutation title -->
2124
<v-card-title class="py-3">
@@ -121,6 +124,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
121124
</template>
122125
</v-snackbar>
123126
</v-card>
127+
</v-defaults-provider>
124128
</template>
125129

126130
<script>
@@ -133,6 +137,8 @@ import {
133137
mutationStatus
134138
} from '@/utils/aotf'
135139
import { mdiClose } from '@mdi/js'
140+
import { useDynamicVuetifyDefaults } from '@/plugins/vuetify'
141+
import { inputDefaults } from '@/components/graphqlFormGenerator/components/vuetify'
136142
137143
export default {
138144
name: 'mutation',
@@ -171,6 +177,14 @@ export default {
171177
},
172178
},
173179
180+
setup () {
181+
const vuetifyDefaults = useDynamicVuetifyDefaults(inputDefaults)
182+
183+
return {
184+
vuetifyDefaults,
185+
}
186+
},
187+
174188
data: () => ({
175189
isValid: false,
176190
submitting: false,

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: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18+
import { computed } from 'vue'
1819
import { aliases, mdi } from 'vuetify/iconsets/mdi-svg'
1920
import { VAutocomplete } from 'vuetify/components/VAutocomplete'
2021
import { VCombobox } from 'vuetify/components/VCombobox'
@@ -23,22 +24,28 @@ import { VTextarea } from 'vuetify/components/VTextarea'
2324
import { VTextField } from 'vuetify/components/VTextField'
2425
import colors from 'vuetify/util/colors'
2526
import { mdiClose } from '@mdi/js'
27+
import { useReducedAnimation } from '@/composables/localStorage'
28+
import { merge } from 'lodash-es'
2629

27-
const inputDefaults = Object.fromEntries([
30+
export const inputComponents = [
2831
VAutocomplete,
2932
VCombobox,
3033
VSelect,
3134
VTextarea,
32-
VTextField
33-
].map(({ name }) => [
34-
name,
35-
{
36-
density: 'compact',
37-
variant: 'outlined',
38-
clearIcon: mdiClose,
39-
hideDetails: true,
40-
}
41-
]))
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+
)
4249

4350
/**
4451
* @type {import('vuetify').VuetifyOptions}
@@ -76,3 +83,25 @@ export const vuetifyOptions = {
7683
...inputDefaults
7784
},
7885
}
86+
87+
/**
88+
* Composable that provides Vuetify defaults that can change at runtime, as opposed to
89+
* the static defaults provided in `createVuetify(vuetifyOptions)`.
90+
*
91+
* For use with a v-defaults-provider.
92+
*
93+
* @param {Object=} other - Additional defaults to provide.
94+
*/
95+
export function useDynamicVuetifyDefaults (other = {}) {
96+
const reducedAnimation = useReducedAnimation()
97+
98+
return computed(() => merge(
99+
{
100+
global: {
101+
transition: reducedAnimation.value ? 'no' : undefined,
102+
ripple: reducedAnimation.value ? false : undefined,
103+
},
104+
},
105+
other
106+
))
107+
}

0 commit comments

Comments
 (0)