Browse Source

Merge remote-tracking branch 'origin/master'

4.3
Jean-Roch Maitre 12 years ago
parent
commit
32e24eb4bc
6 changed files with 294 additions and 107 deletions
  1. +15
    -4
      i18n/en-US.json
  2. +15
    -4
      i18n/fr-FR.json
  3. +40
    -33
      submodules/strategy/strategy.js
  4. +17
    -0
      submodules/users/users.css
  5. +175
    -52
      submodules/users/users.js
  6. +32
    -14
      views/users-feature-faxing.html

+ 15
- 4
i18n/en-US.json View File

@ -414,10 +414,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.",


+ 15
- 4
i18n/fr-FR.json View File

@ -394,10 +394,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.",


+ 40
- 33
submodules/strategy/strategy.js View File

@ -1751,38 +1751,6 @@ define(function(require){
}
});
if(!parallelRequests["MainCallflow"]) {
parallelRequests["MainCallflow"] = function(callback) {
monster.request({
resource: 'strategy.callflows.add',
data: {
accountId: self.accountId,
data: {
contact_list: {
exclude: false
},
numbers: ["undefined"],
name: "MainCallflow",
type: "main",
flow: {
children: {},
data: {
timezone: monster.apps["auth"].currentAccount.timezone
},
module: "temporal_route"
}
}
},
success: function(data, status) {
/* If they don't have a main callflow, check if the feature codes are enabled, and create them if not */
self.strategyCreateFeatureCodes(function() {
callback(null, data.data);
});
}
});
}
}
if(!parallelRequests["MainConference"]) {
parallelRequests["MainConference"] = function(callback) {
monster.request({
@ -1839,7 +1807,46 @@ define(function(require){
});
monster.parallel(parallelRequests, function(err, results) {
callback(results);
if(!parallelRequests["MainCallflow"]) {
monster.request({
resource: 'strategy.callflows.add',
data: {
accountId: self.accountId,
data: {
contact_list: {
exclude: false
},
numbers: ["undefined"],
name: "MainCallflow",
type: "main",
flow: {
children: {
'_': {
children: {},
data: {
id: results["MainOpenHours"].id
},
module:"callflow"
}
},
data: {
timezone: monster.apps["auth"].currentAccount.timezone
},
module: "temporal_route"
}
}
},
success: function(data, status) {
/* If they don't have a main callflow, check if the feature codes are enabled, and create them if not */
self.strategyCreateFeatureCodes(function() {
results["MainCallflow"] = data.data;
callback(results);
});
}
});
} else {
callback(results);
}
});
}
});


+ 17
- 0
submodules/users/users.css View File

@ -715,6 +715,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 */
.smart-edit-popup {
width: 430px;


+ 175
- 52
submodules/users/users.js View File

@ -1248,14 +1248,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);
}
});
}
},
function(err, results) {
results.user = currentUser;
self.usersRenderFaxing(results);
if ( typeof results.callflows !== 'undefined' ) {
self.callApi({
resource: 'faxbox.get',
data: {
accountId: self.accountId,
faxboxId: results.callflows.flow.data.faxbox_id
},
success: function(_data) {
results.faxbox = _data.data;
results.faxbox.id = results.callflows.flow.data.faxbox_id;
self.usersRenderFaxboxes(results);
},
error: function() {
self.usersRenderFaxboxes(results);
}
});
} else {
self.usersRenderFaxboxes(results);
}
}
);
});
@ -1428,16 +1460,25 @@ define(function(require){
},
usersFormatFaxingData: function(data) {
var listNumbers = [];
var tempList = [],
listNumbers = {};
_.each(data.numbers, function(val, key){
tempList.push(key);
});
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[data.callflows.numbers[0]] = data.callflows.numbers[0]
}
}
_.each(data.numbers, function(value, number) {
listNumbers.push(number);
_.each(tempList, function(val, key) {
listNumbers[val] = val;
});
data.extra = $.extend(true, {}, data.extra, {
@ -1500,17 +1541,27 @@ define(function(require){
});
},
usersFormatConferencingData: function(data) {
return data;
},
usersRenderFaxing: function(data) {
usersRenderFaxboxes: function(data) {
var self = this,
data = self.usersFormatFaxingData(data),
featureTemplate = $(monster.template(self, 'users-feature-faxing', data)),
switchFeature = featureTemplate.find('.switch').bootstrapSwitch();
monster.ui.prettyCheck.create(featureTemplate.find('.content'));
if ( !_.isEmpty(data.extra.listNumbers) ) {
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();
});
@ -1520,7 +1571,7 @@ define(function(require){
});
featureTemplate.find('.save').on('click', function() {
var newNumber = popup.find('.dropdown-numbers').val(),
var newNumber = featureTemplate.find('#caller_id').val(),
args = {
openedTab: 'features',
callback: function() {
@ -1528,34 +1579,24 @@ define(function(require){
}
};
if(switchFeature.bootstrapSwitch('status')) {
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;
} else {
self.usersDeleteFaxing(data.user.id, function() {
args.userId = data.user.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);
}
},
usersRenderHotdesk: function(currentUser) {
@ -2356,8 +2397,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) {
@ -3724,18 +3769,7 @@ define(function(require){
monster.parallel({
callflow: function(callback) {
var baseCallflow = {
type: 'faxing',
owner_id: data.user.id,
numbers: [ newNumber ],
flow: {
data: {
owner_id: data.user.id
},
module: 'receive_fax',
children: {}
}
};
var baseCallflow = {};
self.usersListCallflowsUser(data.user.id, function(callflows) {
_.each(callflows, function(callflow) {
@ -3746,7 +3780,7 @@ define(function(require){
}
});
self.usersUpdateCallflowFaxing(baseCallflow, function(callflow) {
self.usersUpdateCallflowFaxing(data, newNumber, baseCallflow, function(callflow) {
callback && callback(null, callflow);
});
});
@ -3762,7 +3796,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);
});
}
}
@ -3773,17 +3807,82 @@ define(function(require){
);
},
usersUpdateCallflowFaxing: function(callflow, callback) {
var self = this;
usersUpdateCallflowFaxing: function(data, newNumber, callflow, callback) {
var self = this,
user = data.user,
faxbox = data.faxbox,
baseCallflow = {
type: 'faxing',
owner_id: user.id,
numbers: [ newNumber ],
flow: {
module: 'faxbox',
children: {},
data: {
faxbox_id: faxbox ? faxbox.id : ''
}
}
},
number = {
caller_id: newNumber,
fax_identity: monster.util.formatPhoneNumber(newNumber)
};
callflow = $.extend(true, {}, baseCallflow, callflow);
if( callflow.hasOwnProperty('id') ) {
faxbox = $.extend(true, {}, faxbox, number);
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);
});
}
});
}
else {
self.usersCreateCallflow(callflow, function(callflow) {
callback && callback(callflow);
} 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_timezone: user.timezone,
owner_id: user.id,
notifications: {
inbound: {
email: {
send_to: user.email
}
},
outbound: {
email: {
send_to: user.email
}
}
}
};
faxbox = $.extend(true, {}, defaultFaxbox, number);
self.callApi({
resource: 'faxbox.create',
data: {
accountId: self.accountId,
userId: user.id,
data: faxbox
},
success: function(_data, status) {
callflow.flow.data.faxbox_id = _data.data.id;
self.usersCreateCallflow(callflow, function(callflow) {
callback && callback(callflow);
});
}
});
}
},
@ -3841,8 +3940,32 @@ define(function(require){
_.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,
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);
});
}
});
}
});
});
}


