diff --git a/i18n/en-US.json b/i18n/en-US.json index 456e162..a1220f4 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -324,7 +324,12 @@ "lastName": "Last Name", "role": "Role", "timezone": "Timezone", - "vmboxNumber": "VMBox Number" + "vmboxNumber": "VMBox Number", + "timeout": "Ringing Timeout", + "timeoutSec": "Sec", + "timeoutEdit": "Edit in Find-Me-Follow-Me feature", + "timeoutEditHint": "The ringing timeout is overriden by the Find-Me-Follow-Me feature. Click on the link below to edit it.", + "disabledTimeoutHint": "You need at least one number or extension to set up the ringing timeout." }, "delete": "Delete User", "errorCallerId": "Before configuring the Caller-ID of this user, you need to assign him a number", diff --git a/i18n/fr-FR.json b/i18n/fr-FR.json index 89b18c1..7376148 100644 --- a/i18n/fr-FR.json +++ b/i18n/fr-FR.json @@ -302,7 +302,12 @@ "lastName": "Nom", "role": "Rôle", "timezone": "Fuseau Horaire", - "vmboxNumber": "Num. Répondeur" + "vmboxNumber": "Num. Répondeur", + "timeout": "Durée de sonnerie", + "timeoutSec": "Sec", + "timeoutEdit": "Editer dans \"Find-Me-Follow-Me\"", + "timeoutEditHint": "La durée de sonnerie est redéfinie dans la fonctionnalité \"Find-Me-Follow-Me\". Cliquez sur le lien ci-dessous pour la modifier.", + "disabledTimeoutHint": "Au moins un numéro ou extension est requis avant de pouvoir définir la durée de sonnerie." }, "delete": "Supprimer Utilisateur", "errorCallerId": "Avant de configurer le Caller-ID de l'utilisateur, vous devez d'abord lui attribuer un numéro.", diff --git a/submodules/users/users.css b/submodules/users/users.css index 547079b..db0f0a1 100644 --- a/submodules/users/users.css +++ b/submodules/users/users.css @@ -288,6 +288,33 @@ margin-left: 7px; } +#users_container .detail-user .row-fields .ringing-timeout { + display: inline-block; +} + +#users_container .detail-user .row-fields .ringing-timeout.disabled * { + opacity: 0.5; + cursor: default !important; +} + +#users_container .detail-user .row-fields .timeout-edit { + margin-left: 50px; +} + +#users_container .detail-user .row-fields .timeout-edit a { + margin: 0px; +} + +#users_container .detail-user .row-fields #ringing_timeout { + margin: 0px 7px; + width: 36px; +} + +#users_container .detail-user .row-fields label.monster-invalid[for="ringing_timeout"] { + margin: 0px; + display: block; +} + #users_container .detail-user .email-border { margin-bottom: 10px; border: 2px dotted transparent; diff --git a/submodules/users/users.js b/submodules/users/users.js index 2f312dc..1475b5a 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -302,6 +302,8 @@ define(function(require){ dataUser.extra = formattedUser; } + // console.log(_mainCallflow) + dataUser.extra.countFeatures = 0; _.each(dataUser.features, function(v) { if(v in dataUser.extra.mapFeatures) { @@ -327,6 +329,21 @@ define(function(require){ if(_mainCallflow) { dataUser.extra.mainCallflowId = _mainCallflow.id; + + if('flow' in _mainCallflow) { + var flow = _mainCallflow.flow, + module = 'user'; + + if(dataUser.features.indexOf('find_me_follow_me') >= 0) { + module = 'ring_group'; + dataUser.extra.groupTimeout = true; + } + + while(flow.module != module && '_' in flow.children) { + flow = flow.children['_']; + } + dataUser.extra.ringingTimeout = flow.data.timeout; + } } if(_vmbox) { @@ -439,7 +456,45 @@ define(function(require){ toastrMessages = self.i18n.active().users.toastrMessages, mainDirectoryId, mainCallflowId, - listUsers = data; + listUsers = data, + renderFindMeFollowMeFeature = function(featureCallback) { + monster.parallel({ + userDevices: function(callback) { + monster.request({ + resource: 'voip.users.listUserDevices', + data: { + accountId: self.accountId, + userId: currentUser.id + }, + success: function(data) { + callback(null, data.data); + } + }); + }, + userCallflow: function(callback) { + self.usersListCallflowsUser(currentUser.id, function(data) { + if(data.length > 0) { + monster.request({ + resource: 'voip.users.getCallflow', + data: { + accountId: self.accountId, + callflowId: data[0].id + }, + success: function(callflow) { + callback(null, callflow.data) + } + }); + } else { + callback(null, null); + } + }); + } + }, + function(error, results) { + self.usersRenderFindMeFollowMe($.extend(true, results, { currentUser: currentUser, saveCallback: featureCallback })); + } + ); + }; template.find('.grid-row:not(.title) .grid-cell').on('click', function() { var cell = $(this), @@ -758,13 +813,33 @@ define(function(require){ monster.parallel({ vmbox: function(callback) { self.usersSmartUpdateVMBox(userToSave, true, function(vmbox) { - callback && callback(null, vmbox); + callback(null, vmbox); }); }, user: function(callback) { self.usersUpdateUser(userToSave, function(userData) { - callback && callback(null, userData.data); + callback(null, userData.data); }); + }, + callflow: function(callback) { + if(userToSave.extra.ringingTimeout && userToSave.features.indexOf('find_me_follow_me') < 0) { + self.usersGetMainCallflow(userToSave.id, function(mainCallflow) { + if('flow' in mainCallflow) { + var flow = mainCallflow.flow; + while(flow.module != 'user' && '_' in flow.children) { + flow = flow.children['_']; + } + flow.data.timeout = parseInt(userToSave.extra.ringingTimeout); + self.usersUpdateCallflow(mainCallflow, function(updatedCallflow) { + callback(null, updatedCallflow); + }); + } else { + callback(null, null); + } + }); + } else { + callback(null, null); + } } }, function(error, results) { @@ -817,6 +892,17 @@ define(function(require){ }); }); + template.on('click', '#open_fmfm_link', function() { + renderFindMeFollowMeFeature(function(usersRenderArgs) { + usersRenderArgs.openedTab = 'name'; + self.usersRender(usersRenderArgs); + }); + }); + + template.on('focus', '.ringing-timeout.disabled #ringing_timeout', function() { + $(this).blur(); + }); + /* Events for Devices in Users */ template.on('click', '.create-device', function() { var $this = $(this), @@ -1023,42 +1109,7 @@ define(function(require){ }); template.on('click', '.feature[data-feature="find_me_follow_me"]', function() { - monster.parallel({ - userDevices: function(callback) { - monster.request({ - resource: 'voip.users.listUserDevices', - data: { - accountId: self.accountId, - userId: currentUser.id - }, - success: function(data) { - callback(null, data.data); - } - }); - }, - userCallflow: function(callback) { - self.usersListCallflowsUser(currentUser.id, function(data) { - if(data.length > 0) { - monster.request({ - resource: 'voip.users.getCallflow', - data: { - accountId: self.accountId, - callflowId: data[0].id - }, - success: function(callflow) { - callback(null, callflow.data) - } - }); - } else { - callback(null, null); - } - }); - } - }, - function(error, results) { - self.usersRenderFindMeFollowMe($.extend(true, results, { currentUser: currentUser })); - } - ); + renderFindMeFollowMeFeature(); }); template.on('click', '.feature[data-feature="call_recording"]', function() { @@ -1818,7 +1869,11 @@ define(function(require){ }, function(err, results) { args.userId = results.user.id; - self.usersRender(args); + if(typeof params.saveCallback === 'function') { + params.saveCallback(args); + } else { + self.usersRender(args); + } } ); }); @@ -2360,6 +2415,9 @@ define(function(require){ rules: { 'extra.vmboxNumber': { checkList: dataTemplate.extra.existingVmboxes + }, + 'extra.ringingTimeout': { + digits: true } }, messages: { @@ -2374,6 +2432,8 @@ define(function(require){ timezone.populateDropdown(template.find('#user_timezone'), dataTemplate.timezone); + template.find('[data-toggle="tooltip"]').tooltip(); + callbackAfterFormat && callbackAfterFormat(template, dataTemplate); } ); @@ -2888,7 +2948,19 @@ define(function(require){ callback(null); } else { - callback(listCallflows[indexMain]); + self.callApi({ + resource: 'callflow.get', + data: { + accountId: self.accountId, + callflowId: listCallflows[indexMain].id + }, + success: function(data) { + callback(data.data); + }, + error: function() { + callback(listCallflows[indexMain]); + } + }); } }); }, diff --git a/views/users-name.html b/views/users-name.html index 8273856..f8600be 100644 --- a/views/users-name.html +++ b/views/users-name.html @@ -71,6 +71,30 @@ + +
+
+ {{#unless extra.ringingTimeout}} +
+ {{else}} + {{#if extra.groupTimeout}} +
+ {{else}} +
+ {{/if}} + {{/unless}} + + + {{ i18n.users.editionForm.timeoutSec }} +
+ {{#if extra.groupTimeout}} + + {{/if}} +