Skip to content

Commit

Permalink
UI-1331: Hotpatch only for 3.19, fixing the callback of the buyNumber…
Browse files Browse the repository at this point in the history
… control so we successfuly add them to the user/groups
  • Loading branch information
JRMaitre committed Mar 31, 2015
1 parent 7eadce8 commit 35f9544
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 35 deletions.
37 changes: 20 additions & 17 deletions submodules/groups/groups.js
Original file line number Diff line number Diff line change
Expand Up @@ -994,33 +994,36 @@ define(function(require){
template.on('click', '.actions .buy-link', function(e) {
e.preventDefault();

var $this = $(this);

monster.pub('common.buyNumbers', {
searchType: $(this).data('type'),
callbacks: {
success: function(numbers) {
var countNew = 0;

monster.pub('common.numbers.getListFeatures', function(features) {
_.each(numbers, function(number, k) {
countNew++;

/* Formating number */
number.viewFeatures = $.extend(true, {}, features);
var parentRow = $this.parents('.grid-row'),
callflowId = parentRow.data('callflow_id'),
name = parentRow.data('name');
dataNumbers = [];

var rowTemplate = monster.template(self, 'users-rowSpareNumber', number);
template.find('.empty-row').hide();

template.find('.list-unassigned-items .empty-row').hide();
template.find('.list-unassigned-items').append(rowTemplate);
});
template.find('.item-row').each(function(idx, elem) {
dataNumbers.push($(elem).data('id'));
});

var previous = parseInt(template.find('.unassigned-list-header .count-spare').data('count')),
newTotal = previous + countNew;
_.each(numbers, function(number, idx) {
number.phoneNumber = number.id;
dataNumbers.push(number.phoneNumber);

template.find('.unassigned-list-header .count-spare')
.data('count', newTotal)
.html(newTotal);
template
.find('.list-assigned-items')
.append($(monster.template(self, 'groups-numbersItemRow', { number: number })));
});

template.find('.spare-link.disabled').removeClass('disabled');
self.groupsUpdateNumbers(callflowId, dataNumbers, function(callflowData) {
toastr.success(monster.template(self, '!' + toastrMessages.numbersUpdated, { name: name }));
self.groupsRender({ groupId: callflowData.group_id });
});
},
error: function(error) {
Expand Down
38 changes: 20 additions & 18 deletions submodules/users/users.js
Original file line number Diff line number Diff line change
Expand Up @@ -1264,33 +1264,35 @@ define(function(require){

template.on('click', '.actions .buy-link', function(e) {
e.preventDefault();

var $this = $(this);

monster.pub('common.buyNumbers', {
searchType: $(this).data('type'),
callbacks: {
success: function(numbers) {
var countNew = 0;

monster.pub('common.numbers.getListFeatures', function(features) {
_.each(numbers, function(number, k) {
countNew++;

/* Formating number */
number.viewFeatures = $.extend(true, {}, features);
var name = $this.parents('.grid-row').find('.grid-cell.name').text(),
dataNumbers = $.extend(true, [], extensionsToSave),
userId = $this.parents('.grid-row').data('id');

var rowTemplate = monster.template(self, 'users-rowSpareNumber', number);
template.find('.empty-row').hide();

template.find('.list-unassigned-items .empty-row').hide();
template.find('.list-unassigned-items').append(rowTemplate);
});
template.find('.item-row').each(function(idx, elem) {
dataNumbers.push($(elem).data('id'));
});

var previous = parseInt(template.find('.unassigned-list-header .count-spare').data('count')),
newTotal = previous + countNew;
_.each(numbers, function(number, index) {
number.phoneNumber = number.id;
dataNumbers.push(number.phoneNumber);

template.find('.unassigned-list-header .count-spare')
.data('count', newTotal)
.html(newTotal);
template
.find('.list-assigned-items')
.append($(monster.template(self, 'users-numbersItemRow', { number: number })));
});

template.find('.spare-link.disabled').removeClass('disabled');
self.usersUpdateCallflowNumbers(userId, (currentCallflow || {}).id, dataNumbers, function(callflowData) {
toastr.success(monster.template(self, '!' + toastrMessages.numbersUpdated, { name: name }));
self.usersRender({ userId: callflowData.owner_id });
});
},
error: function(error) {
Expand Down

0 comments on commit 35f9544

Please sign in to comment.