|
5 | 5 | <h1 class="text-3xl font-bold text-gray-900"> |
6 | 6 | {{ route.params.id ? model.title : "Create a Survey" }} |
7 | 7 | </h1> |
8 | | - <button |
9 | | - v-if="route.params.id" |
10 | | - type="button" |
11 | | - @click="deleteSurvey()" |
12 | | - class="py-2 px-3 text-white bg-red-500 rounded-md hover:bg-red-600" |
13 | | - > |
14 | | - <svg |
15 | | - xmlns="http://www.w3.org/2000/svg" |
16 | | - class="h-5 w-5 -mt-1 inline-block" |
17 | | - viewBox="0 0 20 20" |
18 | | - fill="currentColor" |
| 8 | + |
| 9 | + <div class="flex"> |
| 10 | + <a |
| 11 | + :href="`/view/survey/${model.slug}`" |
| 12 | + target="_blank" |
| 13 | + v-if="model.slug" |
| 14 | + class="flex py-2 px-4 border border-transparent text-sm rounded-md text-indigo-500 hover:bg-indigo-700 hover:text-white transition-colors focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 mr-2" |
19 | 15 | > |
20 | | - <path |
21 | | - fill-rule="evenodd" |
22 | | - d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" |
23 | | - clip-rule="evenodd" |
24 | | - /> |
25 | | - </svg> |
26 | | - Delete Survey |
27 | | - </button> |
| 16 | + <svg |
| 17 | + xmlns="http://www.w3.org/2000/svg" |
| 18 | + class="h-5 w-5" |
| 19 | + fill="none" |
| 20 | + viewBox="0 0 24 24" |
| 21 | + stroke="currentColor" |
| 22 | + > |
| 23 | + <path |
| 24 | + stroke-linecap="round" |
| 25 | + stroke-linejoin="round" |
| 26 | + stroke-width="2" |
| 27 | + d="M10 6H6a2 2 0 00-2 2v10a2 2 0 002 2h10a2 2 0 002-2v-4M14 4h6m0 0v6m0-6L10 14" |
| 28 | + /> |
| 29 | + </svg> |
| 30 | + View Public link |
| 31 | + </a> |
| 32 | + <button |
| 33 | + v-if="route.params.id" |
| 34 | + type="button" |
| 35 | + @click="deleteSurvey()" |
| 36 | + class="py-2 px-3 text-white bg-red-500 rounded-md hover:bg-red-600" |
| 37 | + > |
| 38 | + <svg |
| 39 | + xmlns="http://www.w3.org/2000/svg" |
| 40 | + class="h-5 w-5 -mt-1 inline-block" |
| 41 | + viewBox="0 0 20 20" |
| 42 | + fill="currentColor" |
| 43 | + > |
| 44 | + <path |
| 45 | + fill-rule="evenodd" |
| 46 | + d="M9 2a1 1 0 00-.894.553L7.382 4H4a1 1 0 000 2v10a2 2 0 002 2h8a2 2 0 002-2V6a1 1 0 100-2h-3.382l-.724-1.447A1 1 0 0011 2H9zM7 8a1 1 0 012 0v6a1 1 0 11-2 0V8zm5-1a1 1 0 00-1 1v6a1 1 0 102 0V8a1 1 0 00-1-1z" |
| 47 | + clip-rule="evenodd" |
| 48 | + /> |
| 49 | + </svg> |
| 50 | + Delete Survey |
| 51 | + </button> |
| 52 | + </div> |
28 | 53 | </div> |
29 | 54 | </template> |
30 | 55 | <div v-if="surveyLoading" class="flex justify-center">Loading...</div> |
@@ -220,6 +245,7 @@ const surveyLoading = computed(() => store.state.currentSurvey.loading); |
220 | 245 | // Create empty survey |
221 | 246 | let model = ref({ |
222 | 247 | title: "", |
| 248 | + slug: "", |
223 | 249 | status: false, |
224 | 250 | description: null, |
225 | 251 | image: null, |
@@ -293,17 +319,16 @@ function questionChange(question) { |
293 | 319 | * Create or update survey |
294 | 320 | */ |
295 | 321 | function saveSurvey() { |
296 | | - store.dispatch("saveSurvey", { ...model.value }) |
297 | | - .then(({ data }) => { |
298 | | - store.commit('notify', { |
299 | | - type: 'success', |
300 | | - message: "The survey was successfully updated" |
301 | | - }) |
302 | | - router.push({ |
303 | | - name: "SurveyView", |
304 | | - params: { id: data.data.id }, |
305 | | - }); |
| 322 | + store.dispatch("saveSurvey", { ...model.value }).then(({ data }) => { |
| 323 | + store.commit("notify", { |
| 324 | + type: "success", |
| 325 | + message: "The survey was successfully updated", |
| 326 | + }); |
| 327 | + router.push({ |
| 328 | + name: "SurveyView", |
| 329 | + params: { id: data.data.id }, |
306 | 330 | }); |
| 331 | + }); |
307 | 332 | } |
308 | 333 |
|
309 | 334 | function deleteSurvey() { |
|
0 commit comments