Browse Source

Add pagination request method

pull/4/head
vbarkasov 8 years ago
parent
commit
23c76c15ec
2 changed files with 55 additions and 3 deletions
  1. +52
    -0
      src/apps/callflows/app.js
  2. +3
    -3
      src/apps/callflows/submodules/callcenter/callcenter.js

+ 52
- 0
src/apps/callflows/app.js View File

@ -1915,6 +1915,58 @@ define(function(require){
input.unbind('.link');
}
});
},
getAll: function(callApiData, startKey, continueData) {
// Warning! Method works for listed data only!
// -- Usage:
// self.getAll({
// resource: 'user.list',
// success: function(result){},
// error: function(data){},
// data: {
// someParam: someValue
// }
// })
continueData = continueData || { data:[] };
var self = this;
if(typeof(callApiData.resource) === 'undefined') {
self.log('Error! Api keyword is undefined');
return;
}
var requestData = $.extend({
accountId: self.accountId,
generateError: false
}, callApiData.data || {});
if(typeof(startKey) !== 'undefined') {
requestData.startKey = startKey;
}
var newRequestData = {
resource: callApiData.resource,
data: requestData,
success: function(response){
response.data = $.merge(continueData.data, response.data);
if(response.next_start_key && startKey !== response.next_start_key) {
self.getAll(callApiData, response.next_start_key, response);
return;
}
if(typeof(callApiData.success) === 'function') {
callApiData.success(response);
}
},
error: callApiData.error || function(){}
};
if(self.requests.hasOwnProperty(callApiData.resource)) {
monster.request(newRequestData);
} else {
self.callApi(newRequestData);
}
}
};


+ 3
- 3
src/apps/callflows/submodules/callcenter/callcenter.js View File

@ -170,7 +170,7 @@ define(function(require){
});
},
listEntities: function(callback) {
monster.request({
self.getAll({
resource: 'callcenter.queues.list',
data: {
accountId: self.accountId,
@ -435,7 +435,7 @@ define(function(require){
getUsersList: function(callback) {
var self = this;
self.callApi({
self.getAll({
resource: 'user.list',
data: {
accountId: self.accountId,
@ -480,7 +480,7 @@ define(function(require){
getQueuesList: function(callback) {
var self = this;
monster.request({
self.getAll({
resource: 'callcenter.queues.list',
data: {
accountId: self.accountId,


Loading…
Cancel
Save