Implement pagination to tags and categories query
[MAILPOET-1613]
This commit is contained in:
@ -210,7 +210,8 @@ define([
|
||||
ajax: {
|
||||
data: function (params) {
|
||||
return {
|
||||
term: params.term
|
||||
term: params.term,
|
||||
page: params.page || 1
|
||||
};
|
||||
},
|
||||
transport: function (options, success, failure) {
|
||||
@ -223,6 +224,7 @@ define([
|
||||
// Fetch available terms based on the list of taxonomies already fetched
|
||||
termsPromise = CommunicationComponent.getTerms({
|
||||
search: options.data.term,
|
||||
page: options.data.page,
|
||||
taxonomies: _.keys(taxonomies)
|
||||
}).then(function (terms) {
|
||||
return {
|
||||
@ -248,7 +250,10 @@ define([
|
||||
id: item.term_id
|
||||
}, item);
|
||||
}
|
||||
)
|
||||
),
|
||||
pagination: {
|
||||
more: data.terms.length === 100
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -205,7 +205,8 @@ define([
|
||||
ajax: {
|
||||
data: function (params) {
|
||||
return {
|
||||
term: params.term
|
||||
term: params.term,
|
||||
page: params.page || 1
|
||||
};
|
||||
},
|
||||
transport: function (options, success, failure) {
|
||||
@ -218,6 +219,7 @@ define([
|
||||
// Fetch available terms based on the list of taxonomies already fetched
|
||||
termsPromise = CommunicationComponent.getTerms({
|
||||
search: options.data.term,
|
||||
page: options.data.page,
|
||||
taxonomies: _.keys(taxonomies)
|
||||
}).then(function (terms) {
|
||||
return {
|
||||
@ -243,7 +245,10 @@ define([
|
||||
id: item.term_id
|
||||
}, item);
|
||||
}
|
||||
)
|
||||
),
|
||||
pagination: {
|
||||
more: data.terms.length === 100
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -372,7 +372,8 @@ define([
|
||||
ajax: {
|
||||
data: function (params) {
|
||||
return {
|
||||
term: params.term
|
||||
term: params.term,
|
||||
page: params.page || 1
|
||||
};
|
||||
},
|
||||
transport: function (options, success, failure) {
|
||||
@ -385,6 +386,7 @@ define([
|
||||
// Fetch available terms based on the list of taxonomies already fetched
|
||||
termsPromise = CommunicationComponent.getTerms({
|
||||
search: options.data.term,
|
||||
page: options.data.page,
|
||||
taxonomies: _.keys(taxonomies)
|
||||
}).then(function (terms) {
|
||||
return {
|
||||
@ -410,7 +412,10 @@ define([
|
||||
id: item.term_id
|
||||
}, item);
|
||||
}
|
||||
)
|
||||
),
|
||||
pagination: {
|
||||
more: data.terms.length === 100
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ class AutomatedLatestContent extends APIEndpoint {
|
||||
function getTerms($data = array()) {
|
||||
$taxonomies = (isset($data['taxonomies'])) ? $data['taxonomies'] : array();
|
||||
$search = (isset($data['search'])) ? $data['search'] : '';
|
||||
$limit = (isset($data['limit'])) ? (int)$data['limit'] : 50;
|
||||
$limit = (isset($data['limit'])) ? (int)$data['limit'] : 100;
|
||||
$page = (isset($data['page'])) ? (int)$data['page'] : 1;
|
||||
$args = array(
|
||||
'taxonomy' => $taxonomies,
|
||||
@ -56,8 +56,9 @@ class AutomatedLatestContent extends APIEndpoint {
|
||||
);
|
||||
|
||||
$args = Hooks::applyFilters('mailpoet_search_terms_args', $args);
|
||||
$terms = WPPosts::getTerms($args);
|
||||
|
||||
return $this->successResponse(WPPosts::getTerms($args));
|
||||
return $this->successResponse(array_values($terms));
|
||||
}
|
||||
|
||||
function getPosts($data = array()) {
|
||||
@ -90,4 +91,4 @@ class AutomatedLatestContent extends APIEndpoint {
|
||||
|
||||
return $this->successResponse($rendered_posts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user