mirror of
https://github.com/ansible/awx.git
synced 2026-05-19 14:57:39 -02:30
ugly but working commit of getting pagination to work on edit of a form item
This commit is contained in:
@@ -147,6 +147,7 @@ export default
|
|||||||
new_url += (scope[iterator + 'SearchParams']) ? '&' + scope[iterator + 'SearchParams'] +
|
new_url += (scope[iterator + 'SearchParams']) ? '&' + scope[iterator + 'SearchParams'] +
|
||||||
'&page_size=' + scope[iterator + '_page_size'] : '&page_size=' + scope[iterator + 'PageSize'];
|
'&page_size=' + scope[iterator + '_page_size'] : '&page_size=' + scope[iterator + 'PageSize'];
|
||||||
Wait('start');
|
Wait('start');
|
||||||
|
scope.getNewPage = true;
|
||||||
Refresh({ scope: scope, set: set, iterator: iterator, url: new_url });
|
Refresh({ scope: scope, set: set, iterator: iterator, url: new_url });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -24,8 +24,8 @@
|
|||||||
|
|
||||||
export default
|
export default
|
||||||
angular.module('RefreshHelper', ['RestServices', 'Utilities', 'PaginationHelpers'])
|
angular.module('RefreshHelper', ['RestServices', 'Utilities', 'PaginationHelpers'])
|
||||||
.factory('Refresh', ['ProcessErrors', 'Rest', 'Wait', 'Empty', 'PageRangeSetup',
|
.factory('Refresh', ['$location', 'ProcessErrors', 'Rest', 'Wait', 'Empty', 'PageRangeSetup',
|
||||||
function (ProcessErrors, Rest, Wait, Empty, PageRangeSetup) {
|
function ($location, ProcessErrors, Rest, Wait, Empty, PageRangeSetup) {
|
||||||
return function (params) {
|
return function (params) {
|
||||||
|
|
||||||
var scope = params.scope,
|
var scope = params.scope,
|
||||||
@@ -34,37 +34,87 @@ export default
|
|||||||
url = params.url,
|
url = params.url,
|
||||||
deferWaitStop = params.deferWaitStop;
|
deferWaitStop = params.deferWaitStop;
|
||||||
|
|
||||||
scope.current_url = url;
|
if ($location.$$url.split("/")[2] && !scope.getNewPage) {
|
||||||
Rest.setUrl(url);
|
var id = $location.$$url.split("/")[2];
|
||||||
Rest.get()
|
Rest.setUrl(params.url.split("?")[0] + "?id=" + id);
|
||||||
.success(function (data) {
|
Rest.get()
|
||||||
var i, modifier;
|
.then(function (data) {
|
||||||
PageRangeSetup({
|
var name = data.data.results[0].name;
|
||||||
scope: scope,
|
Rest.setUrl(params.url.split("?")[0] + "?name__lte=" + name);
|
||||||
count: data.count,
|
Rest.get()
|
||||||
next: data.next,
|
.then(function (data) {
|
||||||
previous: data.previous,
|
var currentPage = Math.ceil(data.data.count/scope[iterator + '_page_size']);
|
||||||
iterator: iterator
|
scope[iterator + '_page'] = currentPage;
|
||||||
|
params.url = params.url + "&page=" + currentPage;
|
||||||
|
scope.current_url = params.url;
|
||||||
|
Rest.setUrl(params.url);
|
||||||
|
Rest.get()
|
||||||
|
.success(function (data) {
|
||||||
|
var i, modifier;
|
||||||
|
PageRangeSetup({
|
||||||
|
scope: scope,
|
||||||
|
count: data.count,
|
||||||
|
next: data.next,
|
||||||
|
previous: data.previous,
|
||||||
|
iterator: iterator
|
||||||
|
});
|
||||||
|
for (i = 1; i <= 3; i++) {
|
||||||
|
modifier = (i === 1) ? '' : i;
|
||||||
|
scope[iterator + 'HoldInput' + modifier] = false;
|
||||||
|
}
|
||||||
|
scope[set] = data.results;
|
||||||
|
scope[iterator + 'Loading'] = false;
|
||||||
|
scope[iterator + 'HidePaginator'] = false;
|
||||||
|
if (!deferWaitStop) {
|
||||||
|
Wait('stop');
|
||||||
|
}
|
||||||
|
scope.$emit('PostRefresh', set);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
scope[iterator + 'HoldInput'] = false;
|
||||||
|
ProcessErrors(scope, data, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve ' + set + '. GET returned status: ' + status
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
for (i = 1; i <= 3; i++) {
|
} else {
|
||||||
modifier = (i === 1) ? '' : i;
|
scope.current_url = url;
|
||||||
scope[iterator + 'HoldInput' + modifier] = false;
|
Rest.setUrl(url);
|
||||||
}
|
Rest.get()
|
||||||
scope[set] = data.results;
|
.success(function (data) {
|
||||||
scope[iterator + 'Loading'] = false;
|
var i, modifier;
|
||||||
scope[iterator + 'HidePaginator'] = false;
|
PageRangeSetup({
|
||||||
if (!deferWaitStop) {
|
scope: scope,
|
||||||
Wait('stop');
|
count: data.count,
|
||||||
}
|
next: data.next,
|
||||||
scope.$emit('PostRefresh', set);
|
previous: data.previous,
|
||||||
})
|
iterator: iterator
|
||||||
.error(function (data, status) {
|
});
|
||||||
scope[iterator + 'HoldInput'] = false;
|
for (i = 1; i <= 3; i++) {
|
||||||
ProcessErrors(scope, data, status, null, {
|
modifier = (i === 1) ? '' : i;
|
||||||
hdr: 'Error!',
|
scope[iterator + 'HoldInput' + modifier] = false;
|
||||||
msg: 'Failed to retrieve ' + set + '. GET returned status: ' + status
|
}
|
||||||
|
scope[set] = data.results;
|
||||||
|
scope[iterator + 'Loading'] = false;
|
||||||
|
scope[iterator + 'HidePaginator'] = false;
|
||||||
|
if (!deferWaitStop) {
|
||||||
|
Wait('stop');
|
||||||
|
}
|
||||||
|
scope.$emit('PostRefresh', set);
|
||||||
|
})
|
||||||
|
.error(function (data, status) {
|
||||||
|
scope[iterator + 'HoldInput'] = false;
|
||||||
|
ProcessErrors(scope, data, status, null, {
|
||||||
|
hdr: 'Error!',
|
||||||
|
msg: 'Failed to retrieve ' + set + '. GET returned status: ' + status
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
scope.getNewPage = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user