From 67968adb62adee95b9f0ed4a245193c226ca2d33 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Thu, 24 Jul 2014 16:38:06 -0700 Subject: [PATCH 1/4] UI-294: Create faxbox form --- submodules/users/users.css | 17 ++++ submodules/users/users.js | 138 +++++++++++++++++++++++++++++--- views/users-feature-faxing.html | 95 ++++++++++++++++++---- 3 files changed, 226 insertions(+), 24 deletions(-) diff --git a/submodules/users/users.css b/submodules/users/users.css index 547079b..e2e4537 100644 --- a/submodules/users/users.css +++ b/submodules/users/users.css @@ -687,6 +687,23 @@ padding-right: 13px; } +.feature-popup-container[data-feature="faxing"] { + overflow: hidden; +} + +.feature-popup-container[data-feature="faxing"] #faxbox_form { + margin-bottom: 0; +} + +.feature-popup-container[data-feature="faxing"] #printer_link { + margin-left: 10px; + line-height: 30px; +} + +.feature-popup-container[data-feature="faxing"] #fax_timezone_chosen { + margin-left: 10px; +} + /* Change Password Popup */ .change-password-popup { width: 430px; diff --git a/submodules/users/users.js b/submodules/users/users.js index 83cf1b1..eab9bdf 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -1149,12 +1149,32 @@ define(function(require){ callback && callback(null, existingCallflow) }); + }, + faxboxes: function(callback) { + self.callApi({ + resource: 'faxbox.list', + data: { + accountId: self.accountId + }, + success: function(_data) { + var userFaxboxes = []; + + _.each(_data.data, function(val){ + if ( val.owner_id === currentUser.id ) { + userFaxboxes.push(val); + } + }); + + callback && callback(null, userFaxboxes); + } + }) } }, function(err, results) { results.user = currentUser; - - self.usersRenderFaxing(results); +console.log(results); + self.usersRenderFaxboxes(results); + // self.usersRenderFaxing(results); } ); }); @@ -1329,16 +1349,21 @@ define(function(require){ usersFormatFaxingData: function(data) { var listNumbers = []; + _.each(data.numbers, function(value, number) { + listNumbers.push(number); + }); + + listNumbers.sort(function(a, b) { + return a < b ? -1 : 1; + }); + if(data.callflows) { if(data.callflows.numbers.length > 0) { - listNumbers.push(data.callflows.numbers[0]); + // listNumbers.push(data.callflows.numbers[0]); + listNumbers.unshift(data.callflows.numbers[0]); } } - _.each(data.numbers, function(value, number) { - listNumbers.push(number); - }); - data.extra = $.extend(true, {}, data.extra, { listNumbers: listNumbers }); @@ -1457,6 +1482,99 @@ define(function(require){ }, + + + + usersRenderFaxboxes: function(data) { + var self = this, + data = self.usersFormatFaxingData(data), + featureTemplate = $(monster.template(self, 'users-feature-faxing', data)), + switchFeature = featureTemplate.find('.switch').bootstrapSwitch(); + + timezone.populateDropdown(featureTemplate.find('#fax_timezone')); + + featureTemplate.find('#fax_timezone').chosen({search_contains: true, width: "78.48%"}); + + monster.ui.prettyCheck.create(featureTemplate.find('.content')); + + if ( data.extra.listNumbers.length > 0 ) { + var popup = monster.ui.dialog(featureTemplate, { + title: data.user.extra.mapFeatures.faxing.title, + position: ['center', 20] + }); + } else { + monster.ui.alert('error', self.i18n.active().users.errorNumberFaxing); + } + + featureTemplate.find('.cancel-link').on('click', function() { + popup.dialog('close').remove(); + }); + + switchFeature.on('switch-change', function(e, data) { + data.value ? featureTemplate.find('.content').slideDown() : featureTemplate.find('.content').slideUp(); + }); + + featureTemplate.find('.save').on('click', function() { + var faxboxData = form2object('faxbox_form', '.', true), + args = { + openedTab: 'features', + callback: function() { + popup.dialog('close').remove(); + } + }; +console.log(data); + if ( switchFeature.bootstrapSwitch('status') ) { + faxboxData.owner_id = !faxboxData.hasOwnProperty('owner_id') ? data.user.id : faxboxData.owner_id; + faxboxData.smtp_permission_list = faxboxData.smtp_permission_list.split(' '); + + if ( data.hasOwnProperty('faxbox') && data.faxbox.hasOwnProperty('id') ) { + self.callApi({ + resource: 'faxbox.update', + data: { + accountId: self.accountId, + faxboxId: faxboxId, + data: faxboxData + }, + success: function(_data, status) { +console.log(_data); + // self.usersUpdateFaxing(data, newNumber, function(results) { + // args.userId = results.callflows.owner_id; + + // self.usersRender(args); + // }); + } + }); + } else { + self.callApi({ + resource: 'faxbox.create', + data: { + accountId: self.accountId, + data: faxboxData + }, + success: function(_data, status) { +console.log(_data); + // self.usersUpdateFaxing(data, newNumber, function(results) { + // args.userId = results.callflows.owner_id; + + // self.usersRender(args); + // }); + } + }) + } + } else { + self.usersDeleteFaxing(data.user.id, function() { + args.userId = data.user.id; + + self.usersRender(args); + }); + } + }); + }, + + + + + usersRenderHotdesk: function(currentUser) { var self = this, featureTemplate = $(monster.template(self, 'users-feature-hotdesk', currentUser)), @@ -3590,9 +3708,11 @@ define(function(require){ numbers: [ newNumber ], flow: { data: { - owner_id: data.user.id + faxbox_id: data.faxbox.id + // owner_id: data.user.id }, - module: 'receive_fax', + module: 'faxbox', + // module: 'receive_fax', children: {} } }; diff --git a/views/users-feature-faxing.html b/views/users-feature-faxing.html index 5db4f77..d3441a9 100644 --- a/views/users-feature-faxing.html +++ b/views/users-feature-faxing.html @@ -10,21 +10,86 @@
- {{ i18n.users.faxing.dropdownLabel }} - - -
-
-    -
-
-

