1
- import { ref , onMounted } from "vue"
2
- import { Authenticate , QueryCoupons } from "./dtos.mjs"
3
- import { useAuth , useClient , useFormatters } from '@servicestack/vue'
1
+ import { onMounted } from "vue"
2
+ import { Authenticate } from "./dtos.mjs"
3
+ import { useAuth , useClient } from '@servicestack/vue'
4
4
import { JsonApiClient } from "@servicestack/client"
5
-
6
- export const Responsive = {
7
- template :`<AutoQueryGrid type="Booking" :visibleFrom="{ name:'xl', bookingStartDate:'sm', bookingEndDate:'xl', createdBy:'2xl' }">
8
- <template #id="{ id }">
9
- <span class="text-gray-900">{{ id }}</span>
10
- </template>
11
-
12
- <template #name="{ name }">
13
- {{ name }}
14
- </template>
15
-
16
- <template #roomNumber-header>
17
- <span class="hidden lg:inline">Room </span>No
18
- </template>
19
-
20
- <template #cost="{ cost }">{{ currency(cost) }}</template>
21
-
22
- <template #bookingStartDate-header>
23
- Start<span class="hidden lg:inline"> Date</span>
24
- </template>
25
-
26
- <template #bookingEndDate-header>
27
- End<span class="hidden lg:inline"> Date</span>
28
- </template>
29
-
30
- <template #createdBy-header>
31
- Employee
32
- </template>
33
- <template #createdBy="{ createdBy }">{{ createdBy }}</template>
34
- </AutoQueryGrid>` ,
35
- setup ( ) {
36
- const client = useClient ( )
37
- const coupon = ref ( )
38
- const { currency } = useFormatters ( )
39
-
40
- /** @param {string } id */
41
- async function showCoupon ( id ) {
42
- const api = await client . api ( new QueryCoupons ( { id } ) )
43
- if ( api . succeeded ) {
44
- coupon . value = api . response . results [ 0 ]
45
- }
46
- }
47
- const close = ( ) => coupon . value = null
48
-
49
- return { coupon, showCoupon, close, currency }
50
- }
51
- }
52
-
53
- export const CustomBooking = {
54
- template :`<div>
55
- <AutoQueryGrid type="Booking" selectedColumns="id,name,cost,bookingStartDate,bookingEndDate,discount">
56
- <template #discount="{ discount }">
57
- <TextLink v-if="discount" class="flex items-end" @click.stop="showCoupon(discount.id)" :title="discount.id">
58
- <Icon class="w-5 h-5 mr-1" type="Coupon" />
59
- <PreviewFormat :value="discount.description" />
60
- </TextLink>
61
- </template>
62
- </AutoQueryGrid>
63
- <AutoEditForm v-if="coupon" type="UpdateCoupon" v-model="coupon" @done="close" @save="close" />
64
- </div>` ,
65
- setup ( ) {
66
- const client = useClient ( )
67
- const coupon = ref ( )
68
- /** @param {string } id */
69
- async function showCoupon ( id ) {
70
- const api = await client . api ( new QueryCoupons ( { id } ) )
71
- if ( api . succeeded ) {
72
- coupon . value = api . response . results [ 0 ]
73
- }
74
- }
75
- const close = ( ) => coupon . value = null
76
- return { coupon, showCoupon, close }
77
- }
78
- }
5
+ import Responsive from "./autoquerygrid/Responsive.mjs"
6
+ import CustomBooking from "./autoquerygrid/CustomBooking.mjs"
79
7
80
8
export default {
81
9
install ( app ) {
82
- console . log ( 'install(app)' )
83
10
app . provide ( 'client' , JsonApiClient . create ( 'https://blazor-gallery-api.jamstacks.net' ) )
84
11
} ,
85
12
components : {
@@ -90,7 +17,8 @@ export default {
90
17
const client = useClient ( )
91
18
92
19
onMounted ( async ( ) => {
93
- const api = await client . api ( new Authenticate ( { provider :
'credentials' , userName :
'[email protected] ' , password :
'p@55wOrd' } ) )
20
+ const api = await client . api ( new Authenticate ( {
21
+ provider :
'credentials' , userName :
'[email protected] ' , password :
'p@55wOrd' } ) )
94
22
if ( api . succeeded ) {
95
23
const { signIn } = useAuth ( )
96
24
signIn ( api . response )
0 commit comments