+ 32
- 14
views/users-feature-faxing.html View File

@ -10,21 +10,39 @@
</div>
<div class="content{{#unless user.extra.mapFeatures.faxing.active}} disabled{{/unless}}">
{{ i18n.users.faxing.dropdownLabel }}
<select class="dropdown-numbers">
{{#each extra.listNumbers}}
<option value="{{this}}">{{this}}</option>
{{/each}}
</select>
{{#if faxbox}}
<p>{{replaceVar i18n.users.faxing.text this.faxbox.notifications.inbound.email.send_to}}</p>
{{else}}
<p>{{replaceVar i18n.users.faxing.text this.user.email }}</p>
{{/if}}
<form class="form-horizontal" id="faxbox_form">
<div class="control-group">
<label for="caller_id" class="control-label">{{ i18n.users.faxing.form.label.callerId }}</label>
<div class="controls">
<select name="caller_id" id="caller_id">
{{#each extra.listNumbers}}
<option value="{{@key}}"{{#compare @key '===' ../faxbox.caller_id }} selected="true"{{/compare}}>{{formatPhoneNumber @key}}</option>
{{/each}}
</select>
</div>
</div>
{{#if faxbox.cloud_connector_claim_url}}
<div class="control-group">
<label for="printer_link" class="control-label">{{ i18n.users.faxing.form.label.linkToPrinter }}</label>
<div class="controls">
<a id="printer_link" href="{{faxbox.cloud_connector_claim_url}}" target="_blank">{{faxbox.cloud_connector_claim_url}}</a>
</div>
</div>
{{/if}}
</form>
<div class="help-box gray-box">
<div class="wrapper-icon">
&nbsp;<i class="icon-info-sign2"></i>&nbsp;
</div>
<div class="text-wrapper">
<p>{{replaceVar i18n.users.faxing.help this.user.email }}</p>
</div>
</div>
<div class="wrapper-icon">
&nbsp;<i class="icon-info-sign2"></i>&nbsp;
</div>
<div class="text-wrapper">
<p>{{ i18n.users.faxing.helpOne }}<a href="https://tools.google.com/dlpage/cloudprintdriver" target="_blank">{{ i18n.users.faxing.helpTwo }}</a></p>
</div>
</div>
</div>
<div class="actions clearfix">


Loading…
Cancel
Save