From 82a98ed5392987de3d51655da6c3132473623054 Mon Sep 17 00:00:00 2001 From: Hans-Peter Herzog Date: Wed, 12 Sep 2018 10:01:23 +0200 Subject: [PATCH] TT#43554 Call: Refactor CSC call vue.js component Change-Id: Icefd79362d414bca9ffb857857af461ad3564c24 --- src/components/CscCall.vue | 633 ++++++++++++-------- src/components/CscCallDialpad.vue | 46 +- src/components/CscMedia.vue | 43 +- src/components/call/CscPhoneNumberInput.vue | 61 ++ src/components/layouts/Default.vue | 6 +- src/filters/index.js | 2 + src/filters/string.js | 6 + 7 files changed, 520 insertions(+), 277 deletions(-) create mode 100644 src/filters/string.js diff --git a/src/components/CscCall.vue b/src/components/CscCall.vue index 924ac7fa..26ccca82 100644 --- a/src/components/CscCall.vue +++ b/src/components/CscCall.vue @@ -3,176 +3,187 @@ - +
+ + + + + + {{ $t('call.startNew') }} + + + {{ $t('call.initiating') }} + + + {{ $t('call.ringing') }} + + + {{ $t('call.ended') }} + + + {{ $t('call.incoming') }} + + + {{ $t('call.call') }} + +
+
- - - - - - - - - - - - {{ $t('call.startNew') }} - - - {{ $t('call.initiating') }} - - - {{ $t('call.ringing') }} - - - {{ $t('call.ended') }} - - - {{ $t('call.incoming') }} - - - {{ $t('call.call') }} - - - - - - - - - {{ $t('call.desktopSharingNotInstalled') }} - - -
- -
- - - {{ getNumber | destinationFormat }} -
-
- {{ getEndedReason }} -
- -
- -
- - -
- -
- + + + +
+
+ +
+ + {{ $t('call.desktopSharingNotInstalled') }} + + +
+ + + {{ getNumber | destinationFormat }} +
+
+ {{ getEndedReason | startCase }} +
+
+ + +
+
+ +
- - - +
+
@@ -350,6 +353,16 @@ this.$refs.phoneNumberInput.concat(value); } }, + dialpadRemove() { + if(!this.isEstablished) { + this.$refs.phoneNumberInput.remove(); + } + }, + dialpadRemoveAll() { + if(!this.isEstablished) { + this.$refs.phoneNumberInput.removeAll(); + } + }, focusNumberInput() { this.$refs.phoneNumberInput.focusInput(); }, @@ -474,13 +487,6 @@ return 'volume up'; } }, - mediaPreviewClasses() { - var classes = []; - if(this.isEstablished && this.hasRemoteVideo) { - classes.push('csc-media-preview'); - } - return classes; - }, localMediaStream() { if(this.$store.state.call.localMediaStream !== null) { return this.$store.state.call.localMediaStream.getStream(); @@ -544,18 +550,34 @@ isDialpadEnabled() { return this.dialpadEnabled && (this.isPreparing || this.isEstablished); }, - isDialpadButtonEnabled() { - return this.isPreparing || this.isEstablished; - }, callClasses() { - let callClasses = ['csc-call']; - if(this.isEstablished) { - callClasses.push('csc-call-established'); + let classes = ['csc-call', 'call-state-' + this.callState]; + if (this.isFullscreenEnabled) { + classes.push('csc-call-fullscreen'); + } + if (this.isMobile) { + classes.push('csc-call-mobile'); + } + return classes; + }, + callMediaClasses() { + let classes = ['csc-call-media']; + if (this.hasVideo) { + classes.push('csc-call-media-video'); } - return callClasses; + return classes; + }, + callControlClasses() { + let classes = ['csc-call-controls']; + return classes; } }, watch: { + isEstablished(established) { + if(established) { + this.dialpadEnabled = false; + } + }, callState(state) { if(state === 'incoming') { showCallNotification(numberFormat(this.getNumber)); @@ -566,6 +588,9 @@ } else if (state === 'input') { this.stopIncomingSound(); + if(this.isMobile) { + this.dialpadEnabled = true; + } } else { this.stopIncomingSound(); @@ -577,77 +602,165 @@ diff --git a/src/components/CscCallDialpad.vue b/src/components/CscCallDialpad.vue index 016435bf..f9136669 100644 --- a/src/components/CscCallDialpad.vue +++ b/src/components/CscCallDialpad.vue @@ -3,6 +3,34 @@
+
+
+ +
+
+ +
+
-
-
- +
+
+
- +
@@ -70,11 +84,20 @@ diff --git a/src/components/call/CscPhoneNumberInput.vue b/src/components/call/CscPhoneNumberInput.vue index e323f2a3..d1c474ac 100644 --- a/src/components/call/CscPhoneNumberInput.vue +++ b/src/components/call/CscPhoneNumberInput.vue @@ -1,5 +1,6 @@ @@ -64,6 +91,10 @@ enabled: { type: Boolean, default: true + }, + dialpadButton: { + type: Boolean, + default: false } }, mixins: [ @@ -78,9 +109,27 @@ }, inputReadonly() { return this.isMobile; + }, + inputButtons() { + let self = this; + let buttons = []; + if (this.dialpadButton) { + buttons.push({ + icon: 'dialpad', + error: false, + handler (event) { + event.stopPropagation(); + self.toggleDialpad(); + } + }); + } + return buttons; } }, methods: { + keyReturn() { + this.$emit('key-return'); + }, inputPhoneNumber(value) { this.phoneNumber = normalizeNumber(value, this.isMobile); this.$v.phoneNumber.$touch(); @@ -106,6 +155,18 @@ Vue.nextTick(() => { this.$refs.inputField.blur(); }); + }, + remove() { + this.phoneNumber = _.trim(this.phoneNumber.substring(0, this.phoneNumber.length - 1)); + if (this.phoneNumber === '+') { + this.phoneNumber = ''; + } + }, + removeAll() { + this.phoneNumber = ''; + }, + toggleDialpad() { + this.$emit('toggle-dialpad'); } } } diff --git a/src/components/layouts/Default.vue b/src/components/layouts/Default.vue index 5903d6d7..e685be26 100644 --- a/src/components/layouts/Default.vue +++ b/src/components/layouts/Default.vue @@ -581,11 +581,7 @@ } .csc-call-fullscreen .csc-call .q-card-actions { - position: absolute; - bottom: 0; - right: 0; - left: 0; - z-index: 6001; + } .csc-call-fullscreen .csc-call .q-card-main { diff --git a/src/filters/index.js b/src/filters/index.js index 292bb19c..f0e27c7a 100644 --- a/src/filters/index.js +++ b/src/filters/index.js @@ -5,9 +5,11 @@ import NumberFormatFilter from './number-format' import { normalizeDestination } from './number-format' import DateFilter from './date' import { smartTime } from './date' +import { startCase } from './string' Vue.filter('number', NumberFilter); Vue.filter('readableDate', DateFilter); Vue.filter('numberFormat', NumberFormatFilter); Vue.filter('destinationFormat', normalizeDestination); Vue.filter('smartTime', smartTime); +Vue.filter('startCase', startCase); diff --git a/src/filters/string.js b/src/filters/string.js new file mode 100644 index 00000000..03b1f55e --- /dev/null +++ b/src/filters/string.js @@ -0,0 +1,6 @@ + +import _ from 'lodash' + +export function startCase(str) { + return _.startCase(str); +}