From 3d1f4385a66d3e3abaef8b1c5f133a9060d42078 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Thu, 8 Dec 2016 17:05:21 -0800 Subject: [PATCH 1/9] UI-2500: Add prompt to create faxbox with custom notification email --- submodules/strategy/strategy.js | 26 +++++++++++++++----------- views/strategy-faxingnum.html | 6 ++++++ 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index c8931df..cd83cba 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1104,8 +1104,8 @@ define(function(require){ self.strategyRefreshTemplate(parentContainer, strategyData); }); }; - if(mainFaxing.numbers.length <= 1 - && mainFaxing.numbers[0] === "undefinedfaxing") { + + if(mainFaxing.numbers.length <= 1 && mainFaxing.numbers[0] === "undefinedfaxing") { mainFaxing.numbers = []; } mainFaxing.numbers = mainFaxing.numbers.concat(numbers); @@ -1113,8 +1113,11 @@ define(function(require){ updateCallflow(); } else { + var email = window.prompt('Email address for the main faxbox'); + self.strategyBuildFaxbox({ data: { + email: email, number: mainFaxing.numbers[0] }, success: function(data) { @@ -1158,6 +1161,14 @@ define(function(require){ monster.pub('common.numbers.dialogSpare', args); }); + container.on('click', '.action-links .edit-email', function(e) { + event.preventDefault(); + + var email = window.prompt('Email address for the main faxbox'); + + console.log(email); + }); + container.on('click', '.action-links .buy-link', function(e) { e.preventDefault(); monster.pub('common.buyNumbers', { @@ -2519,14 +2530,11 @@ define(function(require){ return results; }, - strategyBuildFaxbox: function(args) { var self = this; self.strategyGetAccount({ success: function(account) { - var email = account.contact && account.contact.technical && account.contact.technical.hasOwnProperty('email') ? account.contact.technical.email : undefined; - args.data = { name: account.name + self.i18n.active().strategy.faxing.nameExtension, caller_name: account.name, @@ -2538,21 +2546,17 @@ define(function(require){ notifications: { inbound: { email: { - send_to: email + send_to: args.data.email } }, outbound: { email: { - send_to: email + send_to: args.data.email } } } }; - if(!email) { - delete args.data.notifications; - } - self.strategyCreateFaxbox(args); } }); diff --git a/views/strategy-faxingnum.html b/views/strategy-faxingnum.html index 775c44a..feb835f 100644 --- a/views/strategy-faxingnum.html +++ b/views/strategy-faxingnum.html @@ -15,6 +15,12 @@
{{ i18n.close }}
From e59ffa8eae4a48404336775f3cc0a042b95674f6 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Fri, 9 Dec 2016 13:24:20 -0800 Subject: [PATCH 4/9] UI-2500: Wrap faxbox requests in dedicated methods --- submodules/strategy/strategy.js | 54 +++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index ee8c2b6..64b1126 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1168,22 +1168,18 @@ define(function(require){ monster.waterfall([ function(callback) { - self.callApi({ - resource: 'faxbox.get', + self.strategyGetFaxbox({ data: { - accountId: self.accountId, - faxboxId: strategyData.callflows.MainFaxing.flow.data.id + faxboxId: strategyData.callflow.MainFaxing.flow.data.id }, - success: function(data, status) { - callback(null, data.data); + success: function(faxbox) { + callback(null, faxbox); } }); }, function(faxboxData, callback) { - self.callApi({ - resource: 'faxbox.update', + self.strategyUpdateFaxbox({ data: { - accountId: self.accountId, faxboxId: faxboxData.id, data: $.extend(true, {}, faxboxData, { notifications: { @@ -1198,10 +1194,10 @@ define(function(require){ } } } - }) + }); }, - success: function(data, status) { - callback(null, data.data); + success: function(updatedFaxbox) { + callback(null, updatedFaxbox); } }); } @@ -3435,6 +3431,23 @@ define(function(require){ }); }, + strategyGetFaxbox: function(args) { + var self = this; + + self.callApi({ + resource: 'faxbox.get', + data: $.extend(true, { + accountId: self.accountId + }, args.data), + success: function(data, status) { + args.hasOwnProperty('success') && args.success(data.data); + }, + error: function(data, status) { + args.hasOwnProperty('error') && args.error(); + } + }); + }, + strategyCreateFaxbox: function(args) { var self = this; @@ -3453,6 +3466,23 @@ define(function(require){ }); }, + strategyUpdateFaxbox: function(args) { + var self = this; + + self.callApi({ + resource: 'faxbox.update', + data: $.extend(true, { + accountId: self.accountId + }, args.data), + success: function(data, status) { + args.hasOwnProperty('success') && args.success(data.data); + }, + error: function(data, status) { + args.hasOwnProperty('error') && args.error(); + } + }); + }, + strategyDeleteFaxbox: function(args) { var self = this; From ae844081fe965a337cd557a67a5d2fc73bc02f60 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Fri, 9 Dec 2016 13:35:05 -0800 Subject: [PATCH 5/9] UI-2500: Fix faxbox ID access --- submodules/strategy/strategy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index 64b1126..16c2204 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1170,7 +1170,7 @@ define(function(require){ function(callback) { self.strategyGetFaxbox({ data: { - faxboxId: strategyData.callflow.MainFaxing.flow.data.id + faxboxId: strategyData.callflows.MainFaxing.flow.data.id }, success: function(faxbox) { callback(null, faxbox); From a6e143b66117c6ccf0ae727d4cc303bb167c4ee1 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Fri, 9 Dec 2016 13:41:32 -0800 Subject: [PATCH 6/9] UI-2500: Only set inbound notification email for main faxbox --- submodules/strategy/strategy.js | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index 16c2204..aafd348 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1187,11 +1187,6 @@ define(function(require){ email: { send_to: email } - }, - outbound: { - email: { - send_to: email - } } } }); @@ -2587,11 +2582,6 @@ define(function(require){ email: { send_to: args.data.email } - }, - outbound: { - email: { - send_to: args.data.email - } } } }; From bdf75bcd7cecd6255d531dec6815d40738ba090e Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Fri, 9 Dec 2016 13:48:11 -0800 Subject: [PATCH 7/9] UI-2500: Remove unnecessary semi-column --- submodules/strategy/strategy.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index aafd348..8a67297 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1189,7 +1189,7 @@ define(function(require){ } } } - }); + }) }, success: function(updatedFaxbox) { callback(null, updatedFaxbox); From 7ffcc435e7ed740462a0d29c961a24e251663aa5 Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Tue, 13 Dec 2016 12:31:22 -0800 Subject: [PATCH 8/9] UI-2500: Add new popup to create/edit main faxbox --- i18n/en-US.json | 18 +++- submodules/strategy/strategy.js | 123 ++++++++++++++++++++++------ views/strategy-faxingnum.html | 2 +- views/strategy-popupEditFaxbox.html | 30 +++++++ 4 files changed, 146 insertions(+), 27 deletions(-) create mode 100644 views/strategy-popupEditFaxbox.html diff --git a/i18n/en-US.json b/i18n/en-US.json index dd26527..96f9cea 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -908,7 +908,8 @@ "__version": "3.22", "faxing": { "nameExtension": "'s Main Faxbox", - "headerExtension": " Fax Printer" + "headerExtension": " Fax Printer", + "editFaxbox": "Edit Faxbox" }, "__comment": "UI-1774: Adding custom greetings to conference", "__version": "3.22", @@ -922,7 +923,20 @@ "__comment": "UI-2499: Handle case where greeting has been deleted", "__version": "4.0", - "greetingMissing": "The greeting that was configured on this Virtual Receptionist is missing. Please setup a new greeting." + "greetingMissing": "The greeting that was configured on this Virtual Receptionist is missing. Please setup a new greeting.", + + "__comment": "", + "__version": "3.22", + "popupEditFaxbox": { + "titles": { + "create": "Create Main Faxbox", + "edit": "Edit Main Faxbox" + }, + "text": "Main Faxbox", + "labels": { + "inbound": "Inbound Notification Email" + } + } }, "callLogs": { diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index 8a67297..0c0f13f 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1113,18 +1113,53 @@ define(function(require){ updateCallflow(); } else { - var email = window.prompt('Email address for the main faxbox'); + var template = $(monster.template(self, 'strategy-popupEditFaxbox')), + popup = monster.ui.dialog(template, { + title: 'Create Main Faxbox', + position: ['center', 20], + hideClose: true + }); - self.strategyBuildFaxbox({ - data: { - email: email, - number: mainFaxing.numbers[0] - }, - success: function(data) { - mainFaxing.flow.data.id = data.id; - updateCallflow(); - } - }); + template + .find('.cancel-link') + .on('click', function(event) { + event.preventDefault(); + + popup.dialog('close').remove(); + }); + + template + .find('.save') + .on('click', function(event) { + event.preventDefault(); + + var $form = template.find('#faxbox_form'), + email = monster.ui.getFormData('faxbox_form').email; + + monster.ui.validate($form, { + rules: { + email: { + required: true, + email: true + } + } + }); + + if (monster.ui.valid($form)) { + popup.dialog('close').remove(); + + self.strategyBuildFaxbox({ + data: { + email: email, + number: mainFaxing.numbers[0] + }, + success: function(data) { + mainFaxing.flow.data.id = data.id; + updateCallflow(); + } + }); + } + }); } } }, @@ -1164,8 +1199,6 @@ define(function(require){ container.on('click', '.action-links .edit-email', function(e) { event.preventDefault(); - var email = window.prompt('Email address for the main faxbox'); - monster.waterfall([ function(callback) { self.strategyGetFaxbox({ @@ -1173,7 +1206,55 @@ define(function(require){ faxboxId: strategyData.callflows.MainFaxing.flow.data.id }, success: function(faxbox) { - callback(null, faxbox); + var template = $(monster.template(self, 'strategy-popupEditFaxbox', { + email: faxbox.notifications.inbound.email.send_to + })), + popup = monster.ui.dialog(template, { + title: 'Edit Main Faxbox', + position: ['center', 20] + }); + + template + .find('.cancel-link') + .on('click', function(event) { + event.preventDefault(); + + popup.dialog('close').remove(); + + callback(true, null); + }); + + template + .find('.save') + .on('click', function(event) { + event.preventDefault(); + + var $form = template.find('#faxbox_form'), + email = monster.ui.getFormData('faxbox_form').email; + + monster.ui.validate($form, { + rules: { + email: { + required: true, + email: true + } + } + }); + + if (monster.ui.valid($form)) { + popup.dialog('close').remove(); + + callback(null, _.extend(faxbox, { + notifications: { + inbound: { + email: { + send_to: email + } + } + } + })); + } + }); } }); }, @@ -1181,15 +1262,7 @@ define(function(require){ self.strategyUpdateFaxbox({ data: { faxboxId: faxboxData.id, - data: $.extend(true, {}, faxboxData, { - notifications: { - inbound: { - email: { - send_to: email - } - } - } - }) + data: faxboxData }, success: function(updatedFaxbox) { callback(null, updatedFaxbox); @@ -1198,7 +1271,9 @@ define(function(require){ } ], function(err, results) { - toastr.success('Main Fabox Email Successfully Changed'); + if (!err) { + toastr.success('Main Fabox Email Successfully Changed'); + } } ); }); diff --git a/views/strategy-faxingnum.html b/views/strategy-faxingnum.html index feb835f..5c5cae7 100644 --- a/views/strategy-faxingnum.html +++ b/views/strategy-faxingnum.html @@ -18,7 +18,7 @@ {{#unless actionLinksEnabled}} - Edit Fax Recipient + {{i18n.strategy.faxing.editFaxbox}} {{/unless}} {{#if actionLinksEnabled}} diff --git a/views/strategy-popupEditFaxbox.html b/views/strategy-popupEditFaxbox.html new file mode 100644 index 0000000..0858b1c --- /dev/null +++ b/views/strategy-popupEditFaxbox.html @@ -0,0 +1,30 @@ +
+
+
+ +
+ {{i18n.strategy.popupEditFaxbox.text}} +
+ +
+
+
+ +
+ +
+
+
+
+ +
+
+ {{#if email}} + {{ i18n.cancel }} + {{/if}} + +
+
+
From 11946515179598d1a2577400b7ea7f5c7ae42fae Mon Sep 17 00:00:00 2001 From: Joris Tirado Date: Tue, 13 Dec 2016 12:33:30 -0800 Subject: [PATCH 9/9] UI-2500: Set edit faxbox popup titles with i18n references --- submodules/strategy/strategy.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/submodules/strategy/strategy.js b/submodules/strategy/strategy.js index 0c0f13f..5eb9e63 100644 --- a/submodules/strategy/strategy.js +++ b/submodules/strategy/strategy.js @@ -1115,7 +1115,7 @@ define(function(require){ else { var template = $(monster.template(self, 'strategy-popupEditFaxbox')), popup = monster.ui.dialog(template, { - title: 'Create Main Faxbox', + title: self.i18n.active().strategy.popupEditFaxbox.titles.create, position: ['center', 20], hideClose: true }); @@ -1210,7 +1210,7 @@ define(function(require){ email: faxbox.notifications.inbound.email.send_to })), popup = monster.ui.dialog(template, { - title: 'Edit Main Faxbox', + title: self.i18n.active().strategy.popupEditFaxbox.titles.edit, position: ['center', 20] });