From d7aaac2e9730a88b162cf151a50a62a08f870840 Mon Sep 17 00:00:00 2001 From: Antoine Beaubien Date: Wed, 17 Jun 2020 05:31:56 -0400 Subject: [PATCH] (I #2638) Feature to Goto a page directly (#2639) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Start for Goto Page link. First implementation. Is functional. * Background-color & validation Background-color for each « button » & validation for the page choice of the user: number, > 1 & < last & singular for a one page project. * Changed from prompt() to Changed from prompt() to , and visual X out Y. * Manage bounds in a sticky way If the user choose below 1, 1 will be displayed, and if the user choose above the max, the max page will be displayed. * width of & « of X pages » Add pages after « of maxValue », calculate the width of based on max value. * Update data-table-view.js Little fix. * Correct min and max for Correct min and max for * Managment of the arrow's key down. Add managment to keep the arrow's key in the CurrentPage . * Fixes for Thad’s KeyDown's « Infinite Paging » Fixes for Thad’s KeyDown's « Infinite Paging » & PageSize changes. * Code rehookCurrentPageInput & spacing Code rehookCurrentPageInput & spacing for PageSize section * Update data-table-view.js Fix & move code in Page Control. * Wrap in a Try/Catch the currentPageInput.focus() Wrap in a Try/Catch the currentPageInput.focus() and add a verification of focus change with if(!(currentPageInput.is(":focus"))) window.setTimeout(rehookCurrentPageInput, rehookDelay). * Fixed currentPageInput != document.activeElement Fixed currentPageInput != document.activeElement that was before: !(currentPageInput.is(":focus")) * Better handling of the « Infinite Paging » Better handling of the « Infinite Paging » with window.setTimeout(rehookCurrentPageInput, rehookDelay) * $.i18n('core-views/goto-page', … $.i18n('core-views/goto-page', '', '')) * Fix i18n plural Fix i18n plural, FR still not fixed. * Remove {{plural:$2|page|pages}} in french Remove {{plural:$2|page|pages}} in French, not working. * Update data-table-view.js Forgot a semi-comma. * First implementation First implementation, is functional. * Remove setTimeout(refocusCurrentPageInput, refocusDelay); Remove setTimeout(refocusCurrentPageInput, refocusDelay);, instead, onready after creating the page input field. * Typo: missing semi-colon Typo: missing semi-colon * Fix bug related to stealing focus of facets & added a delay Fix bug related to stealing focus of facets & added a delay (1 s.) before changing pages. * Revert "Remove {{plural:$2|page|pages}} in french" This reverts commit 7274a21ee04e6480e50de39f1a7788164dd1981a. * Start for Goto Page link. First implementation. Is functional. * Background-color & validation Background-color for each « button » & validation for the page choice of the user: number, > 1 & < last & singular for a one page project. * Changed from prompt() to Changed from prompt() to , and visual X out Y. * Manage bounds in a sticky way If the user choose below 1, 1 will be displayed, and if the user choose above the max, the max page will be displayed. * width of & « of X pages » Add pages after « of maxValue », calculate the width of based on max value. * Update data-table-view.js Little fix. * Correct min and max for Correct min and max for * Managment of the arrow's key down. Add managment to keep the arrow's key in the CurrentPage . * Fixes for Thad’s KeyDown's « Infinite Paging » Fixes for Thad’s KeyDown's « Infinite Paging » & PageSize changes. * Code rehookCurrentPageInput & spacing Code rehookCurrentPageInput & spacing for PageSize section * Update data-table-view.js Fix & move code in Page Control. * Wrap in a Try/Catch the currentPageInput.focus() Wrap in a Try/Catch the currentPageInput.focus() and add a verification of focus change with if(!(currentPageInput.is(":focus"))) window.setTimeout(rehookCurrentPageInput, rehookDelay). * Fixed currentPageInput != document.activeElement Fixed currentPageInput != document.activeElement that was before: !(currentPageInput.is(":focus")) * Better handling of the « Infinite Paging » Better handling of the « Infinite Paging » with window.setTimeout(rehookCurrentPageInput, rehookDelay) * $.i18n('core-views/goto-page', … $.i18n('core-views/goto-page', '', '')) * Bump rhino from 1.7.10 to 1.7.12 Bumps [rhino](https://github.com/mozilla/rhino) from 1.7.10 to 1.7.12. - [Release notes](https://github.com/mozilla/rhino/releases) - [Changelog](https://github.com/mozilla/rhino/blob/master/RELEASE-NOTES.md) - [Commits](https://github.com/mozilla/rhino/commits) Signed-off-by: dependabot-preview[bot] * Fix i18n plural Fix i18n plural, FR still not fixed. * Remove {{plural:$2|page|pages}} in french Remove {{plural:$2|page|pages}} in French, not working. * Update data-table-view.js Forgot a semi-comma. * Bump guava from 19.0 to 23.0 Bumps [guava](https://github.com/google/guava) from 19.0 to 23.0. - [Release notes](https://github.com/google/guava/releases) - [Commits](https://github.com/google/guava/compare/v19.0...v23.0) Signed-off-by: dependabot-preview[bot] * Bump testng from 6.9.10 to 7.1.0 Bumps [testng](https://github.com/cbeust/testng) from 6.9.10 to 7.1.0. - [Release notes](https://github.com/cbeust/testng/releases) - [Changelog](https://github.com/cbeust/testng/blob/master/CHANGES.txt) - [Commits](https://github.com/cbeust/testng/commits) Signed-off-by: dependabot-preview[bot] * Bump to Guava 23.6.1-jre * Bump jasypt from 1.9.2 to 1.9.3 Bumps [jasypt](https://github.com/jasypt/jasypt) from 1.9.2 to 1.9.3. - [Release notes](https://github.com/jasypt/jasypt/releases) - [Commits](https://github.com/jasypt/jasypt/commits/jasypt-1.9.3) Signed-off-by: dependabot-preview[bot] * Added conflicts-with constraints (#2641) Implemented conflicts-with scrutinizer as part of #2354 * Fix a bug introduced by I #1038, PR #2616 (#2684) Fix a bug introduced by I #1038, where the first tab, in the Wikidata mode, would have a bad background. PR #2616 * Fixed typos made in PR #2641 * Remove setTimeout(refocusCurrentPageInput, refocusDelay); Remove setTimeout(refocusCurrentPageInput, refocusDelay);, instead, onready after creating the page input field. * Trim input url whitespace (#2534) Fixes #2516 * Bump google-http-client-jackson2 from 1.20.0 to 1.35.0 Bumps [google-http-client-jackson2](https://github.com/googleapis/google-http-java-client) from 1.20.0 to 1.35.0. - [Release notes](https://github.com/googleapis/google-http-java-client/releases) - [Changelog](https://github.com/googleapis/google-http-java-client/blob/master/CHANGELOG.md) - [Commits](https://github.com/googleapis/google-http-java-client/compare/1.20.0...v1.35.0) Signed-off-by: dependabot-preview[bot] * Switch to new rhino-runtime component * Typo: missing semi-colon Typo: missing semi-colon * Replace Apache Ant with Commons Compress (#2691) NOTE: Changes the public API where some of the old types were embedded which means that any extensions that extend these interfaces will have to be updated. Fixes #2690. * Fix bug related to stealing focus of facets & added a delay Fix bug related to stealing focus of facets & added a delay (1 s.) before changing pages. * Revert "Remove {{plural:$2|page|pages}} in french" This reverts commit 7274a21ee04e6480e50de39f1a7788164dd1981a. * Update to latest Jython version 2.7.2 Closes #2642 * Bump git-commit-id-plugin from 2.2.4 to 4.0.0 Bumps [git-commit-id-plugin](https://github.com/git-commit-id/maven-git-commit-id-plugin) from 2.2.4 to 4.0.0. - [Release notes](https://github.com/git-commit-id/maven-git-commit-id-plugin/releases) - [Commits](https://github.com/git-commit-id/maven-git-commit-id-plugin/compare/v2.2.4...v4.0.0) Signed-off-by: dependabot-preview[bot] * Bump maven-assembly-plugin from 3.1.0 to 3.3.0 Bumps [maven-assembly-plugin](https://github.com/apache/maven-assembly-plugin) from 3.1.0 to 3.3.0. - [Release notes](https://github.com/apache/maven-assembly-plugin/releases) - [Commits](https://github.com/apache/maven-assembly-plugin/compare/maven-assembly-plugin-3.1.0...maven-assembly-plugin-3.3.0) Signed-off-by: dependabot-preview[bot] * Bump httpclient from 4.5.5 to 4.5.12 Bumps httpclient from 4.5.5 to 4.5.12. Signed-off-by: dependabot-preview[bot] * Bump powermock.version from 2.0.2 to 2.0.7 Bumps `powermock.version` from 2.0.2 to 2.0.7. Updates `powermock-module-testng` from 2.0.2 to 2.0.7 - [Release notes](https://github.com/powermock/powermock/releases) - [Changelog](https://github.com/powermock/powermock/blob/release/2.x/docs/changelog.txt) - [Commits](https://github.com/powermock/powermock/compare/powermock-2.0.2...powermock-2.0.7) Updates `powermock-api-mockito2` from 2.0.2 to 2.0.7 - [Release notes](https://github.com/powermock/powermock/releases) - [Changelog](https://github.com/powermock/powermock/blob/release/2.x/docs/changelog.txt) - [Commits](https://github.com/powermock/powermock/compare/powermock-2.0.2...powermock-2.0.7) Signed-off-by: dependabot-preview[bot] * Bump butterfly from 1.0.2 to 1.0.3 Bumps [butterfly](https://github.com/OpenRefine/simile-butterfly) from 1.0.2 to 1.0.3. - [Release notes](https://github.com/OpenRefine/simile-butterfly/releases) - [Commits](https://github.com/OpenRefine/simile-butterfly/commits) Signed-off-by: dependabot-preview[bot] * Bump slf4j-api from 1.7.18 to 1.7.30 Bumps [slf4j-api](https://github.com/qos-ch/slf4j) from 1.7.18 to 1.7.30. - [Release notes](https://github.com/qos-ch/slf4j/releases) - [Commits](https://github.com/qos-ch/slf4j/compare/v_1.7.18...v_1.7.30) Signed-off-by: dependabot-preview[bot] * Bump commons-validator from 1.5.1 to 1.6 Bumps commons-validator from 1.5.1 to 1.6. Signed-off-by: dependabot-preview[bot] * Added translation using Weblate (Portuguese (Brazil)) * Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (47 of 47 strings) Translation: OpenRefine/gdata Translate-URL: https://hosted.weblate.org/projects/openrefine/gdata/pt_BR/ * Translated using Weblate (Japanese) Currently translated at 100.0% (179 of 179 strings) Translation: OpenRefine/wikidata Translate-URL: https://hosted.weblate.org/projects/openrefine/wikidata/ja/ * Disables FacetContainer while computing clusters fixes #2675 * Added translation using Weblate (Portuguese (Brazil)) * Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (740 of 740 strings) Translation: OpenRefine/Translations Translate-URL: https://hosted.weblate.org/projects/openrefine/translations/pt_BR/ * Added translation using Weblate (Portuguese (Brazil)) * Translated using Weblate (Portuguese (Brazil)) Currently translated at 100.0% (60 of 60 strings) Translation: OpenRefine/database Translate-URL: https://hosted.weblate.org/projects/openrefine/database/pt_BR/ * Translated using Weblate (Portuguese (Brazil)) Currently translated at 6.7% (12 of 179 strings) Translation: OpenRefine/wikidata Translate-URL: https://hosted.weblate.org/projects/openrefine/wikidata/pt_BR/ * Translated using Weblate (Japanese) Currently translated at 100.0% (60 of 60 strings) Translation: OpenRefine/database Translate-URL: https://hosted.weblate.org/projects/openrefine/database/ja/ * Translated using Weblate (Japanese) Currently translated at 100.0% (740 of 740 strings) Translation: OpenRefine/Translations Translate-URL: https://hosted.weblate.org/projects/openrefine/translations/ja/ * Translated using Weblate (Japanese) Currently translated at 100.0% (60 of 60 strings) Translation: OpenRefine/database Translate-URL: https://hosted.weblate.org/projects/openrefine/database/ja/ * Added translation using Weblate (Bengali (India)) * Load GDrive icon from local resource, not Github (#2689) Fixes #2688. * Convert illegal characters into legal ones. (#2431) * Convert illegal characters into leagal ones. * Test tab in key & value string Also fix up test that depended on previous TAB related error message and clean up logging Co-authored-by: Tom Morris * Bump signpost-commonshttp4 from 1.2.1.2 to 2.0.0 (#2695) Bumps [signpost-commonshttp4](https://github.com/mttkay/signpost) from 1.2.1.2 to 2.0.0. - [Release notes](https://github.com/mttkay/signpost/releases) - [Changelog](https://github.com/mttkay/signpost/blob/master/CHANGELOG.md) - [Commits](https://github.com/mttkay/signpost/compare/1.2.1.2...oauth-signpost-2.0.0) Signed-off-by: dependabot-preview[bot] Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> * Add comment to help designers understand TreeData (#2715) * Update jquery.i18n to 1.07 and fix non-English plural support (#2717) * Update jquery.i18n to 1.07 and add missing rule parser Fixes #2700 Adds missing CLDRPluralRuleParser.js so that plurals are supported. Updates all files to jquery.i18n 1.07 Includes a bunch of specialty language support, but only Finnish and Russian are loaded as examples. * Add some missing translations, including plurals Fix some cases of Javascript string concatenation and plural conditionalization to demonstrate that plurals work in both English and French now. NOTE: Corresponding updates need to be made to all the other language files since some keys were renamed or eliminated. * Unused imports and other minor cleanups (#2723) * Two minor fixes - prevent invalid index error on empty strings (shouldn't normally happen) - update deprecated Apache Commons Lang method * Remove unused imports * Remove feature Edit Facet Name Remove feature Edit Facet Name that got merged by mistake. * Remove feature Edit Facet Name Remove feature Edit Facet Name that got merged by mistake. * Spacing Spacing * Fix the delay, adjust to .2 s. Fix the delay, adjust to .2 s. and stop using promises. * Fix headerTable to tableHeader Fix headerTable to tableHeader (PR #2719) * data-header-table to data-table-header data-header-table to data-table-header * Remove .data-header-table-container Remove .data-header-table-container Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com> Co-authored-by: Tom Morris Co-authored-by: Ekta Mishra Co-authored-by: Nishtha <51858166+Nishtha3512@users.noreply.github.com> Co-authored-by: Thad Guidry Co-authored-by: Rafael Fontenelle Co-authored-by: Isao Matsunami Co-authored-by: Biswaranjan Manna Co-authored-by: chuhao zeng <32441682+zengchu2@users.noreply.github.com> --- .../modules/core/langs/translation-en.json | 1 + .../modules/core/langs/translation-es.json | 1 + .../modules/core/langs/translation-fr.json | 1 + .../views/data-table/data-table-view.js | 74 ++++++++++++++++++- .../core/styles/views/data-table-view.less | 39 ++++++++++ 5 files changed, 113 insertions(+), 3 deletions(-) diff --git a/main/webapp/modules/core/langs/translation-en.json b/main/webapp/modules/core/langs/translation-en.json index b2a9df2b2..65ef0d289 100644 --- a/main/webapp/modules/core/langs/translation-en.json +++ b/main/webapp/modules/core/langs/translation-en.json @@ -592,6 +592,7 @@ "core-views/move-to-left": "Move column left", "core-views/move-to-right": "Move column right", "core-views/show-as": "Show as", + "core-views/goto-page": "$1 of $2 {{plural:$2|page|pages}}", "core-views/first": "first", "core-views/previous": "previous", "core-views/next": "next", diff --git a/main/webapp/modules/core/langs/translation-es.json b/main/webapp/modules/core/langs/translation-es.json index 2a94eb0af..c513262b4 100644 --- a/main/webapp/modules/core/langs/translation-es.json +++ b/main/webapp/modules/core/langs/translation-es.json @@ -531,6 +531,7 @@ "core-views/judg-actions2": "acciones del parámetro", "core-views/to-text": "A texto", "core-views/reg-exp": "regex", + "core-views/goto-page": "$1 de $2 {{plural:$2|página|paginas}}", "core-views/word-facet": "Faceta por palabra", "core-views/collapse-left": "Contraer todas las columnas a la izquierda", "core-views/clear-recon": "Quitar la información de cotejo", diff --git a/main/webapp/modules/core/langs/translation-fr.json b/main/webapp/modules/core/langs/translation-fr.json index 3918949f2..a9e49e677 100644 --- a/main/webapp/modules/core/langs/translation-fr.json +++ b/main/webapp/modules/core/langs/translation-fr.json @@ -537,6 +537,7 @@ "core-views/view": "Aperçu", "core-views/extend-not-supported": "Ce service de réconciliation de supporte pas l'extension de données. Essayez de supprimer le service et de l'ajouter à nouveau. Si le problème persiste, contactez le fournisseur de service.", "core-views/to-text": "En texte", + "core-views/goto-page": "$1 de $2 page(s)", "core-views/first": "première", "core-views/word-facet": "Facette par mot", "core-views/check-format": "Merci de vérifier le format du fichier.", diff --git a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js index a257df579..347756857 100644 --- a/main/webapp/modules/core/scripts/views/data-table/data-table-view.js +++ b/main/webapp/modules/core/scripts/views/data-table/data-table-view.js @@ -41,7 +41,10 @@ function DataTableView(div) { this._columnHeaderUIs = []; this._shownulls = false; + this._currentPageNumber = 1; this._showRows(0); + + this._refocusPageInput = false; } DataTableView._extenders = []; @@ -79,6 +82,7 @@ DataTableView.prototype.resize = function() { }; DataTableView.prototype.update = function(onDone) { + this._currentPageNumber = 1; this._showRows(0, onDone); }; @@ -107,6 +111,7 @@ DataTableView.prototype.render = function() { '' ); var elmts = DOM.bind(html); + this._div.empty().append(html); ui.summaryBar.updateResultCount(); @@ -134,7 +139,6 @@ DataTableView.prototype.render = function() { } this._renderDataTables(elmts.table[0], elmts.tableHeader[0]); - this._div.empty().append(html); // show/hide null values in cells $(".data-table-null").toggle(self._shownulls); @@ -160,6 +164,8 @@ DataTableView.prototype._renderSortingControls = function(sortingControls) { DataTableView.prototype._renderPagingControls = function(pageSizeControls, pagingControls) { var self = this; + self._lastPageNumber = Math.floor((theProject.rowModel.filtered - 1) / this._pageSize) + 1; + var from = (theProject.rowModel.start + 1); var to = Math.min(theProject.rowModel.filtered, theProject.rowModel.start + theProject.rowModel.limit); @@ -173,8 +179,30 @@ DataTableView.prototype._renderPagingControls = function(pageSizeControls, pagin previousPage.addClass("inaction"); } - $('').addClass("viewpanel-pagingcount").html(" " + from + " - " + to + " ").appendTo(pagingControls); + var pageControlsSpan = $('').attr("id", "viewpanel-paging-current"); + + var pageInputSize = 20 + (8 * ui.dataTableView._lastPageNumber.toString().length); + var currentPageInput = $('') + .change(function(evt) { self._onChangeGotoPage(this, evt); }) + .keydown(function(evt) { self._onKeyDownGotoPage(this, evt); }) + .attr("id", "viewpanel-paging-current-input") + .attr("min", 1) + .attr("max", self._lastPageNumber) + .attr("required", "required") + .val(self._currentPageNumber) + .css("width", pageInputSize +"px"); + + pageControlsSpan.append($.i18n('core-views/goto-page', '', self._lastPageNumber)); + pageControlsSpan.appendTo(pagingControls); + $('span#currentPageInput').replaceWith($(currentPageInput)); + + if(self._refocusPageInput == true) { + self._refocusPageInput = false; + var currentPageInputForFocus = $('input#viewpanel-paging-current-input'); + currentPageInputForFocus.ready(function(evt) { setTimeout(() => { currentPageInputForFocus.focus(); }, 250); }); + } + var nextPage = $(''+$.i18n('core-views/next')+' ›').appendTo(pagingControls); var lastPage = $(''+$.i18n('core-views/last')+' »').appendTo(pagingControls); if (theProject.rowModel.start + theProject.rowModel.limit < theProject.rowModel.filtered) { @@ -433,20 +461,60 @@ DataTableView.prototype._showRows = function(start, onDone) { }, this._sorting); }; +DataTableView.prototype._onChangeGotoPage = function(elmt, evt) { + var gotoPageNumber = parseInt($('input#viewpanel-paging-current-input').val()); + + if(typeof gotoPageNumber != "number" || isNaN(gotoPageNumber) || gotoPageNumber == "") { + $('input#viewpanel-paging-current-input').val(this._currentPageNumber); + return; + } + + if(gotoPageNumber > this._lastPageNumber) gotoPageNumber = this._lastPageNumber; + if(gotoPageNumber < 1) gotoPageNumber = 1; + + this._currentPageNumber = gotoPageNumber; + this._showRows((gotoPageNumber - 1) * this._pageSize); +}; + +DataTableView.prototype._onKeyDownGotoPage = function(elmt, evt) { + var keyDownCode = event.which; + + if([38, 40].indexOf(keyDownCode) == -1) return; + if(self._refocusPageInput == true) return; + + evt.preventDefault(); + this._refocusPageInput = true; + + var newPageValue = $('input#viewpanel-paging-current-input')[0].value; + if(keyDownCode == 38) { // Up arrow + if(newPageValue <= 1) return; + this._onClickPreviousPage(elmt, evt); + } + + if(keyDownCode == 40) { // Down arrow + if(newPageValue >= this._lastPageNumber) return; + this._onClickNextPage(elmt, evt); + } +}; + DataTableView.prototype._onClickPreviousPage = function(elmt, evt) { + this._currentPageNumber--; this._showRows(theProject.rowModel.start - this._pageSize); }; DataTableView.prototype._onClickNextPage = function(elmt, evt) { + this._currentPageNumber++; this._showRows(theProject.rowModel.start + this._pageSize); }; DataTableView.prototype._onClickFirstPage = function(elmt, evt) { + this._currentPageNumber = 1; this._showRows(0); }; DataTableView.prototype._onClickLastPage = function(elmt, evt) { - this._showRows(Math.floor((theProject.rowModel.filtered - 1) / this._pageSize) * this._pageSize); + this._currentPageNumber = this._lastPageNumber; + this._showRows((this._lastPageNumber - 1) * this._pageSize); }; DataTableView.prototype._getSortingCriteriaCount = function() { diff --git a/main/webapp/modules/core/styles/views/data-table-view.less b/main/webapp/modules/core/styles/views/data-table-view.less index 29259108f..ffe877937 100644 --- a/main/webapp/modules/core/styles/views/data-table-view.less +++ b/main/webapp/modules/core/styles/views/data-table-view.less @@ -55,6 +55,45 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. font-weight: bold; } +.viewpanel-rowrecord a { + background-color: @fill_primary; + margin: 0px 1px 0px 1px; + padding: 2px 5px 2px 5px; + .rounded_corners(4px); + } + +.viewpanel-pagesize a { + background-color: @fill_primary; + margin: 0px 2px 0px 2px; + padding: 2px 3px 2px 3px; + .rounded_corners(4px); + } + +div.viewpanel-pagesize span:first-of-type { + margin: 0px 0px 0px 20px; +} + +.viewpanel-paging a { + background-color: @fill_primary; + margin: 0px 4px 0px 4px; + padding: 2px 10px 2px 10px; + .rounded_corners(4px); + } + +.viewpanel-paging span#viewpanel-paging-current { + margin: 0 10px 0 10px; + padding: 0px; + } + +.viewpanel-paging input#viewpanel-paging-current-input { + width: 60px; + margin: 0px; + padding: 0px; + height: 16px; + position: relative; + top: -2px; + } + .data-table-header { width: 1px; position: relative;