{{replaceVar i18n.users.faxing.help this.user.email }}

-
-
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+ {{#if faxbox.cloud_connector_claim_url}} +
+ + +
+ {{/if}} +
+ +
+ +
+
+
+ +
+ +
+
+
From 6fda3c44df04fbfa1c049929d8a7a97554da3bac Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Tue, 29 Jul 2014 12:04:07 -0700 Subject: [PATCH 2/4] UI-294: New CRUD --- i18n/en-US.json | 19 ++- i18n/fr-FR.json | 19 ++- submodules/users/users.js | 291 ++++++++++++++++---------------- views/users-feature-faxing.html | 73 ++------ 4 files changed, 185 insertions(+), 217 deletions(-) diff --git a/i18n/en-US.json b/i18n/en-US.json index 456e162..537ce0f 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -400,10 +400,21 @@ "noConfNumbers": "You need to add a Main Conference Number (in the Main number section on the left of the SmartPBX) in order to enable the Personnals Conference Bridges" }, "faxing": { - "title": "Fax to Email", - "dropdownLabel": "Personal Fax Number", - "headline": "Fax to Email", - "help": "This user will receive a fax at {{variable}} as an attachment." + "title": "Faxbox", + "headline": "Faxbox", + "text": "This user will receive faxes at {{variable}} as an attachment.", + "helpOne": "For users running Windows, here is a link to the ", + "helpTwo": "Cloud Printer Installer", + "form": { + "label": { + "callerId": "Faxbox number", + "linkToPrinter": "Link to printer" + } + }, + "defaultSettings": { + "nameExtension": "'s Faxbox", + "headerExtension": " Fax Printer" + } }, "vm_to_email": { "deleteAfterNotify": "Delete messages from database after sending the notification.", diff --git a/i18n/fr-FR.json b/i18n/fr-FR.json index 89b18c1..7c5a12e 100644 --- a/i18n/fr-FR.json +++ b/i18n/fr-FR.json @@ -380,10 +380,21 @@ "noConfNumbers": "Vous devez ajouter un Numéro principal de Conférence (Voir \"Numéro principal\" dans le menu de gauche) avant de pouvoir configurer les Conférences personnelles des utilisateurs" }, "faxing": { - "title": "Fax vers Email", - "dropdownLabel": "Numéro de Fax Perso", - "help": "Un fax sera envoyé à {{variable}} en tant que pièce jointe.", - "headline": "Fax vers Email" + "title": "Faxbox", + "headline": "Faxbox", + "text": "Cet utilisateur recevra les fax à l'adresse mail {{variable}} sous la forme d'une pièce jointe.", + "helpOne": "Pour les utilisateurs sur Windows, voici un lien pour ", + "helpTwo": "l'installeur de l'imprimante en ligne", + "form": { + "label": { + "callerId": "Numéro de Faxbox", + "linkToPrinter": "Lien de l'imprimante" + } + }, + "defaultSettings": { + "nameExtension": "'s Faxbox", + "headerExtension": " Fax Printer" + } }, "vm_to_email": { "deleteAfterNotify": "Supprimer les messages vocaux de la base de données après l'envoi de la notification.", diff --git a/submodules/users/users.js b/submodules/users/users.js index eab9bdf..525a0d6 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -1147,34 +1147,46 @@ define(function(require){ } }); - callback && callback(null, existingCallflow) + if ( existingCallflow ) { + self.callApi({ + resource: 'callflow.get', + data: { + accountId: self.accountId, + callflowId: existingCallflow.id + }, + success: function(data, status) { + callback && callback(null, data.data); + } + }); + } else { + callback && callback(null, existingCallflow); + } }); - }, - faxboxes: function(callback) { + } + }, + function(err, results) { + results.user = currentUser; + + if ( typeof results.callflows !== 'undefined' ) { self.callApi({ - resource: 'faxbox.list', + resource: 'faxbox.get', data: { - accountId: self.accountId + accountId: self.accountId, + faxboxId: results.callflows.flow.data.faxbox_id }, success: function(_data) { - var userFaxboxes = []; - - _.each(_data.data, function(val){ - if ( val.owner_id === currentUser.id ) { - userFaxboxes.push(val); - } - }); + results.faxbox = _data.data; + results.faxbox.id = results.callflows.flow.data.faxbox_id; - callback && callback(null, userFaxboxes); + self.usersRenderFaxboxes(results); + }, + error: function() { + self.usersRenderFaxboxes(results); } - }) + }); + } else { + self.usersRenderFaxboxes(results); } - }, - function(err, results) { - results.user = currentUser; -console.log(results); - self.usersRenderFaxboxes(results); - // self.usersRenderFaxing(results); } ); }); @@ -1347,23 +1359,27 @@ console.log(results); }, usersFormatFaxingData: function(data) { - var listNumbers = []; + var tempList = [], + listNumbers = {}; - _.each(data.numbers, function(value, number) { - listNumbers.push(number); + _.each(data.numbers, function(val, key){ + tempList.push(key); }); - listNumbers.sort(function(a, b) { + tempList.sort(function(a, b) { return a < b ? -1 : 1; }); if(data.callflows) { if(data.callflows.numbers.length > 0) { - // listNumbers.push(data.callflows.numbers[0]); - listNumbers.unshift(data.callflows.numbers[0]); + listNumbers[data.callflows.numbers[0]] = data.callflows.numbers[0] } } + _.each(tempList, function(val, key) { + listNumbers[val] = val; + }); + data.extra = $.extend(true, {}, data.extra, { listNumbers: listNumbers }); @@ -1424,80 +1440,19 @@ console.log(results); }); }, - usersFormatConferencingData: function(data) { return data; }, - usersRenderFaxing: function(data) { - var self = this, - data = self.usersFormatFaxingData(data), - featureTemplate = $(monster.template(self, 'users-feature-faxing', data)), - switchFeature = featureTemplate.find('.switch').bootstrapSwitch(); - - featureTemplate.find('.cancel-link').on('click', function() { - popup.dialog('close').remove(); - }); - - switchFeature.on('switch-change', function(e, data) { - data.value ? featureTemplate.find('.content').slideDown() : featureTemplate.find('.content').slideUp(); - }); - - featureTemplate.find('.save').on('click', function() { - var newNumber = popup.find('.dropdown-numbers').val(), - args = { - openedTab: 'features', - callback: function() { - popup.dialog('close').remove(); - } - }; - - if(switchFeature.bootstrapSwitch('status')) { - self.usersUpdateFaxing(data, newNumber, function(results) { - args.userId = results.callflow.owner_id; - - self.usersRender(args); - }); - } - else { - self.usersDeleteFaxing(data.callflows.owner_id, function() { - args.userId = data.callflows.owner_id; - - self.usersRender(args); - }); - } - }); - - monster.ui.prettyCheck.create(featureTemplate.find('.content')); - - if(data.extra.listNumbers.length > 0) { - var popup = monster.ui.dialog(featureTemplate, { - title: data.user.extra.mapFeatures.faxing.title, - position: ['center', 20] - }); - } - else { - monster.ui.alert('error', self.i18n.active().users.errorNumberFaxing); - } - }, - - - - - usersRenderFaxboxes: function(data) { var self = this, data = self.usersFormatFaxingData(data), featureTemplate = $(monster.template(self, 'users-feature-faxing', data)), switchFeature = featureTemplate.find('.switch').bootstrapSwitch(); - timezone.populateDropdown(featureTemplate.find('#fax_timezone')); - - featureTemplate.find('#fax_timezone').chosen({search_contains: true, width: "78.48%"}); - monster.ui.prettyCheck.create(featureTemplate.find('.content')); - if ( data.extra.listNumbers.length > 0 ) { + if ( !_.isEmpty(data.extra.listNumbers) ) { var popup = monster.ui.dialog(featureTemplate, { title: data.user.extra.mapFeatures.faxing.title, position: ['center', 20] @@ -1522,45 +1477,19 @@ console.log(results); popup.dialog('close').remove(); } }; -console.log(data); + if ( switchFeature.bootstrapSwitch('status') ) { - faxboxData.owner_id = !faxboxData.hasOwnProperty('owner_id') ? data.user.id : faxboxData.owner_id; - faxboxData.smtp_permission_list = faxboxData.smtp_permission_list.split(' '); + faxboxData.owner_id = faxboxData.hasOwnProperty('owner_id') ? faxboxData.owner_id : data.user.id; - if ( data.hasOwnProperty('faxbox') && data.faxbox.hasOwnProperty('id') ) { - self.callApi({ - resource: 'faxbox.update', - data: { - accountId: self.accountId, - faxboxId: faxboxId, - data: faxboxData - }, - success: function(_data, status) { -console.log(_data); - // self.usersUpdateFaxing(data, newNumber, function(results) { - // args.userId = results.callflows.owner_id; + if ( data.hasOwnProperty('faxbox') ) { + faxboxData.id = data.faxbox.id; + } - // self.usersRender(args); - // }); - } - }); - } else { - self.callApi({ - resource: 'faxbox.create', - data: { - accountId: self.accountId, - data: faxboxData - }, - success: function(_data, status) { -console.log(_data); - // self.usersUpdateFaxing(data, newNumber, function(results) { - // args.userId = results.callflows.owner_id; + self.usersUpdateFaxing(data, faxboxData, function(results) { + args.userId = results.callflow.owner_id; - // self.usersRender(args); - // }); - } - }) - } + self.usersRender(args); + }); } else { self.usersDeleteFaxing(data.user.id, function() { args.userId = data.user.id; @@ -3697,25 +3626,12 @@ console.log(_data); ); }, - usersUpdateFaxing: function(data, newNumber, globalCallback) { + usersUpdateFaxing: function(data, faxboxData, globalCallback) { var self = this; monster.parallel({ callflow: function(callback) { - var baseCallflow = { - type: 'faxing', - owner_id: data.user.id, - numbers: [ newNumber ], - flow: { - data: { - faxbox_id: data.faxbox.id - // owner_id: data.user.id - }, - module: 'faxbox', - // module: 'receive_fax', - children: {} - } - }; + var baseCallflow = {}; self.usersListCallflowsUser(data.user.id, function(callflows) { _.each(callflows, function(callflow) { @@ -3726,7 +3642,8 @@ console.log(_data); } }); - self.usersUpdateCallflowFaxing(baseCallflow, function(callflow) { + self.usersUpdateCallflowFaxing(data.user, faxboxData, baseCallflow, function(callflow) { +console.log(callflow); callback && callback(null, callflow); }); }); @@ -3753,17 +3670,79 @@ console.log(_data); ); }, - usersUpdateCallflowFaxing: function(callflow, callback) { - var self = this; + usersUpdateCallflowFaxing: function(user, faxbox, callflow, callback) { + var self = this, + baseCallflow = { + type: 'faxing', + owner_id: faxbox.owner_id, + numbers: [ faxbox.caller_id ], + flow: { + module: 'faxbox', + children: {}, + data: { + faxbox_id: faxbox.id + } + } + }; + + callflow = $.extend(true, {}, baseCallflow, callflow); if(callflow.id) { - self.usersUpdateCallflow(callflow, function(callflow) { - callback && callback(callflow); + self.callApi({ + resource: 'faxbox.update', + data:{ + accountId: self.accountId, + faxboxId: faxbox.id, + data: faxbox + }, + success: function(_data, status) { + self.usersUpdateCallflow(callflow, function(callflow) { + callback && callback(callflow); + }); + }, + error: function(_data, status) { + console.log(_data, status); + } }); } else { - self.usersCreateCallflow(callflow, function(callflow) { - callback && callback(callflow); + var defaultFaxbox = { + name: user.first_name.concat(' ', user.last_name, self.i18n.active().users.faxing.defaultSettings.nameExtension), + caller_name: user.first_name.concat(' ', user.last_name), + fax_header: monster.config.company.name.concat(self.i18n.active().users.faxing.defaultSettings.headerExtension), + fax_identity: monster.util.formatPhoneNumber(faxbox.caller_id), + smtp_permission_list: [], + retries: 3, + fax_timezone: user.timezone, + notifications: { + inbound: { + email: { + send_to: user.email + } + }, + outbound: { + email: { + send_to: user.email + } + } + } + }; + + faxbox = $.extend(true, {}, defaultFaxbox, faxbox); + + self.callApi({ + resource: 'faxbox.create', + data: { + accountId: self.accountId, + data: faxbox + }, + success: function(_data, status) { + callflow.flow.data.faxbox_id = _data.data.id; + + self.usersCreateCallflow(callflow, function(callflow) { + callback && callback(callflow); + }); + } }); } }, @@ -3821,8 +3800,26 @@ console.log(_data); _.each(callflows, function(callflow) { if(callflow.type === 'faxing') { listRequests.push(function(subCallback) { - self.usersDeleteCallflow(callflow.id, function(data) { - subCallback(null, data); + self.callApi({ + resource: 'callflow.get', + data: { + accountId: self.accountId, + callflowId: callflow.id + }, + success: function(data, status) { + self.callApi({ + resource: 'faxbox.delete', + data: { + accountId: self.accountId, + faxboxId: data.data.flow.data.faxbox_id + }, + success: function(_data, status) { + self.usersDeleteCallflow(callflow.id, function(results) { + subCallback(null, results); + }); + } + }); + } }); }); } diff --git a/views/users-feature-faxing.html b/views/users-feature-faxing.html index d3441a9..32e143e 100644 --- a/views/users-feature-faxing.html +++ b/views/users-feature-faxing.html @@ -10,86 +10,35 @@
+

{{replaceVar i18n.users.faxing.text this.user.email }}

- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- +
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
-
- -
- -
-
{{#if faxbox.cloud_connector_claim_url}}
- +
{{/if}} -
- -
- -
+ +
+
+   
-
- -
- -
+
+

{{ i18n.users.faxing.helpOne }}{{ i18n.users.faxing.helpTwo }}

- +
From d9c4004f74b26fbcead0d61cbcaa1f9433685e48 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Tue, 29 Jul 2014 17:37:02 -0700 Subject: [PATCH 3/4] UI-294: Add default faxbox settings --- submodules/users/users.js | 46 ++++++++++++++++----------------- views/users-feature-faxing.html | 4 +-- 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/submodules/users/users.js b/submodules/users/users.js index 525a0d6..b5bb305 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -1470,7 +1470,7 @@ define(function(require){ }); featureTemplate.find('.save').on('click', function() { - var faxboxData = form2object('faxbox_form', '.', true), + var newNumber = featureTemplate.find('#caller_id').val(), args = { openedTab: 'features', callback: function() { @@ -1479,13 +1479,7 @@ define(function(require){ }; if ( switchFeature.bootstrapSwitch('status') ) { - faxboxData.owner_id = faxboxData.hasOwnProperty('owner_id') ? faxboxData.owner_id : data.user.id; - - if ( data.hasOwnProperty('faxbox') ) { - faxboxData.id = data.faxbox.id; - } - - self.usersUpdateFaxing(data, faxboxData, function(results) { + self.usersUpdateFaxing(data, newNumber, function(results) { args.userId = results.callflow.owner_id; self.usersRender(args); @@ -3626,7 +3620,7 @@ define(function(require){ ); }, - usersUpdateFaxing: function(data, faxboxData, globalCallback) { + usersUpdateFaxing: function(data, newNumber, globalCallback) { var self = this; monster.parallel({ @@ -3642,8 +3636,7 @@ define(function(require){ } }); - self.usersUpdateCallflowFaxing(data.user, faxboxData, baseCallflow, function(callflow) { -console.log(callflow); + self.usersUpdateCallflowFaxing(data, newNumber, baseCallflow, function(callflow) { callback && callback(null, callflow); }); }); @@ -3670,24 +3663,32 @@ console.log(callflow); ); }, - usersUpdateCallflowFaxing: function(user, faxbox, callflow, callback) { + usersUpdateCallflowFaxing: function(data, newNumber, callflow, callback) { var self = this, + user = data.user, + faxbox = data.faxbox, baseCallflow = { type: 'faxing', - owner_id: faxbox.owner_id, - numbers: [ faxbox.caller_id ], + owner_id: user.id, + numbers: [ newNumber ], flow: { module: 'faxbox', children: {}, data: { - faxbox_id: faxbox.id + faxbox_id: faxbox ? faxbox.id : '' } } + }, + number = { + caller_id: newNumber, + fax_identity: monster.util.formatPhoneNumber(newNumber) }; callflow = $.extend(true, {}, baseCallflow, callflow); - if(callflow.id) { + if( callflow.hasOwnProperty('id') ) { + faxbox = $.extend(true, {}, faxbox, number); + self.callApi({ resource: 'faxbox.update', data:{ @@ -3699,21 +3700,17 @@ console.log(callflow); self.usersUpdateCallflow(callflow, function(callflow) { callback && callback(callflow); }); - }, - error: function(_data, status) { - console.log(_data, status); } }); - } - else { + } else { var defaultFaxbox = { name: user.first_name.concat(' ', user.last_name, self.i18n.active().users.faxing.defaultSettings.nameExtension), caller_name: user.first_name.concat(' ', user.last_name), fax_header: monster.config.company.name.concat(self.i18n.active().users.faxing.defaultSettings.headerExtension), - fax_identity: monster.util.formatPhoneNumber(faxbox.caller_id), + fax_timezone: user.timezone, smtp_permission_list: [], + owner_id: user.id, retries: 3, - fax_timezone: user.timezone, notifications: { inbound: { email: { @@ -3728,12 +3725,13 @@ console.log(callflow); } }; - faxbox = $.extend(true, {}, defaultFaxbox, faxbox); + faxbox = $.extend(true, {}, defaultFaxbox, number); self.callApi({ resource: 'faxbox.create', data: { accountId: self.accountId, + userId: user.id, data: faxbox }, success: function(_data, status) { diff --git a/views/users-feature-faxing.html b/views/users-feature-faxing.html index 32e143e..c3eca17 100644 --- a/views/users-feature-faxing.html +++ b/views/users-feature-faxing.html @@ -22,14 +22,14 @@
- {{#if faxbox.cloud_connector_claim_url}} + {{#if faxbox.cloud_connector_claim_url}}
- {{/if}} + {{/if}}
From 45c583707e892cda0191050312bf27b7fbdd6e76 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Fri, 8 Aug 2014 12:30:50 -0700 Subject: [PATCH 4/4] UI-294: Use correct user email address and handle DELETE faxbox endpoint not working --- submodules/users/users.js | 20 ++++++++++++++------ views/users-feature-faxing.html | 4 ++++ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/submodules/users/users.js b/submodules/users/users.js index b5bb305..108bad9 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -2279,8 +2279,12 @@ define(function(require){ } } - if('differentEmail' in userData.extra) { - userData.email = userData.extra.differentEmail ? userData.extra.email : userData.username; + if('differentEmail' in userData.extra && userData.extra.differentEmail) { + if ( 'email' in userData.extra ) { + userData.email = userData.extra.email + } + } else { + userData.email = userData.username; } if('language' in userData.extra) { @@ -3652,7 +3656,7 @@ define(function(require){ data.user.smartpbx.faxing.enabled = true; self.usersUpdateUser(data.user, function(user) { - callback && callback(null, user); + callback && callback(null, user.data); }); } } @@ -3708,9 +3712,7 @@ define(function(require){ caller_name: user.first_name.concat(' ', user.last_name), fax_header: monster.config.company.name.concat(self.i18n.active().users.faxing.defaultSettings.headerExtension), fax_timezone: user.timezone, - smtp_permission_list: [], owner_id: user.id, - retries: 3, notifications: { inbound: { email: { @@ -3809,12 +3811,18 @@ define(function(require){ resource: 'faxbox.delete', data: { accountId: self.accountId, - faxboxId: data.data.flow.data.faxbox_id + faxboxId: data.data.flow.data.faxbox_id, + generateError: false }, success: function(_data, status) { self.usersDeleteCallflow(callflow.id, function(results) { subCallback(null, results); }); + }, + error: function(_data, error) { + self.usersDeleteCallflow(callflow.id, function(results) { + subCallback(null, results); + }); } }); } diff --git a/views/users-feature-faxing.html b/views/users-feature-faxing.html index c3eca17..a7fca75 100644 --- a/views/users-feature-faxing.html +++ b/views/users-feature-faxing.html @@ -10,7 +10,11 @@
+ {{#if faxbox}} +

{{replaceVar i18n.users.faxing.text this.faxbox.notifications.inbound.email.send_to}}

+ {{else}}

{{replaceVar i18n.users.faxing.text this.user.email }}

+ {{/if}}