|
22 | 22 | "savingInfo": "Speichere Angaben", |
23 | 23 | "sendingFile": "Sende Datei", |
24 | 24 | "done": "Fertig" |
| 25 | + }, |
| 26 | + "error": { |
| 27 | + "unspecified": "Etwas ist schiefgelaufen. Stellen Sie sicher, dass Sie eingeloggt sind und alle Daten korrekt eingegeben haben." |
25 | 28 | } |
26 | 29 | }, |
27 | 30 | "fr": { |
|
40 | 43 | "savefile": "Sende Datei", |
41 | 44 | "predecessor": "version prédécesseuse", |
42 | 45 | "municipalityMandatory": "Veuillez sélectionner une municipalité", |
43 | | - "noMatches": "Aucun résultat" |
| 46 | + "noMatches": "Aucun résultat", |
| 47 | + "status": { |
| 48 | + "savingInfo": "Enregistrer les détails", |
| 49 | + "sendingFile": "Envoyer le fichier", |
| 50 | + "done": "Prêt" |
| 51 | + }, |
| 52 | + "error": { |
| 53 | + "unspecified": "Quelque chose a mal tourné. Assurez-vous que vous êtes connecté et que vous avez saisi toutes les données correctement." |
| 54 | + } |
44 | 55 | } |
45 | 56 | } |
46 | 57 | </i18n> |
|
50 | 61 | <v-card id="snapshotedit" light width="400" class="pa-4"> |
51 | 62 | <h3 v-if="isNew">{{ $t('newsnapshot') }}</h3> |
52 | 63 | <h3 v-else>{{ $t('editsnapshot') }}</h3> |
| 64 | + <v-alert |
| 65 | + v-for="(error, errorIndex) in errors" |
| 66 | + :key="errorIndex" |
| 67 | + type="error" |
| 68 | + class="mt-2 mb-0" |
| 69 | + > |
| 70 | + {{ $t(`error.${error.code || 'unspecified'}`) }} |
| 71 | + </v-alert> |
53 | 72 | <v-form |
54 | 73 | v-if="!saving" |
55 | 74 | class="pt-4" |
|
83 | 102 | required |
84 | 103 | @update:search-input="queryAndSetMunicipalities" |
85 | 104 | :rules="[ |
86 | | - (municipality) => municipality && municipality.bfsNumber || $t('municipalityMandatory') |
| 105 | + (municipality) => |
| 106 | + !!(municipality && municipality.bfsNumber) || |
| 107 | + $t('municipalityMandatory') |
87 | 108 | ]" |
88 | 109 | :hide-no-data="!municipalities.length" |
89 | 110 | > |
|
99 | 120 | :label="$t('file')" |
100 | 121 | truncate-length="20" |
101 | 122 | :rules="[ |
102 | | - file => !!snapshot.datafile || |
| 123 | + file => !!datafile || |
103 | 124 | !!(file && file.name && file.type === 'application/json') || |
104 | 125 | $t('mandatory') |
105 | 126 | ]" |
@@ -166,7 +187,9 @@ export default { |
166 | 187 | municipality: this.municipality, |
167 | 188 | file: undefined |
168 | 189 | }, |
169 | | - wshash: btoa(`WorkspaceNode:${this.$route.params.wshash}`) |
| 190 | + wshash: btoa(`WorkspaceNode:${this.$route.params.wshash}`), |
| 191 | + selectedMunicipality: undefined, |
| 192 | + errors: [] |
170 | 193 | }; |
171 | 194 | }, |
172 | 195 |
|
@@ -225,6 +248,7 @@ export default { |
225 | 248 | return; |
226 | 249 | } |
227 | 250 |
|
| 251 | + this.errors = []; |
228 | 252 | this.saving = true; |
229 | 253 | this.status = this.$t('status.savingInfo'); |
230 | 254 |
|
@@ -264,7 +288,12 @@ export default { |
264 | 288 | this.$emit('saved', { isNew: this.isNew, snapshot: data.snapshotmutation.snapshot }); |
265 | 289 | this.status = this.$t('status.done'); |
266 | 290 | } catch (error) { |
267 | | - // TODO: show error |
| 291 | + // apollo's errors are a bit strange |
| 292 | + if (error.graphQLErrors && error.networkError) { |
| 293 | + this.showErrors(...error.graphQLErrors, ...error.networkError.result.errors); |
| 294 | + } else { |
| 295 | + this.showErrors(error); |
| 296 | + } |
268 | 297 | this.progress = 0; |
269 | 298 | this.selected.file = undefined; |
270 | 299 | } finally { |
@@ -297,6 +326,9 @@ export default { |
297 | 326 | const municipalities = await this.queryMunicipalities(searchInput); |
298 | 327 | this.municipalities = municipalities; |
299 | 328 | } |
| 329 | + }, |
| 330 | + showErrors(...errors) { |
| 331 | + this.errors = [...this.errors, ...errors]; |
300 | 332 | } |
301 | 333 | } |
302 | 334 | }; |
|
0 commit comments