diff --git a/src/api/call-forwarding.js b/src/api/call-forwarding.js index 4d9188c9..1136f728 100644 --- a/src/api/call-forwarding.js +++ b/src/api/call-forwarding.js @@ -49,19 +49,12 @@ export async function cfLoadTimeSets (subscriberId) { }) } -/* Note: It needs to retrieve all Sets (DestinationSets, SourceSets, -** TimeSets, and BNumberSets) without filtering by subscriberId -** because some sets might belong to the admin subscriber -** and would not appear in the seats/groups CF. -*/ export async function cfLoadMappingsFull (mappingId) { - return await Promise.all([ - cfLoadMappings(mappingId), - cfLoadDestinationSets(), - cfLoadSourceSets(), - cfLoadTimeSets(), - cfLoadBNumberSets() - ]) + return get({ + resource: 'cfmappings', + params: { expand: 'all' }, + resourceId: mappingId + }) } export async function cfLoadAnnouncements () { @@ -102,6 +95,7 @@ export async function cfRewriteDestination (payload) { }) } +// Note this doesn't return any data in the response. export async function cfUpdateDestinationSets (payload) { return patchReplace({ resource: 'cfdestinationsets', diff --git a/src/components/CscPageSticky.vue b/src/components/CscPageSticky.vue index c48b9e05..a1409eb8 100644 --- a/src/components/CscPageSticky.vue +++ b/src/components/CscPageSticky.vue @@ -1,6 +1,7 @@ - -
- -
-
+ + +
+ +
+
+
diff --git a/src/helpers/normalize-mappings-response.js b/src/helpers/normalize-mappings-response.js new file mode 100644 index 00000000..e8b1961d --- /dev/null +++ b/src/helpers/normalize-mappings-response.js @@ -0,0 +1,49 @@ +import { sortDestinationsByPriority } from 'src/helpers/call-forwarding-destinations' +import { MAPPING_TYPES } from 'src/store/call-forwarding/normalizers' + +export function normalizeFullMappingsResponse (mappings) { + const destinationSetMap = {} + const sourceSetMap = {} + const timeSetMap = {} + const bNumberSetMap = {} + + MAPPING_TYPES.forEach((type) => { + mappings[type]?.forEach((mapping) => { + if (mapping.destinationset_id_expand) { + destinationSetMap[mapping.destinationset_id] = { + ...mapping.destinationset_id_expand, + destinations: sortDestinationsByPriority( + mapping.destinationset_id_expand.destinations + ) + } + delete mapping.destinationset_id_expand + } + + if (mapping.sourceset_id_expand) { + sourceSetMap[mapping.sourceset_id] = + mapping.sourceset_id_expand + delete mapping.sourceset_id_expand + } + + if (mapping.timeset_id_expand) { + timeSetMap[mapping.timeset_id] = + mapping.timeset_id_expand + delete mapping.timeset_id_expand + } + + if (mapping.bnumberset_id_expand) { + bNumberSetMap[mapping.bnumberset_id] = + mapping.bnumberset_id_expand + delete mapping.bnumberset_id_expand + } + }) + }) + + return { + mappings, + destinationSetMap, + sourceSetMap, + timeSetMap, + bNumberSetMap + } +} diff --git a/src/pages/CscPageCf.vue b/src/pages/CscPageCf.vue index f503651a..762cb0c7 100644 --- a/src/pages/CscPageCf.vue +++ b/src/pages/CscPageCf.vue @@ -24,17 +24,21 @@ -