cypress_test/integration_tests/desktop/writer/form_field_spec.js | 15 +++ loleaflet/css/loleaflet.css | 4 - loleaflet/src/layer/FormFieldButtonLayer.js | 38 ++++++---- 3 files changed, 44 insertions(+), 13 deletions(-)
New commits: commit 166c6d87f790d0f0a4d5731431914278ad47ccd8 Author: Tamás Zolnai <[email protected]> AuthorDate: Mon May 11 17:18:50 2020 +0200 Commit: Tamás Zolnai <[email protected]> CommitDate: Mon May 11 20:14:21 2020 +0200 MSForms: add a small padding to the list items. Change-Id: I4ba449a1c82ab046454a87d09f351879b5ac9f26 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93981 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tamás Zolnai <[email protected]> diff --git a/loleaflet/css/loleaflet.css b/loleaflet/css/loleaflet.css index b2f788141..3ec71f0f1 100644 --- a/loleaflet/css/loleaflet.css +++ b/loleaflet/css/loleaflet.css @@ -562,7 +562,9 @@ body { } .drop-down-field-list-item { - width: 100%; + width: calc(100% - 10px); + padding-left: 5px; + padding-right: 5px; } .drop-down-field-list-item.selected { commit f7bf4d5cdd5e97a7a11745ce9839db676ea9bbc4 Author: Tamás Zolnai <[email protected]> AuthorDate: Mon May 11 13:40:05 2020 +0200 Commit: Tamás Zolnai <[email protected]> CommitDate: Mon May 11 20:14:13 2020 +0200 MSForms: display placeholder text, when there is no items. Change-Id: I8acd29d734820f6ddc36871c7777fefd2956c213 Reviewed-on: https://gerrit.libreoffice.org/c/online/+/93962 Tested-by: Jenkins CollaboraOffice <[email protected]> Reviewed-by: Tamás Zolnai <[email protected]> diff --git a/cypress_test/integration_tests/desktop/writer/form_field_spec.js b/cypress_test/integration_tests/desktop/writer/form_field_spec.js index 8fbc268fb..def301989 100644 --- a/cypress_test/integration_tests/desktop/writer/form_field_spec.js +++ b/cypress_test/integration_tests/desktop/writer/form_field_spec.js @@ -227,6 +227,21 @@ describe('Form field button tests.', function() { buttonShouldExist(); cy.get('.drop-down-field-list-item') + .should('have.text', 'No Item specified'); + + cy.get('.drop-down-field-list-item.selected') + .should('not.exist'); + + cy.get('.form-field-button') + .click(); + + cy.get('.drop-down-field-list') + .should('be.visible'); + + cy.contains('.drop-down-field-list-item', 'No Item specified') + .click(); + + cy.get('.drop-down-field-list-item.selected') .should('not.exist'); }); }); diff --git a/loleaflet/src/layer/FormFieldButtonLayer.js b/loleaflet/src/layer/FormFieldButtonLayer.js index 0acaabce5..fcd826c28 100644 --- a/loleaflet/src/layer/FormFieldButtonLayer.js +++ b/loleaflet/src/layer/FormFieldButtonLayer.js @@ -104,20 +104,30 @@ L.FormFieldButton = L.Layer.extend({ var itemList = this._buttonData.params.items; var selected = parseInt(this._buttonData.params.selected); + for (var i = 0; i < itemList.length; ++i) { - var option = L.DomUtil.create('div', 'drop-down-field-list-item', dropDownList); - option.innerHTML = itemList[i]; + this._buildListItem(dropDownList, itemList[i], i === selected); + } + + if (this._buttonData.params.items.length === 0) { + this._buildListItem(dropDownList, this._buttonData.params.placeholderText, false); + } + }, - option.addEventListener('click', this._onListItemSelect); - option.map = this.map; + _buildListItem: function(parent, text, selected) { + var option = L.DomUtil.create('div', 'drop-down-field-list-item', parent); + option.innerHTML = text; - // Stop propagation to the main document - option.addEventListener('mouseup', function(event) {event.stopPropagation();}); - option.addEventListener('mousedown', function(event) {event.stopPropagation();}); + option.addEventListener('click', this._onListItemSelect); + option.map = this.map; + option._buttonData = this._buttonData; - if (i === selected) - option.classList.add('selected'); - } + // Stop propagation to the main document + option.addEventListener('mouseup', function(event) {event.stopPropagation();}); + option.addEventListener('mousedown', function(event) {event.stopPropagation();}); + + if (selected === true) + option.classList.add('selected'); }, onRemove: function () { @@ -131,16 +141,20 @@ L.FormFieldButton = L.Layer.extend({ _onListItemSelect: function(event) { $('.drop-down-field-list').hide(); + event.stopPropagation(); + + if (this._buttonData.params.items.length === 0) + return; + $('.drop-down-field-list-item.selected').removeClass('selected'); event.target.classList.add('selected'); - event.stopPropagation(); // Find item index var index = $(event.target).index(); var message = 'formfieldevent {\"type\": \"drop-down\",' + - '\"cmd\": \"selected\",' + + '\"cmd\": \"selected\",' + '\"data\":\"' + index.toString() + '\"}'; // Apply selection in the document. _______________________________________________ Libreoffice-commits mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits
