Skip to content

Commit

Permalink
UI-3119: Use monster toast helper instead of Toastr directly (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
joristirado authored Jul 24, 2018
1 parent 377bfce commit d6e7fb5
Show file tree
Hide file tree
Showing 5 changed files with 227 additions and 121 deletions.
28 changes: 18 additions & 10 deletions submodules/devices/devices.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
define(function(require) {
var $ = require('jquery'),
_ = require('lodash'),
monster = require('monster'),
toastr = require('toastr');
monster = require('monster');

var app = {

Expand Down Expand Up @@ -459,14 +458,20 @@ define(function(require) {
templateDevice.find('#restart_device').on('click', function() {
if (!$(this).hasClass('disabled')) {
self.devicesRestart(data.id, function() {
toastr.success(self.i18n.active().devices.popupSettings.miscellaneous.restart.success);
monster.ui.toast({
type: 'success',
message: self.i18n.active().devices.popupSettings.miscellaneous.restart.success
});
});
}
});

templateDevice.find('#unlock_device').on('click', function() {
self.devicesUnlock(data.mac_address.replace(/:/g, ''), function() {
toastr.success(self.i18n.active().devices.popupSettings.miscellaneous.unlock.success);
monster.ui.toast({
type: 'success',
message: self.i18n.active().devices.popupSettings.miscellaneous.unlock.success
});
});
});

Expand Down Expand Up @@ -494,12 +499,15 @@ define(function(require) {
self.devicesDeleteDevice(deviceId, function(device) {
popup.dialog('close').remove();

toastr.success(self.getTemplate({
name: '!' + self.i18n.active().devices.deletedDevice,
data: {
deviceName: device.name
}
}));
monster.ui.toast({
type: 'success',
message: self.getTemplate({
name: '!' + self.i18n.active().devices.deletedDevice,
data: {
deviceName: device.name
}
})
});

callbackDelete && callbackDelete(device);
});
Expand Down
58 changes: 36 additions & 22 deletions submodules/groups/groups.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
define(function(require) {
var $ = require('jquery'),
_ = require('lodash'),
monster = require('monster'),
toastr = require('toastr');
monster = require('monster');

var app = {

Expand Down Expand Up @@ -1064,12 +1063,15 @@ define(function(require) {
template.find('.delete-group').on('click', function() {
monster.ui.confirm(self.i18n.active().groups.confirmDeleteGroup, function() {
self.groupsDelete(data.group.id, function(data) {
toastr.success(self.getTemplate({
name: '!' + self.i18n.active().groups.groupDeleted,
data: {
name: data.group.name
}
}));
monster.ui.toast({
type: 'success',
message: self.getTemplate({
name: '!' + self.i18n.active().groups.groupDeleted,
data: {
name: data.group.name
}
})
});

self.groupsRender();
});
Expand Down Expand Up @@ -1249,12 +1251,15 @@ define(function(require) {
});

self.groupsUpdateNumbers(callflowId, dataNumbers, function(callflowData) {
toastr.success(self.getTemplate({
name: '!' + toastrMessages.numbersUpdated,
data: {
name: name
}
}));
monster.ui.toast({
type: 'success',
message: self.getTemplate({
name: '!' + toastrMessages.numbersUpdated,
data: {
name: name
}
})
});
self.groupsRender({ groupId: callflowData.group_id });
});
});
Expand All @@ -1281,12 +1286,15 @@ define(function(require) {
});

self.groupsUpdateExtensions(callflowId, extensionsToSave, function(callflowData) {
toastr.success(self.getTemplate({
name: '!' + toastrMessages.numbersUpdated,
data: {
name: name
}
}));
monster.ui.toast({
type: 'success',
message: self.getTemplate({
name: '!' + toastrMessages.numbersUpdated,
data: {
name: name
}
})
});
self.groupsRender({ groupId: callflowData.group_id });
});
});
Expand Down Expand Up @@ -1951,7 +1959,10 @@ define(function(require) {
} else {
callbackError && callbackError(data);

toastr.error(self.i18n.active().groups.ringGroupMissing);
monster.ui.toast({
type: 'error',
message: self.i18n.active().groups.ringGroupMissing
});
}
},
error: function(data) {
Expand Down Expand Up @@ -1981,7 +1992,10 @@ define(function(require) {
} else {
callbackError && callbackError(data);

toastr.error(self.i18n.active().groups.ringGroupMissing);
monster.ui.toast({
type: 'error',
message: self.i18n.active().groups.ringGroupMissing
});
}
},
error: function(data) {
Expand Down
88 changes: 66 additions & 22 deletions submodules/strategy/strategy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ define(function(require) {
var $ = require('jquery'),
_ = require('lodash'),
monster = require('monster'),
timezone = require('monster-timezone'),
toastr = require('toastr');
timezone = require('monster-timezone');

var app = {

Expand Down Expand Up @@ -363,12 +362,15 @@ define(function(require) {
popup.dialog('close');
} else {
self.strategyChangeEmergencyCallerId(number, function() {
toastr.success(self.getTemplate({
name: '!' + self.i18n.active().startegy.updateE911Dialog.success,
data: {
number: monster.util.formatPhoneNumber(number)
}
}));
monster.ui.toast({
type: 'success',
message: self.getTemplate({
name: '!' + self.i18n.active().startegy.updateE911Dialog.success,
data: {
number: monster.util.formatPhoneNumber(number)
}
})
});
popup.dialog('close');
});
}
Expand Down Expand Up @@ -938,10 +940,16 @@ define(function(require) {
callbacks: {
success: function(numbers) {
addNumbersToMainCallflow(_.keys(numbers));
toastr.success(self.i18n.active().strategy.toastrMessages.buyNumbersSuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.buyNumbersSuccess
});
},
error: function(error) {
toastr.error(self.i18n.active().strategy.toastrMessages.buyNumbersError);
monster.ui.toast({
type: 'error',
message: self.i18n.active().strategy.toastrMessages.buyNumbersError
});
}
}
});
Expand Down Expand Up @@ -978,7 +986,10 @@ define(function(require) {

self.strategyUpdateCallflow(strategyData.callflows.MainCallflow, function(updatedCallflow) {
var parentContainer = container.parents('.element-container');
toastr.success(self.i18n.active().strategy.toastrMessages.removeNumberSuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.removeNumberSuccess
});
strategyData.callflows.MainCallflow = updatedCallflow;
refreshNumbersHeader(parentContainer);
self.strategyRefreshTemplate(parentContainer, strategyData);
Expand Down Expand Up @@ -1221,10 +1232,16 @@ define(function(require) {
callbacks: {
success: function(numbers) {
addNumbersToMainConference(_.keys(numbers));
toastr.success(self.i18n.active().strategy.toastrMessages.buyNumbersSuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.buyNumbersSuccess
});
},
error: function(error) {
toastr.error(self.i18n.active().strategy.toastrMessages.buyNumbersError);
monster.ui.toast({
type: 'error',
message: self.i18n.active().strategy.toastrMessages.buyNumbersError
});
}
}
});
Expand All @@ -1244,7 +1261,10 @@ define(function(require) {

self.strategyUpdateCallflow(strategyData.callflows.MainConference, function(updatedCallflow) {
var parentContainer = container.parents('.element-container');
toastr.success(self.i18n.active().strategy.toastrMessages.removeNumberSuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.removeNumberSuccess
});
strategyData.callflows.MainConference = updatedCallflow;
refreshConfNumHeader(parentContainer);
self.strategyRefreshTemplate(parentContainer, strategyData);
Expand Down Expand Up @@ -1476,7 +1496,10 @@ define(function(require) {
}
], function(err, results) {
if (!err) {
toastr.success('Main Fabox Email Successfully Changed');
monster.ui.toast({
type: 'success',
message: 'Main Fabox Email Successfully Changed'
});
}
});
});
Expand All @@ -1489,10 +1512,16 @@ define(function(require) {
callbacks: {
success: function(numbers) {
addNumbersToMainFaxing(_.keys(numbers));
toastr.success(self.i18n.active().strategy.toastrMessages.buyNumbersSuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.buyNumbersSuccess
});
},
error: function(error) {
toastr.error(self.i18n.active().strategy.toastrMessages.buyNumbersError);
monster.ui.toast({
type: 'error',
message: self.i18n.active().strategy.toastrMessages.buyNumbersError
});
}
}
});
Expand All @@ -1517,7 +1546,10 @@ define(function(require) {
delete mainFaxing.flow.data.id;
self.strategyUpdateCallflow(mainFaxing, function(updatedCallflow) {
var parentContainer = container.parents('.element-container');
toastr.success(self.i18n.active().strategy.toastrMessages.removeNumberSuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.removeNumberSuccess
});
strategyData.callflows.MainFaxing = updatedCallflow;
refreshFaxingNumHeader(parentContainer);
self.strategyRefreshTemplate(parentContainer, strategyData);
Expand Down Expand Up @@ -1768,7 +1800,10 @@ define(function(require) {
strategyData.callflows.MainCallflow = updatedCallflow;
parent.find('.element-content').hide();
parent.removeClass('open');
toastr.success(self.i18n.active().strategy.toastrMessages.updateHolidaySuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.updateHolidaySuccess
});
});
});
}
Expand Down Expand Up @@ -1797,7 +1832,10 @@ define(function(require) {
strategyData.callflows.MainCallflow = updatedCallflow;
parent.find('.element-content').hide();
parent.removeClass('open');
toastr.success(self.i18n.active().strategy.toastrMessages.updateHolidaySuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.updateHolidaySuccess
});
});
});
});
Expand Down Expand Up @@ -2324,7 +2362,10 @@ define(function(require) {
monster.parallel(parallelRequests, function(err, results) {
container.hide();
container.parents('.element-container').removeClass('open');
toastr.success(self.i18n.active().strategy.toastrMessages.updateCallSuccess);
monster.ui.toast({
type: 'success',
message: self.i18n.active().strategy.toastrMessages.updateCallSuccess
});
});
}
});
Expand Down Expand Up @@ -2470,7 +2511,10 @@ define(function(require) {
error: function(data, status, globalHandler) {
if (data && data.error === '404') {
showPopup();
toastr.warning(self.i18n.active().strategy.greetingMissing);
monster.ui.toast({
type: 'warning',
message: self.i18n.active().strategy.greetingMissing
});
} else {
globalHandler(data, { generateError: true });
}
Expand Down
Loading

0 comments on commit d6e7fb5

Please sign in to comment.