Skip to content

Commit a6d0866

Browse files
committed
Add public survey view link on survey page
1 parent 106588e commit a6d0866

File tree

1 file changed

+54
-29
lines changed

1 file changed

+54
-29
lines changed

vue/src/views/SurveyView.vue

Lines changed: 54 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,26 +5,51 @@
55
<h1 class="text-3xl font-bold text-gray-900">
66
{{ route.params.id ? model.title : "Create a Survey" }}
77
</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"
1915
>
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>
2853
</div>
2954
</template>
3055
<div v-if="surveyLoading" class="flex justify-center">Loading...</div>
@@ -220,6 +245,7 @@ const surveyLoading = computed(() => store.state.currentSurvey.loading);
220245
// Create empty survey
221246
let model = ref({
222247
title: "",
248+
slug: "",
223249
status: false,
224250
description: null,
225251
image: null,
@@ -293,17 +319,16 @@ function questionChange(question) {
293319
* Create or update survey
294320
*/
295321
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 },
306330
});
331+
});
307332
}
308333
309334
function deleteSurvey() {

0 commit comments

Comments
 (0)