toggle row details as mixin

This commit is contained in:
Moriz Wahl 2022-02-09 09:02:48 +01:00
parent 7b76e18444
commit d0a189b329
2 changed files with 33 additions and 23 deletions

View File

@ -79,11 +79,13 @@ import CreationFormular from '../CreationFormular.vue'
import ConfirmRegisterMailFormular from '../ConfirmRegisterMailFormular.vue' import ConfirmRegisterMailFormular from '../ConfirmRegisterMailFormular.vue'
import RowDetails from '../RowDetails.vue' import RowDetails from '../RowDetails.vue'
import CreationTransactionListFormular from '../CreationTransactionListFormular.vue' import CreationTransactionListFormular from '../CreationTransactionListFormular.vue'
import { toggleRowDetails } from '../../mixins/toggleRowDetails'
const slotNames = ['show-creation', 'show-register-mail', 'show-transaction-list'] const slotNames = ['show-creation', 'show-register-mail', 'show-transaction-list']
export default { export default {
name: 'SearchUserTable', name: 'SearchUserTable',
mixins: [toggleRowDetails],
components: { components: {
CreationFormular, CreationFormular,
ConfirmRegisterMailFormular, ConfirmRegisterMailFormular,
@ -102,33 +104,10 @@ export default {
}, },
data() { data() {
return { return {
slotIndex: 0,
openRow: null,
creationUserData: {}, creationUserData: {},
} }
}, },
methods: { methods: {
rowToogleDetails(row, index) {
if (this.openRow) {
if (this.openRow.index === row.index) {
if (index === this.slotIndex) {
row.toggleDetails()
this.openRow = null
} else {
this.slotIndex = index
}
} else {
this.openRow.toggleDetails()
row.toggleDetails()
this.slotIndex = index
this.openRow = row
}
} else {
row.toggleDetails()
this.slotIndex = index
this.openRow = row
}
},
updateUserData(rowItem, newCreation) { updateUserData(rowItem, newCreation) {
rowItem.creation = newCreation rowItem.creation = newCreation
}, },

View File

@ -0,0 +1,31 @@
export const toggleRowDetails = {
data() {
return {
slotIndex: 0,
openRow: null,
}
},
methods: {
rowToogleDetails(row, index) {
if (this.openRow) {
if (this.openRow.index === row.index) {
if (index === this.slotIndex) {
row.toggleDetails()
this.openRow = null
} else {
this.slotIndex = index
}
} else {
this.openRow.toggleDetails()
row.toggleDetails()
this.slotIndex = index
this.openRow = row
}
} else {
row.toggleDetails()
this.slotIndex = index
this.openRow = row
}
},
},
}