mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
Merge pull request #1409 from gradido/mixin-for-creation-labels
refactor: Mixin for Creation Labels
This commit is contained in:
commit
69a631bb3e
2
.github/workflows/test.yml
vendored
2
.github/workflows/test.yml
vendored
@ -448,7 +448,7 @@ jobs:
|
|||||||
report_name: Coverage Admin Interface
|
report_name: Coverage Admin Interface
|
||||||
type: lcov
|
type: lcov
|
||||||
result_path: ./coverage/lcov.info
|
result_path: ./coverage/lcov.info
|
||||||
min_coverage: 81
|
min_coverage: 82
|
||||||
token: ${{ github.token }}
|
token: ${{ github.token }}
|
||||||
|
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|||||||
@ -27,15 +27,7 @@
|
|||||||
</b-button>
|
</b-button>
|
||||||
</b-jumbotron>
|
</b-jumbotron>
|
||||||
</div>
|
</div>
|
||||||
<b-table-lite
|
<b-table-lite :items="itemsUser" :fields="fieldsTable" caption-top striped hover stacked="md">
|
||||||
:items="itemsUser"
|
|
||||||
:fields="fieldsTable"
|
|
||||||
:filter="criteria"
|
|
||||||
caption-top
|
|
||||||
striped
|
|
||||||
hover
|
|
||||||
stacked="md"
|
|
||||||
>
|
|
||||||
<template #cell(creation)="data">
|
<template #cell(creation)="data">
|
||||||
<div v-html="data.value"></div>
|
<div v-html="data.value"></div>
|
||||||
</template>
|
</template>
|
||||||
@ -187,15 +179,6 @@ export default {
|
|||||||
type: Array,
|
type: Array,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
criteria: {
|
|
||||||
type: String,
|
|
||||||
required: false,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
creation: {
|
|
||||||
type: Array,
|
|
||||||
required: false,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
CreationFormular,
|
CreationFormular,
|
||||||
|
|||||||
@ -1,6 +1,9 @@
|
|||||||
export const creationMonths = {
|
export const creationMonths = {
|
||||||
props: {
|
props: {
|
||||||
creation: [1000, 1000, 1000],
|
creation: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [1000, 1000, 1000],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
creationDates() {
|
creationDates() {
|
||||||
@ -31,5 +34,8 @@ export const creationMonths = {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
creationLabel() {
|
||||||
|
return this.creationDates.map((date) => this.$d(date, 'monthShort')).join(' | ')
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { shallowMount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import Creation from './Creation.vue'
|
import Creation from './Creation.vue'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
@ -51,10 +51,10 @@ describe('Creation', () => {
|
|||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
const Wrapper = () => {
|
const Wrapper = () => {
|
||||||
return shallowMount(Creation, { localVue, mocks })
|
return mount(Creation, { localVue, mocks })
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('shallowMount', () => {
|
describe('mount', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
|
|||||||
@ -14,8 +14,6 @@
|
|||||||
type="UserListSearch"
|
type="UserListSearch"
|
||||||
:itemsUser="itemsList"
|
:itemsUser="itemsList"
|
||||||
:fieldsTable="Searchfields"
|
:fieldsTable="Searchfields"
|
||||||
:criteria="criteria"
|
|
||||||
:creation="creation"
|
|
||||||
@push-item="pushItem"
|
@push-item="pushItem"
|
||||||
/>
|
/>
|
||||||
<b-pagination
|
<b-pagination
|
||||||
@ -33,8 +31,6 @@
|
|||||||
type="UserListMassCreation"
|
type="UserListMassCreation"
|
||||||
:itemsUser="itemsMassCreation"
|
:itemsUser="itemsMassCreation"
|
||||||
:fieldsTable="fields"
|
:fieldsTable="fields"
|
||||||
:criteria="null"
|
|
||||||
:creation="creation"
|
|
||||||
@remove-item="removeItem"
|
@remove-item="removeItem"
|
||||||
/>
|
/>
|
||||||
<div v-if="itemsMassCreation.length === 0">
|
<div v-if="itemsMassCreation.length === 0">
|
||||||
@ -55,9 +51,11 @@
|
|||||||
import CreationFormular from '../components/CreationFormular.vue'
|
import CreationFormular from '../components/CreationFormular.vue'
|
||||||
import UserTable from '../components/UserTable.vue'
|
import UserTable from '../components/UserTable.vue'
|
||||||
import { searchUsers } from '../graphql/searchUsers'
|
import { searchUsers } from '../graphql/searchUsers'
|
||||||
|
import { creationMonths } from '../mixins/creationMonths'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Creation',
|
name: 'Creation',
|
||||||
|
mixins: [creationMonths],
|
||||||
components: {
|
components: {
|
||||||
CreationFormular,
|
CreationFormular,
|
||||||
UserTable,
|
UserTable,
|
||||||
@ -69,7 +67,6 @@ export default {
|
|||||||
itemsMassCreation: this.$store.state.userSelectedInMassCreation,
|
itemsMassCreation: this.$store.state.userSelectedInMassCreation,
|
||||||
radioSelectedMass: '',
|
radioSelectedMass: '',
|
||||||
criteria: '',
|
criteria: '',
|
||||||
creation: [null, null, null],
|
|
||||||
rows: 0,
|
rows: 0,
|
||||||
currentPage: 1,
|
currentPage: 1,
|
||||||
perPage: 25,
|
perPage: 25,
|
||||||
@ -163,16 +160,6 @@ export default {
|
|||||||
{ key: 'bookmark', label: this.$t('remove') },
|
{ key: 'bookmark', label: this.$t('remove') },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
creationLabel() {
|
|
||||||
const now = new Date(this.now)
|
|
||||||
const lastMonth = new Date(now.getFullYear(), now.getMonth() - 1, 1)
|
|
||||||
const beforeLastMonth = new Date(now.getFullYear(), now.getMonth() - 2, 1)
|
|
||||||
return [
|
|
||||||
this.$d(beforeLastMonth, 'monthShort'),
|
|
||||||
this.$d(lastMonth, 'monthShort'),
|
|
||||||
this.$d(now, 'monthShort'),
|
|
||||||
].join(' | ')
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
currentPage() {
|
currentPage() {
|
||||||
|
|||||||
@ -42,6 +42,7 @@ describe('UserSearch', () => {
|
|||||||
|
|
||||||
describe('mount', () => {
|
describe('mount', () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
|
jest.clearAllMocks()
|
||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -49,13 +50,73 @@ describe('UserSearch', () => {
|
|||||||
expect(wrapper.find('div.user-search').exists()).toBeTruthy()
|
expect(wrapper.find('div.user-search').exists()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('calls the API', () => {
|
||||||
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
variables: {
|
||||||
|
searchText: '',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 25,
|
||||||
|
notActivated: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
describe('unconfirmed emails', () => {
|
describe('unconfirmed emails', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
await wrapper.find('button.btn-block').trigger('click')
|
await wrapper.find('button.btn-block').trigger('click')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('filters the users by unconfirmed emails', () => {
|
it('calls API with filter', () => {
|
||||||
expect(wrapper.vm.searchResult).toHaveLength(1)
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
variables: {
|
||||||
|
searchText: '',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 25,
|
||||||
|
notActivated: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('pagination', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
wrapper.setData({ currentPage: 2 })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('calls the API with new page', () => {
|
||||||
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
variables: {
|
||||||
|
searchText: '',
|
||||||
|
currentPage: 2,
|
||||||
|
pageSize: 25,
|
||||||
|
notActivated: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('user search', () => {
|
||||||
|
beforeEach(async () => {
|
||||||
|
wrapper.setData({ criteria: 'search string' })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('calls the API with search string', () => {
|
||||||
|
expect(apolloQueryMock).toBeCalledWith(
|
||||||
|
expect.objectContaining({
|
||||||
|
variables: {
|
||||||
|
searchText: 'search string',
|
||||||
|
currentPage: 1,
|
||||||
|
pageSize: 25,
|
||||||
|
notActivated: false,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -12,15 +12,8 @@
|
|||||||
v-model="criteria"
|
v-model="criteria"
|
||||||
class="shadow p-3 mb-3 bg-white rounded"
|
class="shadow p-3 mb-3 bg-white rounded"
|
||||||
:placeholder="$t('user_search')"
|
:placeholder="$t('user_search')"
|
||||||
@input="getUsers"
|
|
||||||
></b-input>
|
></b-input>
|
||||||
|
<user-table type="PageUserSearch" :itemsUser="searchResult" :fieldsTable="fields" />
|
||||||
<user-table
|
|
||||||
type="PageUserSearch"
|
|
||||||
:itemsUser="searchResult"
|
|
||||||
:fieldsTable="fields"
|
|
||||||
:criteria="criteria"
|
|
||||||
/>
|
|
||||||
<b-pagination
|
<b-pagination
|
||||||
pills
|
pills
|
||||||
size="lg"
|
size="lg"
|
||||||
@ -35,9 +28,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import UserTable from '../components/UserTable.vue'
|
import UserTable from '../components/UserTable.vue'
|
||||||
import { searchUsers } from '../graphql/searchUsers'
|
import { searchUsers } from '../graphql/searchUsers'
|
||||||
|
import { creationMonths } from '../mixins/creationMonths'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'UserSearch',
|
name: 'UserSearch',
|
||||||
|
mixins: [creationMonths],
|
||||||
components: {
|
components: {
|
||||||
UserTable,
|
UserTable,
|
||||||
},
|
},
|
||||||
@ -83,16 +78,11 @@ export default {
|
|||||||
currentPage() {
|
currentPage() {
|
||||||
this.getUsers()
|
this.getUsers()
|
||||||
},
|
},
|
||||||
|
criteria() {
|
||||||
|
this.getUsers()
|
||||||
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
lastMonthDate() {
|
|
||||||
const now = new Date(this.now)
|
|
||||||
return new Date(now.getFullYear(), now.getMonth() - 1, 1)
|
|
||||||
},
|
|
||||||
beforeLastMonthDate() {
|
|
||||||
const now = new Date(this.now)
|
|
||||||
return new Date(now.getFullYear(), now.getMonth() - 2, 1)
|
|
||||||
},
|
|
||||||
fields() {
|
fields() {
|
||||||
return [
|
return [
|
||||||
{ key: 'email', label: this.$t('e_mail') },
|
{ key: 'email', label: this.$t('e_mail') },
|
||||||
@ -100,11 +90,7 @@ export default {
|
|||||||
{ key: 'lastName', label: this.$t('lastname') },
|
{ key: 'lastName', label: this.$t('lastname') },
|
||||||
{
|
{
|
||||||
key: 'creation',
|
key: 'creation',
|
||||||
label: [
|
label: this.creationLabel,
|
||||||
this.$d(this.beforeLastMonthDate, 'monthShort'),
|
|
||||||
this.$d(this.lastMonthDate, 'monthShort'),
|
|
||||||
this.$d(this.now, 'monthShort'),
|
|
||||||
].join(' | '),
|
|
||||||
formatter: (value, key, item) => {
|
formatter: (value, key, item) => {
|
||||||
return value.join(' | ')
|
return value.join(' | ')
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user