TT#96500 Fix date range filter for Conversations

Change-Id: I6f6442bcd76f2d4e8ab293646cd8bfadd30130eb
mr9.1.1
Hans-Peter Herzog 5 years ago
parent 2dd8cce49b
commit 88b66464c6

@ -15,6 +15,8 @@ import {
export function getConversations (options) { export function getConversations (options) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const type = _.get(options, 'type', null) const type = _.get(options, 'type', null)
const from = _.get(options, 'from', '')
const to = _.get(options, 'to', '')
const params = { const params = {
subscriber_id: _.get(options, 'subscriberId'), subscriber_id: _.get(options, 'subscriberId'),
order_by: _.get(options, 'order_by', 'timestamp'), order_by: _.get(options, 'order_by', 'timestamp'),
@ -27,6 +29,12 @@ export function getConversations (options) {
if (type !== null) { if (type !== null) {
params.type = type params.type = type
} }
if (from !== '') {
params.from = from
}
if (to !== '') {
params.to = to
}
getList({ getList({
path: 'api/conversations/', path: 'api/conversations/',
root: '_embedded.ngcp:conversations', root: '_embedded.ngcp:conversations',

@ -32,7 +32,7 @@
<script> <script>
import CscPage from 'components/CscPage' import CscPage from 'components/CscPage'
export default { export default {
name: 'QPageStickyTabs', name: 'CscPageStickyTabs',
components: { components: {
CscPage CscPage
}, },

@ -0,0 +1,47 @@
<template>
<csc-input
:value="value"
v-bind="$attrs"
@click="$refs.popupTime.show()"
@input="$emit('input', $event)"
>
<template
v-slot:prepend
>
<q-btn
icon="date_range"
color="primary"
dense
flat
>
<q-popup-proxy
ref="popupTime"
>
<q-date
:value="value"
mask="YYYY-MM-DD"
color="primary"
@input="$emit('input', $event); $refs.popupTime.hide()"
/>
</q-popup-proxy>
</q-btn>
</template>
</csc-input>
</template>
<script>
import CscInput from 'components/form/CscInput'
export default {
name: 'CscInputDate',
components: { CscInput },
props: {
value: {
type: String,
default: undefined
}
},
data () {
return {}
}
}
</script>

@ -0,0 +1,66 @@
<template>
<q-toolbar>
<q-space />
<csc-input-date
v-model="value.from"
class="q-mr-sm"
dense
clearable
label="From"
:disable="loading"
@input="inputFrom"
/>
<csc-input-date
v-model="value.to"
dense
clearable
label="To"
:disable="loading"
@input="inputTo"
/>
<q-space />
</q-toolbar>
</template>
<script>
import CscInputDate from 'components/form/CscInputDate'
export default {
name: 'CscConversationsFilter',
components: {
CscInputDate
},
props: {
value: {
type: Object,
default () {
return {
from: '',
to: ''
}
}
},
loading: {
type: Boolean,
default: false
},
disable: {
type: Boolean,
default: false
}
},
methods: {
inputFrom (from) {
this.$emit('input', {
from: from,
to: this.value.to
})
},
inputTo (to) {
this.$emit('input', {
from: this.value.from,
to: to
})
}
}
}
</script>

@ -97,7 +97,6 @@ export default {
this.$emit('download-fax', this.fax) this.$emit('download-fax', this.fax)
}, },
startCall () { startCall () {
this.$refs.callPopover.close()
this.$emit('start-call', this.fax.caller) this.$emit('start-call', this.fax.caller)
} }
} }

@ -165,7 +165,6 @@ export default {
this.$refs.voicemailPlayer.setPausedFalse() this.$refs.voicemailPlayer.setPausedFalse()
}, },
startCall () { startCall () {
this.$refs.callPopover.close()
this.$emit('start-call', this.voiceMail.callee) this.$emit('start-call', this.voiceMail.callee)
}, },
toggleBlockIncoming () { toggleBlockIncoming () {
@ -178,7 +177,6 @@ export default {
this.$emit('toggle-block-both') this.$emit('toggle-block-both')
}, },
deleteVoicemail (voiceMail) { deleteVoicemail (voiceMail) {
this.$refs.callPopover.close()
this.$emit('delete-voicemail', voiceMail) this.$emit('delete-voicemail', voiceMail)
} }
} }

@ -1,34 +1,32 @@
<template> <template>
<csc-page <csc-page-sticky-tabs
:style="pageStyle" ref="pageSticky"
:value="selectedTab"
> >
<q-page-sticky <template
ref="pageSticky" v-slot:tabs
class="bg-secondary q-pt-lg"
style="z-index: 10"
expand
position="top"
> >
<q-tabs <q-tab
:value="selectedTab" v-for="tab in tabs"
class="col-sm-12 col-md-8" :key="tab.value"
align="justify" :name="tab.value"
inline-label :icon="tab.icon"
active-color="primary" :label="tab.label"
dense :default="tab.value === selectedTab"
> @click="selectTab(tab.value)"
<q-tab />
v-for="tab in tabs" </template>
:key="tab.value" <template
:name="tab.value" v-slot:toolbar
:icon="tab.icon" >
:label="tab.label" <csc-conversations-filter
:default="tab.value === selectedTab" v-model="filter"
@click="selectTab(tab.value)" class="q-pb-sm"
/> :loading="isNextPageRequesting"
</q-tabs> :disable="isNextPageRequesting"
<q-separator /> @input="filterTab(selectedTab)"
</q-page-sticky> />
</template>
<q-infinite-scroll <q-infinite-scroll
ref="infiniteScroll" ref="infiniteScroll"
:offset="500" :offset="500"
@ -81,12 +79,13 @@
<csc-remove-dialog <csc-remove-dialog
ref="confirmDeletionDialog" ref="confirmDeletionDialog"
title-icon="delete" title-icon="delete"
title-icon-color="negative"
:title="$t('conversations.deleteVoicemailTitle')" :title="$t('conversations.deleteVoicemailTitle')"
:message="$t('conversations.deleteVoicemailText')" :message="$t('conversations.deleteVoicemailText')"
@remove="deleteVoicemail({id:deletionId, tab: selectedTab})" @remove="deleteVoicemail({id:deletionId, tab: selectedTab})"
@cancel="deletionId=null" @cancel="deletionId=null"
/> />
</csc-page> </csc-page-sticky-tabs>
</template> </template>
<script> <script>
@ -96,23 +95,26 @@ import {
mapActions, mapActions,
mapState mapState
} from 'vuex' } from 'vuex'
import CscPage from 'components/CscPage' import CscPageStickyTabs from 'components/CscPageStickyTabs'
import CscListSpinner from 'components/CscListSpinner'
import CscConversationItem from 'components/pages/Conversations/CscConversationItem' import CscConversationItem from 'components/pages/Conversations/CscConversationItem'
import CscConversationsFilter from 'components/pages/Conversations/CscConversationsFilter'
import CscRemoveDialog from 'components/CscRemoveDialog' import CscRemoveDialog from 'components/CscRemoveDialog'
import CscListSpinner from 'components/CscListSpinner'
export default { export default {
name: 'CscConversations', name: 'CscConversations',
components: { components: {
CscListSpinner,
CscRemoveDialog, CscRemoveDialog,
CscPage, CscConversationsFilter,
CscConversationItem CscConversationItem,
CscListSpinner,
CscPageStickyTabs
}, },
mixins: [ mixins: [
platformMixin platformMixin
], ],
data () { data () {
return { return {
filter: undefined,
topMargin: 0, topMargin: 0,
deletionId: null, deletionId: null,
selectedTab: 'call-fax-voicemail' selectedTab: 'call-fax-voicemail'
@ -226,22 +228,29 @@ export default {
this.$store.dispatch('conversations/nextPage', { this.$store.dispatch('conversations/nextPage', {
type: type, type: type,
index: index, index: index,
filter: this.filter,
done: done done: done
}) })
}, },
async selectTab (tabName) { selectTab (tabName) {
if (this.selectedTab !== tabName) { if (this.selectedTab !== tabName) {
this.selectedTab = tabName this.forceTabReload(tabName)
this.$store.commit('conversations/resetList') }
this.$refs.infiniteScroll.reset() },
if (this.reachedLastPage) { forceTabReload (tabName) {
this.$refs.infiniteScroll.resume() this.selectedTab = tabName
this.$refs.infiniteScroll.trigger() this.$store.commit('conversations/resetList')
} else { this.$refs.infiniteScroll.reset()
this.$refs.infiniteScroll.poll() if (this.reachedLastPage) {
} this.$refs.infiniteScroll.resume()
this.$refs.infiniteScroll.trigger()
} else {
this.$refs.infiniteScroll.poll()
} }
}, },
filterTab (tabName) {
this.forceTabReload(tabName)
},
async reload () { async reload () {
this.$store.commit('conversations/resetList') this.$store.commit('conversations/resetList')
}, },
@ -264,22 +273,6 @@ export default {
format: voiceMail.format format: voiceMail.format
}) })
}, },
reloadItems () {
let type = this.selectedTab
if (type === 'call-fax-voicemail') {
type = null
}
this.$store.dispatch('conversations/reloadItems', {
retryCount: 1,
type: type
})
},
filterByType (type) {
if (type !== this.selectedTab) {
this.$store.commit('conversations/resetList')
this.$store.dispatch('conversations/nextPage', type)
}
},
toggleBlockIncoming (options) { toggleBlockIncoming (options) {
this.$store.dispatch('conversations/toggleBlockIncoming', options).finally(() => { this.$store.dispatch('conversations/toggleBlockIncoming', options).finally(() => {
this.reload() this.reload()

@ -88,14 +88,17 @@ export default {
subscriberId: context.getters.getSubscriberId, subscriberId: context.getters.getSubscriberId,
page: options.index, page: options.index,
rows: ROWS_PER_PAGE, rows: ROWS_PER_PAGE,
type: options.type type: options.type,
from: _.get(options, 'filter.from', ''),
to: _.get(options, 'filter.to', '')
}) })
context.commit('nextPageSucceeded', res) context.commit('nextPageSucceeded', res)
} catch (err) { } catch (err) {
context.commit('nextPageFailed', err.message) context.commit('nextPageFailed', err.message)
} finally { } finally {
console.log(res) if (options.done !== undefined && (res === undefined || res.items === undefined)) {
if (options.done !== undefined && res.items && res.items.length === 0) { options.done(true)
} else if (options.done !== undefined && res.items && res.items.length === 0) {
options.done(true) options.done(true)
} else if (options.done !== undefined) { } else if (options.done !== undefined) {
options.done() options.done()

Loading…
Cancel
Save