77 <server-error :server-error =" serverError" />
88
99 <e-select
10- v-model =" localCamp.campPrototype "
10+ v-model =" selectedPrototypeValue "
1111 :vee-rules =" { required: true }"
1212 :skip-if-empty =" false"
1313 :label =" $tc('entity.camp.prototype')"
1414 :hint =" prototypeHint"
1515 persistent-hint
1616 :items =" campTemplates"
1717 :menu-props =" { offsetY: true }"
18+ data-testid =" prototype-select"
1819 />
1920 <div
20- v-if =" localCamp.campPrototype === 'other'"
21+ v-if =" selectedPrototypeValue === 'other'"
2122 class =" e-form-container d-flex gap-2"
2223 >
2324 <e-text-field
177178 </v-btn >
178179 <div class =" ml-auto" >
179180 <ButtonCancel :disabled =" isSaving" @click =" $router.go(-1)" />
180- <ButtonAdd v-if =" valid" type =" submit" :loading =" isSaving" >
181+ <ButtonAdd
182+ v-if =" valid"
183+ type =" submit"
184+ :loading =" isSaving"
185+ data-testid =" create-camp-button"
186+ >
181187 {{ $tc('components.campCreate.campCreateStep2.create') }}
182188 </ButtonAdd >
183189 <v-tooltip v-else top >
@@ -213,7 +219,7 @@ import ClipboardInfoDialog from '@/components/generic/ClipboardInfoDialog.vue'
213219import { useClipboardEntity } from ' @/components/generic/useClipboardEntity.js'
214220import router from ' @/router.js'
215221import { apiStore as api } from ' @/plugins/store/index.js'
216- import { reactive , ref } from ' vue'
222+ import { reactive , ref , watchEffect } from ' vue'
217223
218224export default {
219225 name: ' CampCreateStep2' ,
@@ -237,6 +243,14 @@ export default {
237243 setup ({ camp }) {
238244 const localCamp = reactive (camp)
239245 const copyCampUrl = ref (' ' )
246+ const selectedPrototypeValue = ref (null )
247+ watchEffect (() => {
248+ if ([' other' , ' none' , null ].includes (selectedPrototypeValue .value )) {
249+ localCamp .campPrototype = null
250+ } else {
251+ localCamp .campPrototype = selectedPrototypeValue .value
252+ }
253+ })
240254
241255 const clipboard = useClipboardEntity ({
242256 fetchClipboardEntity: async (url ) => {
@@ -248,11 +262,11 @@ export default {
248262 return await api .get ().camps ({ id: match .params .campId })
249263 },
250264 onEntityLoaded (entity ) {
251- localCamp . campPrototype = entity ._meta .self
265+ selectedPrototypeValue . value = entity ._meta .self
252266 },
253267 onEntityLoadFailed () {
254268 // If "other" is selected, leave the selection as it is, so the user can try again
255- if (localCamp . campPrototype !== ' other' ) localCamp . campPrototype = ' '
269+ if (selectedPrototypeValue . value !== ' other' ) selectedPrototypeValue . value = ' '
256270 },
257271 })
258272
@@ -266,6 +280,7 @@ export default {
266280 setClipboardEntityUrl,
267281 localCamp,
268282 copyCampUrl,
283+ selectedPrototypeValue,
269284 }
270285 },
271286 computed: {
@@ -291,28 +306,28 @@ export default {
291306 },
292307 prototypeHint () {
293308 const campPrototypeUris = this .campPrototypes .map ((prototype ) => prototype .value )
294- switch (this .localCamp . campPrototype ) {
309+ switch (this .selectedPrototypeValue ) {
295310 case ' ' :
296311 return this .$tc (' components.campCreate.campCreateStep2.prototypeHint' )
297312 case ' none' :
298313 return this .$tc (' components.campCreate.campCreateStep2.prototypeHintEmpty' )
299314 case ' other' :
300315 return ' '
301316 default :
302- if (! campPrototypeUris .includes (this .localCamp . campPrototype )) {
317+ if (! campPrototypeUris .includes (this .selectedPrototypeValue )) {
303318 return this .$tc (' components.campCreate.campCreateStep2.prototypeHintOther' )
304319 }
305320 return this .$tc (' components.campCreate.campCreateStep2.prototypeHintSelected' )
306321 }
307322 },
308323 prototypePreview () {
309324 if (
310- this .localCamp . campPrototype === ' none' ||
311- this .localCamp . campPrototype === ' other'
325+ this .selectedPrototypeValue === ' none' ||
326+ this .selectedPrototypeValue === ' other'
312327 ) {
313328 return null
314329 }
315- if (this .localCamp .campPrototype ) {
330+ if (this .localCamp ? .campPrototype ) {
316331 return this .api .get (this .localCamp .campPrototype )
317332 }
318333 return null
@@ -335,7 +350,7 @@ export default {
335350 },
336351 },
337352 watch: {
338- ' localCamp.campPrototype ' (newPrototype) {
353+ selectedPrototypeValue (newPrototype ) {
339354 if (newPrototype === ' other' ) {
340355 this .$nextTick (() => {
341356 if (this .$refs .clipboardInfoDialog ) {
0 commit comments