Explorar el Código

Update parameter/path error handling (i.e. where a tooltip is used to display an error) for backend refactor

sbkwgh hace 8 años
padre
commit
12fea7ddc4

+ 12 - 12
src/App.vue

@@ -22,7 +22,7 @@
 					</fancy-input>
 					<fancy-input
 						v-model='signup.password'
-						:error='signup.errors.password'
+						:error='signup.errors.hash'
 						placeholder='Password'
 						type='password'
 						width='100%'
@@ -56,7 +56,7 @@
 					</fancy-input>
 					<fancy-input
 						v-model='login.password'
-						:error='login.errors.password'
+						:error='login.errors.hash'
 						placeholder='Password'
 						type='password'
 						width='100%'
@@ -135,7 +135,7 @@
 
 					errors: {
 						username: '',
-						password: '',
+						hash: '',
 						confirmPassword: ''
 					}
 				},
@@ -147,7 +147,7 @@
 
 					errors: {
 						username: '',
-						password: ''
+						hash: ''
 					}
 				},
 				loadingLogout: false,
@@ -220,7 +220,7 @@
 			},
 			clearSignupErrors () {
 				this.signup.errors.username = ''
-				this.signup.errors.password = ''
+				this.signup.errors.hash = ''
 				this.signup.errors.confirmPassword = ''
 			},
 			clearLogin () {
@@ -229,7 +229,7 @@
 			},
 			clearLoginErrors () {
 				this.login.errors.username = ''
-				this.login.errors.password = ''
+				this.login.errors.hash = ''
 			},
 			closeAccountModal () {
 				this.showAccountModal = false
@@ -260,10 +260,10 @@
 						this.signup.loading = false
 
 						this.ajaxErrorHandler(e, (error) => {
-							let param = error.parameter
+							let path = error.path
 
-							if(this.signup.errors[param] !== undefined) {
-								this.signup.errors[param] = error.message
+							if(this.signup.errors[path] !== undefined && this.signup.errors[path] !== undefined) {
+								this.signup.errors[path] = error.message
 							}
 						})
 					})
@@ -291,10 +291,10 @@
 				}).catch(e => {
 					this.login.loading = false
 					this.ajaxErrorHandler(e, (error) => {
-						let param = error.parameter
+						let path = error.path
 
-						if(this.login.errors[param] !== undefined) {
-							this.login.errors[param] = error.message
+						if(this.signup.errors[path] !== undefined && this.signup.errors[path] !== undefined) {
+							this.signup.errors[path] = error.message
 						}
 					})
 				})

+ 4 - 4
src/assets/js/errorHandler.js

@@ -1,15 +1,15 @@
 module.exports = function(vuex) {
-	return function (res, ignoreParamErrorCb) {
+	return function (res, ignorePathErrorCb) {
 		let errors = []
 
 		if(res.response === undefined || res.response.data.errors === undefined) {
 			errors.push('An error occured. Try again later')
 		} else {
 			res.response.data.errors.forEach(error => {
-				let param = error.parameter
+				let path = error.path
 
-				if(param && ignoreParamErrorCb) {
-					ignoreParamErrorCb(error, errors)
+				if(path && ignorePathErrorCb) {
+					ignorePathErrorCb(error, errors)
 					return
 				}
 				errors.push(error.message)

+ 3 - 1
src/components/routes/SettingsAccount.vue

@@ -102,7 +102,9 @@
 						console.log(e)
 
 						AjaxErrorHandler(this.$store)(e, error => {
-							this.password.errors[error.parameter] = error.message
+							if(error.path === 'hash') {
+								this.password.errors['new password'] = error.message
+							}
 						})
 					})
 			},

+ 5 - 5
src/components/routes/Start.vue

@@ -14,7 +14,7 @@
 				></fancy-input>
 				<fancy-input
 					v-model='password'
-					:error='errors.password'
+					:error='errors.hash'
 					width='100%'
 					placeholder='Password'
 					type='password'
@@ -125,7 +125,7 @@
 
 				errors: {
 					username: '',
-					password: '',
+					hash: '',
 					confirmPassword: '',
 					forumName: '',
 					forumDescription: '',
@@ -147,7 +147,7 @@
 		methods: {
 			clearErrors () {
 				this.errors.username = ''
-				this.errors.password = ''
+				this.errors.hash = ''
 				this.errors.confirmPassword = ''
 				this.errors.forumName = ''
 				this.errors.forumDescription = ''
@@ -157,8 +157,8 @@
 				this.loading = false
 
 				AjaxErrorHandler(this.$store)(err, (error, modalErrors) => {
-					if(this.errors[error.parameter] !== undefined) {
-						this.errors[error.parameter] = error.message
+					if(this.errors[error.path] !== undefined) {
+						this.errors[error.path] = error.message
 					} else {
 						modalErrors.push(error.message)
 					}

+ 3 - 3
src/components/routes/ThreadNew.vue

@@ -103,10 +103,10 @@
 					this.loading = false
 
 					AjaxErrorHandler(this.$store)(e, (error, errors) => {
-						let param = error.parameter
+						let path = error.path
 
-						if(this.errors[param] !== undefined) {
-							this.errors[param] = error.message
+						if(this.errors[path] !== undefined) {
+							this.errors[path] = error.message
 						} else {
 							errors.push(error.message)
 						}