Skip to content

Commit

Permalink
Merge pull request #816 from webitel/fix/obac-rbac-popups-reset-state
Browse files Browse the repository at this point in the history
fix/ add state resetting in obac`s and rbac`s popup [WTEL-5156]
  • Loading branch information
RomanZaritskyi authored Dec 20, 2024
2 parents cfb0e98 + d58bcdd commit b3bd913
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default {
},
},
data: () => ({
newGrantee: '',
newGrantee: null,
}),
computed: {
...mapState({
Expand Down Expand Up @@ -53,8 +53,19 @@ export default {
fields,
});
},
resetNewGrantee() {
this.newGrantee = null;
},
resetNewGrantor() {
this.newGrantor = null;
},
resetPopupState() {
if (this.newGrantor) this.resetNewGrantor();
this.resetNewGrantee();
},
close() {
this.$emit('close');
this.resetPopupState();
},
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,21 @@ import { required } from '@vuelidate/validators';
import getNamespacedState from '@webitel/ui-sdk/src/store/helpers/getNamespacedState';
import deepCopy from 'deep-copy';
import { mapActions, mapState } from 'vuex';
import nestedObjectMixin
from '../../../../../../../../app/mixins/objectPagesMixins/openedObjectMixin/nestedObjectMixin';
import nestedObjectMixin from '../../../../../../../../app/mixins/objectPagesMixins/openedObjectMixin/nestedObjectMixin';
import CommunicationsAPI from '../../../../../../../lookups/modules/communications/api/communications';
import ResourcesAPI from '../../../../../resources/api/resources';
import { digitsDtmfOnly } from '../../validation/dtmf';
const getDefaultItemInstance = () => ({
destination: '',
display: '',
priority: 0,
type: {},
resource: {},
description: '',
dtmf: '',
});
export default {
name: 'OpenedAgentSkillsPopup',
mixins: [nestedObjectMixin],
Expand All @@ -89,15 +98,7 @@ export default {
}),
data: () => ({
namespace: 'ccenter/queues/members',
itemInstanceValue: {
destination: '',
display: '',
priority: 0,
type: {},
resource: {},
description: '',
dtmf: '',
},
itemInstanceValue: getDefaultItemInstance(),
}),
validations: {
itemInstance: {
Expand All @@ -110,7 +111,8 @@ export default {
computed: {
...mapState({
commList(state) {
return getNamespacedState(state, `${this.namespace}`).itemInstance.communications;
return getNamespacedState(state, `${this.namespace}`).itemInstance
.communications;
},
}),
// override mixin map state
Expand All @@ -127,7 +129,7 @@ export default {
},
communicationIndex() {
return this.$route.params.communicationIndex;
}
},
},
methods: {
Expand All @@ -136,7 +138,10 @@ export default {
return dispatch(`${this.namespace}/ADD_MEMBER_COMMUNICATION`, payload);
},
updateItem(dispatch, payload) {
return dispatch(`${this.namespace}/UPDATE_MEMBER_COMMUNICATION`, payload);
return dispatch(
`${this.namespace}/UPDATE_MEMBER_COMMUNICATION`,
payload,
);
},
}),
initEditedValue() {
Expand All @@ -162,20 +167,25 @@ export default {
return ResourcesAPI.getLookup(params);
},
loadItem() {},
resetState() {},
resetItemInstance() {
this.itemInstance = getDefaultItemInstance();
},
resetState() {
this.resetItemInstance();
},
},
watch: {
communicationIndex: {
handler(index) {
handler(index) {
if (index) {
this.initEditedValue();
}
}, immediate: true,
}
this.resetState();
},
immediate: true,
},
},
};
</script>

<style scoped>
</style>
<style scoped></style>
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export default {
setup: () => ({
// Reasons for use $stopPropagation
// https://webitel.atlassian.net/browse/WTEL-4559?focusedCommentId=621761
v$: useVuelidate({$stopPropagation: true}),
v$: useVuelidate({ $stopPropagation: true }),
}),
data: () => ({
Expand All @@ -73,8 +73,13 @@ export default {
return AgentsAPI.getLookup(params);
},
},
watch: {
agentId() {
this.resetState();
},
},
};
</script>

<style lang="scss" scoped>
</style>
<style lang="scss" scoped></style>
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export default {
components: { PermissionsRoleSelect },
mixins: [permissionsTabRolePopupMixins],
data: () => ({
newGrantor: '',
newGrantor: null,
}),
methods: {
Expand All @@ -56,7 +56,7 @@ export default {
grantee: this.newGrantee,
grantor: this.newGrantor,
});
this.$emit('close');
this.close();
} catch (err) {
throw err;
}
Expand Down

0 comments on commit b3bd913

Please sign in to comment.