aboutsummaryrefslogtreecommitdiff
path: root/ufund-ui
diff options
context:
space:
mode:
authorbenal01 <bja4245@rit.edu>2025-04-02 10:27:48 -0400
committerbenal01 <bja4245@rit.edu>2025-04-02 10:27:48 -0400
commit91e8835b84b00bffc6db350f7cf6641c0d128a93 (patch)
tree7d2171ba311357d1a0f4ec9ab84c277ee2d2f128 /ufund-ui
parent41a18efce59852ccff91816bbe63f5001346f2ed (diff)
downloadJellySolutions-91e8835b84b00bffc6db350f7cf6641c0d128a93.tar.gz
JellySolutions-91e8835b84b00bffc6db350f7cf6641c0d128a93.tar.bz2
JellySolutions-91e8835b84b00bffc6db350f7cf6641c0d128a93.zip
negative and large input handling for need page amount
Diffstat (limited to 'ufund-ui')
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.html2
-rw-r--r--ufund-ui/src/app/components/need-list/need-list.component.ts11
2 files changed, 9 insertions, 4 deletions
diff --git a/ufund-ui/src/app/components/need-list/need-list.component.html b/ufund-ui/src/app/components/need-list/need-list.component.html
index c0501ba..c166152 100644
--- a/ufund-ui/src/app/components/need-list/need-list.component.html
+++ b/ufund-ui/src/app/components/need-list/need-list.component.html
@@ -16,7 +16,7 @@
<span class="icon">{{sortMode === 'Ascending' ? 'arrow_upward': 'arrow_downward'}}</span>
</button>
<label>Needs per page: </label>
- <input type ="number" [(ngModel)]="itemsPerPage" (change)="resetVisibleNeeds()" min="1" max="{{searchResults.length}}">
+ <input type ="number" [(ngModel)]="itemsPerPage" (change)="editNeedsPerPage()" min="1" max="{{searchResults.length}}">
</div>
<!--<button (click)="close()">Close</button>-->
</div>
diff --git a/ufund-ui/src/app/components/need-list/need-list.component.ts b/ufund-ui/src/app/components/need-list/need-list.component.ts
index cd3d9bd..ed14d6a 100644
--- a/ufund-ui/src/app/components/need-list/need-list.component.ts
+++ b/ufund-ui/src/app/components/need-list/need-list.component.ts
@@ -82,9 +82,14 @@ export class NeedListComponent {
this.updateVisibleNeeds();
}
- editNeedsPerPage(amount: number) {
- this.itemsPerPage = amount;
- this.updateVisibleNeeds();
+ editNeedsPerPage() {
+ if (this.itemsPerPage > this.searchResults.length) {
+ this.itemsPerPage = this.searchResults.length;
+ }
+ if (this.itemsPerPage < 1) {
+ this.itemsPerPage = 1;
+ }
+ this.resetVisibleNeeds();
}
updateVisibleNeeds() {