Updated seasonedinput to also handle two-way binded value prop. This changes is reflected most all places that seaoned-input is used

. Fuck, also added the new ResultsList which replaces MoviesList
This commit is contained in:
2019-10-22 23:09:29 +02:00
parent 4528b240e1
commit 6d6f1ffd06
8 changed files with 139 additions and 441 deletions

View File

@@ -2,12 +2,13 @@
<section>
<h1>Register new user</h1>
<seasoned-input text="username" icon="Email" type="username"
@inputValue="setValue('username', $event)" />
<seasoned-input text="password" icon="Keyhole" type="password"
@inputValue="setValue('password', $event)" @enter="requestNewUser"/>
<seasoned-input text="repeat password" icon="Keyhole" type="password"
@inputValue="setValue('password', $event)" @enter="requestNewUser"/>
<seasoned-input placeholder="username" icon="Email" type="username" :value.sync="username" />
<seasoned-input placeholder="password" icon="Keyhole" type="password"
:value.sync="password" @enter="requestNewUser"/>
<seasoned-input placeholder="repeat password" icon="Keyhole" type="password"
:value.sync="passwordRepeat" @enter="requestNewUser"/>
<seasoned-button @click="requestNewUser">Register</seasoned-button>
@@ -18,29 +19,26 @@
<script>
import axios from 'axios'
import storage from '@/storage.js'
import SeasonedButton from '@/components/ui/SeasonedButton.vue'
import SeasonedInput from '@/components/ui/SeasonedInput.vue'
import SeasonedMessages from '@/components/ui/SeasonedMessages.vue'
export default {
components: { SeasonedButton, SeasonedInput, SeasonedMessages },
data(){
return{
data() {
return {
messages: [],
username: undefined,
password: undefined,
passwordRepeat: undefined
username: null,
password: null,
passwordRepeat: null
}
},
methods: {
requestNewUser(){
let username = this.username
let password = this.password
let password_re = this.passwordRepeat
let { username, password, passwordRepeat } = this
let verifyCredentials = this.checkCredentials(username, password, passwordRepeat);
let verifyCredentials = this.checkCredentials(username, password, password_re);
if (verifyCredentials.verified) {
axios.post(`https://api.kevinmidboe.com/api/v1/user`, {
username: username,
@@ -65,19 +63,25 @@ export default {
this.messages.push({ type: 'warning', title: 'Parse error', message: verifyCredentials.reason })
}
},
checkCredentials(username, password, password_re) {
if (password !== password_re) {
checkCredentials(username, password, passwordRepeat) {
if (!username || username.length === 0) {
return {
verified: false,
reason: 'Fill inn username'
}
}
else if (!password || !passwordRepeat) {
return {
verified: false,
reason: "Fill inn both password fields"
}
}
else if (password !== passwordRepeat) {
return {
verified: false,
reason: 'Passwords do not match'
}
}
else if (username === undefined) {
return {
verified: false,
reason: 'Please insert username'
}
}
else {
return {
verified: true,
@@ -85,9 +89,6 @@ export default {
}
}
},
setValue(l, t) {
this[l] = t
},
logOut(){
localStorage.clear();
eventHub.$emit('setUserStatus');