|
1 | 1 | <script lang="ts">
|
2 | 2 | import Layout from '../Components/Layout.vue'
|
| 3 | +import TestGrid from '../Components/TestGrid.vue' |
| 4 | +import TestGridItem from '../Components/TestGridItem.vue' |
3 | 5 | export default { layout: Layout }
|
4 | 6 | </script>
|
5 | 7 |
|
6 | 8 | <script setup lang="ts">
|
7 | 9 | import { Head, router, useForm } from '@inertiajs/vue3'
|
8 | 10 | import { ref, watch } from 'vue'
|
9 | 11 |
|
10 |
| -let timer = null |
11 | 12 | const reloadCount = ref(0)
|
12 | 13 |
|
13 | 14 | const props = defineProps<{
|
@@ -108,49 +109,54 @@ watch(reloadCount, () => {
|
108 | 109 | <Head title="Async Request" />
|
109 | 110 | <h1 class="text-3xl">Async Request</h1>
|
110 | 111 | <p class="mt-6">Reload Count: {{ reloadCount }}</p>
|
111 |
| - <div class="grid grid-cols-3 gap-4 mt-6"> |
112 |
| - <div class="p-4 space-y-4 text-sm text-gray-500 border border-gray-300 rounded"> |
| 112 | + <TestGrid> |
| 113 | + <TestGridItem class="space-y-4"> |
113 | 114 | <p>Trigger an async reload that takes a moment and immediately programatically visit another page</p>
|
114 |
| - <button @click="simulateConflict" class="px-4 py-2 text-white bg-green-600 rounded">Reload → Visit</button> |
115 |
| - </div> |
116 |
| - <div class="p-4 space-y-4 text-sm text-gray-500 border border-gray-300 rounded"> |
117 |
| - <div class="flex flex-col"> |
118 |
| - <label> |
| 115 | + <button @click="simulateConflict" class="rounded bg-green-600 px-4 py-2 text-white">Reload → Visit</button> |
| 116 | + </TestGridItem> |
| 117 | + |
| 118 | + <TestGridItem class="space-y-4"> |
| 119 | + <div> |
| 120 | + <label class="block"> |
119 | 121 | <input v-model="form.jonathan" type="checkbox" class="mr-2" />
|
120 | 122 | Jonathan
|
121 | 123 | </label>
|
122 |
| - <label> |
| 124 | + <label class="block"> |
123 | 125 | <input v-model="form.taylor" type="checkbox" class="mr-2" />
|
124 | 126 | Taylor
|
125 | 127 | </label>
|
126 |
| - <label> |
| 128 | + <label class="block"> |
127 | 129 | <input v-model="form.joe" type="checkbox" class="mr-2" />
|
128 | 130 | Joe
|
129 | 131 | </label>
|
130 | 132 | </div>
|
131 | 133 | <p>You can check these on and off and then navigate to another page and the requests should still complete.</p>
|
132 | 134 | <p>Toggling "Joe" on will cause a redirect to "Article", simulating an authorized action e.g.</p>
|
133 |
| - </div> |
134 |
| - <div class="p-4 space-y-4 text-sm text-gray-500 border border-gray-300 rounded"> |
| 135 | + </TestGridItem> |
| 136 | + |
| 137 | + <TestGridItem class="space-y-4"> |
135 | 138 | <p>Trigger programatic visit and an async reload one after another</p>
|
136 | 139 |
|
137 | 140 | <p>Reload should still happen but won't re-direct back to the reloaded component, we should respect the visit</p>
|
138 | 141 |
|
139 |
| - <button @click="triggerVisitThenReload" class="px-4 py-2 text-white bg-green-600 rounded">Visit → Reload</button> |
140 |
| - </div> |
141 |
| - <div class="p-4 space-y-4 text-sm text-gray-500 border border-gray-300 rounded"> |
| 142 | + <button @click="triggerVisitThenReload" class="rounded bg-green-600 px-4 py-2 text-white">Visit → Reload</button> |
| 143 | + </TestGridItem> |
| 144 | + |
| 145 | + <TestGridItem class="space-y-4"> |
142 | 146 | <p>Simply trigger a 4 second reload so you can navigate or do whatever you'd like during it.</p>
|
143 |
| - <button @click="triggerLongReload" class="px-4 py-2 text-white bg-green-600 rounded">Trigger Long Reload</button> |
144 |
| - </div> |
145 |
| - <div class="p-4 space-y-4 text-sm text-gray-500 border border-gray-300 rounded"> |
| 147 | + <button @click="triggerLongReload" class="rounded bg-green-600 px-4 py-2 text-white">Trigger Long Reload</button> |
| 148 | + </TestGridItem> |
| 149 | + |
| 150 | + <TestGridItem class="space-y-4"> |
146 | 151 | <p>Trigger an automatic cancellation from the token.</p>
|
147 |
| - <button @click="triggerCancel" class="px-4 py-2 text-white bg-green-600 rounded">Trigger Cancel</button> |
148 |
| - </div> |
149 |
| - <div class="p-4 space-y-4 text-sm text-gray-500 border border-gray-300 rounded"> |
| 152 | + <button @click="triggerCancel" class="rounded bg-green-600 px-4 py-2 text-white">Trigger Cancel</button> |
| 153 | + </TestGridItem> |
| 154 | + |
| 155 | + <TestGridItem class="space-y-4"> |
150 | 156 | <p>Trigger an automatic cancellation from the token after finishing request.</p>
|
151 |
| - <button @click="triggerCancelAfterFinish" class="px-4 py-2 text-white bg-green-600 rounded"> |
| 157 | + <button @click="triggerCancelAfterFinish" class="rounded bg-green-600 px-4 py-2 text-white"> |
152 | 158 | Trigger Cancel After Finish
|
153 | 159 | </button>
|
154 |
| - </div> |
155 |
| - </div> |
| 160 | + </TestGridItem> |
| 161 | + </TestGrid> |
156 | 162 | </template>
|
0 commit comments