TT#92007 and #96801 CSC: As a Customer, I want to filter PBXDevice by Extension and Username (Seat assigned as Private Line)

AC:
Can filter by extension
Can filter by Username (Seat assigned as Private Line)
Can select filter criteria from criteria selection
Can see the right input component according to this criteria
Change-Id: I6f35098854a866fe2b7de68d17570582dc693340
mr9.1.1
Sergii Leonenko 5 years ago committed by Hans-Peter Herzog
parent e0832ea3f1
commit 307252da12

@ -29,29 +29,32 @@ export function getDevices (options) {
export function getDeviceList (options) { export function getDeviceList (options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const filters = options.filters || {}
// normalize filters
Object.keys(filters).forEach(key => {
let value = filters[key]
if (value === null || value === undefined || value === '') {
delete filters[key]
} else {
switch (key) {
case 'profile_id':
value = String(value)
break
case 'identifier':
case 'station_name':
value = '*' + value + '*'
break
}
filters[key] = value
}
})
const params = { const params = {
page: options.page, page: options.page,
profile_id: options.profile_id, ...filters,
identifier: options.identifier,
station_name: options.station_name,
order_by: PBX_CONFIG_ORDER_BY, order_by: PBX_CONFIG_ORDER_BY,
order_by_direction: PBX_CONFIG_ORDER_DIRECTION order_by_direction: PBX_CONFIG_ORDER_DIRECTION
} }
if (params.profile_id === null || params.profile_id === undefined || params.profile_id === '') {
delete params.profile_id
} else {
params.profile_id = String(params.profile_id)
}
if (params.identifier === null || params.identifier === undefined || params.identifier === '') {
delete params.identifier
} else {
params.identifier = '*' + params.identifier + '*'
}
if (params.station_name === null || params.station_name === undefined || params.station_name === '') {
delete params.station_name
} else {
params.station_name = '*' + params.station_name + '*'
}
getDevices({ getDevices({
params: params params: params
}).then((devices) => { }).then((devices) => {

@ -18,7 +18,7 @@
class="col-xs-12 col-md-2" class="col-xs-12 col-md-2"
> >
<q-input <q-input
v-if="filterType !== 'profileFilter'" v-if="filterType !== 'profile_id'"
v-model="typedFilter" v-model="typedFilter"
type="text" type="text"
dense dense
@ -40,7 +40,7 @@
</template> </template>
</q-input> </q-input>
<csc-pbx-model-select <csc-pbx-model-select
v-if="filterType === 'profileFilter'" v-if="filterType === 'profile_id'"
v-model="typedFilter" v-model="typedFilter"
:profiles="deviceProfileList" :profiles="deviceProfileList"
:profile-map="deviceProfileMap" :profile-map="deviceProfileMap"
@ -109,22 +109,30 @@ export default {
return [ return [
{ {
label: this.$t('pbxConfig.deviceStationName'), label: this.$t('pbxConfig.deviceStationName'),
value: 'stationNameFilter' value: 'station_name'
}, },
{ {
label: this.$t('pbxConfig.deviceIdentifier'), label: this.$t('pbxConfig.deviceIdentifier'),
value: 'identifierFilter' value: 'identifier'
}, },
{ {
label: this.$t('pbxConfig.deviceModel'), label: this.$t('pbxConfig.deviceModel'),
value: 'profileFilter' value: 'profile_id'
},
{
label: this.$t('pbxConfig.extension'),
value: 'pbx_extension'
},
{
label: this.$t('pbxConfig.queueExtensionName'),
value: 'display_name'
} }
] ]
}, },
filtersList () { filtersList () {
return this.filters.map((filterItem) => { return this.filters.map((filterItem) => {
let filterDisplayValue = filterItem.value let filterDisplayValue = filterItem.value
if (filterItem.name === 'profileFilter') { if (filterItem.name === 'profile_id') {
filterDisplayValue = this.deviceProfileMap[filterItem.value].name filterDisplayValue = this.deviceProfileMap[filterItem.value].name
} }
return { return {
@ -171,6 +179,12 @@ export default {
this.filters.forEach(filter => { this.filters.forEach(filter => {
params[filter.name] = filter.value params[filter.name] = filter.value
}) })
// a special fix because of q-select behaviour. it stores 0 for empty selection
if (!params.profile_id) {
delete params.profile_id
}
this.$emit('filter', params) this.$emit('filter', params)
} }
} }

@ -176,9 +176,7 @@ export default {
}, },
data () { data () {
return { return {
stationNameFilter: null, filters: {},
identifierFilter: null,
profileFilter: null,
filtersEnabled: false filtersEnabled: false
} }
}, },
@ -222,9 +220,7 @@ export default {
'getDeviceRemovalToastMessage' 'getDeviceRemovalToastMessage'
]), ]),
hasFilters () { hasFilters () {
return this.stationNameFilter !== null || return Object.keys(this.filters).length > 0
this.identifierFilter !== null ||
this.profileFilter !== null
} }
}, },
watch: { watch: {
@ -282,9 +278,7 @@ export default {
loadDeviceListItemsFiltered (page) { loadDeviceListItemsFiltered (page) {
this.loadDeviceListItems({ this.loadDeviceListItems({
page: page || 1, page: page || 1,
stationNameFilter: this.stationNameFilter, filters: this.filters
identifierFilter: this.identifierFilter,
profileFilter: this.profileFilter
}) })
}, },
enableAddForm () { enableAddForm () {
@ -296,9 +290,7 @@ export default {
this.disableDeviceAddForm() this.disableDeviceAddForm()
}, },
applyFilter (filterData) { applyFilter (filterData) {
this.stationNameFilter = filterData.stationNameFilter this.filters = filterData
this.identifierFilter = filterData.identifierFilter
this.profileFilter = filterData.profileFilter ? Number(filterData.profileFilter) : null
this.loadDeviceListItemsFiltered() this.loadDeviceListItemsFiltered()
}, },
closeFilters () { closeFilters () {
@ -306,12 +298,8 @@ export default {
this.resetFilters() this.resetFilters()
}, },
resetFilters () { resetFilters () {
if (this.stationNameFilter !== null || if (this.hasFilters) {
this.identifierFilter !== null || this.filters = {}
this.profileFilter !== null) {
this.stationNameFilter = null
this.identifierFilter = null
this.profileFilter = null
this.loadDeviceListItemsFiltered() this.loadDeviceListItemsFiltered()
} }
}, },

@ -204,9 +204,7 @@ export default {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const page = _.get(options, 'page', context.state.deviceListCurrentPage) const page = _.get(options, 'page', context.state.deviceListCurrentPage)
const clearList = _.get(options, 'clearList', true) const clearList = _.get(options, 'clearList', true)
const stationNameFilter = _.get(options, 'stationNameFilter', null) const filters = _.get(options, 'filters', {})
const identifierFilter = _.get(options, 'identifierFilter', null)
const profileFilter = _.get(options, 'profileFilter', null)
context.commit('deviceListItemsRequesting', { context.commit('deviceListItemsRequesting', {
clearList: clearList clearList: clearList
}) })
@ -215,9 +213,7 @@ export default {
}).then(() => { }).then(() => {
return getDeviceList({ return getDeviceList({
page: page, page: page,
station_name: stationNameFilter, filters
identifier: identifierFilter,
profile_id: profileFilter
}) })
}).then((devices) => { }).then((devices) => {
context.commit('deviceListItemsSucceeded', { context.commit('deviceListItemsSucceeded', {

Loading…
Cancel
Save