MT#62578 Migrate api v1 to v2 for subscriber phonebook

- Add include option for customers to display the shared phonebook

Change-Id: Id14f95e159e1719d7aa6a0168e724ca7db3b8497
mr14.1
nidrissi-zouggari 8 months ago committed by Nouhaila Idrissi-Zouggari
parent ee99017a28
commit ec97299ed7

@ -773,20 +773,8 @@ export async function getSubscriberRegistrations (options) {
return list return list
} }
export async function getSubscriberPhonebook (options) { export async function getSubscriberPhonebook (options) {
let all = false const list = await get({
if (options.rows === 0) { path: `api/v2/subscribers/${options.subscriber_id}/phonebook`,
delete options.rows
delete options.page
all = true
}
if (!options.order_by) {
delete options.order_by
delete options.order_by_direction
}
options.include = 'all'
const list = await getList({
resource: 'subscriberphonebookentries',
all,
params: options params: options
}) })
return list return list
@ -813,9 +801,10 @@ export async function createPhonebook (data) {
const payLoad = { const payLoad = {
name: data.name, name: data.name,
number: data.number, number: data.number,
shared: data.shared shared: data.shared,
subscriber_id: Number(data.subscriber_id)
} }
return await httpApi.post('api/subscriberphonebookentries/', payLoad) return await httpApi.post(`api/v2/subscribers/${data.subscriber_id}/phonebook`, payLoad)
} }
export async function createCustomerPhonebook (data) { export async function createCustomerPhonebook (data) {
const payLoad = { const payLoad = {

@ -241,6 +241,7 @@ export default {
rows: rowsPerPage, rows: rowsPerPage,
order_by: sortBy, order_by: sortBy,
order_by_direction: descending ? 'desc' : 'asc', order_by_direction: descending ? 'desc' : 'asc',
include: 'customer',
subscriber_id: this.getSubscriberId subscriber_id: this.getSubscriberId
}) })
this.pagination = { ...props.pagination } this.pagination = { ...props.pagination }
@ -272,7 +273,10 @@ export default {
cancel: true, cancel: true,
persistent: true persistent: true
}).onOk(async (data) => { }).onOk(async (data) => {
await this.removeSubscriberPhonebook(row) await this.removeSubscriberPhonebook({
row,
subscriberId: this.getSubscriberId
})
await this.refresh() await this.refresh()
}) })
}, },
@ -320,6 +324,7 @@ export default {
rows: this.pagination.rowsPerPage, rows: this.pagination.rowsPerPage,
order_by: this.pagination.sortBy, order_by: this.pagination.sortBy,
order_by_direction: this.pagination.descending ? 'desc' : 'asc', order_by_direction: this.pagination.descending ? 'desc' : 'asc',
include: 'customer',
subscriber_id: this.getSubscriberId subscriber_id: this.getSubscriberId
}) })
} }

@ -107,7 +107,8 @@ export default {
}, },
computed: { computed: {
...mapGetters('user', [ ...mapGetters('user', [
'prefilledNumber' 'prefilledNumber',
'getSubscriberId'
]), ]),
nameErrorMessage () { nameErrorMessage () {
const errorsTab = this.v$.formData.name.$errors const errorsTab = this.v$.formData.name.$errors
@ -158,6 +159,7 @@ export default {
}, },
async confirm () { async confirm () {
try { try {
this.formData.subscriber_id = this.getSubscriberId
await this.createPhonebookSubscriber(this.formData) await this.createPhonebookSubscriber(this.formData)
await this.$router.push('/user/subscriber-phonebook/') await this.$router.push('/user/subscriber-phonebook/')
} catch (error) { } catch (error) {

@ -75,6 +75,7 @@
<script> <script>
import CscPageSticky from 'components/CscPageSticky' import CscPageSticky from 'components/CscPageSticky'
import { mapWaitingActions } from 'vue-wait-vue3' import { mapWaitingActions } from 'vue-wait-vue3'
import { mapGetters } from 'vuex'
export default { export default {
name: 'CscPageSubscriberPhonebookDetails', name: 'CscPageSubscriberPhonebookDetails',
components: { components: {
@ -92,6 +93,11 @@ export default {
async mounted () { async mounted () {
await this.getPhonebook(this.id) await this.getPhonebook(this.id)
}, },
computed: {
...mapGetters('user', [
'getSubscriberId'
])
},
methods: { methods: {
...mapWaitingActions('user', { ...mapWaitingActions('user', {
getPhonebookDetails: 'getPhonebookDetails', getPhonebookDetails: 'getPhonebookDetails',
@ -100,7 +106,7 @@ export default {
getValueNumber: 'getValueNumber' getValueNumber: 'getValueNumber'
}), }),
async getPhonebook (id) { async getPhonebook (id) {
const response = await this.getPhonebookDetails(id) const response = await this.getPhonebookDetails({ phonebookId: id, subscriberId: this.getSubscriberId })
this.name = response.data.name this.name = response.data.name
this.number = response.data.number this.number = response.data.number
this.shared = response.data.shared this.shared = response.data.shared

@ -571,7 +571,7 @@ export default {
const list = await getSubscriberPhonebook({ const list = await getSubscriberPhonebook({
...options ...options
}) })
commit('setSubscriberPhonebook', list.items) commit('setSubscriberPhonebook', list.data)
return list.totalCount return list.totalCount
} catch (err) { } catch (err) {
commit('setSubscriberPhonebook', []) commit('setSubscriberPhonebook', [])
@ -611,8 +611,8 @@ export default {
async removeSubscriberRegistration (context, row) { async removeSubscriberRegistration (context, row) {
await httpApi.delete(`api/subscriberregistrations/${row.id}`) await httpApi.delete(`api/subscriberregistrations/${row.id}`)
}, },
async removeSubscriberPhonebook (context, row) { async removeSubscriberPhonebook (context, { row, subscriberId }) {
await httpApi.delete(`api/subscriberphonebookentries/${row.id}`) await httpApi.delete(`api/v2/subscribers/${subscriberId}/phonebook/${row.id}`)
}, },
async removeCustomerPhonebook (context, row) { async removeCustomerPhonebook (context, row) {
await httpApi.delete(`api/customerphonebookentries/${row.id}`) await httpApi.delete(`api/customerphonebookentries/${row.id}`)
@ -652,8 +652,8 @@ export default {
async setNcosLevelsSubscriber (value) { async setNcosLevelsSubscriber (value) {
await setPreference(getSubscriberId(), 'ncos', value) await setPreference(getSubscriberId(), 'ncos', value)
}, },
async getPhonebookDetails (context, id) { async getPhonebookDetails (context, { phonebookId, subscriberId }) {
const list = await httpApi.get(`api/subscriberphonebookentries/${id}`) const list = await httpApi.get(`api/v2/subscribers/${subscriberId}/phonebook/${phonebookId}`)
return list return list
}, },
async getPhonebookCustomerDetails (context, id) { async getPhonebookCustomerDetails (context, id) {

Loading…
Cancel
Save