Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c707b68
Work on adding show options to code list pop up
Crabcyborg Nov 17, 2023
5d653ef
Fix merge conflict and merge master
AbdiTolesa Sep 20, 2024
e54e79e
Add show=label shortcode types to calculation fields popup
AbdiTolesa Sep 20, 2024
d0e5cc0
Fix eslint error
AbdiTolesa Sep 23, 2024
dc3afa1
Move name field additional shortcode variants implementation to pro b…
AbdiTolesa Sep 26, 2024
2d3c6b7
Undo last commit
AbdiTolesa Sep 26, 2024
9d04319
Refactor code a bit
AbdiTolesa Sep 26, 2024
e4b34b6
Add a return type definition
AbdiTolesa Sep 26, 2024
65de1c9
Reduce nesting complication
AbdiTolesa Sep 26, 2024
bbbbb97
Add condition check for showing show=xx shortcodes in calculation popup
AbdiTolesa Sep 26, 2024
d6b8a36
Add inline comment to clarify condition check
AbdiTolesa Sep 26, 2024
cdafa45
Add Rename function
AbdiTolesa Sep 26, 2024
8d1c7f5
Fix eslint error
AbdiTolesa Oct 1, 2024
f80ffde
Improve performance
AbdiTolesa Oct 3, 2024
b528490
Merge branch 'master' into work_on_adding_show_options_to_code_list_p…
Crabcyborg Jan 9, 2025
9152b45
Make sure a function always return boolean
AbdiTolesa Jan 12, 2025
3ca1927
Merge branch 'work_on_adding_show_options_to_code_list_popup' of http…
AbdiTolesa Jan 12, 2025
7da58a6
Merge branch 'master' into work_on_adding_show_options_to_code_list_p…
Crabcyborg Feb 14, 2025
5cbcf7a
Merge master
AbdiTolesa Oct 23, 2025
5319d99
Move changes to source file
AbdiTolesa Oct 23, 2025
ee49592
Build files
AbdiTolesa Oct 23, 2025
20367ef
Fix eslint errors
AbdiTolesa Oct 23, 2025
cb38709
Get rid of unnecessary checks dependent on Pro
AbdiTolesa Oct 27, 2025
54305f9
Add Address field part shortcodes to calculation popup
shervElmi Dec 8, 2025
84962d2
Refactor: Improve maybeAddAddressPartShortcodes with modern ES6 syntax
shervElmi Dec 8, 2025
1ad9068
Refactor: Clean up JSDoc parameter formatting in maybeAddAddressPartS…
shervElmi Dec 8, 2025
434318a
Add extensibility hook for field part shortcodes in calculation popup
shervElmi Dec 9, 2025
6b72e5c
Merge pull request #2639 from Strategy11/feature/address-field-show-o…
Crabcyborg Dec 9, 2025
fb5eeb3
Rebuild files
AbdiTolesa Dec 10, 2025
6c3eae1
Rebuild files
AbdiTolesa Dec 10, 2025
9f75a6c
Rebuild files
AbdiTolesa Dec 10, 2025
1bb6eb7
Rebuild files and merge master
AbdiTolesa Dec 10, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css/admin/frm-settings-components.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/frm_admin.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion css/frm_testing_mode.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/addons-page.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/form-templates.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/formidable-settings-components.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/formidable_admin.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/formidable_blocks.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/formidable_dashboard.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/formidable_overlay.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion js/formidable_styles.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/frm_testing_mode.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/onboarding-wizard.js

Large diffs are not rendered by default.

110 changes: 98 additions & 12 deletions js/src/admin/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3088,21 +3088,107 @@ window.frmAdminBuildJS = function() {
continue;
}

const a = document.createElement( 'a' );
a.setAttribute( 'href', '#' );
a.setAttribute( 'data-code', fields[ i ].fieldId );
a.classList.add( 'frm_insert_code' );
a.appendChild( span( fields[ i ].fieldName ) );
a.appendChild( span( { className: 'frm-text-sm frm-text-grey-500', text: '[' + fields[ i ].fieldId + ']' } ) );

