mirror of
https://github.com/ansible/awx.git
synced 2026-02-19 12:10:06 -03:30
Fix app crash from our pagination when editing invalid things
Addresses the most important part of #1742 , next patch will be to make it so we just navigate away from the detail page if we delete the item we're on.
This commit is contained in:
@@ -12,11 +12,16 @@ export default ['$http', '$q', function($http, $q) {
|
|||||||
return $http.get(url + "?id=" + id)
|
return $http.get(url + "?id=" + id)
|
||||||
.then(function (data) {
|
.then(function (data) {
|
||||||
var queryValue, queryType;
|
var queryValue, queryType;
|
||||||
if (data.data.results[0].type === "user") {
|
if (data.data.results.length) {
|
||||||
queryValue = data.data.results[0].username;
|
if (data.data.results[0].type === "user") {
|
||||||
queryType = "username";
|
queryValue = data.data.results[0].username;
|
||||||
|
queryType = "username";
|
||||||
|
} else {
|
||||||
|
queryValue = data.data.results[0].name;
|
||||||
|
queryType = "name";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
queryValue = data.data.results[0].name;
|
queryValue = "";
|
||||||
queryType = "name";
|
queryType = "name";
|
||||||
}
|
}
|
||||||
// get how many results are less than or equal to
|
// get how many results are less than or equal to
|
||||||
@@ -26,7 +31,7 @@ export default ['$http', '$q', function($http, $q) {
|
|||||||
// divide by the page size to get what
|
// divide by the page size to get what
|
||||||
// page the data should be on
|
// page the data should be on
|
||||||
var count = data.data.count;
|
var count = data.data.count;
|
||||||
return Math.ceil(count/parseInt(pageSize));
|
return Math.max(1, Math.ceil(count/parseInt(pageSize)));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user