Skip to content

Commit

Permalink
[5.4] MSPB-366: Validate if extesion already exist on users managemen…
Browse files Browse the repository at this point in the history
…t section
  • Loading branch information
masmerino13 committed Jun 11, 2024
1 parent 4665cc1 commit b18d940
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions i18n/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 17 additions & 1 deletion submodules/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
Expand Down Expand Up @@ -4896,7 +4912,7 @@ define(function(require) {
}, function(devices) {
callback(null, devices);
});
}
},
}, function(err, results) {
callback && callback(results);
});
Expand Down
9 changes: 9 additions & 0 deletions submodules/users/users.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions submodules/users/views/newExtension.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<div class="item-row larger">
<div class="number">
{{ i18n.users.addNewExtension }}
<input type="text" class="input-extension" value="{{recommendedExtension}}"></input>
<a class="cancel-extension-link monster-link"><i class="monster-red fa fa-times"></i></a>
{{ i18n.users.addNewExtension }}
<input type="text" class="input-extension" value="{{recommendedExtension}}"></input>
<a class="cancel-extension-link monster-link"><i class="monster-red fa fa-times"></i></a>
</div>
<p class="extesion-already-exist">{{ i18n.users.extensionAlreadyExist }}</p>
</div>

0 comments on commit b18d940

Please sign in to comment.