|
1 | 1 | <script setup lang="ts"> |
2 | 2 | import { |
3 | | - deleteSurvey, exportSurvey |
| 3 | + deleteSurvey, |
| 4 | + exportSurvey |
4 | 5 | } from '@/ts/surveys'; |
| 6 | + import { |
| 7 | + ref, |
| 8 | + watch |
| 9 | + } from 'vue'; |
5 | 10 | import { |
6 | 11 | useNotification |
7 | 12 | } from '@kyvg/vue3-notification'; |
|
14 | 19 | import { |
15 | 20 | useSurveyStore |
16 | 21 | } from '@/ts/stores/admin'; |
17 | | - import { |
18 | | - watch |
19 | | - } from 'vue'; |
20 | | -
|
21 | | - // TODO: Download magic links from server to display (if this is supported) |
22 | | - // --> Likely won't be due to bcrypt or the like being used for passwords |
23 | 22 |
|
24 | 23 | const route = useRoute(); |
25 | 24 | const surveyStore = useSurveyStore(); |
26 | 25 | const maxSurveyLength = 50; |
27 | 26 | const notifications = useNotification(); |
28 | 27 | const status = useStatusStore(); |
| 28 | + const deleting = ref( false ); |
| 29 | + const exporting = ref( false ); |
29 | 30 |
|
30 | 31 | const removeSurvey = () => { |
31 | | - deleteSurvey( surveyStore.getSelectedSurveyID! ).then( ( success: boolean ) => { |
32 | | - if ( success ) { |
33 | | - notifications.notify( { |
34 | | - 'text': 'Survey was deleted successfuly', |
35 | | - 'type': 'success', |
36 | | - 'title': 'Survey Deleted' |
37 | | - } ); |
38 | | - window.location.reload(); |
39 | | - } else { |
| 32 | + deleting.value = true; |
| 33 | + deleteSurvey( surveyStore.getSelectedSurveyID! ) |
| 34 | + .then( ( success: boolean ) => { |
| 35 | + if ( success ) { |
| 36 | + notifications.notify( { |
| 37 | + 'text': 'Survey was deleted successfuly', |
| 38 | + 'type': 'success', |
| 39 | + 'title': 'Survey Deleted' |
| 40 | + } ); |
| 41 | + window.location.reload(); |
| 42 | + } else { |
| 43 | + deleting.value = false; |
| 44 | + notifications.notify( { |
| 45 | + 'text': 'Survey could not be deleted', |
| 46 | + 'type': 'error', |
| 47 | + 'title': 'Error: Survey Deletion' |
| 48 | + } ); |
| 49 | + } |
| 50 | + } ) |
| 51 | + .catch( e => { |
| 52 | + console.debug( e ); |
| 53 | + deleting.value = false; |
40 | 54 | notifications.notify( { |
41 | 55 | 'text': 'Survey could not be deleted', |
42 | 56 | 'type': 'error', |
43 | 57 | 'title': 'Error: Survey Deletion' |
44 | 58 | } ); |
45 | | - } |
46 | | - } ); |
| 59 | + } ); |
47 | 60 | }; |
48 | 61 |
|
49 | 62 | const exportThisSurvey = () => { |
50 | | - exportSurvey( surveyStore.getSelectedSurveyID! ).then( ( success: boolean ) => { |
51 | | - if ( success ) |
52 | | - notifications.notify( { |
53 | | - 'text': 'Survey exported successfuly', |
54 | | - 'type': 'success', |
55 | | - 'title': 'Survey Export' |
56 | | - } ); |
57 | | - else |
| 63 | + exporting.value = true; |
| 64 | + exportSurvey( surveyStore.getSelectedSurveyID! ) |
| 65 | + .then( ( success: boolean ) => { |
| 66 | + exporting.value = false; |
| 67 | +
|
| 68 | + if ( success ) |
| 69 | + notifications.notify( { |
| 70 | + 'text': 'Survey exported successfuly', |
| 71 | + 'type': 'success', |
| 72 | + 'title': 'Survey Export' |
| 73 | + } ); |
| 74 | + else |
| 75 | + notifications.notify( { |
| 76 | + 'text': 'Survey could not be exported', |
| 77 | + 'type': 'error', |
| 78 | + 'title': 'Error: Survey Export' |
| 79 | + } ); |
| 80 | + } ) |
| 81 | + .catch( e => { |
| 82 | + console.debug( e ); |
| 83 | + exporting.value = false; |
58 | 84 | notifications.notify( { |
59 | 85 | 'text': 'Survey could not be exported', |
60 | 86 | 'type': 'error', |
61 | 87 | 'title': 'Error: Survey Export' |
62 | 88 | } ); |
63 | | - } ); |
| 89 | + } ); |
64 | 90 | }; |
65 | 91 |
|
66 | 92 | const truncate = ( text: string, limit: number ) => { |
|
119 | 145 | v-if="surveyStore.selectedSurveyIndex >= 0" |
120 | 146 | class="bar-buttons" |
121 | 147 | > |
122 | | - <span> |
| 148 | + <span |
| 149 | + :class="deleting ? 'progress-active' : ''" |
| 150 | + > |
123 | 151 | <i |
124 | 152 | class="fa-solid fa-trash fa-lg trash-icon" |
125 | 153 | @click="removeSurvey" |
126 | 154 | ></i> |
127 | 155 | </span> |
128 | | - <span> |
| 156 | + <span |
| 157 | + :class="exporting ? 'progress-active' : ''" |
| 158 | + > |
129 | 159 | <i |
130 | 160 | class="fa-solid fa-download fa-lg dl-icon" |
131 | 161 | @click="exportThisSurvey" |
|
165 | 195 | @use '@/scss/admin/general'; |
166 | 196 | @use '@/scss/admin/top-bar'; |
167 | 197 |
|
| 198 | +@keyframes progressing-bounce { |
| 199 | + 0% { |
| 200 | + transform: scale(1); |
| 201 | + } |
| 202 | + 30% { |
| 203 | + transform: scale(0.9); |
| 204 | + } |
| 205 | + 50% { |
| 206 | + transform: scale(1.25); |
| 207 | + } |
| 208 | + 70% { |
| 209 | + transform: scale(0.9); |
| 210 | + } |
| 211 | +} |
| 212 | +
|
| 213 | +.progress-active { |
| 214 | + animation: progressing-bounce 0.5s linear infinite; |
| 215 | +} |
| 216 | +
|
| 217 | +
|
168 | 218 | .survey-properties { |
169 | 219 | // Mainly for wide displays |
170 | 220 | .top-bar { |
|
0 commit comments