details: https://code.openbravo.com/erp/devel/pi/rev/d41eeba32732 changeset: 33872:d41eeba32732 user: Javier Armendáriz <javier.armendariz <at> openbravo.com> date: Wed Apr 25 12:32:18 2018 +0200 summary: Fixed issue 38421: Grid selector dropdown is too small.
Dropdown width calculations doesn't take into account that grid fields length may be longer than the available viewport, so part of the space left of the field is not visible in the viewport. ScrollLeft property gives the distance from the beginning to the point where fields starts to be visible in viewport, so subtracting this value gives the visible left space available. Also, the code is refactored to make this calculations more readable. diffstat: modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js | 37 +++++++-- 1 files changed, 29 insertions(+), 8 deletions(-) diffs (59 lines): diff -r 7b899caa2ef2 -r d41eeba32732 modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js --- a/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js Thu Apr 26 09:24:04 2018 +0200 +++ b/modules/org.openbravo.userinterface.selector/web/org.openbravo.userinterface.selector/js/ob-selector-item.js Wed Apr 25 12:32:18 2018 +0200 @@ -694,26 +694,47 @@ setPickListWidth: function () { var extraWidth = 0, leftFieldsWidth = 0, - i = 0, nameField = this.name, fieldWidth = this.getVisibleWidth(); // minimum width for smaller fields. fieldWidth = (fieldWidth < 150 ? 150 : fieldWidth); // Dropdown selector that shows more than one column. if (this.pickListFields.length > 1) { - // calculate width of checkBox and first fields before selector field in viewGrid if (this.form.view && !this.form.view.isShowingForm && this.grid) { - while (i < this.grid.fields.size() && nameField.localeCompare(this.grid.fields.get(i).valueField) !== 0) { - leftFieldsWidth = leftFieldsWidth + this.grid.fields.get(i).width; - i++; - } - // prevents a pickListWidth longer than width of the grid. - extraWidth = Math.min(150 * (this.pickListFields.length - 1), this.grid.width - fieldWidth - this.grid.scrollbarSize - leftFieldsWidth); + // Calculate the extra space available right of the field to add it as extra space to the pick list width + leftFieldsWidth = this.getVisibleLeftFieldWidth(nameField); + extraWidth = Math.min(150 * (this.pickListFields.length - 1), Math.max(this.getAvailableRightFieldWidth(fieldWidth, leftFieldsWidth), 0)); } } this.pickListWidth = fieldWidth + extraWidth; }, + getAvailableRightFieldWidth: function (fieldWidth, leftFieldsWidth) { + return this.grid.width - fieldWidth - this.grid.scrollbarSize - leftFieldsWidth; + }, + + getVisibleLeftFieldWidth: function (fieldName) { + var i = 0, + leftFieldsWidth = 0; + + // Calculate the width of all fields located left of the field which will display the pick list + while (i < this.grid.fields.size() && fieldName.localeCompare(this.grid.fields.get(i).valueField) !== 0) { + leftFieldsWidth = leftFieldsWidth + this.grid.fields.get(i).width; + i++; + } + + return this.removeSpaceHiddenByScroll(leftFieldsWidth); + }, + + removeSpaceHiddenByScroll: function (space) { + var visibleSpace = 0; + if (this.grid.body && isc.isA.Number(this.grid.body.scrollLeft)) { + visibleSpace = space - this.grid.body.scrollLeft; + return (visibleSpace >= 0) ? visibleSpace : space; + } + return space; + }, + enableShortcuts: function () { var ksAction_ShowPopup; ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Openbravo-commits mailing list Openbravo-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/openbravo-commits