Edit and Create forms send to index in edit mode

This commit is contained in:
Bubka 2020-01-07 15:46:48 +01:00
parent bd54b53647
commit 552773ab81
4 changed files with 12 additions and 6 deletions

3
resources/js/app.js vendored
View File

@ -24,7 +24,8 @@ const router = new VueRouter({
{
path: '/',
name: 'accounts',
component: Accounts
component: Accounts,
props: true
},
{
path: '/login',

View File

@ -81,11 +81,14 @@
accounts : [],
ShowTwofaccountInModal : false,
twofaccount: {},
editMode : false,
token : null,
username : null,
editMode: this.InitialEditMode
}
},
props: ['InitialEditMode'],
mounted(){
this.token = localStorage.getItem('jwt')
this.username = localStorage.getItem('user')
@ -109,7 +112,9 @@
this.$refs.OneTimePassword.clearOTP()
});
this.editMode = this.$router.params.editMode
},
components: {
Modal,
TwofaccountShow,

View File

@ -56,7 +56,7 @@
</div>
<div class="field is-grouped">
<div class="control">
<router-link :to="{ name: 'accounts' }" class="button is-light">Cancel</router-link>
<router-link :to="{ name: 'accounts', params: { InitialEditMode: true } }" class="button is-light">Cancel</router-link>
</div>
<div class="control">
<button type="submit" class="button is-link">Create</button>
@ -90,7 +90,7 @@
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
axios.post('/api/twofaccounts', this.twofaccount).then(response => {
this.$router.push({name: 'accounts'});
this.$router.push({name: 'accounts', params: { InitialEditMode: true }});
})
},

View File

@ -37,7 +37,7 @@
</div>
<div class="field is-grouped">
<div class="control">
<router-link :to="{ name: 'accounts' }" class="button is-light">Cancel</router-link>
<router-link :to="{ name: 'accounts', params: { InitialEditMode: true } }" class="button is-light">Cancel</router-link>
</div>
<div class="control">
<button type="submit" class="button is-link">Save</button>
@ -80,7 +80,7 @@
axios.defaults.headers.common['Authorization'] = 'Bearer ' + token
axios.put('/api/twofaccounts/' + this.$route.params.twofaccountId, this.twofaccount).then(response => {
this.$router.push({name: 'accounts'});
this.$router.push({name: 'accounts', params: { InitialEditMode: true }});
})
},