Skip to content

Commit ee89797

Browse files
hotfixes for logout, profile server errors and avatar in menu
1 parent 9454be2 commit ee89797

6 files changed

Lines changed: 72 additions & 42 deletions

File tree

generator/templates/Authorisation/src/Views/Profile.vue

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<v-container>
33
<v-layout align-center justify-center mt-5>
44
<v-flex xs12 sm10 md8 lg6 xl4>
5-
<v-form ref="form">
5+
<v-form @submit.prevent="updateProfile" ref="profileForm">
66
<v-subheader class="pa-0">Profiel</v-subheader>
77
<v-card class="themed-color">
88
<div class="text-xs-center pa-5"
@@ -18,11 +18,13 @@
1818
v-model="profileForm.name"
1919
label="Naam"
2020
hint="Hoe heet je?"
21+
:rules="[(v) => !!v || 'Naam is verplicht', v => serverError('name', v)]"
2122
></v-text-field>
2223
<v-text-field
2324
v-model="profileForm.email"
2425
label="Email"
2526
hint="Welk e-mail adres wil je gebruiken om in te loggen?"
27+
:rules="[(v) => !!v || 'E-mail is verplicht', v => serverError('email', v)]"
2628
></v-text-field>
2729
</v-card-text>
2830
<v-btn
@@ -34,11 +36,14 @@
3436
right
3537
fab
3638
@click="updateProfile"
39+
type="submit"
3740
>
3841
<v-icon>fa-save</v-icon>
3942
</v-btn>
4043
</v-card>
4144

45+
</v-form>
46+
<v-form @submit.prevent="updatePassword" ref="passwordForm">
4247
<v-subheader class="pa-0">Wachtwoord</v-subheader>
4348
<v-card class="themed-color">
4449
<div class="text-xs-center pa-5"
@@ -57,6 +62,7 @@
5762
label="Wachtwoord"
5863
hint="kies een veilig en lang wachtwoord"
5964
@click:append="passwordShow = !passwordShow"
65+
:rules="[(v) => v === passwordForm.password || 'Beiden wachtwoorden moeten hezelfde zijn', (v) => serverError('password', v)]"
6066
></v-text-field>
6167
<v-text-field
6268
v-model="passwordForm.password_confirmation"
@@ -65,7 +71,7 @@
6571
label="Wachtwoord ter controle"
6672
hint="Hetzelfde wachtwoord"
6773
@click:append="passwordShow = !passwordShow"
68-
:rules="[(v) => v === passwordForm.password || 'Beiden wachtwoorden moeten hezelfde zijn']"
74+
:rules="[(v) => v === passwordForm.password || 'Beiden wachtwoorden moeten hezelfde zijn', (v) => serverError('password', v)]"
6975
></v-text-field>
7076
</v-card-text>
7177
<v-btn
@@ -77,6 +83,7 @@
7783
right
7884
fab
7985
@click="updatePassword"
86+
type="submit"
8087
>
8188
<v-icon>fa-save</v-icon>
8289
</v-btn>
@@ -105,19 +112,30 @@
105112
profileFormLoading: false,
106113
ipFormErrors: null,
107114
passwordShow: false,
115+
errors: {},
108116
};
109117
},
110118
methods: {
111119
updateProfile() {
120+
this.errors = {};
112121
this.profileFormLoading = true;
113-
this.$http.put('profile', this.profileForm).finally(() => {
122+
this.$http.put('profile', this.profileForm).then(() => {
123+
this.profileFormLoading = false;
124+
}).catch((error) => {
125+
this.errors = error.response.data.errors;
114126
this.profileFormLoading = false;
127+
this.$refs.profileForm.validate();
115128
});
116129
},
117130
updatePassword() {
131+
this.errors = {};
118132
this.passwordFormLoading = true;
119-
this.$http.put('profile/password', this.passwordForm).finally(() => {
133+
this.$http.put('profile/password', this.passwordForm).then(() => {
134+
this.passwordFormLoading = false;
135+
}).catch((error) => {
136+
this.errors = error.response.data.errors;
120137
this.passwordFormLoading = false;
138+
this.$refs.passwordForm.validate();
121139
});
122140
},
123141
getProfile() {
@@ -126,17 +144,23 @@
126144
resolve(response.data.data);
127145
});
128146
});
129-
}
147+
},
148+
serverError(name, v) {
149+
if (this.errors !== null && typeof this.errors[name] !== 'undefined') {
150+
return this.errors[name][0];
151+
}
152+
return true;
153+
},
130154
},
131155
created() {
132156
this.getProfile().then((profile) => {
133157
this.profileForm.email = profile.email;
134158
this.profileForm.name = profile.name;
135-
})
159+
});
136160
},
137161
};
138162
</script>
139163

140164
<style scoped>
141165
142-
</style>
166+
</style>

