From 7fcc1223c2e607d7481831d0000a4f76ababf394 Mon Sep 17 00:00:00 2001
From: Simon Mayer <simon.mayer@onb.ac.at>
Date: Wed, 19 Oct 2022 11:11:57 +0200
Subject: [PATCH] Fix page input conversion to integer

---
 app/javascript/packs/controllers/dataset_controller.js | 4 ++--
 app/views/dataset/_pagination.html.erb                 | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/app/javascript/packs/controllers/dataset_controller.js b/app/javascript/packs/controllers/dataset_controller.js
index 92e65ec..c183ae6 100644
--- a/app/javascript/packs/controllers/dataset_controller.js
+++ b/app/javascript/packs/controllers/dataset_controller.js
@@ -101,8 +101,8 @@ export default class extends Controller {
 
     page_select(event) {
         event.preventDefault()
-        const input_page = this.inputPageTarget.value
-        if (!Number.isNaN(input_page) && 1 <= input_page && input_page <= this.nbPagesValue && !(this.currentPageValue == input_page)) {
+        const input_page = parseInt(this.inputPageTarget.value)
+        if (!isNaN(input_page) && 1 <= input_page && input_page <= this.nbPagesValue && !(this.currentPageValue == input_page)) {
             this.currentPageValue = input_page
             this.loadDocuments(this.idValue, this.currentPageValue, this.perPageValue, this.sortValue, this.sortOrderValue, $("#doctype_selection input:checked").data("doctype"))
         }
diff --git a/app/views/dataset/_pagination.html.erb b/app/views/dataset/_pagination.html.erb
index 41546fc..7e2c650 100644
--- a/app/views/dataset/_pagination.html.erb
+++ b/app/views/dataset/_pagination.html.erb
@@ -10,7 +10,7 @@
                         <% if i == current_page %>
                             <li class="page-item active">
                                 <form class="page-link" data-action="dataset#page_select">
-                                    <input type="text" data-dataset-target="inputPage" value="<%= i %>" style="width:25px; height:20px">
+                                    <input type="text" data-dataset-target="inputPage" value="<%= i %>" style="width:25px; height:20px; text-align:center">
                                     <input type="submit" class="sr-only" tabindex="-1">
                                 </form>
                             </li>
@@ -30,7 +30,7 @@
                     <% if i == current_page %>
                         <li class="page-item active">
                             <form class="page-link" data-action="dataset#page_select">
-                                <input type="text" data-dataset-target="inputPage" value="<%= i %>" style="width:30px; height:25px">
+                                <input type="text" data-dataset-target="inputPage" value="<%= i %>" style="width:25px; height:20px; text-align:center">
                                 <input type="submit" class="sr-only" tabindex="-1">
                             </form>
                         </li>
-- 
GitLab