diff --git a/i18n/en-US.json b/i18n/en-US.json index 2cc4871d..8d10b3d2 100644 --- a/i18n/en-US.json +++ b/i18n/en-US.json @@ -481,6 +481,7 @@ "add": "Add User", "addExtension": "Add an extension to this user", "addNewExtension": "Extension number: ", + "extensionAlreadyExist": "Already exists", "addFromSpare": "Add from Spare Numbers", "addFromSpareDevices": "Add from Spare Devices", "buy": "Buy Numbers", diff --git a/submodules/users/users.js b/submodules/users/users.js index b3f6e375..8b26c2ec 100644 --- a/submodules/users/users.js +++ b/submodules/users/users.js @@ -833,6 +833,21 @@ define(function(require) { listExtensions.append(newLineTemplate); existingExtensions.push(nextExtension); + + newLineTemplate.find('.extesion-already-exist').hide(); + + newLineTemplate.find('.input-extension ').on('keyup', function() { + var val = $(this).val(); + + if (existingExtensions.indexOf(val) >= 0) { + newLineTemplate.find('.extesion-already-exist').show(); + template.find('.save-extensions').attr('disabled', true) + return; + } + + newLineTemplate.find('.extesion-already-exist').hide(); + template.find('.save-extensions').attr('disabled', false) + }); }); template.on('click', '.remove-extension', function() { @@ -854,6 +869,7 @@ define(function(require) { if (index > -1) { existingExtensions.splice(index, 1); + template.find('.save-extensions').attr('disabled', false) } $(this).parents('.item-row').remove(); @@ -4896,7 +4912,7 @@ define(function(require) { }, function(devices) { callback(null, devices); }); - } + }, }, function(err, results) { callback && callback(results); }); diff --git a/submodules/users/users.scss b/submodules/users/users.scss index 59412f65..9ae2cd5b 100644 --- a/submodules/users/users.scss +++ b/submodules/users/users.scss @@ -456,6 +456,15 @@ line-height: 32px; } +#users_container .list-wrapper .item-row .extesion-already-exist { + margin: 0; + padding: 0; + font-size: 12px; + font-style: italic; + color: #ee1212; + font-weight: 600; +} + #users_container .list-wrapper .empty-search-row, #users_container .list-wrapper .empty-row { display: none; diff --git a/submodules/users/views/newExtension.html b/submodules/users/views/newExtension.html index 43bd9427..9380a23a 100644 --- a/submodules/users/views/newExtension.html +++ b/submodules/users/views/newExtension.html @@ -1,7 +1,8 @@