michaelbromley / michaelbromley/angularUtils
dirPagination: Search with api on page 2 refreshes the page
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 2k
- Forks
- 842
- PR merge metrics
- No merged PRs in 30d
Description
Hi
Version -> "angular-utils-pagination": "^0.11.1"
**Description of issue**: I have 2 apis, data api (for the initial result, 10 items at a time and paged) and the second, search api (api to search table). When i search on page 1, then search result is displayed just fine but when i navigate to page 2 and search, after the search api is called, the data api is called too thereby reloading the api all over again
**Steps to reproduce**: Write api to fetch data and search data from api. Navigate to page 2 and search.
**Expected result**: displays search result irrespective of the page number.
**Actual result**: displays search result only in page 1. If search is done in page 2, the data api is reloaded after search api.
Any relevant code:
scope.getErrorTerminals = function( pageNumber ) {
scope.search = "";
scope.searched = false;
let pageNum = pageNumber ? pageNumber : scope.errorPageNum;
scope.errorPageNum = pageNum;
scope.errorTerminalsError = null;
scope.loading = true;
scope.showFileSizesColumn = false;
CampaignService.campaignTerminalsByStatus (scope.campaign.id , 'error', pageNum)
.then((data) => {
scope.$evalAsync(() => {
scope.totalCount = data.noOfRecords;
scope.errorTerminalsData = data;
scope.errorPageNum = data.currentPageNumber;
for (var count = 0; count < data.list.length; count++ ) {
data.list[count].lastDate = new Date((data.list[count].lastDate).replace(/-/g,'/'));
}
scope.errorTerminals = data.list;
scope.loading = false;
});
}, (error) => {
scope.$evalAsync(() => {
$scope.errorTerminalsError = err.toString();
scope.loading = false;
});
});
};
scope.searchTerminals = function(searchTerm) {
scope.searched = true;
let pageNum = scope.searchPageNum;
scope.errorTerminalsError = null;
scope.loading = true;
scope.showFileSizesColumn = false;
CampaignService.searchErrorTerminalsById (scope.campaign.id, searchTerm, pageNum)
.then((data) => {
scope.$evalAsync(() => {
scope.totalCount = data.noOfRecords;
scope.errorTerminalsData = data;
scope.searchPageNum = data.currentPageNumber;
for (var count = 0; count < data.list.length; count++ ) {
data.list[count].lastDate = new Date((data.list[count].lastDate).replace(/-/g,'/'));
}
scope.errorTerminals = data.list;
scope.loading = false;
});
}, (error) => {
scope.$evalAsync(() => {
scope.errorTerminalsError = error.toString();
scope.loading = false;
});
});
};
Terminal ID
Last Communication
Error Description
File Size
Action
{{ errorTerminal.terminalId }}
{{ errorTerminal.lastDate | date : "yyyy-MM-dd HH:mm:ss" }}
{{ errorTerminal.status }}
Re-send
`
```
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the supplied dir-paginate template and the getErrorTerminals and searchTerminals callbacks, then trace how on-page-change interacts with pagination.current when searching on page 2. Done means a page-2 search displays its results without triggering the data API or reloading the original results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- angularjs, javascript
- Domain
- frontend
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100