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 = { const propsData = {
type: '', type: '',
creation: [], creation: [],
itemsMassCreation: {}, userSelectedInMassCreation: {},
} }
describe('CreationFormular', () => { 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', () => { describe('type UserListSearch', () => {
@ -214,11 +209,6 @@ describe('UserTable', () => {
it('has a DIV element with the class.component-user-table', () => { it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy() 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', () => { describe('type UserListMassCreation', () => {
@ -229,11 +219,6 @@ describe('UserTable', () => {
it('has a DIV element with the class.component-user-table', () => { it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy() 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', () => { describe('type PageCreationConfirm', () => {
@ -244,48 +229,6 @@ describe('UserTable', () => {
it('has a DIV element with the class.component-user-table', () => { it('has a DIV element with the class.component-user-table', () => {
expect(wrapper.find('.component-user-table').exists()).toBeTruthy() 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', () => { it('adds the pushed item to userSelectedInMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([ expect(wrapper.vm.userSelectedInMassCreation).toEqual([
{ {
userId: 2, userId: 2,
firstName: 'Benjamin', firstName: 'Benjamin',
@ -156,8 +156,8 @@ describe('Creation', () => {
) )
}) })
it('removes the item from itemsMassCreation', () => { it('removes the item from userSelectedInMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([]) expect(wrapper.vm.userSelectedInMassCreation).toEqual([])
}) })
it('adds the item to itemsList', () => { it('adds the item to itemsList', () => {
@ -221,8 +221,8 @@ describe('Creation', () => {
wrapper.findComponent({ name: 'CreationFormular' }).vm.$emit('remove-all-bookmark') wrapper.findComponent({ name: 'CreationFormular' }).vm.$emit('remove-all-bookmark')
}) })
it('removes all items from itemsMassCreation', () => { it('removes all items from userSelectedInMassCreation', () => {
expect(wrapper.vm.itemsMassCreation).toEqual([]) expect(wrapper.vm.userSelectedInMassCreation).toEqual([])
}) })
it('adds all items to itemsList', () => { it('adds all items to itemsList', () => {

View File

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

View File

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