From 273d0fab554492f727da4929134c71adf8db0044 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Martin?= Date: Wed, 11 Dec 2024 11:06:22 +0100 Subject: [PATCH 1/2] fix edition : hide select when launched from attribute table via parent --- assets/src/legacy/edition.js | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/assets/src/legacy/edition.js b/assets/src/legacy/edition.js index a1c1a23f6e..d67480524f 100644 --- a/assets/src/legacy/edition.js +++ b/assets/src/legacy/edition.js @@ -1617,19 +1617,13 @@ var lizEdition = function() { } else { var select = form.find('select[name="'+relationRefField+'"]'); if( select.length == 1 ){ - // Disable the select, the value will be stored in an hidden input - select.val(parentFeatProp) - .attr('disabled','disabled'); - // Create hidden input to store value because the select is disabled - var hiddenInput = $('') - .attr('id', select.attr('id')+'_hidden') - .attr('name', relationRefField) - .attr('value', parentFeatProp); - form.find('div.jforms-hiddens').append(hiddenInput); - // Disable required constraint - jFormsJQ.getForm(form.attr('id')) - .getControl(relationRefField) - .required=false; + // select the option via jquery (and fire event with "change", will update depending controls) + select.val(parentFeatProp).change(); + // create a disabled input with selected option value (will look alike a select) + let readOnlyInput4Select = $(''); + select.parent().append(readOnlyInput4Select); + // hide the select, we don't want to see it, but it need to still be enable for controls that depends of its value + select.addClass('hide'); } else { var input = form.find('input[name="'+relationRefField+'"]'); if( input.length == 1 && input.attr('type') != 'hidden'){ From 5047016d0f4aff88f485bbf94d7db11b24912fbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Martin?= Date: Wed, 11 Dec 2024 12:33:21 +0100 Subject: [PATCH 2/2] fix end2end test --- .../cypress/integration/feature_toolbar-ghaction.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/end2end/cypress/integration/feature_toolbar-ghaction.js b/tests/end2end/cypress/integration/feature_toolbar-ghaction.js index 7213ccc3c1..f8a9ffcbb4 100644 --- a/tests/end2end/cypress/integration/feature_toolbar-ghaction.js +++ b/tests/end2end/cypress/integration/feature_toolbar-ghaction.js @@ -442,8 +442,8 @@ describe('Feature Toolbar in popup', function () { cy.wait(300) - // Parent_id is disabled in form when edition is started from parent form - cy.get('#jforms_view_edition_parent_id').should('be.disabled') + // Parent_id is hidden in form when edition is started from parent form + cy.get('#jforms_view_edition_parent_id').should('have.class', 'hide'); // Parent_id input should have the value 2 selected cy.get('#jforms_view_edition_parent_id').find('option:selected').should('have.value', '2'); @@ -459,8 +459,8 @@ describe('Feature Toolbar in popup', function () { cy.wait(300) - // Parent_id is disabled in form when edition is started from parent form - cy.get('#jforms_view_edition_parent_id').should('be.disabled') + // Parent_id is hidden in form when edition is started from parent form + cy.get('#jforms_view_edition_parent_id').should('have.class', 'hide'); // Parent_id input should have the value 2 selected cy.get('#jforms_view_edition_parent_id').find('option:selected').should('have.value', '2');