From ef7aba0f242081c9cf9334fb68d0095ce2e2db33 Mon Sep 17 00:00:00 2001 From: veryspry Date: Thu, 27 Feb 2025 12:13:53 +0100 Subject: [PATCH 1/5] `gpadvs-dropdown-remove-button.js`: Added snippet to show remove button on Dropdown fields. --- .../gpadvs-dropdown-remove-button.js | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 gp-advanced-select/gpadvs-dropdown-remove-button.js diff --git a/gp-advanced-select/gpadvs-dropdown-remove-button.js b/gp-advanced-select/gpadvs-dropdown-remove-button.js new file mode 100644 index 000000000..f366360ae --- /dev/null +++ b/gp-advanced-select/gpadvs-dropdown-remove-button.js @@ -0,0 +1,24 @@ +/** + * Gravity Perks // Advanced Select // Dropdown Remove Button + * https://gravitywiz.com/documentation/gravity-forms-advanced-select/ + * + * Adds a Remove button to selection options in Dropdown fields. By default, + * the remove button is only added to Multi-Select fields. + * + * Instructions: + * + * 1. Install this snippet with our free Custom JavaScript plugin. + * https://gravitywiz.com/gravity-forms-code-chest/ + */ +window.gform.addFilter( + 'gpadvs_settings', + function(settings, gpadvsInstance, selectNamespace) { + settings.plugins.remove_button = { + title: window.GPADVS.strings?.remove_this_item + ? window.GPADVS.strings.remove_this_item + : 'Remove this item', + } + + return settings; + } +); From 0de9613eda6889bb064ceced9ad696b786d0aa64 Mon Sep 17 00:00:00 2001 From: veryspry Date: Fri, 28 Feb 2025 10:31:38 +0100 Subject: [PATCH 2/5] `gpadvs-dropdown-remove-button.js`: Added Tom Select remove button plugin reference. --- gp-advanced-select/gpadvs-dropdown-remove-button.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/gp-advanced-select/gpadvs-dropdown-remove-button.js b/gp-advanced-select/gpadvs-dropdown-remove-button.js index f366360ae..dd34e0228 100644 --- a/gp-advanced-select/gpadvs-dropdown-remove-button.js +++ b/gp-advanced-select/gpadvs-dropdown-remove-button.js @@ -4,6 +4,9 @@ * * Adds a Remove button to selection options in Dropdown fields. By default, * the remove button is only added to Multi-Select fields. + * + * The Remove Button is a built in plugin of Tom Select. + * @reference https://tom-select.js.org/plugins/remove-button/ * * Instructions: * From 793d79e72c6d2ecc8e9be923b572ee65bbee30cf Mon Sep 17 00:00:00 2001 From: veryspry Date: Fri, 28 Feb 2025 10:32:04 +0100 Subject: [PATCH 3/5] `gpadvs-dropdown-remove-button.js`: Added snippet to show "Clear" button. --- gp-advanced-select/gpadvs-clear-button.js | 25 +++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 gp-advanced-select/gpadvs-clear-button.js diff --git a/gp-advanced-select/gpadvs-clear-button.js b/gp-advanced-select/gpadvs-clear-button.js new file mode 100644 index 000000000..0c2dcfb0d --- /dev/null +++ b/gp-advanced-select/gpadvs-clear-button.js @@ -0,0 +1,25 @@ +/** + * Gravity Perks // Advanced Select // Clear Button + * https://gravitywiz.com/documentation/gravity-forms-advanced-select/ + * + * Adds a Clearn button to selection options in Dropdown fields. By default, + * the remove button is only added to Multi-Select fields. + * + * The Clear Button is a built in plugin of Tom Select. + * @reference https://tom-select.js.org/plugins/clear-button/ + * + * Instructions: + * + * 1. Install this snippet with our free Custom JavaScript plugin. + * https://gravitywiz.com/gravity-forms-code-chest/ + */ +window.gform.addFilter( + 'gpadvs_settings', + function(settings, gpadvsInstance, selectNamespace) { + settings.plugins.clear_button = { + title: 'Clear options', + }; + + return settings; + } +); From 8752ed8db8fbdfbc1bdb3f361d9ac9b9e043c124 Mon Sep 17 00:00:00 2001 From: veryspry Date: Tue, 18 Mar 2025 23:13:35 +0100 Subject: [PATCH 4/5] `gpadvs-dropdown-remove-button.js`: Added conditional showing how to scope to _only_ `dropdown` or `multiselect` fields. --- gp-advanced-select/gpadvs-clear-button.js | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/gp-advanced-select/gpadvs-clear-button.js b/gp-advanced-select/gpadvs-clear-button.js index 0c2dcfb0d..aad093133 100644 --- a/gp-advanced-select/gpadvs-clear-button.js +++ b/gp-advanced-select/gpadvs-clear-button.js @@ -2,8 +2,7 @@ * Gravity Perks // Advanced Select // Clear Button * https://gravitywiz.com/documentation/gravity-forms-advanced-select/ * - * Adds a Clearn button to selection options in Dropdown fields. By default, - * the remove button is only added to Multi-Select fields. + * Adds a Clear buton to GP Advanced Select fields. * * The Clear Button is a built in plugin of Tom Select. * @reference https://tom-select.js.org/plugins/clear-button/ @@ -16,9 +15,16 @@ window.gform.addFilter( 'gpadvs_settings', function(settings, gpadvsInstance, selectNamespace) { - settings.plugins.clear_button = { - title: 'Clear options', - }; + /** + * Scope to only dropdown fields. + * This can also be changed to 'multiselect' to only target multi-select fields + * OR the conditional can be removed to apply to all fields. + */ + if (gpadvsInstance.fieldType === 'dropdown') { + settings.plugins.clear_button = { + title: 'Clear options', + }; + } return settings; } From 148b7c536c7406436f97696f32ab64132a0bb9a5 Mon Sep 17 00:00:00 2001 From: veryspry Date: Thu, 20 Mar 2025 16:08:43 +0100 Subject: [PATCH 5/5] `gpadvs-dropdown-remove-button.js`: Updated documentation comment. --- gp-advanced-select/gpadvs-dropdown-remove-button.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gp-advanced-select/gpadvs-dropdown-remove-button.js b/gp-advanced-select/gpadvs-dropdown-remove-button.js index dd34e0228..a729c02ca 100644 --- a/gp-advanced-select/gpadvs-dropdown-remove-button.js +++ b/gp-advanced-select/gpadvs-dropdown-remove-button.js @@ -2,8 +2,7 @@ * Gravity Perks // Advanced Select // Dropdown Remove Button * https://gravitywiz.com/documentation/gravity-forms-advanced-select/ * - * Adds a Remove button to selection options in Dropdown fields. By default, - * the remove button is only added to Multi-Select fields. + * Adds a Remove button to selection options in Dropdown and MultiSelect fields. * * The Remove Button is a built in plugin of Tom Select. * @reference https://tom-select.js.org/plugins/remove-button/