From 8a1adda61527b462a5aec808d046d82d2d767de4 Mon Sep 17 00:00:00 2001 From: Carlo Venusino Date: Wed, 26 Feb 2020 18:07:51 +0100 Subject: [PATCH] TT#75404 CF: As a Customer, I want to add phone numbers in order to forward calls to these numbers What is missing: - loader during requests - message on destination saved - timeout requests on filed blur (current on value change => multiple requests) - the form to add destinations currently shows up a the bottom of the destinationset instead as popover - (cosmetic) + icon instead of char before ADD FORWARD label Change-Id: I61986bcdc9f157787c1cd9d690c752b9fd44fe24 --- src/api/call-forward.js | 11 ++ .../NewCallForward/CscNewCallForward.vue | 165 ++++++++++++++++++ .../CscNewCallForwardAddDestinationForm.vue | 152 ++++++++++++++++ .../CscNewCallForwardDestination.vue | 136 +++++++++++++++ .../NewCallForward/CscNewCallForwardInput.vue | 109 ++++++++++++ .../pages/NewCallForward/NewCallForward.vue | 64 ------- src/helpers/validation.js | 5 + src/locales/en.json | 7 +- src/routes.js | 4 +- src/store/new-call-forward.js | 133 +++++++++++++- 10 files changed, 717 insertions(+), 69 deletions(-) create mode 100644 src/components/pages/NewCallForward/CscNewCallForward.vue create mode 100644 src/components/pages/NewCallForward/CscNewCallForwardAddDestinationForm.vue create mode 100644 src/components/pages/NewCallForward/CscNewCallForwardDestination.vue create mode 100644 src/components/pages/NewCallForward/CscNewCallForwardInput.vue delete mode 100644 src/components/pages/NewCallForward/NewCallForward.vue diff --git a/src/api/call-forward.js b/src/api/call-forward.js index 314844a0..5f75b5a6 100644 --- a/src/api/call-forward.js +++ b/src/api/call-forward.js @@ -319,6 +319,17 @@ export function addNewDestinationset() { }); } +export function addNewDestinationsetWithName(destinationsetName) { + return new Promise((resolve, reject) => { + Vue.http.post('api/cfdestinationsets/', { name: destinationsetName }) + .then((response) => { + resolve(_.last(_.split(response.headers.get('Location'), '/'))); + }).catch((err) => { + reject(err); + }); + }); +} + export function addDestinationToExistingGroup(options) { return new Promise((resolve, reject)=> { Promise.resolve().then(() => { diff --git a/src/components/pages/NewCallForward/CscNewCallForward.vue b/src/components/pages/NewCallForward/CscNewCallForward.vue new file mode 100644 index 00000000..d7a35e11 --- /dev/null +++ b/src/components/pages/NewCallForward/CscNewCallForward.vue @@ -0,0 +1,165 @@ + + + + + + diff --git a/src/components/pages/NewCallForward/CscNewCallForwardAddDestinationForm.vue b/src/components/pages/NewCallForward/CscNewCallForwardAddDestinationForm.vue new file mode 100644 index 00000000..71827673 --- /dev/null +++ b/src/components/pages/NewCallForward/CscNewCallForwardAddDestinationForm.vue @@ -0,0 +1,152 @@ + + + + + diff --git a/src/components/pages/NewCallForward/CscNewCallForwardDestination.vue b/src/components/pages/NewCallForward/CscNewCallForwardDestination.vue new file mode 100644 index 00000000..b6552870 --- /dev/null +++ b/src/components/pages/NewCallForward/CscNewCallForwardDestination.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/src/components/pages/NewCallForward/CscNewCallForwardInput.vue b/src/components/pages/NewCallForward/CscNewCallForwardInput.vue new file mode 100644 index 00000000..ff72e173 --- /dev/null +++ b/src/components/pages/NewCallForward/CscNewCallForwardInput.vue @@ -0,0 +1,109 @@ + + + + + + diff --git a/src/components/pages/NewCallForward/NewCallForward.vue b/src/components/pages/NewCallForward/NewCallForward.vue deleted file mode 100644 index a3db692f..00000000 --- a/src/components/pages/NewCallForward/NewCallForward.vue +++ /dev/null @@ -1,64 +0,0 @@ - - - - - diff --git a/src/helpers/validation.js b/src/helpers/validation.js index 30cfa3f9..8d0bafb3 100644 --- a/src/helpers/validation.js +++ b/src/helpers/validation.js @@ -16,3 +16,8 @@ export function userInfoAndEmpty(value) { export function customMacAddress (value) { return macAddressRegExp.test(value); } + + +export function isPhone(value) { + return /^\+[0-9]?()[0-9](\s|\S)(\d[0-9]{9})$/.test(value); +} diff --git a/src/locales/en.json b/src/locales/en.json index f56f3ead..a0bbb2fe 100644 --- a/src/locales/en.json +++ b/src/locales/en.json @@ -211,7 +211,12 @@ }, "newCallForward": { "primarNumberEnabled": "All calls go to the primary number", - "primarNumberDisabled": "No call goes to" + "primarNumberDisabled": "No call goes to", + "forwardBtnLabel": "Add forwarding", + "numberLabel": "Number", + "voiceMailLabel": "Voicemail", + "destinationTimeoutLabel": "Then after ", + "destinationNumberLabel": "seconds forwarded to" }, "callForward": { "titles": { diff --git a/src/routes.js b/src/routes.js index 21999aae..06dcaaa0 100644 --- a/src/routes.js +++ b/src/routes.js @@ -6,7 +6,7 @@ import ConferenceLayout from './components/layouts/Conference' import DefaultLayout from './components/layouts/Default' import Home from './components/pages/Home' import Conversations from './components/pages/Conversations/Conversations' -import NewCallForward from './components/pages/NewCallForward/NewCallForward' +import CscNewCallForward from './components/pages/NewCallForward/CscNewCallForward' import CallForwardAlways from './components/pages/CallForward/Always' import CallForwardCompanyHours from './components/pages/CallForward/CompanyHours' import CallForwardAfterHours from './components/pages/CallForward/AfterHours' @@ -48,7 +48,7 @@ export default [ }, { path: 'new-call-forward', - component: NewCallForward + component: CscNewCallForward }, { path: 'call-forward/always', diff --git a/src/store/new-call-forward.js b/src/store/new-call-forward.js index 7ae69224..33ff502a 100644 --- a/src/store/new-call-forward.js +++ b/src/store/new-call-forward.js @@ -1,13 +1,142 @@ 'use strict'; +import Vue from 'vue' +// import _ from 'lodash'; +// import { RequestState } from './common' +// import { i18n } from '../i18n'; +import { + // getSourcesets, + getDestinationsets, + addNewDestinationsetWithName, + // deleteDestinationFromDestinationset, + addDestinationToDestinationset, + // addDestinationToEmptyGroup, + // addDestinationToExistingGroup, + // changePositionOfDestination, + // moveDestinationUp, + // moveDestinationDown, + // loadTimesetTimes, + // deleteTimeFromTimeset, + // deleteTimesetById, + // resetTimesetByName, + // createTimesetWithTime, + // appendTimeToTimeset, + // loadDestinations, + // createSourcesetWithSource, + // appendSourceToSourceset, + // deleteSourcesetById, + // deleteSourceFromSourcesetByIndex, + // flipCfuAndCft, + // getOwnPhoneTimeout, + // updateOwnPhoneTimeout +} from '../api/call-forward'; export default { namespaced: true, + state: { + destinationsets:[], + destinations: [], + }, getters: { subscriberDisplayName(state, getters, rootState, rootGetters) { return rootGetters['user/getUsername']; + }, + destinations(state) { + return state.destinations; + }, + destinationsets(state){ + return state.destinationsets; + } + }, + mutations: { + addDestination(state, destination){ + state.destinations.push(destination); + }, + editDestination(state, data){ + let destination = state.destinations.slice(data.index, data.index+1)[0]; + destination.simple_destination = data.destination; + destination.destination = data.destination; + Vue.set(state.destinations, data.index, destination) + }, + editTimeout(state, data){ + let destination = state.destinations.slice(data.index, data.index+1)[0]; + destination.timeout = data.timeout; + Vue.set(state.destinations, data.index, destination) + }, + loadDestinationsets(state, destinationsets){ + state.destinationsets = destinationsets; + }, + loadDestinations(state, destinations){ + state.destinations = destinations; } }, - mutations: {}, - actions: {} + actions: { + async loadDestinationsets(context) { + try{ + const destinationsets = await getDestinationsets(localStorage.getItem('subscriberId')); + context.commit('loadDestinationsets', destinationsets); + } + catch(err){ + console.log(err) + } + }, + loadDestinations(context, destinations){ + context.commit('loadDestinations', destinations); + }, + async addDestinationSet(context, name) { + try{ + const newDestinationset = await addNewDestinationsetWithName(name); + return newDestinationset; + } + catch(err){ + console.log(err) + } + }, + getDestinationSetByName(context, name){ + let destinationsets = context.getters.destinationsets; + destinationsets = destinationsets.filter(($destinationset) => { + return $destinationset.name === name; + }); + return destinationsets.length > 0 ? destinationsets[0] : null; + }, + async addDestination(context, data){ + try{ + const destination = { + "announcement_id": null, + "simple_destination": data.destination, + "destination": data.destination, + "priority": 1, + "timeout": 10 + }; + await addDestinationToDestinationset({ + id: data.destinationSetId, + data: [...context.state.destinations, destination] + }); + + context.commit('addDestination', destination); + } + catch(err){ + console.log(err); + } + }, + async editDestination(context, data){ + let destination = context.state.destinations.slice(data.index, data.index+1)[0]; + destination.simple_destination = data.destination; + destination.destination = data.destination; + context.commit('editDestination', data); + await addDestinationToDestinationset({ + id: data.destinationSetId, + data: context.state.destinations + }); + }, + async editTimeout(context, data){ + let destination = context.state.destinations.slice(data.index, data.index+1)[0]; + destination.timeout = data.timeout; + context.commit('editTimeout', data); + await addDestinationToDestinationset({ + id: data.destinationSetId, + data: context.state.destinations + }); + } + } };