cache for selected users in multiple creation

This commit is contained in:
ogerly 2022-01-30 10:00:29 +01:00
parent c4334ace0d
commit b2cb072c04
5 changed files with 33 additions and 75 deletions

View File

@ -56,7 +56,7 @@ const mocks = {
const propsData = {
type: '',
creation: [],
itemsMassCreation: {},
userSelectedInMassCreation: {},
}
describe('CreationFormular', () => {

View File

@ -199,11 +199,6 @@ describe('UserTable', () => {
})
})
})
// it('expect(wrapper.html()).', () => {
// // eslint-disable-next-line no-console
// console.log(wrapper.html())
// })
})
describe('type UserListSearch', () => {
@ -214,11 +209,6 @@ describe('UserTable', () => {
it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
})
// it('expect(wrapper.html()).', () => {
// // eslint-disable-next-line no-console
// console.log(wrapper.html())
// })
})
describe('type UserListMassCreation', () => {
@ -229,11 +219,6 @@ describe('UserTable', () => {
it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
})
// it('expect(wrapper.html()).', () => {
// // eslint-disable-next-line no-console
// console.log(wrapper.html())
// })
})
describe('type PageCreationConfirm', () => {
@ -244,48 +229,6 @@ describe('UserTable', () => {
it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy()
})
// it('expect(wrapper.html()).', () => {
// // eslint-disable-next-line no-console
// console.log(wrapper.html())
// })
})
/**
<user-table
v-if="itemsList.length > 0"
type="UserListSearch"
:itemsUser="itemsList"
:fieldsTable="Searchfields"
:criteria="criteria"
:creation="creation"
@update-item="updateItem"
/>
<user-table
v-show="itemsMassCreation.length > 0"
class="shadow p-3 mb-5 bg-white rounded"
type="UserListMassCreation"
:itemsUser="itemsMassCreation"
:fieldsTable="fields"
:criteria="null"
:creation="creation"
@update-item="updateItem"
/>
<user-table
class="mt-4"
type="PageCreationConfirm"
:itemsUser="confirmResult"
:fieldsTable="fields"
@remove-confirm-result="removeConfirmResult"
/>
<user-table
type="PageUserSearch"
:itemsUser="searchResult"
:fieldsTable="fields"
:criteria="criteria"
/>
*/
})
})

View File

@ -127,8 +127,8 @@ describe('Creation', () => {
])
})
it('adds the pushed item to itemsMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([
it('adds the pushed item to userSelectedInMassCreation', () => {
expect(wrapper.vm.userSelectedInMassCreation).toEqual([
{
userId: 2,
firstName: 'Benjamin',
@ -156,8 +156,8 @@ describe('Creation', () => {
)
})
it('removes the item from itemsMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([])
it('removes the item from userSelectedInMassCreation', () => {
expect(wrapper.vm.userSelectedInMassCreation).toEqual([])
})
it('adds the item to itemsList', () => {
@ -221,8 +221,8 @@ describe('Creation', () => {
wrapper.findComponent({ name: 'CreationFormular' }).vm.$emit('remove-all-bookmark')
})
it('removes all items from itemsMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([])
it('removes all items from userSelectedInMassCreation', () => {
expect(wrapper.vm.userSelectedInMassCreation).toEqual([])
})
it('adds all items to itemsList', () => {

View File

@ -28,7 +28,7 @@
</b-col>
<b-col cols="12" lg="6" class="shadow p-3 mb-5 rounded bg-info">
<user-table
v-show="itemsMassCreation.length > 0"
v-show="userSelectedInMassCreation.length > 0"
class="shadow p-3 mb-5 bg-white rounded"
type="UserListMassCreation"
:itemsUser="itemsMassCreationReverse"
@ -37,14 +37,16 @@
:creation="creation"
@update-item="updateItem"
/>
<div v-if="itemsMassCreation.length === 0">
<div v-if="userSelectedInMassCreation.length === 0">
userSelectedInMassCreation: {{ userSelectedInMassCreation }}
<br />
{{ $t('multiple_creation_text') }}
</div>
<creation-formular
v-else
type="massCreation"
:creation="creation"
:items="itemsMassCreation"
:items="userSelectedInMassCreation"
@remove-all-bookmark="removeAllBookmark"
/>
</b-col>
@ -62,6 +64,11 @@ export default {
CreationFormular,
UserTable,
},
props: {
userSelectedInMassCreation: {
type: Array,
},
},
data() {
return {
showArrays: false,
@ -104,8 +111,7 @@ export default {
{ key: 'bookmark', label: this.$t('remove') },
],
itemsList: [],
itemsMassCreation: [],
itemsMassCreationReverse: [],
itemsMassCreationReverse: this.userSelectedInMassCreation,
radioSelectedMass: '',
criteria: '',
creation: [null, null, null],
@ -137,6 +143,7 @@ export default {
showDetails: false,
}
})
this.updateItem(this.userSelectedInMassCreation, 'mounted')
})
.catch((error) => {
this.$toasted.error(error.message)
@ -151,22 +158,29 @@ export default {
findArr = this.itemsList.find((item) => e.userId === item.userId)
index = this.itemsList.indexOf(findArr)
this.itemsList.splice(index, 1)
this.itemsMassCreation.push(findArr)
this.userSelectedInMassCreation.push(findArr)
break
case 'remove':
findArr = this.itemsMassCreation.find((item) => e.userId === item.userId)
index = this.itemsMassCreation.indexOf(findArr)
this.itemsMassCreation.splice(index, 1)
findArr = this.userSelectedInMassCreation.find((item) => e.userId === item.userId)
index = this.userSelectedInMassCreation.indexOf(findArr)
this.userSelectedInMassCreation.splice(index, 1)
this.itemsList.push(findArr)
break
case 'mounted':
this.userSelectedInMassCreation.map((value, key) => {
findArr = this.itemsList.find((item) => value.userId === item.userId)
index = this.itemsList.indexOf(findArr)
this.itemsList.splice(index, 1)
})
break
default:
throw new Error(event)
}
this.itemsMassCreationReverse = this.itemsMassCreation
this.itemsMassCreationReverse = this.userSelectedInMassCreation
this.itemsMassCreationReverse.reverse()
},
removeAllBookmark() {
this.itemsMassCreation = []
this.userSelectedInMassCreation = []
this.getUsers()
},
},

View File

@ -18,6 +18,7 @@ const routes = [
{
path: '/creation',
component: () => import('@/pages/Creation.vue'),
props: { userSelectedInMassCreation: [] },
},
{
path: '/creation-confirm',