const li = document.createElement( 'li' );
li.classList.add( 'frm-field-list-' + fieldId );
li.classList.add( 'frm-field-list-' + fields[ i ].fieldType );
li.appendChild( a );
list.appendChild( li );
addCalcFieldLiToList( list, fieldId, fields[ i ].fieldId, fields[ i ].fieldName, fields[ i ].fieldType );
if ( shouldShowFieldLabelShortcode( fields[ i ].fieldType, fields[ i ].fieldId ) ) {
addCalcFieldLiToList( list, fieldId, fields[ i ].fieldId + ' show=label', fields[ i ].fieldName + ' (Label)', fields[ i ].fieldType );
}
maybeAddNamePartShortcodes( fields[ i ], fieldId, list );

/**
* Allows add-ons to add field part shortcodes to calculation popup.
*
* @since x.x
*
* @param {Object} hookArgs Arguments passed to the hook.
* @param {Object} hookArgs.field Field object containing fieldType, fieldId, and fieldName.
* @param {Number} hookArgs.fieldId ID of the field triggering the popup.
* @param {HTMLElement} hookArgs.list The 'ul' element containing field shortcodes.
* @param {Function} hookArgs.addCalcFieldLiToList Helper function: addCalcFieldLiToList(list, fieldId, code, label, fieldType).
*/
wp.hooks.doAction( 'frm_add_calc_field_shortcodes', { field: fields[ i ], fieldId, list, addCalcFieldLiToList } );
}
}

/**
* Adds shortcodes like [nameFieldId show=last] to the calculation popup.
*
* @since x.x
*
* @param {Object} field
* @param {Number} fieldId
* @param {HTMLElement} list The 'ul' element that contains field shortcodes available for calculation.
*
* @returns {void}
*/
function maybeAddNamePartShortcodes( field, fieldId, list ) {
if ( 'name' !== field.fieldType ) {
return;
}
Object.entries( {
first: __( 'First', 'formidable' ),
middle: __( 'Middle', 'formidable' ),
last: __( 'Last', 'formidable' ),
} ).forEach(
( [ code, label ] ) => {
addCalcFieldLiToList(
list,
fieldId,
field.fieldId + ' show=' + code,
field.fieldName + ' (' + label + ')',
field.fieldType
);
}
);
}

/**
* Returns true if [fieldId show=label] type shortcodes should be available in calculation fields popup.
*
* @since x.x
*
* @param {string} fieldType
* @param {Number} fieldId
*
* @returns {Boolean}
*/
function shouldShowFieldLabelShortcode( fieldType, fieldId ) {
return [ 'radio', 'checkbox', 'dropdown' ].includes( fieldType ) && !! document.getElementById( `separate_value_${ fieldId }` )?.checked;
}

Comment thread
Crabcyborg marked this conversation as resolved.
/**
* @param {HTMLElement} list
* @param {string} fieldId
* @param {string} code
* @param {string} label
* @param {string} fieldType
*
* @returns {void}
*/
function addCalcFieldLiToList( list, fieldId, code, label, fieldType ) {
const anchor = a( {
className: 'frm_insert_code',
children: [
span( {
text: '[' + code + ']'
} ),
document.createTextNode( label )
],
data: {
code
}
} );

list.appendChild(
tag(
'li',
{
className: 'frm-field-list-' + fieldId + ' ' + 'frm-field-list-' + fieldType,
child: anchor
}
)
);
}

function getExcludeArray( calcBox, isSummary ) {
const codeList = calcBox.querySelector( '.frm_code_list' );
const exclude = JSON.parse( codeList.getAttribute( 'data-exclude' ) );
Expand Down
2 changes: 1 addition & 1 deletion js/welcome-tour.js

Large diffs are not rendered by default.