Browse Source

KAZOO-2452: Changed the nextExtension/nextVMBox function to work better (supposedly hehehe)

4.3
Jean-Roch Maitre 12 years ago
parent
commit
f3760e60ca
4 changed files with 44 additions and 20 deletions
  1. +0
    -3
      submodules/callLogs/callLogs.js
  2. +0
    -2
      submodules/devices/devices.js
  3. +43
    -14
      submodules/users/users.js
  4. +1
    -1
      views/users-creation.html

+ 0
- 3
submodules/callLogs/callLogs.js View File

@ -100,7 +100,6 @@ define(function(require){
// toDate: monster.util.dateToGregorian(toDate)
// },
// success: function(data, status) {
// console.log('success');
// }
// });
});
@ -306,8 +305,6 @@ define(function(require){
}
});
console.log(result);
result.sort(function(a, b) {
return b.timestamp - a.timestamp;
})


+ 0
- 2
submodules/devices/devices.js View File

@ -348,12 +348,10 @@ define(function(require){
e.preventDefault();
var number = templateDevice.find('.restriction-matcher-input').val(),
matched = false;
console.log(number);
templateDevice.find('.restriction-matcher-label').each(function() {
var label = $(this),
regex = new RegExp(data.extra.restrictions[label.data('restriction')].regex);
console.log(regex)
if(regex.test(number)) {
label.show();
if(matched) {


+ 43
- 14
submodules/users/users.js View File

@ -651,7 +651,7 @@ define(function(require){
});
template.on('click', '#add_extensions', function() {
var nextExtension = (parseInt(existingExtensions[existingExtensions.length - 1]) || 2000) + 1 + '',
var nextExtension = parseInt(self.usersGetNextInt(existingExtensions)) + '',
dataTemplate = {
recommendedExtension: nextExtension
},
@ -1243,8 +1243,46 @@ define(function(require){
});
},
/* Helper function that takes an array of number in parameter, sorts it, and returns the first number not in the array, greater than the minVal */
usersGetNextInt: function(arr) {
var orderedArr = arr,
prevVal = 0,
minVal = 2000,
increment = 1;
orderedArr.sort(function(a,b) {
var parsedA = parseInt(a),
parsedB = parseInt(b);
return parsedA > parsedB ? 1 : -1;
});
_.each(orderedArr, function(val) {
var curr = parseInt(val);
/* If we already stored a previous value */
if(prevVal) {
if(curr - prevVal !== increment) {
return prevVal + increment;
}
}
/* Otherwise, if we didn't, and the current value is greater than the minVal, we return the minVal */
else if(curr > minVal) {
return minVal;
}
/* We don't want to return value lower than our min val, so we only store prevVal that are greater than the minVal */
if(curr >= minVal) {
prevVal = curr;
}
});
return (prevVal) ? prevVal + increment : minVal;
},
usersFormatAddUser: function(data) {
var formattedData = {
var self = this,
formattedData = {
sendToSameEmail: true,
nextExtension: '',
nextVMBox: '',
@ -1263,24 +1301,15 @@ define(function(require){
});
});
arrayExtensions.sort(function(a, b) {
return parseInt(a) > parseInt(b);
});
//Set the Next extension to 2001 if there are no extensions in the system, or to the latest extension + 1 if there are
formattedData.nextExtension = (parseInt(arrayExtensions[arrayExtensions.length - 1] || 2000) + 1) + '';
formattedData.nextExtension = parseInt(self.usersGetNextInt(arrayExtensions)) + '';
_.each(data.vmboxes, function(vmbox) {
formattedData.listVMBoxes[vmbox.mailbox] = vmbox;
arrayVMBoxes.push(vmbox.mailbox);
});
arrayVMBoxes.sort(function(a, b) {
return parseInt(a) > parseInt(b);
});
//Set the VMBox Number to 2001 if there are no VMBox in the system, or to the latest vmbox number + 1 if there are
formattedData.nextVMBox = (parseInt(arrayVMBoxes[arrayVMBoxes.length - 1] || 2000) + 1) + '';
formattedData.nextVMBox = parseInt(self.usersGetNextInt(arrayVMBoxes)) + '';
return formattedData;
},
@ -2487,7 +2516,7 @@ define(function(require){
name: callerIdName
}
},
email: data.extra.differentEmail ? data.extra.email : data.user.userName,
email: data.extra.differentEmail ? data.extra.email : data.user.username,
priv_level: 'user',
timezone: defaultTimezone
}, data.user),


+ 1
- 1
views/users-creation.html View File

@ -37,7 +37,7 @@
<div class="split-title">{{ i18n.users.dialogCreationUser.vmboxNumber }}</div>
<div class="split-field">
<i class="icon-telicon-voicemail"></i>
<input required maxlength="6" class="input-mini" type="text" name="vmbox.number" id="extension" placeholder="{{i18n.users.dialogCreationUser.extension}}" value="{{nextExtension}}"/>
<input required maxlength="6" class="input-mini" type="text" name="vmbox.number" id="extension" placeholder="{{i18n.users.dialogCreationUser.extension}}" value="{{nextVMBox}}"/>
</div>
</div>
</div>


Loading…
Cancel
Save