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 @@ +