221
221
222
222
<div v-if =" metadataApi" class =" mx-auto max-w-4xl" >
223
223
<h1 class =" my-8 text-3xl" >AutoCreateForm</h1 >
224
+
224
225
<div class =" space-x-2" >
225
226
<SecondaryButton @click =" showCreateBooking=!showCreateBooking" >Create Booking</SecondaryButton >
226
227
<SecondaryButton @click =" showCreateBookingCard=!showCreateBookingCard" >Card</SecondaryButton >
227
228
</div >
228
229
229
230
<div >
230
231
<h3 class =" my-4 text-xl" >Bookings</h3 >
231
- <DataGrid :items =" bookings" :selectedColumns =" ['id','name','roomType','bookingStartDate','cost','timeAgo']" @rowSelected =" selectedBooking = $event" />
232
- <AutoEditForm v-if =" selectedBooking" type =" UpdateBooking" deleteType =" DeleteBooking" v-model =" selectedBooking"
233
- @done =" selectedBooking=null" @save =" refreshBookings" @delete =" refreshBookings" />
232
+ <DataGrid :items =" bookings" :selectedColumns =" ['id','name','roomType','bookingStartDate','cost','timeAgo']"
233
+ @rowSelected =" selectBooking($event)" class =" mb-4" />
234
+ <AutoEditForm v-if =" selectedBooking" formStyle =" card" type =" UpdateBooking" deleteType =" DeleteBooking" v-model =" selectedBooking"
235
+ @done =" selectedBooking=null" @save =" refreshBookings" @delete =" refreshBookings" />
234
236
</div >
235
237
236
238
<div v-if =" showCreateBooking" >
239
241
<div v-if =" showCreateBookingCard" >
240
242
<AutoCreateForm type =" CreateBooking" formStyle =" card" @done =" showCreateBookingCard=false" @save =" refreshBookings" />
241
243
</div >
244
+
245
+ <div class =" mt-4 space-x-2" >
246
+ <SecondaryButton @click =" showGameItem=!showGameItem" >Create Game Item</SecondaryButton >
247
+ </div >
248
+
249
+ <div >
250
+ <h3 class =" my-4 text-xl" >Game Items</h3 >
251
+ <DataGrid :items =" gameIems" @rowSelected =" selectGameItem($event)" class =" mb-4" />
252
+ <AutoEditForm v-if =" selectedGameItem" formStyle =" card" type =" UpdateGameItem" deleteType =" DeleteGameItem" v-model =" selectedGameItem"
253
+ @done =" selectedGameItem=null" @save =" refreshGameIems" @delete =" refreshGameIems" />
254
+ <div v-if =" showGameItem" >
255
+ <AutoCreateForm :type =" CreateGameItem" @done =" showGameItem=false" @save =" refreshGameIems" />
256
+ </div >
257
+ </div >
258
+
242
259
</div >
243
260
244
261
<div v-if =" metadataApi" class =" mx-auto max-w-4xl" >
321
338
<script setup lang="ts">
322
339
import type { ApiRequest , ApiResponse } from ' ../types'
323
340
import { inject , onMounted , ref } from ' vue'
324
- import DarkModeToggle from ' ../components/DarkModeToggle.vue'
325
- import { useClient , dateInputFormat } from ' ./api'
326
- import { useAppMetadata , useFiles } from ' ../api'
327
- import { AllTypes , Authenticate , Booking , CreateBooking , CreateJobApplication , JobApplicationAttachment , QueryBookings , RoomType } from ' ./dtos'
328
341
import { lastRightPart , JsonServiceClient } from ' @servicestack/client'
342
+ import { dateInputFormat } from ' ./api'
343
+ import { useConfig , useAppMetadata , useFiles } from ' ../api'
344
+ import { AllTypes , Authenticate ,
345
+ Booking , CreateBooking , QueryBookings , RoomType ,
346
+ CreateJobApplication , JobApplicationAttachment ,
347
+ GameItem , CreateGameItem , QueryGameItem
348
+ } from ' ./dtos'
329
349
330
350
const emit = defineEmits <{
331
351
(e : ' done' ): () => void
@@ -354,6 +374,12 @@ if (!metadataApi.value) {
354
374
})()
355
375
}
356
376
377
+
378
+ const { setConfig } = useConfig ()
379
+ setConfig ({
380
+ assetsPathResolver : (src : string ) => src .startsWith (' /' ) ? ' http://localhost:5000' + src : src
381
+ })
382
+
357
383
const client = inject (' client' ) as JsonServiceClient
358
384
359
385
client .api (new Authenticate ({ provider:' credentials' , userName:' [email protected] ' , password:' p@55wOrd' }))
@@ -424,8 +450,6 @@ let allContacts = [
424
450
425
451
const { getMimeType } = useFiles ()
426
452
427
- const selectedBooking = ref <Booking | null >(null )
428
- const createBookingResponse = ref <any >()
429
453
const createBooking = new CreateBooking ()
430
454
const createBookingApi: ApiResponse | null = null
431
455
@@ -435,9 +459,6 @@ const toFile = (filePath:string) => ({
435
459
contentType: getMimeType (filePath )
436
460
})
437
461
438
- const showCreateBooking = ref (false )
439
- const showCreateBookingCard = ref (false )
440
-
441
462
const createJobApplication = new CreateJobApplication ({
442
463
// attachments: [new JobApplicationAttachment(toFile('https://cdn.diffusion.works/artifacts/2023/01/26/9060157/output_77487570.png'))]
443
464
})
@@ -447,6 +468,14 @@ const allTypes = new AllTypes({ stringList:['red','green'] })
447
468
const allTypesApi: ApiResponse | null = null
448
469
449
470
const bookings = ref <Booking []>([])
471
+ const selectedBooking = ref <Booking | null >(null )
472
+ const showCreateBooking = ref (false )
473
+ const showCreateBookingCard = ref (false )
474
+
475
+ function selectBooking(item : Booking | null ) {
476
+ selectedBooking .value = null
477
+ if (item ) requestAnimationFrame (() => selectedBooking .value = item )
478
+ }
450
479
451
480
async function refreshBookings(arg ? : any ) {
452
481
if (arg ) console .log (' refreshBookings' , arg )
@@ -458,7 +487,26 @@ async function refreshBookings(arg?:any) {
458
487
}
459
488
}
460
489
461
- onMounted (() => refreshBookings ())
490
+ const gameIems = ref <GameItem []>([])
491
+ const selectedGameItem = ref <GameItem | null >(null )
492
+ const showGameItem = ref (false )
493
+
494
+ function selectGameItem(item : GameItem | null ) {
495
+ selectedGameItem .value = null
496
+ if (item ) requestAnimationFrame (() => selectedGameItem .value = item )
497
+ }
498
+
499
+ async function refreshGameIems(arg ? : any ) {
500
+ if (arg ) console .log (' refreshGameIems' , arg )
501
+ showGameItem .value = false
502
+ selectedGameItem .value = null
503
+ let api = await client .api (new QueryGameItem ())
504
+ if (api .succeeded ) {
505
+ gameIems .value = api .response ! .results
506
+ }
507
+ }
508
+
509
+ onMounted (() => { refreshBookings (); refreshGameIems (); })
462
510
463
511
</script >
464
512
0 commit comments