Skip to content

Commit

Permalink
Merge pull request #490 from infinum/origin/conditional-tags
Browse files Browse the repository at this point in the history
5.9.7
  • Loading branch information
iruzevic authored Jan 29, 2025
2 parents 949ea42 + 19db918 commit 925a702
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 4 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.

This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a CHANGELOG](https://keepachangelog.com/).

## [5.9.7]

### Fixed

- Conditional tags for `select`, `select multiple`, `country` and `country multiple` fields.

## [5.9.6]

### Added
Expand Down Expand Up @@ -1023,6 +1029,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a

- Initial production release.

[5.9.7]: https://github.com/infinum/eightshift-forms/compare/5.9.6...5.9.7
[5.9.6]: https://github.com/infinum/eightshift-forms/compare/5.9.5...5.9.6
[5.9.5]: https://github.com/infinum/eightshift-forms/compare/5.9.4...5.9.5
[5.9.4]: https://github.com/infinum/eightshift-forms/compare/5.9.3...5.9.4
Expand Down
2 changes: 1 addition & 1 deletion eightshift-forms.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Description: Eightshift Forms is a complete form builder plugin that utilizes modern Block editor features with multiple third-party integrations, bringing your project to a new level.
* Author: WordPress team @Infinum
* Author URI: https://eightshift.com/
* Version: 5.9.6
* Version: 5.9.7
* Text Domain: eightshift-forms
*
* @package EightshiftForms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const CONDITIONAL_TAGS_OPERATORS_LABELS = {
[globalManifest.comparator.LT]: __('less than', 'eightshift-forms'),
[globalManifest.comparator.LTE]: __('less than or equal', 'eightshift-forms'),
[globalManifest.comparator.C]: __('contains', 'eightshift-forms'),
[globalManifest.comparator.CN]: __('not contains', 'eightshift-forms'),
[globalManifest.comparator.SW]: __('starts with', 'eightshift-forms'),
[globalManifest.comparator.EW]: __('ends with', 'eightshift-forms'),
};
Expand Down
25 changes: 24 additions & 1 deletion src/Blocks/components/form/assets/conditional-tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export class ConditionalTags {
this.HIDE = globalManifest.comparatorActions.HIDE;
this.OR = globalManifest.comparatorLogic.OR;
this.AND = globalManifest.comparatorLogic.AND;
this.IS = globalManifest.comparator.IS;
this.ISN = globalManifest.comparator.ISN;
this.C = globalManifest.comparator.C;
this.CN = globalManifest.comparator.CN;

// Map all conditional logic as a object.
this.OPERATORS = this.utils.getComparator();
Expand Down Expand Up @@ -707,6 +711,25 @@ export class ConditionalTags {
value = this.state.getStateElementValue(inner[0], formId)[inner[2]] === inner[2] ? inner[2] : '';
}
break;
case 'select':
case 'country':
value = this.state.getStateElementValue(inner[0], formId).map((item) => item?.value);

if (value.length === 0) {
value = '';
}

if (inner[1] === this.IS) {
inner[1] = this.C;
}

if (inner[1] === this.ISN) {
inner[1] = this.CN;
}
break;
case 'phone':
value = this.utils.getPhoneCombinedValue(formId, inner[0]);
break;
default:
// Get element value by name.
value = this.state.getStateElementValue(inner[0], formId);
Expand Down Expand Up @@ -742,7 +765,7 @@ export class ConditionalTags {
*
* @returns {vodi}
*/
removeEvents(formId) {
removeEvents() {
window?.removeEventListener(
this.state.getStateEvent('formJsLoaded'),
this.onInitEvent
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/form/assets/enrichment.js
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,7 @@ export class Enrichment {
*
* @returns {vodi}
*/
removeEvents(formId) {
removeEvents() {
window?.removeEventListener(
this.state.getStateEvent('formJsLoaded'),
this.onLocalstoragePrefillEvent
Expand Down
2 changes: 1 addition & 1 deletion src/Blocks/components/form/assets/geolocation.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Geolocation {
*
* @returns {vodi}
*/
removeEvents(formId) {
removeEvents() {
window?.removeEventListener(
this.state.getStateEvent('formJsLoaded'),
this.onSetSelectField
Expand Down
2 changes: 2 additions & 0 deletions src/Blocks/components/form/assets/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1440,6 +1440,7 @@ export class Utils {
* lt - less than - if value is less than.
* lte - less/equal than - if value is less/equal than.
* c - contains - if value contains value.
* cn - contains not - if value doesn't contain value.
* sw - starts with - if value starts with value.
* ew - ends with - if value ends with value.
* b - between range - if value is between two values.
Expand All @@ -1458,6 +1459,7 @@ export class Utils {
[globalManifest.comparator.LT]: (start, value) => parseFloat(String(start)) < parseFloat(String(value)),
[globalManifest.comparator.LTE]: (start, value) => parseFloat(String(start)) <= parseFloat(String(value)),
[globalManifest.comparator.C]: (start, value) => start.includes(value),
[globalManifest.comparator.CN]: (start, value) => !start.includes(value),
[globalManifest.comparator.SW]: (start, value) => start.startsWith(value),
[globalManifest.comparator.EW]: (start, value) => start.endsWith(value),
[globalManifest.comparatorExtended.B]: (start, value, end) =>
Expand Down
1 change: 1 addition & 0 deletions src/Blocks/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@
"LT": "lt",
"LTE": "lte",
"C": "c",
"CN": "cn",
"SW": "sw",
"EW": "ew"
},
Expand Down

0 comments on commit 925a702

Please sign in to comment.