diff --git a/i18n/en-US.json b/i18n/en-US.json index a1220f4..d5b4b1e 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -385,7 +385,8 @@ "number": "This number", "placeholder": "+14157283992", "requireKeyPress": "Leave voicemails on forwarded numbers", - "title": "Call Forwarding" + "title": "Call Forwarding", + "timeoutWarning": "In order to leave voicemails on forwarded numbers, your ringing timeout needs to be set to at least 30sec. By saving now, you will automatically be redirected to the user edition where you can update the ringing timeout." }, "callRecording": { "title": "Inbound Call Recording", diff --git a/i18n/fr-FR.json b/i18n/fr-FR.json index 7376148..2bce11a 100644 --- a/i18n/fr-FR.json +++ b/i18n/fr-FR.json @@ -363,7 +363,8 @@ "number": "Ce numéro", "placeholder": "+14157283992", "requireKeyPress": "Laisser message sur le répondeur du numéro transferé", - "title": "Transfert d'appels" + "title": "Transfert d'appels", + "timeoutWarning": "Afin de pouvoir laisser un message sur le répondeur du numéro transferé, la durée de sonnerie de l'utilisateur doit être d'au moins 30sec. En cliquant sur le bouton \"Sauvegarder\", vous serez automatiquement redirigé vers l'édition d'utilisateur où vous pourrez modifier la durée de sonnerie." }, "callRecording": { "title": "Enregistrement d'appel entrant", diff --git a/submodules/users/users.js b/submodules/users/users.js index 1475b5a..e7bcdd6 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -302,8 +302,6 @@ define(function(require){ dataUser.extra = formattedUser; } - // console.log(_mainCallflow) - dataUser.extra.countFeatures = 0; _.each(dataUser.features, function(v) { if(v in dataUser.extra.mapFeatures) { @@ -1101,7 +1099,23 @@ define(function(require){ }); template.on('click', '.feature[data-feature="call_forward"]', function() { - self.usersRenderCallForward(currentUser); + if(currentUser.features.indexOf('find_me_follow_me') < 0) { + var featureUser = $.extend(true, {}, currentUser); + self.usersGetMainCallflow(featureUser.id, function(mainCallflow) { + if(mainCallflow && 'flow' in mainCallflow) { + var flow = mainCallflow.flow; + while(flow.module != 'user' && '_' in flow.children) { + flow = flow.children['_']; + } + if(flow.data.timeout < 30) { + featureUser.extra.timeoutTooShort = true; + } + } + self.usersRenderCallForward(featureUser); + }); + } else { + self.usersRenderCallForward(currentUser); + } }); template.on('click', '.feature[data-feature="hotdesk"]', function() { @@ -1724,12 +1738,22 @@ define(function(require){ featureForm = featureTemplate.find('#call_forward_form'), args = { callback: function() { - popup.dialog('close').remove() + popup.dialog('close').remove(); }, openedTab: 'features' - }; + }, + timeoutWarningBox = featureTemplate.find('.timeout-warning'); + + if(currentUser.call_forward.require_keypress) { + timeoutWarningBox.hide(); + } monster.ui.validate(featureForm); + monster.ui.prettyCheck.create(featureTemplate.find('.content')); + + featureTemplate.find('input[name="require_keypress"]').on('ifToggled', function() { + timeoutWarningBox.toggle(); + }); featureTemplate.find('.cancel-link').on('click', function() { popup.dialog('close').remove(); @@ -1750,6 +1774,7 @@ define(function(require){ featureTemplate.find('.save').on('click', function() { if(monster.ui.valid(featureForm)) { var formData = form2object('call_forward_form'); + formData.require_keypress = !formData.require_keypress; formData.enabled = switchFeature.bootstrapSwitch('status'); formData.number = monster.util.unformatPhoneNumber(formData.number, 'keepPlus'); @@ -1757,6 +1782,10 @@ define(function(require){ var userToSave = $.extend(true, {}, currentUser, { call_forward: formData}); + if(timeoutWarningBox.is(':visible')) { + args.openedTab = 'name'; + } + self.usersUpdateUser(userToSave, function(data) { args.userId = data.data.id; @@ -1765,8 +1794,6 @@ define(function(require){ } }); - monster.ui.prettyCheck.create(featureTemplate.find('.content')); - if ( currentUser.call_forward.number && /^(\+1)/.test(currentUser.call_forward.number) ) { featureTemplate.find('#phoneType').val('mobile'); featureTemplate.find('#number').mask('+1 (999) 999-9999'); diff --git a/views/users-feature-call_forward.html b/views/users-feature-call_forward.html index a07eb27..493913f 100644 --- a/views/users-feature-call_forward.html +++ b/views/users-feature-call_forward.html @@ -34,7 +34,7 @@ --> + {{#if extra.timeoutTooShort}} +
{{ i18n.users.call_forward.timeoutWarning }}
+