From dd4ea075defb070b63c21a456f182c3a5d3856fa Mon Sep 17 00:00:00 2001 From: Hans-Peter Herzog Date: Thu, 12 Oct 2017 15:29:28 +0200 Subject: [PATCH] TT#23176 CallBlocking: As a Customer I want to remove a number from the list Change-Id: I77ac239f7c8ec6ac97f604a692f672008d9eef01 --- src/api/call-blocking.js | 12 ++- src/api/subscriber.js | 24 ++++++ src/components/layouts/Default.vue | 5 +- .../pages/CallBlocking/Incoming.vue | 82 +++++++++++++------ src/helpers/ui.js | 9 +- src/store/call-blocking.js | 16 +++- 6 files changed, 115 insertions(+), 33 deletions(-) diff --git a/src/api/call-blocking.js b/src/api/call-blocking.js index b130bed1..9e0db2d9 100644 --- a/src/api/call-blocking.js +++ b/src/api/call-blocking.js @@ -1,7 +1,7 @@ import Vue from 'vue'; import { enableBlockIn, disableBlockIn, - getPreferences, addToBlockInList } from './subscriber'; + getPreferences, addToBlockInList, removeFromBlockInList } from './subscriber'; export function enableIncomingCallBlocking(id) { return enableBlockIn(id); @@ -37,3 +37,13 @@ export function addNumberToIncomingList(id, number) { } }); } + +export function removeNumberFromIncomingList(id, index) { + return new Promise((resolve, reject)=>{ + removeFromBlockInList(id, index).then(()=>{ + resolve(); + }).catch((err)=>{ + reject(err); + }); + }); +} diff --git a/src/api/subscriber.js b/src/api/subscriber.js index 082b00c0..9ea7e03c 100644 --- a/src/api/subscriber.js +++ b/src/api/subscriber.js @@ -65,6 +65,26 @@ export function appendItemToArrayPreference(id, field, value) { }); } +export function removeItemFromArrayPreference(id, field, itemIndex) { + return new Promise((resolve, reject)=>{ + Promise.resolve().then(()=>{ + return getPreferences(id); + }).then((result)=>{ + var prefs = _.cloneDeep(result); + delete prefs._links; + prefs[field] = _.get(prefs, field, []); + _.remove(prefs[field], (value, index)=>{ + return index === itemIndex; + }); + return Vue.http.put('/api/subscriberpreferences/' + id, prefs); + }).then(()=>{ + resolve(); + }).catch((err)=>{ + reject(); + }); + }); +} + export function setBlockInMode(id, value) { return setPreference(id, 'block_in_mode', value); } @@ -80,3 +100,7 @@ export function disableBlockIn(id) { export function addToBlockInList(id, number) { return prependItemToArrayPreference(id, 'block_in_list', number); } + +export function removeFromBlockInList(id, index) { + return removeItemFromArrayPreference(id, 'block_in_list', index); +} diff --git a/src/components/layouts/Default.vue b/src/components/layouts/Default.vue index 17eb19e3..b1775c9a 100644 --- a/src/components/layouts/Default.vue +++ b/src/components/layouts/Default.vue @@ -47,11 +47,11 @@ :label="$t('mainNavigation.callBlocking.title')" :sublabel="$t('mainNavigation.callBlocking.subTitle')"> - + - + @@ -233,6 +233,7 @@ .q-card { margin:15px; margin-left: 0px; + margin-right: 0px; } .q-card.page { diff --git a/src/components/pages/CallBlocking/Incoming.vue b/src/components/pages/CallBlocking/Incoming.vue index 8209c2f6..280be19a 100644 --- a/src/components/pages/CallBlocking/Incoming.vue +++ b/src/components/pages/CallBlocking/Incoming.vue @@ -1,8 +1,8 @@