generator/templates/Authorisation/src/store/modules/Authorization.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default {
3333
});
3434
},
3535
unauthorized(context) {
36+
context.commit('setAuthorizationTokens', null);
3637
router.push({name: 'login'});
3738
},
3839
refreshToken() {

generator/templates/Crud/src/Components/BaseResource.vue

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,27 @@
11
<template>
2-
<vuetify-resource
3-
:beforeCreateCallback="beforeOpenCreate"
4-
:beforeUpdateCallback="beforeOpenUpdate"
5-
:canDelete="false"
6-
:createCallback="createEvent"
7-
:deleteCallback="deleteEvent"
8-
:getDataCallback="getDataFromApi"
9-
:getItemCallback="getItemFromApi"
10-
:meta="meta"
11-
:tableContent="tableContent"
12-
:texts="require('../VuetifyResourceTexts.js').default"
13-
:updateCallback="updateEvent"
14-
ref="resourceList"
15-
v-model="selected"
16-
>
17-
<div slot="createContent">
18-
<component :errors="errors" :is="createFormComponent" ref="createForm" v-model="createForm"/>
19-
</div>
20-
<div slot="updateContent">
21-
<component :errors="errors" :is="updateFormComponent" ref="updateForm" v-model="updateForm"/>
22-
</div>
23-
</vuetify-resource>
2+
<v-container fluid pt-5>
3+
<vuetify-resource
4+
:beforeCreateCallback="beforeOpenCreate"
5+
:beforeUpdateCallback="beforeOpenUpdate"
6+
:createCallback="createEvent"
7+
:deleteCallback="deleteEvent"
8+
:getDataCallback="getDataFromApi"
9+
:getItemCallback="getItemFromApi"
10+
:meta="meta"
11+
:tableContent="tableContent"
12+
:texts="require('../VuetifyResourceTexts.js').default"
13+
:updateCallback="updateEvent"
14+
ref="resourceList"
15+
v-model="selected"
16+
>
17+
<div slot="createContent">
18+
<component :errors="errors" :is="createFormComponent" ref="createForm" v-model="createForm"/>
19+
</div>
20+
<div slot="updateContent">
21+
<component :errors="errors" :is="updateFormComponent" ref="updateForm" v-model="updateForm"/>
22+
</div>
23+
</vuetify-resource>
24+
</v-container>
2425
</template>
2526
<script>
2627
export default {
@@ -47,7 +48,7 @@
4748
const {sortBy, descending, page, rowsPerPage} = pagination;
4849
return new Promise((resolve, reject) => {
4950
50-
$http.get(this.resourceUri, {
51+
this.$http.get(this.resourceUri, {
5152
params: {
5253
q: search,
5354
sortBy: sortBy,
@@ -69,7 +70,7 @@
6970
},
7071
getItemFromApi(id) {
7172
return new Promise((resolve) => {
72-
$http.get((this.showResourceUri || this.resourceUri) + '/' + id)
73+
this.$http.get((this.showResourceUri || this.resourceUri) + '/' + id)
7374
.then((response) => {
7475
let item = response.data.data;
7576
resolve({
@@ -93,7 +94,7 @@
9394
return new Promise((resolve, reject) => {
9495
process.nextTick(() => {
9596
if (this.createForm.valid) {
96-
$http.post((this.createResourceUri || this.resourceUri), this.getCreateFormValues(),
97+
this.$http.post((this.createResourceUri || this.resourceUri), this.getCreateFormValues(),
9798
{
9899
headers: {
99100
'Content-Type': 'multipart/form-data',
@@ -128,7 +129,7 @@
128129
return new Promise((resolve, reject) => {
129130
process.nextTick(() => {
130131
if (this.updateForm.valid) {
131-
$http.put((this.updateResourceUri || this.resourceUri) + '/' + selected[0].id, this.getUpdateFormValues(),
132+
this.$http.put((this.updateResourceUri || this.resourceUri) + '/' + selected[0].id, this.getUpdateFormValues(),
132133
{
133134
headers: {
134135
'Content-Type': 'multipart/form-data',
@@ -158,16 +159,21 @@
158159
},
159160
deleteEvent(ids) {
160161
return new Promise((resolve) => {
161-
$http.delete(this.resourceUri + '/delete-many', {
162-
data: {ids: ids},
163-
})
164-
.then(() => {
165-
resolve();
166-
});
162+
let promises = [];
163+
ids.forEach((id) => {
164+
promises.push(this.$http.delete((this.deleteResourceUri || this.resourceUri) + '/' + id));
165+
});
166+
Promise.all(promises).then(() => {
167+
resolve();
168+
})
169+
167170
});
168171
},
169172
afterUpdated() {
170173
174+
},
175+
afterCreated() {
176+
171177
},
172178
},
173179
};

generator/templates/Crud/src/Components/forms/User.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
v-model="values.name"></v-text-field>
1515
<v-text-field
1616
:counter="150"
17-
:rules="[(v) => !!v || 'E-mail is verplicht', v => serverError('name', v), (v) => !!v && v.length <= 100 || 'het e-mailadres mag maximaal 150 tekens bevatten']"
17+
:rules="[(v) => !!v || 'E-mail is verplicht', v => serverError('email', v), (v) => !!v && v.length <= 100 || 'het e-mailadres mag maximaal 150 tekens bevatten']"
1818
label="E-mail"
1919
hint="Het e-mailadres waarmee de gebruiker gaat inloggen en waarnaar een mail verzonden wordt met instructies om een wachtwoord aan te maken"
2020
required

generator/templates/Default/src/Components/MainMenu.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@
5454
<script>
5555
export default {
5656
name: 'MainMenu',
57-
computed: {
5857
data() {
5958
return {
6059
items: [

generator/templates/Default/src/Components/ProfileMenu.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
>
88
<v-btn class="mr-3" fab icon slot="activator">
99
<v-avatar class="accent" size="48" title>
10-
<span class="white--text headline"></span>
10+
<v-icon>fa-user</v-icon>
1111
</v-avatar>
1212
</v-btn>
1313
<v-list>

0 commit comments

Comments
 (0)