Fixed Input deletion on Add Team Member Popup. (#1316)

This commit is contained in:
Bogdan Artemenko 2019-02-14 18:02:22 +02:00 committed by GitHub
parent dfd6589fbe
commit b7d377bafb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -69,7 +69,6 @@
<script lang='ts'> <script lang='ts'>
import { Component, Vue } from 'vue-property-decorator'; import { Component, Vue } from 'vue-property-decorator';
import Button from '@/components/common/Button.vue'; import Button from '@/components/common/Button.vue';
import { removeToken } from '@/utils/tokenManager';
import { EMPTY_STATE_IMAGES } from '@/utils/constants/emptyStatesImages'; import { EMPTY_STATE_IMAGES } from '@/utils/constants/emptyStatesImages';
import { PM_ACTIONS, NOTIFICATION_ACTIONS, APP_STATE_ACTIONS } from '@/utils/constants/actionNames'; import { PM_ACTIONS, NOTIFICATION_ACTIONS, APP_STATE_ACTIONS } from '@/utils/constants/actionNames';
import { EmailInput } from '@/types/EmailInput'; import { EmailInput } from '@/types/EmailInput';
@ -126,9 +125,9 @@ import { validateEmail } from '@/utils/validation';
} }
if (!areAllEmailsValid) return; if (!areAllEmailsValid) return;
let result = await this.$store.dispatch(PM_ACTIONS.ADD, emailArray); let result = await this.$store.dispatch(PM_ACTIONS.ADD, emailArray);
if (!result.isSuccess) { if (!result.isSuccess) {
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Error during adding team members!'); this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Error during adding team members!');
@ -139,7 +138,7 @@ import { validateEmail } from '@/utils/validation';
if (!response.isSuccess) { if (!response.isSuccess) {
this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Unable to fetch project members'); this.$store.dispatch(NOTIFICATION_ACTIONS.ERROR, 'Unable to fetch project members');
return; return;
} }
@ -163,15 +162,29 @@ import { validateEmail } from '@/utils/validation';
deleteInput: function(index): void { deleteInput: function(index): void {
if (this.$data.inputs.length === 1) return; if (this.$data.inputs.length === 1) return;
(this as any).resetFormErrors(index);
this.$delete(this.$data.inputs, index); this.$delete(this.$data.inputs, index);
}, },
resetFormErrors: function(index): void { resetFormErrors: function(index): void {
this.$data.formError = '';
this.$data.inputs[index].setError(false); this.$data.inputs[index].setError(false);
if(!(this as any).hasInputError()) {
this.$data.formError = '';
}
}, },
onClose: function(): void { onClose: function(): void {
this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_TEAM_MEMBERS); this.$store.dispatch(APP_STATE_ACTIONS.TOGGLE_TEAM_MEMBERS);
}, },
hasInputError: function (): boolean {
let hasError = false;
this.$data.inputs.some((element: EmailInput)=>{
if(element.error) {
hasError = true;
return true;
}
});
return hasError;
}
}, },
computed: { computed: {
isMaxInputsCount: function(): boolean { isMaxInputsCount: function(): boolean {
@ -187,7 +200,7 @@ import { validateEmail } from '@/utils/validation';
} }
return false; return false;
} },
}, },
components: { components: {
Button Button
@ -251,7 +264,7 @@ export default class AddUserPopup extends Vue {}
padding-left: 30px; padding-left: 30px;
} }
} }
} }
} }
.inactive-label { .inactive-label {
color: #DADDE5; color: #DADDE5;
@ -387,7 +400,7 @@ export default class AddUserPopup extends Vue {}
margin-bottom: 0; margin-bottom: 0;
} }
} }
span { span {
margin-bottom: 18px; margin-bottom: 18px;
margin-left: 20px; margin-left: 20px;