From 06b1bbae03f8897d45bf36f3de8845da908a1282 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Wed, 28 Feb 2024 15:49:20 +0100 Subject: [PATCH 01/35] small fixes for JS on older version --- src/Blocks/components/form/assets/form.js | 2 +- src/Blocks/components/form/assets/state.js | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Blocks/components/form/assets/form.js b/src/Blocks/components/form/assets/form.js index d7384a0ce..3112b4ca1 100644 --- a/src/Blocks/components/form/assets/form.js +++ b/src/Blocks/components/form/assets/form.js @@ -1503,7 +1503,7 @@ export class Form { const formId = this.state.getFormIdByElement(event.target); if (this.state.getStateFormStepsIsUsed(formId)) { - const button = event.submitter; + const button = event?.submitter; const field = this.state.getFormFieldElementByChild(button); // Steps flow. diff --git a/src/Blocks/components/form/assets/state.js b/src/Blocks/components/form/assets/state.js index d6a22a85a..d2a57d92c 100644 --- a/src/Blocks/components/form/assets/state.js +++ b/src/Blocks/components/form/assets/state.js @@ -536,19 +536,19 @@ export class State { return Object?.values(Object?.fromEntries(Object?.entries(getState([obj], formId) ?? {})?.filter(([key, value]) => value[targetKey] === findItem))); // eslint-disable-line no-unused-vars }; getFormElementByChild = (element) => { - return element.closest(this.getStateSelector('form', true)); + return element?.closest(this.getStateSelector('form', true)); }; getFormFieldElementByChild = (element) => { - return element.closest(this.getStateSelector('field', true)); + return element?.closest(this.getStateSelector('field', true)); }; getFormId = (element) => { - return element.getAttribute(this.getStateAttribute('formId')); + return element?.getAttribute(this.getStateAttribute('formId')); }; getFormIdByElement = (element) => { - return this.getFormElementByChild(element).getAttribute(this.getStateAttribute('formId')); + return this.getFormElementByChild(element)?.getAttribute(this.getStateAttribute('formId')); }; getFieldNameByElement = (element) => { - return this.getFormFieldElementByChild(element).getAttribute(this.getStateAttribute('fieldName')); + return this.getFormFieldElementByChild(element)?.getAttribute(this.getStateAttribute('fieldName')); }; getRestUrl = (value, isPartial = false) => { return getRestUrl(value, isPartial); From 526a7e7bdef42cecba94f9673045ca6a6342293f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Thu, 29 Feb 2024 14:06:17 +0100 Subject: [PATCH 02/35] update --- composer.json | 8 +- composer.lock | 39 +++-- src/Blocks/components/rating/manifest.json | 40 ----- .../slider/components/slider-editor.js | 71 ++++++++ .../slider/components/slider-options.js | 157 ++++++++++++++++++ src/Blocks/components/slider/manifest.json | 113 +++++++++++++ .../components/slider/slider-editor.scss | 1 + .../slider/slider-frontend-mandatory.scss | 1 + .../components/slider/slider-frontend.scss | 69 ++++++++ src/Blocks/components/slider/slider.php | 110 ++++++++++++ .../custom/slider/components/slider-editor.js | 14 ++ .../slider/components/slider-options.js | 13 ++ src/Blocks/custom/slider/manifest.json | 19 +++ src/Blocks/custom/slider/slider-block.js | 15 ++ src/Blocks/custom/slider/slider.php | 14 ++ src/Blocks/manifest.json | 3 +- 16 files changed, 633 insertions(+), 54 deletions(-) create mode 100644 src/Blocks/components/slider/components/slider-editor.js create mode 100644 src/Blocks/components/slider/components/slider-options.js create mode 100644 src/Blocks/components/slider/manifest.json create mode 100644 src/Blocks/components/slider/slider-editor.scss create mode 100644 src/Blocks/components/slider/slider-frontend-mandatory.scss create mode 100644 src/Blocks/components/slider/slider-frontend.scss create mode 100644 src/Blocks/components/slider/slider.php create mode 100644 src/Blocks/custom/slider/components/slider-editor.js create mode 100644 src/Blocks/custom/slider/components/slider-options.js create mode 100644 src/Blocks/custom/slider/manifest.json create mode 100644 src/Blocks/custom/slider/slider-block.js create mode 100644 src/Blocks/custom/slider/slider.php diff --git a/composer.json b/composer.json index 0d3837d74..2d35f56a2 100644 --- a/composer.json +++ b/composer.json @@ -37,10 +37,16 @@ "szepeviktor/phpstan-wordpress": "^1.3", "wp-cli/wp-cli": "^2.9" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/infinum/eightshift-forms-utils.git" + } + ], "require": { "php": "^7.4 || >=8.0", "erusev/parsedown": "^1.7.4", - "infinum/eightshift-forms-utils": "^1.2.4" + "infinum/eightshift-forms-utils": "dev-feature/calculator" }, "suggest": { "ext-pcov": "* || This extension is used for code coverage generation. Use either pcov, or xdebug, but not both.", diff --git a/composer.lock b/composer.lock index f7d91e595..348fc1728 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4af23d84c4cb0933ffd292f56030fa05", + "content-hash": "437c7adfe65a6cb984edaa04ba89bde9", "packages": [ { "name": "erusev/parsedown", @@ -58,16 +58,16 @@ }, { "name": "infinum/eightshift-forms-utils", - "version": "1.2.4", + "version": "dev-feature/calculator", "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "d17843ca1611c8880eac59ea783c96d6d278fddc" + "reference": "af5f0b66f48b4078fdf46dbdb8b615a1c1c5ee18" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/d17843ca1611c8880eac59ea783c96d6d278fddc", - "reference": "d17843ca1611c8880eac59ea783c96d6d278fddc", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/af5f0b66f48b4078fdf46dbdb8b615a1c1c5ee18", + "reference": "af5f0b66f48b4078fdf46dbdb8b615a1c1c5ee18", "shasum": "" }, "require": { @@ -90,7 +90,21 @@ "EightshiftFormsUtils\\": "src/" } }, - "notification-url": "https://packagist.org/downloads/", + "scripts": { + "test:types": [ + "@php ./vendor/bin/phpstan analyze" + ], + "test:standards": [ + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 7.4-" + ], + "standards:fix": [ + "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --runtime-set testVersion 7.4-" + ], + "test": [ + "@test:standards", + "@test:types" + ] + }, "license": [ "MIT" ], @@ -105,21 +119,21 @@ "description": "Eightshift Forms Utils library for shared functionality", "homepage": "https://eightshift.com/", "keywords": [ - "Forms", + "Gutenberg", + "Mailchimp", + "WordPress", "blocks", "composer", "email", "form", - "gutenberg", - "mailchimp", - "plugin", - "wordpress" + "forms", + "plugin" ], "support": { "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-02-27T16:57:22+00:00" + "time": "2024-02-29T12:17:26+00:00" }, { "name": "infinum/eightshift-libs", @@ -5036,6 +5050,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { + "infinum/eightshift-forms-utils": 20, "brain/faker": 20 }, "prefer-stable": true, diff --git a/src/Blocks/components/rating/manifest.json b/src/Blocks/components/rating/manifest.json index adc0a314b..17ea6b8e5 100644 --- a/src/Blocks/components/rating/manifest.json +++ b/src/Blocks/components/rating/manifest.json @@ -61,45 +61,5 @@ "ratingDisabledOptions": { "type": "array" } - }, - "options": { - "ratingType": [ - { - "label": "Plain text", - "value": "text" - }, - { - "label": "E-mail", - "value": "email" - }, - { - "label": "URL", - "value": "url" - }, - { - "label": "Number", - "value": "number" - } - ], - "ratingMinLength": { - "min": 0, - "step": 1 - }, - "ratingMaxLength": { - "min": 1, - "step": 1 - }, - "ratingMin": { - "min": 0, - "step": 1 - }, - "ratingMax": { - "min": 1, - "step": 1 - }, - "ratingStep": { - "min": 1, - "step": 1 - } } } diff --git a/src/Blocks/components/slider/components/slider-editor.js b/src/Blocks/components/slider/components/slider-editor.js new file mode 100644 index 000000000..0fb6d2d30 --- /dev/null +++ b/src/Blocks/components/slider/components/slider-editor.js @@ -0,0 +1,71 @@ +import React from 'react'; +import { select } from '@wordpress/data'; +import classnames from 'classnames'; +import { + selector, + checkAttr, + props, + STORE_NAME, + getAttrKey, +} from '@eightshift/frontend-libs/scripts'; +import { FieldEditor } from '../../field/components/field-editor'; +import { MissingName, preventSaveOnMissingProps } from '../../utils'; +import { ConditionalTagsEditor } from '../../conditional-tags/components/conditional-tags-editor'; +import { getUtilsIcons } from '../../form/assets/state-init'; + +export const SliderEditor = (attributes) => { + const manifest = select(STORE_NAME).getComponent('slider'); + + const { + componentName, + componentClass + } = manifest; + + const { + additionalFieldClass, + blockClientId, + additionalClass, + } = attributes; + + const sliderName = checkAttr('sliderName', attributes, manifest); + // const sliderAmount = checkAttr('sliderAmount', attributes, manifest); + const sliderValue = checkAttr('sliderValue', attributes, manifest); + + const sliderClass = classnames([ + selector(componentClass, componentClass), + selector(additionalClass, additionalClass), + ]); + + preventSaveOnMissingProps(blockClientId, getAttrKey('sliderName', attributes, manifest), sliderName); + + const slider = ( +
+ {/* {sliderAmount && + <> + {[...Array(parseInt(sliderAmount, 10))].map((x, i) => { + return
; + })} + + } */} + + + + {sliderName && + + } +
+ ); + + return ( + + ); +}; diff --git a/src/Blocks/components/slider/components/slider-options.js b/src/Blocks/components/slider/components/slider-options.js new file mode 100644 index 000000000..eef19a0c3 --- /dev/null +++ b/src/Blocks/components/slider/components/slider-options.js @@ -0,0 +1,157 @@ +import React from 'react'; +import { useState } from '@wordpress/element'; +import { select } from '@wordpress/data'; +import { __ } from '@wordpress/i18n'; +import { TextControl, PanelBody } from '@wordpress/components'; +import { + icons, + checkAttr, + getAttrKey, + IconLabel, + props, + Section, + IconToggle, + STORE_NAME, +} from '@eightshift/frontend-libs/scripts'; +import { FieldOptions, FieldOptionsMore, FieldOptionsLayout, FieldOptionsVisibility } from '../../field/components/field-options'; +import { isOptionDisabled, NameField } from '../../utils'; +import { ConditionalTagsOptions } from '../../conditional-tags/components/conditional-tags-options'; + +export const SliderOptions = (attributes) => { + const manifest = select(STORE_NAME).getComponent('slider'); + + const { + setAttributes, + title = __('Slider', 'eightshift-forms'), + } = attributes; + + const [isNameChanged, setIsNameChanged] = useState(false); + + const sliderName = checkAttr('sliderName', attributes, manifest); + const sliderValue = checkAttr('sliderValue', attributes, manifest); + const sliderIsDisabled = checkAttr('sliderIsDisabled', attributes, manifest); + const sliderIsReadOnly = checkAttr('sliderIsReadOnly', attributes, manifest); + const sliderIsRequired = checkAttr('sliderIsRequired', attributes, manifest); + const sliderTracking = checkAttr('sliderTracking', attributes, manifest); + const sliderDisabledOptions = checkAttr('sliderDisabledOptions', attributes, manifest); + const sliderStartAmount = checkAttr('sliderStartAmount', attributes, manifest); + const sliderEndAmount = checkAttr('sliderEndAmount', attributes, manifest); + const sliderStepAmount = checkAttr('sliderStepAmount', attributes, manifest); + + return ( + +
+ + + } + value={sliderStartAmount} + onChange={(value) => setAttributes({ [getAttrKey('sliderStartAmount', attributes, manifest)]: value })} + type='number' + disabled={isOptionDisabled(getAttrKey('sliderStartAmount', attributes, manifest), sliderDisabledOptions)} + /> + } + value={sliderEndAmount} + onChange={(value) => setAttributes({ [getAttrKey('sliderEndAmount', attributes, manifest)]: value })} + type='number' + disabled={isOptionDisabled(getAttrKey('sliderEndAmount', attributes, manifest), sliderDisabledOptions)} + /> + } + value={sliderStepAmount} + onChange={(value) => setAttributes({ [getAttrKey('sliderStepAmount', attributes, manifest)]: value })} + type='number' + className='es-no-field-spacing' + disabled={isOptionDisabled(getAttrKey('sliderStepAmount', attributes, manifest), sliderDisabledOptions)} + /> +
+ + + + + +
+ } + value={sliderValue} + onChange={(value) => setAttributes({ [getAttrKey('sliderValue', attributes, manifest)]: value })} + disabled={isOptionDisabled(getAttrKey('sliderValue', attributes, manifest), sliderDisabledOptions)} + /> + + + + + setAttributes({ [getAttrKey('sliderIsReadOnly', attributes, manifest)]: value })} + disabled={isOptionDisabled(getAttrKey('sliderIsReadOnly', attributes, manifest), sliderDisabledOptions)} + /> + + setAttributes({ [getAttrKey('sliderIsDisabled', attributes, manifest)]: value })} + disabled={isOptionDisabled(getAttrKey('sliderIsDisabled', attributes, manifest), sliderDisabledOptions)} + noBottomSpacing + /> +
+ +
+ setAttributes({ [getAttrKey('sliderIsRequired', attributes, manifest)]: value })} + disabled={isOptionDisabled(getAttrKey('sliderIsRequired', attributes, manifest), sliderDisabledOptions)} + /> +
+ +
+ } + value={sliderTracking} + onChange={(value) => setAttributes({ [getAttrKey('sliderTracking', attributes, manifest)]: value })} + disabled={isOptionDisabled(getAttrKey('sliderTracking', attributes, manifest), sliderDisabledOptions)} + className='es-no-field-spacing' + /> +
+ + + + +
+ ); +}; diff --git a/src/Blocks/components/slider/manifest.json b/src/Blocks/components/slider/manifest.json new file mode 100644 index 000000000..858939b27 --- /dev/null +++ b/src/Blocks/components/slider/manifest.json @@ -0,0 +1,113 @@ +{ + "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/component.json", + "componentName": "slider", + "title": "Slider", + "componentClass": "es-slider", + "example": { + "attributes": { + "sliderName": "Name", + "sliderValue": "Value", + "sliderIsDisabled": false, + "sliderIsReadOnly": false, + "sliderIsRequired": false + } + }, + "components": { + "field": "field", + "conditionalTags": "conditionalTags" + }, + "attributes": { + "sliderName": { + "type": "string" + }, + "sliderStartAmount": { + "type": "string", + "default": "0" + }, + "sliderStepAmount": { + "type": "string", + "default": "1" + }, + "sliderEndAmount": { + "type": "string", + "default": "10" + }, + "sliderValue": { + "type": "string" + }, + "sliderTypeCustom": { + "type": "string" + }, + "sliderIsDisabled": { + "type": "boolean", + "default": false + }, + "sliderUseLabelAsPlaceholder": { + "type": "boolean", + "default": false + }, + "sliderIsReadOnly": { + "type": "boolean", + "default": false + }, + "sliderIsRequired": { + "type": "boolean", + "default": false + }, + "sliderTracking": { + "type": "string" + }, + "sliderMeta": { + "type": "string" + }, + "sliderAttrs": { + "type": "object" + }, + "sliderFieldAttrs": { + "type": "object" + }, + "sliderDisabledOptions": { + "type": "array" + } + }, + "options": { + "sliderType": [ + { + "label": "Plain text", + "value": "text" + }, + { + "label": "E-mail", + "value": "email" + }, + { + "label": "URL", + "value": "url" + }, + { + "label": "Number", + "value": "number" + } + ], + "sliderMinLength": { + "min": 0, + "step": 1 + }, + "sliderMaxLength": { + "min": 1, + "step": 1 + }, + "sliderMin": { + "min": 0, + "step": 1 + }, + "sliderMax": { + "min": 1, + "step": 1 + }, + "sliderStep": { + "min": 1, + "step": 1 + } + } +} diff --git a/src/Blocks/components/slider/slider-editor.scss b/src/Blocks/components/slider/slider-editor.scss new file mode 100644 index 000000000..a1a6b8275 --- /dev/null +++ b/src/Blocks/components/slider/slider-editor.scss @@ -0,0 +1 @@ +@import './slider-frontend'; diff --git a/src/Blocks/components/slider/slider-frontend-mandatory.scss b/src/Blocks/components/slider/slider-frontend-mandatory.scss new file mode 100644 index 000000000..a1a6b8275 --- /dev/null +++ b/src/Blocks/components/slider/slider-frontend-mandatory.scss @@ -0,0 +1 @@ +@import './slider-frontend'; diff --git a/src/Blocks/components/slider/slider-frontend.scss b/src/Blocks/components/slider/slider-frontend.scss new file mode 100644 index 000000000..4e45c6d07 --- /dev/null +++ b/src/Blocks/components/slider/slider-frontend.scss @@ -0,0 +1,69 @@ +.es-slider { + $this: &; + + --es-slider-icon-size: 1.5rem; + --es-slider-icon-spacing: 0.1rem; + --es-slider-icon-color: var(--global-colors-esf-gray-300); + --es-slider-icon-active-color: var(--global-colors-esf-yellow-500); + + display: inline-flex; + align-items: center; + position: relative; + + &:hover { + #{$this}__star path { + color: var(--es-slider-icon-active-color) !important; // stylelint-disable-line declaration-no-important + fill: var(--es-slider-icon-active-color) !important; // stylelint-disable-line declaration-no-important + } + } + + &__star { + display: flex; + cursor: pointer; + + svg { + padding: 0 var(--es-slider-icon-spacing); + inline-size: calc(var(--es-slider-icon-size) + calc(var(--es-slider-icon-spacing) * 2)); + block-size: calc(var(--es-slider-icon-size) + calc(var(--es-slider-icon-spacing) * 2)); + } + + path { + color: var(--es-slider-icon-active-color); + fill: var(--es-slider-icon-active-color); + + transition: { + property: color, fill; + timing-function: ease-out, cubic-bezier(0.34, 1.56, 0.64, 1); + duration: 0.15s; + delay: 0.05s; + } + } + + * { + user-select: none !important; // stylelint-disable-line declaration-no-important + pointer-events: none !important; // stylelint-disable-line declaration-no-important + } + + &:hover ~ #{$this}__star path { + color: var(--es-slider-icon-color) !important; // stylelint-disable-line declaration-no-important + fill: var(--es-slider-icon-color) !important; // stylelint-disable-line declaration-no-important + } + } + + &[data-slider="0"] #{$this}__star path, + &[data-slider=""] #{$this}__star path { + color: var(--es-slider-icon-color); + fill: var(--es-slider-icon-color); + } + + @for $i from 1 through 10 { + &[data-slider="#{$i}"] #{$this}__star[data-slider="#{$i}"] ~ #{$this}__star path { + color: var(--es-slider-icon-color); + fill: var(--es-slider-icon-color); + } + } + + &__input { + display: none; + } +} diff --git a/src/Blocks/components/slider/slider.php b/src/Blocks/components/slider/slider.php new file mode 100644 index 000000000..dd9324cf6 --- /dev/null +++ b/src/Blocks/components/slider/slider.php @@ -0,0 +1,110 @@ + $value) { + $sliderAttrsOutput .= wp_kses_post(" {$key}='" . $value . "'"); + } +} + +// Additional content filter. +$additionalContent = UtilsGeneralHelper::getBlockAdditionalContentViaFilter('slider', $attributes); + +$stars = ''; + +// for ($i = 1; $i < $sliderAmount + 1; $i++) { +// $stars .= ' +//
+// ' . UtilsHelper::getUtilsIcons('slider') . +// '
'; +// } + +$slider = ' + +
+ ' . $stars . ' +
+ ' . $additionalContent . ' +'; + +echo Components::render( + 'field', + array_merge( + Components::props('field', $attributes, [ + 'fieldContent' => $slider, + 'fieldId' => $sliderName, + 'fieldName' => $sliderName, + 'fieldTypeInternal' => FormsHelper::getStateFieldType('slider'), + 'fieldIsRequired' => $sliderIsRequired, + 'fieldDisabled' => !empty($sliderIsDisabled), + 'fieldTypeCustom' => $sliderTypeCustom ?: 'slider', // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found + 'fieldTracking' => $sliderTracking, + 'fieldHideLabel' => $sliderHideLabel, + 'fieldConditionalTags' => Components::render( + 'conditional-tags', + Components::props('conditionalTags', $attributes) + ), + 'fieldAttrs' => $sliderFieldAttrs, + ]), + [ + 'additionalFieldClass' => $attributes['additionalFieldClass'] ?? '', + 'selectorClass' => $manifest['componentName'] ?? '' + ] + ) +); diff --git a/src/Blocks/custom/slider/components/slider-editor.js b/src/Blocks/custom/slider/components/slider-editor.js new file mode 100644 index 000000000..b75f4a1da --- /dev/null +++ b/src/Blocks/custom/slider/components/slider-editor.js @@ -0,0 +1,14 @@ +import React from 'react'; +import { props } from '@eightshift/frontend-libs/scripts'; +import { SliderEditor as SliderEditorComponent } from '../../../components/slider/components/slider-editor'; + +export const SliderEditor = ({ attributes, setAttributes, clientId }) => { + return ( + + ); +}; diff --git a/src/Blocks/custom/slider/components/slider-options.js b/src/Blocks/custom/slider/components/slider-options.js new file mode 100644 index 000000000..3f3162903 --- /dev/null +++ b/src/Blocks/custom/slider/components/slider-options.js @@ -0,0 +1,13 @@ +import React from 'react'; +import { props } from '@eightshift/frontend-libs/scripts'; +import { SliderOptions as SliderOptionsComponent } from '../../../components/slider/components/slider-options'; + +export const SliderOptions = ({ attributes, setAttributes }) => { + return ( + + ); +}; diff --git a/src/Blocks/custom/slider/manifest.json b/src/Blocks/custom/slider/manifest.json new file mode 100644 index 000000000..66b0791ef --- /dev/null +++ b/src/Blocks/custom/slider/manifest.json @@ -0,0 +1,19 @@ +{ + "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", + "blockName": "slider", + "title": "Slider", + "description" : "A simple star slider field", + "category": "eightshift-forms", + "icon": { + "src": "es-slider" + }, + "keywords": [ + "slider" + ], + "components": { + "slider": "slider" + }, + "parent": [ + "eightshift-forms/form" + ] +} diff --git a/src/Blocks/custom/slider/slider-block.js b/src/Blocks/custom/slider/slider-block.js new file mode 100644 index 000000000..f5788c275 --- /dev/null +++ b/src/Blocks/custom/slider/slider-block.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { InspectorControls } from '@wordpress/block-editor'; +import { SliderEditor } from './components/slider-editor'; +import { SliderOptions } from './components/slider-options'; + +export const Slider = (props) => { + return ( + <> + + + + + + ); +}; diff --git a/src/Blocks/custom/slider/slider.php b/src/Blocks/custom/slider/slider.php new file mode 100644 index 000000000..2175b61c0 --- /dev/null +++ b/src/Blocks/custom/slider/slider.php @@ -0,0 +1,14 @@ + Date: Thu, 29 Feb 2024 19:24:18 +0100 Subject: [PATCH 03/35] update --- .../input/components/input-editor.js | 36 ++-- .../input/components/input-options.js | 18 +- src/Blocks/components/input/input-admin.scss | 1 - src/Blocks/components/input/input-editor.scss | 4 + src/Blocks/components/input/input-style.scss | 17 ++ src/Blocks/components/input/input.php | 15 +- src/Blocks/components/input/manifest.json | 16 +- .../phone/components/phone-options.js | 2 +- .../slider/components/slider-editor.js | 71 -------- .../slider/components/slider-options.js | 157 ------------------ src/Blocks/components/slider/manifest.json | 113 ------------- .../components/slider/slider-editor.scss | 1 - .../slider/slider-frontend-mandatory.scss | 1 - .../components/slider/slider-frontend.scss | 69 -------- src/Blocks/components/slider/slider.php | 110 ------------ .../custom/slider/components/slider-editor.js | 14 -- .../slider/components/slider-options.js | 13 -- src/Blocks/custom/slider/manifest.json | 19 --- src/Blocks/custom/slider/slider-block.js | 15 -- src/Blocks/custom/slider/slider.php | 14 -- src/Blocks/manifest.json | 3 +- 21 files changed, 76 insertions(+), 633 deletions(-) delete mode 100644 src/Blocks/components/slider/components/slider-editor.js delete mode 100644 src/Blocks/components/slider/components/slider-options.js delete mode 100644 src/Blocks/components/slider/manifest.json delete mode 100644 src/Blocks/components/slider/slider-editor.scss delete mode 100644 src/Blocks/components/slider/slider-frontend-mandatory.scss delete mode 100644 src/Blocks/components/slider/slider-frontend.scss delete mode 100644 src/Blocks/components/slider/slider.php delete mode 100644 src/Blocks/custom/slider/components/slider-editor.js delete mode 100644 src/Blocks/custom/slider/components/slider-options.js delete mode 100644 src/Blocks/custom/slider/manifest.json delete mode 100644 src/Blocks/custom/slider/slider-block.js delete mode 100644 src/Blocks/custom/slider/slider.php diff --git a/src/Blocks/components/input/components/input-editor.js b/src/Blocks/components/input/components/input-editor.js index 924e4f6bc..57f15b76a 100644 --- a/src/Blocks/components/input/components/input-editor.js +++ b/src/Blocks/components/input/components/input-editor.js @@ -23,15 +23,13 @@ export const InputEditor = (attributes) => { const inputName = checkAttr('inputName', attributes, manifest); const inputValue = checkAttr('inputValue', attributes, manifest); const inputPlaceholder = checkAttr('inputPlaceholder', attributes, manifest); - let inputType = checkAttr('inputType', attributes, manifest); + const inputType = checkAttr('inputType', attributes, manifest); + const inputMin = checkAttr('inputMin', attributes, manifest); + const inputMax = checkAttr('inputMax', attributes, manifest); + const inputStep = checkAttr('inputStep', attributes, manifest); preventSaveOnMissingProps(blockClientId, getAttrKey('inputName', attributes, manifest), inputName); - // For some reason React won't allow input type email. - if (inputType === 'email' || inputType === 'url') { - inputType = 'text'; - } - const inputClass = classnames([ selector(componentClass, componentClass), selector(additionalClass, additionalClass), @@ -39,13 +37,25 @@ export const InputEditor = (attributes) => { const input = ( <> - + {inputType === 'range' ? + : + + } diff --git a/src/Blocks/components/input/components/input-options.js b/src/Blocks/components/input/components/input-options.js index da9e506db..99010e2fc 100644 --- a/src/Blocks/components/input/components/input-options.js +++ b/src/Blocks/components/input/components/input-options.js @@ -81,6 +81,9 @@ export const InputOptions = (attributes) => { inputValidationPatternOptions = esFormsLocalization.validationPatternsOptions; } + // Output number to 2 decimal places if it's a float if not output to fixed number. + const formatNumber = (number) => (Number.isInteger(number) ? number.toString() : number.toFixed(2)); + return (
@@ -113,7 +116,7 @@ export const InputOptions = (attributes) => { setAttributes({ [getAttrKey('inputIsEmail', attributes, manifest)]: true }); } - if (value === 'number') { + if (value === 'number' || value === 'range') { setAttributes({ [getAttrKey('inputIsNumber', attributes, manifest)]: true }); } @@ -213,7 +216,7 @@ export const InputOptions = (attributes) => { /> } - {(showInputMinLength || showInputMaxLength) && + {(!['number', 'range'].includes(inputType) && (showInputMinLength || showInputMaxLength)) && { } - {inputType === 'number' && (showInputMin || showInputMax) && + {((inputType === 'number' || inputType === 'range') && (showInputMin || showInputMax)) && { setAttributes({ [getAttrKey('inputMin', attributes, manifest)]: value })} + onChange={(value) => setAttributes({ [getAttrKey('inputMin', attributes, manifest)]: formatNumber(value) })} min={options.inputMin.min} step={options.inputMin.step} disabled={isOptionDisabled(getAttrKey('inputMin', attributes, manifest), inputDisabledOptions)} @@ -314,7 +317,7 @@ export const InputOptions = (attributes) => { setAttributes({ [getAttrKey('inputMax', attributes, manifest)]: value })} + onChange={(value) => setAttributes({ [getAttrKey('inputMax', attributes, manifest)]: formatNumber(value) })} min={options.inputMax.min} step={options.inputMax.step} disabled={isOptionDisabled(getAttrKey('inputMax', attributes, manifest), inputDisabledOptions)} @@ -338,18 +341,17 @@ export const InputOptions = (attributes) => { } - {inputType === 'number' && showInputStep && + {(inputType === 'number' || inputType === 'range') && showInputStep &&
setAttributes({ [getAttrKey('inputStep', attributes, manifest)]: value })} + onChange={(value) => setAttributes({ [getAttrKey('inputStep', attributes, manifest)]: formatNumber(value) })} min={options.inputStep.min} step={options.inputStep.step} disabled={isOptionDisabled(getAttrKey('inputStep', attributes, manifest), inputDisabledOptions)} fixedWidth={4} noBottomSpacing - placeholder='1' /> {inputStep > 0 && !isOptionDisabled(getAttrKey('inputStep', attributes, manifest), inputDisabledOptions) && diff --git a/src/Blocks/components/input/input-admin.scss b/src/Blocks/components/input/input-admin.scss index 1359a5fda..ac2a8e192 100644 --- a/src/Blocks/components/input/input-admin.scss +++ b/src/Blocks/components/input/input-admin.scss @@ -49,7 +49,6 @@ input.es-input { } } - .es-field__content:has(.es-field__before-content):has(.es-field__after-content):has(.es-input:focus-visible) { .es-field__after-content, .es-field__before-content { diff --git a/src/Blocks/components/input/input-editor.scss b/src/Blocks/components/input/input-editor.scss index c38c0c9c9..430326d81 100644 --- a/src/Blocks/components/input/input-editor.scss +++ b/src/Blocks/components/input/input-editor.scss @@ -2,6 +2,10 @@ input.es-input { @include input-styles-editor; + + &[type='range'] { + padding: 0 !important; // stylelint-disable-line declaration-no-important + } } // Collision with WPML. diff --git a/src/Blocks/components/input/input-style.scss b/src/Blocks/components/input/input-style.scss index 75f94e36c..01d6e0347 100644 --- a/src/Blocks/components/input/input-style.scss +++ b/src/Blocks/components/input/input-style.scss @@ -1,3 +1,20 @@ input.es-input { @include input-styles; + + &[type='range'] { + padding: 0; + appearance: none; + background: transparent; + block-size: 0.9375rem; + + &::-webkit-slider-thumb, + &::-moz-range-thumb { + appearance: none; + height: 1.45rem; + width: 1.45rem; + cursor: pointer; + background-color: var(--global-colors-esf-admin-accent); + border-radius: 50%; + } + } } diff --git a/src/Blocks/components/input/input.php b/src/Blocks/components/input/input.php index ca6a4dae5..a9fe67b2f 100644 --- a/src/Blocks/components/input/input.php +++ b/src/Blocks/components/input/input.php @@ -44,11 +44,6 @@ Components::selector($additionalClass, $additionalClass), ]); -// Override types. -if ($inputType === 'email' || $inputType === 'url') { - $inputType = 'text'; -} - if ($inputValue) { $inputAttrs['value'] = esc_attr($inputValue); } @@ -62,6 +57,16 @@ $inputHideLabel = true; } +if ($inputType === 'range') { + $inputAttrs['min'] = esc_attr($inputMin); + $inputAttrs['max'] = esc_attr($inputMax); + $inputAttrs['step'] = esc_attr($inputStep); + + if (!$inputValue) { + $inputAttrs['value'] = esc_attr($inputMin); + } +} + $inputAttrsOutput = ''; if ($inputAttrs) { foreach ($inputAttrs as $key => $value) { diff --git a/src/Blocks/components/input/manifest.json b/src/Blocks/components/input/manifest.json index b7a67039e..1de6f3d7a 100644 --- a/src/Blocks/components/input/manifest.json +++ b/src/Blocks/components/input/manifest.json @@ -114,6 +114,10 @@ { "label": "Number", "value": "number" + }, + { + "label": "Range", + "value": "range" } ], "inputMinLength": { @@ -125,16 +129,16 @@ "step": 1 }, "inputMin": { - "min": 0, - "step": 1 + "min": 0.01, + "step": 0.01 }, "inputMax": { - "min": 1, - "step": 1 + "min": 0.01, + "step": 0.01 }, "inputStep": { - "min": 1, - "step": 1 + "min": 0.01, + "step": 0.01 } } } diff --git a/src/Blocks/components/phone/components/phone-options.js b/src/Blocks/components/phone/components/phone-options.js index 6fcf0da3d..33f00c663 100644 --- a/src/Blocks/components/phone/components/phone-options.js +++ b/src/Blocks/components/phone/components/phone-options.js @@ -24,7 +24,7 @@ export const PhoneOptions = (attributes) => { const phoneName = checkAttr('phoneName', attributes, manifest); const phoneValue = checkAttr('phoneValue', attributes, manifest); const phonePlaceholder = checkAttr('phonePlaceholder', attributes, manifest); - const phoneIsNumber = checkAttr('phoneIsNumber', attributes, manifest); + const phoneIsNumber = checkAttr('phoneIsNumber', attributes, manifest); // Used in validation class to validate if the input is a number. const phoneIsDisabled = checkAttr('phoneIsDisabled', attributes, manifest); const phoneIsReadOnly = checkAttr('phoneIsReadOnly', attributes, manifest); const phoneIsRequired = checkAttr('phoneIsRequired', attributes, manifest); diff --git a/src/Blocks/components/slider/components/slider-editor.js b/src/Blocks/components/slider/components/slider-editor.js deleted file mode 100644 index 0fb6d2d30..000000000 --- a/src/Blocks/components/slider/components/slider-editor.js +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react'; -import { select } from '@wordpress/data'; -import classnames from 'classnames'; -import { - selector, - checkAttr, - props, - STORE_NAME, - getAttrKey, -} from '@eightshift/frontend-libs/scripts'; -import { FieldEditor } from '../../field/components/field-editor'; -import { MissingName, preventSaveOnMissingProps } from '../../utils'; -import { ConditionalTagsEditor } from '../../conditional-tags/components/conditional-tags-editor'; -import { getUtilsIcons } from '../../form/assets/state-init'; - -export const SliderEditor = (attributes) => { - const manifest = select(STORE_NAME).getComponent('slider'); - - const { - componentName, - componentClass - } = manifest; - - const { - additionalFieldClass, - blockClientId, - additionalClass, - } = attributes; - - const sliderName = checkAttr('sliderName', attributes, manifest); - // const sliderAmount = checkAttr('sliderAmount', attributes, manifest); - const sliderValue = checkAttr('sliderValue', attributes, manifest); - - const sliderClass = classnames([ - selector(componentClass, componentClass), - selector(additionalClass, additionalClass), - ]); - - preventSaveOnMissingProps(blockClientId, getAttrKey('sliderName', attributes, manifest), sliderName); - - const slider = ( -
- {/* {sliderAmount && - <> - {[...Array(parseInt(sliderAmount, 10))].map((x, i) => { - return
; - })} - - } */} - - - - {sliderName && - - } -
- ); - - return ( - - ); -}; diff --git a/src/Blocks/components/slider/components/slider-options.js b/src/Blocks/components/slider/components/slider-options.js deleted file mode 100644 index eef19a0c3..000000000 --- a/src/Blocks/components/slider/components/slider-options.js +++ /dev/null @@ -1,157 +0,0 @@ -import React from 'react'; -import { useState } from '@wordpress/element'; -import { select } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; -import { TextControl, PanelBody } from '@wordpress/components'; -import { - icons, - checkAttr, - getAttrKey, - IconLabel, - props, - Section, - IconToggle, - STORE_NAME, -} from '@eightshift/frontend-libs/scripts'; -import { FieldOptions, FieldOptionsMore, FieldOptionsLayout, FieldOptionsVisibility } from '../../field/components/field-options'; -import { isOptionDisabled, NameField } from '../../utils'; -import { ConditionalTagsOptions } from '../../conditional-tags/components/conditional-tags-options'; - -export const SliderOptions = (attributes) => { - const manifest = select(STORE_NAME).getComponent('slider'); - - const { - setAttributes, - title = __('Slider', 'eightshift-forms'), - } = attributes; - - const [isNameChanged, setIsNameChanged] = useState(false); - - const sliderName = checkAttr('sliderName', attributes, manifest); - const sliderValue = checkAttr('sliderValue', attributes, manifest); - const sliderIsDisabled = checkAttr('sliderIsDisabled', attributes, manifest); - const sliderIsReadOnly = checkAttr('sliderIsReadOnly', attributes, manifest); - const sliderIsRequired = checkAttr('sliderIsRequired', attributes, manifest); - const sliderTracking = checkAttr('sliderTracking', attributes, manifest); - const sliderDisabledOptions = checkAttr('sliderDisabledOptions', attributes, manifest); - const sliderStartAmount = checkAttr('sliderStartAmount', attributes, manifest); - const sliderEndAmount = checkAttr('sliderEndAmount', attributes, manifest); - const sliderStepAmount = checkAttr('sliderStepAmount', attributes, manifest); - - return ( - -
- - - } - value={sliderStartAmount} - onChange={(value) => setAttributes({ [getAttrKey('sliderStartAmount', attributes, manifest)]: value })} - type='number' - disabled={isOptionDisabled(getAttrKey('sliderStartAmount', attributes, manifest), sliderDisabledOptions)} - /> - } - value={sliderEndAmount} - onChange={(value) => setAttributes({ [getAttrKey('sliderEndAmount', attributes, manifest)]: value })} - type='number' - disabled={isOptionDisabled(getAttrKey('sliderEndAmount', attributes, manifest), sliderDisabledOptions)} - /> - } - value={sliderStepAmount} - onChange={(value) => setAttributes({ [getAttrKey('sliderStepAmount', attributes, manifest)]: value })} - type='number' - className='es-no-field-spacing' - disabled={isOptionDisabled(getAttrKey('sliderStepAmount', attributes, manifest), sliderDisabledOptions)} - /> -
- - - - - -
- } - value={sliderValue} - onChange={(value) => setAttributes({ [getAttrKey('sliderValue', attributes, manifest)]: value })} - disabled={isOptionDisabled(getAttrKey('sliderValue', attributes, manifest), sliderDisabledOptions)} - /> - - - - - setAttributes({ [getAttrKey('sliderIsReadOnly', attributes, manifest)]: value })} - disabled={isOptionDisabled(getAttrKey('sliderIsReadOnly', attributes, manifest), sliderDisabledOptions)} - /> - - setAttributes({ [getAttrKey('sliderIsDisabled', attributes, manifest)]: value })} - disabled={isOptionDisabled(getAttrKey('sliderIsDisabled', attributes, manifest), sliderDisabledOptions)} - noBottomSpacing - /> -
- -
- setAttributes({ [getAttrKey('sliderIsRequired', attributes, manifest)]: value })} - disabled={isOptionDisabled(getAttrKey('sliderIsRequired', attributes, manifest), sliderDisabledOptions)} - /> -
- -
- } - value={sliderTracking} - onChange={(value) => setAttributes({ [getAttrKey('sliderTracking', attributes, manifest)]: value })} - disabled={isOptionDisabled(getAttrKey('sliderTracking', attributes, manifest), sliderDisabledOptions)} - className='es-no-field-spacing' - /> -
- - - - -
- ); -}; diff --git a/src/Blocks/components/slider/manifest.json b/src/Blocks/components/slider/manifest.json deleted file mode 100644 index 858939b27..000000000 --- a/src/Blocks/components/slider/manifest.json +++ /dev/null @@ -1,113 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/component.json", - "componentName": "slider", - "title": "Slider", - "componentClass": "es-slider", - "example": { - "attributes": { - "sliderName": "Name", - "sliderValue": "Value", - "sliderIsDisabled": false, - "sliderIsReadOnly": false, - "sliderIsRequired": false - } - }, - "components": { - "field": "field", - "conditionalTags": "conditionalTags" - }, - "attributes": { - "sliderName": { - "type": "string" - }, - "sliderStartAmount": { - "type": "string", - "default": "0" - }, - "sliderStepAmount": { - "type": "string", - "default": "1" - }, - "sliderEndAmount": { - "type": "string", - "default": "10" - }, - "sliderValue": { - "type": "string" - }, - "sliderTypeCustom": { - "type": "string" - }, - "sliderIsDisabled": { - "type": "boolean", - "default": false - }, - "sliderUseLabelAsPlaceholder": { - "type": "boolean", - "default": false - }, - "sliderIsReadOnly": { - "type": "boolean", - "default": false - }, - "sliderIsRequired": { - "type": "boolean", - "default": false - }, - "sliderTracking": { - "type": "string" - }, - "sliderMeta": { - "type": "string" - }, - "sliderAttrs": { - "type": "object" - }, - "sliderFieldAttrs": { - "type": "object" - }, - "sliderDisabledOptions": { - "type": "array" - } - }, - "options": { - "sliderType": [ - { - "label": "Plain text", - "value": "text" - }, - { - "label": "E-mail", - "value": "email" - }, - { - "label": "URL", - "value": "url" - }, - { - "label": "Number", - "value": "number" - } - ], - "sliderMinLength": { - "min": 0, - "step": 1 - }, - "sliderMaxLength": { - "min": 1, - "step": 1 - }, - "sliderMin": { - "min": 0, - "step": 1 - }, - "sliderMax": { - "min": 1, - "step": 1 - }, - "sliderStep": { - "min": 1, - "step": 1 - } - } -} diff --git a/src/Blocks/components/slider/slider-editor.scss b/src/Blocks/components/slider/slider-editor.scss deleted file mode 100644 index a1a6b8275..000000000 --- a/src/Blocks/components/slider/slider-editor.scss +++ /dev/null @@ -1 +0,0 @@ -@import './slider-frontend'; diff --git a/src/Blocks/components/slider/slider-frontend-mandatory.scss b/src/Blocks/components/slider/slider-frontend-mandatory.scss deleted file mode 100644 index a1a6b8275..000000000 --- a/src/Blocks/components/slider/slider-frontend-mandatory.scss +++ /dev/null @@ -1 +0,0 @@ -@import './slider-frontend'; diff --git a/src/Blocks/components/slider/slider-frontend.scss b/src/Blocks/components/slider/slider-frontend.scss deleted file mode 100644 index 4e45c6d07..000000000 --- a/src/Blocks/components/slider/slider-frontend.scss +++ /dev/null @@ -1,69 +0,0 @@ -.es-slider { - $this: &; - - --es-slider-icon-size: 1.5rem; - --es-slider-icon-spacing: 0.1rem; - --es-slider-icon-color: var(--global-colors-esf-gray-300); - --es-slider-icon-active-color: var(--global-colors-esf-yellow-500); - - display: inline-flex; - align-items: center; - position: relative; - - &:hover { - #{$this}__star path { - color: var(--es-slider-icon-active-color) !important; // stylelint-disable-line declaration-no-important - fill: var(--es-slider-icon-active-color) !important; // stylelint-disable-line declaration-no-important - } - } - - &__star { - display: flex; - cursor: pointer; - - svg { - padding: 0 var(--es-slider-icon-spacing); - inline-size: calc(var(--es-slider-icon-size) + calc(var(--es-slider-icon-spacing) * 2)); - block-size: calc(var(--es-slider-icon-size) + calc(var(--es-slider-icon-spacing) * 2)); - } - - path { - color: var(--es-slider-icon-active-color); - fill: var(--es-slider-icon-active-color); - - transition: { - property: color, fill; - timing-function: ease-out, cubic-bezier(0.34, 1.56, 0.64, 1); - duration: 0.15s; - delay: 0.05s; - } - } - - * { - user-select: none !important; // stylelint-disable-line declaration-no-important - pointer-events: none !important; // stylelint-disable-line declaration-no-important - } - - &:hover ~ #{$this}__star path { - color: var(--es-slider-icon-color) !important; // stylelint-disable-line declaration-no-important - fill: var(--es-slider-icon-color) !important; // stylelint-disable-line declaration-no-important - } - } - - &[data-slider="0"] #{$this}__star path, - &[data-slider=""] #{$this}__star path { - color: var(--es-slider-icon-color); - fill: var(--es-slider-icon-color); - } - - @for $i from 1 through 10 { - &[data-slider="#{$i}"] #{$this}__star[data-slider="#{$i}"] ~ #{$this}__star path { - color: var(--es-slider-icon-color); - fill: var(--es-slider-icon-color); - } - } - - &__input { - display: none; - } -} diff --git a/src/Blocks/components/slider/slider.php b/src/Blocks/components/slider/slider.php deleted file mode 100644 index dd9324cf6..000000000 --- a/src/Blocks/components/slider/slider.php +++ /dev/null @@ -1,110 +0,0 @@ - $value) { - $sliderAttrsOutput .= wp_kses_post(" {$key}='" . $value . "'"); - } -} - -// Additional content filter. -$additionalContent = UtilsGeneralHelper::getBlockAdditionalContentViaFilter('slider', $attributes); - -$stars = ''; - -// for ($i = 1; $i < $sliderAmount + 1; $i++) { -// $stars .= ' -//
-// ' . UtilsHelper::getUtilsIcons('slider') . -// '
'; -// } - -$slider = ' - -
- ' . $stars . ' -
- ' . $additionalContent . ' -'; - -echo Components::render( - 'field', - array_merge( - Components::props('field', $attributes, [ - 'fieldContent' => $slider, - 'fieldId' => $sliderName, - 'fieldName' => $sliderName, - 'fieldTypeInternal' => FormsHelper::getStateFieldType('slider'), - 'fieldIsRequired' => $sliderIsRequired, - 'fieldDisabled' => !empty($sliderIsDisabled), - 'fieldTypeCustom' => $sliderTypeCustom ?: 'slider', // phpcs:ignore WordPress.PHP.DisallowShortTernary.Found - 'fieldTracking' => $sliderTracking, - 'fieldHideLabel' => $sliderHideLabel, - 'fieldConditionalTags' => Components::render( - 'conditional-tags', - Components::props('conditionalTags', $attributes) - ), - 'fieldAttrs' => $sliderFieldAttrs, - ]), - [ - 'additionalFieldClass' => $attributes['additionalFieldClass'] ?? '', - 'selectorClass' => $manifest['componentName'] ?? '' - ] - ) -); diff --git a/src/Blocks/custom/slider/components/slider-editor.js b/src/Blocks/custom/slider/components/slider-editor.js deleted file mode 100644 index b75f4a1da..000000000 --- a/src/Blocks/custom/slider/components/slider-editor.js +++ /dev/null @@ -1,14 +0,0 @@ -import React from 'react'; -import { props } from '@eightshift/frontend-libs/scripts'; -import { SliderEditor as SliderEditorComponent } from '../../../components/slider/components/slider-editor'; - -export const SliderEditor = ({ attributes, setAttributes, clientId }) => { - return ( - - ); -}; diff --git a/src/Blocks/custom/slider/components/slider-options.js b/src/Blocks/custom/slider/components/slider-options.js deleted file mode 100644 index 3f3162903..000000000 --- a/src/Blocks/custom/slider/components/slider-options.js +++ /dev/null @@ -1,13 +0,0 @@ -import React from 'react'; -import { props } from '@eightshift/frontend-libs/scripts'; -import { SliderOptions as SliderOptionsComponent } from '../../../components/slider/components/slider-options'; - -export const SliderOptions = ({ attributes, setAttributes }) => { - return ( - - ); -}; diff --git a/src/Blocks/custom/slider/manifest.json b/src/Blocks/custom/slider/manifest.json deleted file mode 100644 index 66b0791ef..000000000 --- a/src/Blocks/custom/slider/manifest.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", - "blockName": "slider", - "title": "Slider", - "description" : "A simple star slider field", - "category": "eightshift-forms", - "icon": { - "src": "es-slider" - }, - "keywords": [ - "slider" - ], - "components": { - "slider": "slider" - }, - "parent": [ - "eightshift-forms/form" - ] -} diff --git a/src/Blocks/custom/slider/slider-block.js b/src/Blocks/custom/slider/slider-block.js deleted file mode 100644 index f5788c275..000000000 --- a/src/Blocks/custom/slider/slider-block.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import { InspectorControls } from '@wordpress/block-editor'; -import { SliderEditor } from './components/slider-editor'; -import { SliderOptions } from './components/slider-options'; - -export const Slider = (props) => { - return ( - <> - - - - - - ); -}; diff --git a/src/Blocks/custom/slider/slider.php b/src/Blocks/custom/slider/slider.php deleted file mode 100644 index 2175b61c0..000000000 --- a/src/Blocks/custom/slider/slider.php +++ /dev/null @@ -1,14 +0,0 @@ - Date: Thu, 29 Feb 2024 19:31:49 +0100 Subject: [PATCH 04/35] update --- CHANGELOG.md | 12 ++++++++++++ composer.json | 8 +------- composer.lock | 39 ++++++++++++--------------------------- 3 files changed, 25 insertions(+), 34 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eeb87ca44..a855ab910 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,18 @@ 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/). +### Added +- New `range` field for the forms. + +### Changed +- `Input` field now output email and url as a correct type so it can be user on mobile devices. + +### Fixed +- Js errors when missing data. + +### Removed +- Unnecessary options in the `rating` field. + ## [3.0.4] ### Added diff --git a/composer.json b/composer.json index 2d35f56a2..0d3837d74 100644 --- a/composer.json +++ b/composer.json @@ -37,16 +37,10 @@ "szepeviktor/phpstan-wordpress": "^1.3", "wp-cli/wp-cli": "^2.9" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/infinum/eightshift-forms-utils.git" - } - ], "require": { "php": "^7.4 || >=8.0", "erusev/parsedown": "^1.7.4", - "infinum/eightshift-forms-utils": "dev-feature/calculator" + "infinum/eightshift-forms-utils": "^1.2.4" }, "suggest": { "ext-pcov": "* || This extension is used for code coverage generation. Use either pcov, or xdebug, but not both.", diff --git a/composer.lock b/composer.lock index 348fc1728..f7d91e595 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "437c7adfe65a6cb984edaa04ba89bde9", + "content-hash": "4af23d84c4cb0933ffd292f56030fa05", "packages": [ { "name": "erusev/parsedown", @@ -58,16 +58,16 @@ }, { "name": "infinum/eightshift-forms-utils", - "version": "dev-feature/calculator", + "version": "1.2.4", "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "af5f0b66f48b4078fdf46dbdb8b615a1c1c5ee18" + "reference": "d17843ca1611c8880eac59ea783c96d6d278fddc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/af5f0b66f48b4078fdf46dbdb8b615a1c1c5ee18", - "reference": "af5f0b66f48b4078fdf46dbdb8b615a1c1c5ee18", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/d17843ca1611c8880eac59ea783c96d6d278fddc", + "reference": "d17843ca1611c8880eac59ea783c96d6d278fddc", "shasum": "" }, "require": { @@ -90,21 +90,7 @@ "EightshiftFormsUtils\\": "src/" } }, - "scripts": { - "test:types": [ - "@php ./vendor/bin/phpstan analyze" - ], - "test:standards": [ - "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs --runtime-set testVersion 7.4-" - ], - "standards:fix": [ - "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf --runtime-set testVersion 7.4-" - ], - "test": [ - "@test:standards", - "@test:types" - ] - }, + "notification-url": "https://packagist.org/downloads/", "license": [ "MIT" ], @@ -119,21 +105,21 @@ "description": "Eightshift Forms Utils library for shared functionality", "homepage": "https://eightshift.com/", "keywords": [ - "Gutenberg", - "Mailchimp", - "WordPress", + "Forms", "blocks", "composer", "email", "form", - "forms", - "plugin" + "gutenberg", + "mailchimp", + "plugin", + "wordpress" ], "support": { "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-02-29T12:17:26+00:00" + "time": "2024-02-27T16:57:22+00:00" }, { "name": "infinum/eightshift-libs", @@ -5050,7 +5036,6 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { - "infinum/eightshift-forms-utils": 20, "brain/faker": 20 }, "prefer-stable": true, From 068c817225515147a64442d6aacf781d2c92e9e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Thu, 29 Feb 2024 19:45:00 +0100 Subject: [PATCH 05/35] update --- CHANGELOG.md | 1 + src/Blocks/components/country/country.php | 2 ++ src/Blocks/components/country/manifest.json | 4 ++++ src/Blocks/components/input/input.php | 3 +++ src/Blocks/components/input/manifest.json | 4 ++++ src/Blocks/components/rating/manifest.json | 4 ++++ src/Blocks/components/rating/rating.php | 2 ++ src/Blocks/components/textarea/manifest.json | 4 ++++ src/Blocks/components/textarea/textarea.php | 2 ++ 9 files changed, 26 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a855ab910..da7771499 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a ### Added - New `range` field for the forms. +- New `singleSubmit` attribute on all fields to allow only one submit per form to be used as calculation form. ### Changed - `Input` field now output email and url as a correct type so it can be user on mobile devices. diff --git a/src/Blocks/components/country/country.php b/src/Blocks/components/country/country.php index f3060f021..8f30c2209 100644 --- a/src/Blocks/components/country/country.php +++ b/src/Blocks/components/country/country.php @@ -35,6 +35,7 @@ $countryFieldAttrs = Components::checkAttr('countryFieldAttrs', $attributes, $manifest); $countryPlaceholder = Components::checkAttr('countryPlaceholder', $attributes, $manifest); $countryUseLabelAsPlaceholder = Components::checkAttr('countryUseLabelAsPlaceholder', $attributes, $manifest); +$countrySingleSubmit = Components::checkAttr('countrySingleSubmit', $attributes, $manifest); // Fix for getting attribute that is part of the child component. $countryHideLabel = false; @@ -44,6 +45,7 @@ Components::selector($manifestSelect['componentClass'], $manifestSelect['componentClass'], 'select'), Components::selector($componentClass, $componentClass, 'select'), Components::selector($additionalClass, $additionalClass), + Components::selector($countrySingleSubmit, UtilsHelper::getStateSelectorAdmin('singleSubmit')), ]); if ($countryUseSearch) { diff --git a/src/Blocks/components/country/manifest.json b/src/Blocks/components/country/manifest.json index cbe5790b6..a0dc020b7 100644 --- a/src/Blocks/components/country/manifest.json +++ b/src/Blocks/components/country/manifest.json @@ -57,6 +57,10 @@ }, "countryTypeCustom": { "type": "string" + }, + "countrySingleSubmit": { + "type": "boolean", + "default": false } } } diff --git a/src/Blocks/components/input/input.php b/src/Blocks/components/input/input.php index a9fe67b2f..3b0901a63 100644 --- a/src/Blocks/components/input/input.php +++ b/src/Blocks/components/input/input.php @@ -8,6 +8,7 @@ use EightshiftForms\Helpers\FormsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; +use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper; use EightshiftFormsVendor\EightshiftLibs\Helpers\Components; $manifest = Components::getManifest(__DIR__); @@ -34,6 +35,7 @@ $inputAttrs = Components::checkAttr('inputAttrs', $attributes, $manifest); $inputFieldAttrs = Components::checkAttr('inputFieldAttrs', $attributes, $manifest); $inputUseLabelAsPlaceholder = Components::checkAttr('inputUseLabelAsPlaceholder', $attributes, $manifest); +$inputSingleSubmit = Components::checkAttr('inputSingleSubmit', $attributes, $manifest); // Fix for getting attribute that is part of the child component. $inputHideLabel = false; @@ -42,6 +44,7 @@ $inputClass = Components::classnames([ Components::selector($componentClass, $componentClass), Components::selector($additionalClass, $additionalClass), + Components::selector($inputSingleSubmit, UtilsHelper::getStateSelectorAdmin('singleSubmit')), ]); if ($inputValue) { diff --git a/src/Blocks/components/input/manifest.json b/src/Blocks/components/input/manifest.json index 1de6f3d7a..3aa2692bf 100644 --- a/src/Blocks/components/input/manifest.json +++ b/src/Blocks/components/input/manifest.json @@ -95,6 +95,10 @@ }, "inputDisabledOptions": { "type": "array" + }, + "inputSingleSubmit": { + "type": "boolean", + "default": false } }, "options": { diff --git a/src/Blocks/components/rating/manifest.json b/src/Blocks/components/rating/manifest.json index 17ea6b8e5..8423f3c94 100644 --- a/src/Blocks/components/rating/manifest.json +++ b/src/Blocks/components/rating/manifest.json @@ -60,6 +60,10 @@ }, "ratingDisabledOptions": { "type": "array" + }, + "ratingSingleSubmit": { + "type": "boolean", + "default": false } } } diff --git a/src/Blocks/components/rating/rating.php b/src/Blocks/components/rating/rating.php index aa684d411..fa6850aed 100644 --- a/src/Blocks/components/rating/rating.php +++ b/src/Blocks/components/rating/rating.php @@ -30,11 +30,13 @@ $ratingAttrs = Components::checkAttr('ratingAttrs', $attributes, $manifest); $ratingFieldAttrs = Components::checkAttr('ratingFieldAttrs', $attributes, $manifest); $ratingAmount = Components::checkAttr('ratingAmount', $attributes, $manifest); +$ratingSingleSubmit = Components::checkAttr('ratingSingleSubmit', $attributes, $manifest); $ratingHideLabel = false; $ratingClass = Components::classnames([ Components::selector($componentClass, $componentClass), Components::selector($additionalClass, $additionalClass), + Components::selector($ratingSingleSubmit, UtilsHelper::getStateSelectorAdmin('singleSubmit')), UtilsHelper::getStateSelector('rating'), ]); diff --git a/src/Blocks/components/textarea/manifest.json b/src/Blocks/components/textarea/manifest.json index 9fe9b015c..aa053d7d5 100644 --- a/src/Blocks/components/textarea/manifest.json +++ b/src/Blocks/components/textarea/manifest.json @@ -89,6 +89,10 @@ "textareaIsPreventSubmit": { "type": "boolean", "default": false + }, + "textareaSingleSubmit": { + "type": "boolean", + "default": false } }, "options": { diff --git a/src/Blocks/components/textarea/textarea.php b/src/Blocks/components/textarea/textarea.php index 0936ffeaf..a9eab2744 100644 --- a/src/Blocks/components/textarea/textarea.php +++ b/src/Blocks/components/textarea/textarea.php @@ -36,6 +36,7 @@ $textareaLimitHeight = Components::checkAttr('textareaLimitHeight', $attributes, $manifest); $textareaIsPreventSubmit = Components::checkAttr('textareaIsPreventSubmit', $attributes, $manifest); $textareaUseLabelAsPlaceholder = Components::checkAttr('textareaUseLabelAsPlaceholder', $attributes, $manifest); +$textareaSingleSubmit = Components::checkAttr('textareaSingleSubmit', $attributes, $manifest); // Fix for getting attribute that is part of the child component. $textareaHideLabel = false; @@ -47,6 +48,7 @@ Components::selector($textareaIsMonospace, $componentClass, '', 'monospace'), Components::selector($textareaSize, $componentClass, 'size', $textareaSize), Components::selector($textareaLimitHeight, $componentClass, '', 'limit-height'), + Components::selector($textareaSingleSubmit, UtilsHelper::getStateSelectorAdmin('singleSubmit')), ]); if ($textareaSaveAsJson) { From 2104ab5f1cde80cb37763020e24d46169c041e76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 1 Mar 2024 09:36:37 +0100 Subject: [PATCH 06/35] updating PR --- .../custom/calculator/calculator-block.js | 24 ++++++++++++ .../custom/calculator/calculator-hooks.js | 34 +++++++++++++++++ src/Blocks/custom/calculator/calculator.php | 16 ++++++++ .../components/calculator-editor.js | 27 +++++++++++++ .../components/calculator-options.js | 30 +++++++++++++++ src/Blocks/custom/calculator/manifest.json | 38 +++++++++++++++++++ src/Blocks/custom/form-selector/manifest.json | 19 +++++++++- 7 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 src/Blocks/custom/calculator/calculator-block.js create mode 100644 src/Blocks/custom/calculator/calculator-hooks.js create mode 100644 src/Blocks/custom/calculator/calculator.php create mode 100644 src/Blocks/custom/calculator/components/calculator-editor.js create mode 100644 src/Blocks/custom/calculator/components/calculator-options.js create mode 100644 src/Blocks/custom/calculator/manifest.json diff --git a/src/Blocks/custom/calculator/calculator-block.js b/src/Blocks/custom/calculator/calculator-block.js new file mode 100644 index 000000000..56134145c --- /dev/null +++ b/src/Blocks/custom/calculator/calculator-block.js @@ -0,0 +1,24 @@ +import React from 'react'; +import { InspectorControls } from '@wordpress/block-editor'; +import { CalculatorEditor } from './components/calculator-editor'; +import { CalculatorOptions } from './components/calculator-options'; + +export const Calculator = (props) => { + const itemIdKey = 'calculatorIntegrationId'; + + return ( + <> + + + + + + ); +}; diff --git a/src/Blocks/custom/calculator/calculator-hooks.js b/src/Blocks/custom/calculator/calculator-hooks.js new file mode 100644 index 000000000..6b254364e --- /dev/null +++ b/src/Blocks/custom/calculator/calculator-hooks.js @@ -0,0 +1,34 @@ +/* global esFormsLocalization */ + +import { addFilter } from '@wordpress/hooks'; +import { select } from '@wordpress/data'; +import { STORE_NAME } from '@eightshift/frontend-libs/scripts/editor'; +import { isArray } from 'lodash'; + +// Provide additional blocks to the forms. +export const hooks = () => { + const { blockName } = select(STORE_NAME).getBlock('calculator'); + const namespace = select(STORE_NAME).getSettingsNamespace(); + + // All adding additional blocks to the custom form builder. + addFilter('blocks.registerBlockType', `${namespace}/${blockName}`, (settings, name) => { + if (name === `${namespace}/${blockName}`) { + if (typeof esFormsLocalization !== 'undefined' && isArray(esFormsLocalization?.additionalBlocks)) { + esFormsLocalization.additionalBlocks.forEach((element) => { + if (!settings.attributes.calculatorAllowedBlocks.default.includes(element)) { + settings.attributes.calculatorAllowedBlocks.default.push(element); + } + }); + } + + select(STORE_NAME).getSettings().allowedBlocksBuilderIntegrationAdditionalBlocksList.forEach((element) => { + if (!settings.attributes.calculatorAllowedBlocks.default.includes(element)) { + settings.attributes.calculatorAllowedBlocks.default.push(element); + } + }); + } + + return settings; + }); +}; + diff --git a/src/Blocks/custom/calculator/calculator.php b/src/Blocks/custom/calculator/calculator.php new file mode 100644 index 000000000..8ed7a6007 --- /dev/null +++ b/src/Blocks/custom/calculator/calculator.php @@ -0,0 +1,16 @@ + $innerBlockContent, + ]) +); diff --git a/src/Blocks/custom/calculator/components/calculator-editor.js b/src/Blocks/custom/calculator/components/calculator-editor.js new file mode 100644 index 000000000..539cf6acf --- /dev/null +++ b/src/Blocks/custom/calculator/components/calculator-editor.js @@ -0,0 +1,27 @@ +import React from 'react'; +import { select } from '@wordpress/data'; +import { STORE_NAME, checkAttr } from '@eightshift/frontend-libs/scripts'; +import { IntegrationsEditor } from '../../../components/integrations/components/integrations-editor'; + +export const CalculatorEditor = ({ + attributes, + setAttributes, + itemIdKey, +}) => { + const manifest = select(STORE_NAME).getBlock('calculator'); + + const { + blockClass, + } = attributes; + + return ( +
+ +
+ ); +}; diff --git a/src/Blocks/custom/calculator/components/calculator-options.js b/src/Blocks/custom/calculator/components/calculator-options.js new file mode 100644 index 000000000..31f854dad --- /dev/null +++ b/src/Blocks/custom/calculator/components/calculator-options.js @@ -0,0 +1,30 @@ +import React from 'react'; +import { select } from '@wordpress/data'; +import { STORE_NAME, checkAttr } from '@eightshift/frontend-libs/scripts'; +import { IntegrationsOptions } from '../../../components/integrations/components/integrations-options'; + +export const CalculatorOptions = ({ + attributes, + setAttributes, + clientId, + itemIdKey, +}) => { + const manifest = select(STORE_NAME).getBlock('calculator'); + + const { + title, + blockName, + } = manifest; + + return ( + + ); +}; diff --git a/src/Blocks/custom/calculator/manifest.json b/src/Blocks/custom/calculator/manifest.json new file mode 100644 index 000000000..60ab97bd1 --- /dev/null +++ b/src/Blocks/custom/calculator/manifest.json @@ -0,0 +1,38 @@ +{ + "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", + "blockName": "calculator", + "title": "Calculator form", + "description" : "Calculator subscription form", + "category": "eightshift-forms", + "icon": { + "src": "esf-infobip" + }, + "keywords": [ + "calculator" + ], + "example": { + }, + "components": { + "form": "form", + "step": "step" + }, + "hasInnerBlocks": true, + "attributes": { + "calculatorIntegrationId": { + "type": "string" + }, + "calculatorFormPostId": { + "type": "string" + }, + "calculatorFormDataTypeSelector": { + "type": "string" + }, + "calculatorAllowedBlocks": { + "type": "array", + "default": [] + } + }, + "parent": [ + "eightshift-forms/form-selector" + ] +} diff --git a/src/Blocks/custom/form-selector/manifest.json b/src/Blocks/custom/form-selector/manifest.json index 9cdb40f7e..00f0a26d8 100644 --- a/src/Blocks/custom/form-selector/manifest.json +++ b/src/Blocks/custom/form-selector/manifest.json @@ -26,7 +26,8 @@ "eightshift-forms/moments", "eightshift-forms/workable", "eightshift-forms/jira", - "eightshift-forms/pipedrive" + "eightshift-forms/pipedrive", + "eightshift-forms/calculator" ] } }, @@ -216,6 +217,22 @@ "eightshift-forms/submit" ] ] + }, + { + "label": "Calculator form", + "slug": "calculator", + "blockName": "eightshift-forms/calculator", + "innerBlocks": [ + [ + "eightshift-forms/input", + { + "inputInputFieldLabel": "Range", + "inputInputType": "range", + "inputInputName": "range", + "inputInputIsNumber": true + } + ] + ] } ] } From 1cc62784ef8adb681db068cdae8e7ae1282cfb1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 1 Mar 2024 14:48:23 +0100 Subject: [PATCH 07/35] update --- src/Blocks/custom/calculator/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blocks/custom/calculator/manifest.json b/src/Blocks/custom/calculator/manifest.json index 60ab97bd1..f662be896 100644 --- a/src/Blocks/custom/calculator/manifest.json +++ b/src/Blocks/custom/calculator/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", "blockName": "calculator", "title": "Calculator form", - "description" : "Calculator subscription form", + "description" : "Calculator form", "category": "eightshift-forms", "icon": { "src": "esf-infobip" From 65d551004c4e126ed96044aa4ad27ab134187cd0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Mon, 4 Mar 2024 17:41:12 +0100 Subject: [PATCH 08/35] update --- composer.json | 8 +- composer.lock | 13 +- src/AdminMenus/FormSettingsAdminSubMenu.php | 2 +- src/Blocks/assets/scripts/blocks-editor.js | 2 +- .../calculator-result-block.js | 53 +++++++ .../calculator-result-editor.scss | 24 ++++ .../calculator-result/calculator-result.php | 41 ++++++ .../components/calculator-result-editor.js | 102 +++++++++++++ .../components/calculator-result-options.js | 65 +++++++++ .../custom/calculator-result/manifest.json | 43 ++++++ .../custom/calculator/calculator-block.js | 13 +- .../custom/calculator/calculator-overrides.js | 15 ++ .../components/calculator-editor.js | 28 ++-- .../components/calculator-options.js | 13 +- src/Blocks/custom/calculator/manifest.json | 28 ++-- src/Blocks/custom/field/field-hooks.js | 4 +- .../custom/forms/components/forms-editor.js | 2 +- .../custom/forms/components/forms-options.js | 3 +- src/Blocks/custom/forms/forms-block.js | 19 +-- src/Blocks/custom/forms/manifest.json | 1 - src/Blocks/manifest.json | 3 +- src/CustomPostType/Calculator.php | 103 ++++++++++++++ src/Enqueue/Blocks/EnqueueBlocks.php | 8 +- src/Hooks/Filters.php | 6 + src/Hooks/FiltersSettingsBuilder.php | 14 ++ .../Calculator/SettingsCalculator.php | 134 ++++++++++++++++++ src/Labels/Labels.php | 21 +++ .../Calculator/FormSubmitCalculatorRoute.php | 114 +++++++++++++++ src/Validation/Validator.php | 2 + 29 files changed, 807 insertions(+), 77 deletions(-) create mode 100644 src/Blocks/custom/calculator-result/calculator-result-block.js create mode 100644 src/Blocks/custom/calculator-result/calculator-result-editor.scss create mode 100644 src/Blocks/custom/calculator-result/calculator-result.php create mode 100644 src/Blocks/custom/calculator-result/components/calculator-result-editor.js create mode 100644 src/Blocks/custom/calculator-result/components/calculator-result-options.js create mode 100644 src/Blocks/custom/calculator-result/manifest.json create mode 100644 src/Blocks/custom/calculator/calculator-overrides.js create mode 100644 src/CustomPostType/Calculator.php create mode 100644 src/Integrations/Calculator/SettingsCalculator.php create mode 100644 src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php diff --git a/composer.json b/composer.json index 0d3837d74..94910126b 100644 --- a/composer.json +++ b/composer.json @@ -26,6 +26,12 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, + "repositories": [ + { + "type": "vcs", + "url": "https://github.com/infinum/eightshift-libs.git" + } + ], "require-dev": { "brain/faker": "dev-master", "brain/monkey": "^2.6.1", @@ -40,7 +46,7 @@ "require": { "php": "^7.4 || >=8.0", "erusev/parsedown": "^1.7.4", - "infinum/eightshift-forms-utils": "^1.2.4" + "infinum/eightshift-forms-utils": "dev-feature/calculator" }, "suggest": { "ext-pcov": "* || This extension is used for code coverage generation. Use either pcov, or xdebug, but not both.", diff --git a/composer.lock b/composer.lock index f7d91e595..e7cb3ef08 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4af23d84c4cb0933ffd292f56030fa05", + "content-hash": "172272e1b58c5ab88e42b618bd896799", "packages": [ { "name": "erusev/parsedown", @@ -58,16 +58,16 @@ }, { "name": "infinum/eightshift-forms-utils", - "version": "1.2.4", + "version": "dev-feature/calculator", "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "d17843ca1611c8880eac59ea783c96d6d278fddc" + "reference": "ca1188b2d10025027e2a72efd12bd3ac28f1a23c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/d17843ca1611c8880eac59ea783c96d6d278fddc", - "reference": "d17843ca1611c8880eac59ea783c96d6d278fddc", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/ca1188b2d10025027e2a72efd12bd3ac28f1a23c", + "reference": "ca1188b2d10025027e2a72efd12bd3ac28f1a23c", "shasum": "" }, "require": { @@ -119,7 +119,7 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-02-27T16:57:22+00:00" + "time": "2024-03-04T16:18:22+00:00" }, { "name": "infinum/eightshift-libs", @@ -5036,6 +5036,7 @@ "aliases": [], "minimum-stability": "dev", "stability-flags": { + "infinum/eightshift-forms-utils": 20, "brain/faker": 20 }, "prefer-stable": true, diff --git a/src/AdminMenus/FormSettingsAdminSubMenu.php b/src/AdminMenus/FormSettingsAdminSubMenu.php index de8c9e8d8..f3a5cbcf8 100644 --- a/src/AdminMenus/FormSettingsAdminSubMenu.php +++ b/src/AdminMenus/FormSettingsAdminSubMenu.php @@ -141,7 +141,7 @@ protected function getMenuSlug(): string */ protected function getParentMenu(): string { - return ''; + return 'null'; } /** diff --git a/src/Blocks/assets/scripts/blocks-editor.js b/src/Blocks/assets/scripts/blocks-editor.js index 09671838e..182713165 100644 --- a/src/Blocks/assets/scripts/blocks-editor.js +++ b/src/Blocks/assets/scripts/blocks-editor.js @@ -37,7 +37,7 @@ registerBlocks( outputCssVariablesGlobal(); // Remove form-selector block from anywhere else other than form CPT. -if (esFormsLocalization?.postType !== 'eightshift-forms') { +if (esFormsLocalization?.currentPostType !== esFormsLocalization?.postTypes?.forms) { const namespace = select(STORE_NAME).getSettingsNamespace(); unregisterBlockType(`${namespace}/form-selector`); diff --git a/src/Blocks/custom/calculator-result/calculator-result-block.js b/src/Blocks/custom/calculator-result/calculator-result-block.js new file mode 100644 index 000000000..4c512baeb --- /dev/null +++ b/src/Blocks/custom/calculator-result/calculator-result-block.js @@ -0,0 +1,53 @@ +import React from 'react'; +import { InspectorControls } from '@wordpress/block-editor'; +import { CalculatorResultEditor } from './components/calculator-result-editor'; +import { CalculatorResultOptions } from './components/calculator-result-options'; +import { getFetchWpApi } from '@eightshift/frontend-libs/scripts'; +import { outputFormSelectItemWithIcon } from '../../components/utils'; + +const formSelectOptions = function(postType) { + return getFetchWpApi( + postType, + { + noCache: true, + processLabel: ({ title: { rendered: label }, integration_type: metadata, id }) => { + return outputFormSelectItemWithIcon({ + label, + id, + metadata, + })?.label; + }, + fields: 'id,title,integration_type', + processMetadata: ({ title: { rendered: label }, integration_type: metadata, id }) => ({ + id, + value: id, + label, + metadata, + }), + } + ); +}; + +export const CalculatorResult = (props) => { + const { + forms, + calculator, + } = esFormsLocalization?.postTypes; + + return ( + <> + + + + + + ); +}; diff --git a/src/Blocks/custom/calculator-result/calculator-result-editor.scss b/src/Blocks/custom/calculator-result/calculator-result-editor.scss new file mode 100644 index 000000000..09e4d1b50 --- /dev/null +++ b/src/Blocks/custom/calculator-result/calculator-result-editor.scss @@ -0,0 +1,24 @@ +.es-block-calculator-result { + &__intro { + text-align: center; + transform: translateY(50%); + + &::before { + content: ''; + width: 100%; + height: 1px; + display: block; + background-color: var(--global-colors-esf-gray-300); + } + + &-inner { + border: 1px solid var(--global-colors-esf-gray-300); + padding: 0.3125rem 1.25rem; + display: inline-block; + border-radius: var(--es-input-radius); + font-weight: 500; + transform: translateY(-50%); + background-color: var(--global-colors-esf-white); + } + } +} diff --git a/src/Blocks/custom/calculator-result/calculator-result.php b/src/Blocks/custom/calculator-result/calculator-result.php new file mode 100644 index 000000000..380e403b6 --- /dev/null +++ b/src/Blocks/custom/calculator-result/calculator-result.php @@ -0,0 +1,41 @@ + esc_attr($calculatorResultFormPostId), +]; + +$calculatorAttrsOutput = ''; +if ($calculatorAttrs) { + foreach ($calculatorAttrs as $key => $value) { + $calculatorAttrsOutput .= wp_kses_post(" {$key}='" . $value . "'"); + } +} + +$calculatorClass = Components::classnames([ + Components::selector($blockClass, $blockClass), + UtilsHelper::getStateSelector('calculator'), +]); + +?> + +
> + +
diff --git a/src/Blocks/custom/calculator-result/components/calculator-result-editor.js b/src/Blocks/custom/calculator-result/components/calculator-result-editor.js new file mode 100644 index 000000000..f5a448818 --- /dev/null +++ b/src/Blocks/custom/calculator-result/components/calculator-result-editor.js @@ -0,0 +1,102 @@ +import React from 'react'; +import { select } from '@wordpress/data'; +import { ServerSideRender, + checkAttr, + props, + icons, + AsyncSelect, + getAttrKey, + STORE_NAME, +} from '@eightshift/frontend-libs/scripts'; +import { __ } from '@wordpress/i18n'; +import { Placeholder } from '@wordpress/components'; +import { getFilteredAttributes, outputFormSelectItemWithIcon } from '../../../components/utils'; + +export const CalculatorResultEditor = ({ + attributes, + setAttributes, + formSelectOptions, + calculatorSelectOptions, +}) => { + const manifest = select(STORE_NAME).getBlock('calculator-result'); + + const { + blockFullName + } = attributes; + + const { + attributesSsr, + } = manifest; + + const calculatorResultFormPostId = checkAttr('calculatorResultFormPostId', attributes, manifest); + const calculatorResultFormPostIdRaw = checkAttr('calculatorResultFormPostIdRaw', attributes, manifest); + const calculatorResultPostIdRaw = checkAttr('calculatorResultPostIdRaw', attributes, manifest); + const calculatorResultPostId = checkAttr('calculatorResultPostId', attributes, manifest); + + if (calculatorResultPostId?.length < 1) { + return ( + {__('Eightshift Forms - Calculator result', 'productive')}} + className='es-max-w-80 es-rounded-3! es-mx-auto! es-font-weight-400 es-color-cool-gray-500! es-nested-color-current!' + > + To get started, select a form:} + help={__('If you can\'t find you output item, start typing its name while the dropdown is open.', 'eightshift-forms')} + value={outputFormSelectItemWithIcon(Object.keys(calculatorResultPostIdRaw).length ? calculatorResultPostIdRaw : {id: calculatorResultPostId})} + loadOptions={calculatorSelectOptions} + onChange={(value) => { + setAttributes({ + [getAttrKey('calculatorResultPostIdRaw', attributes, manifest)]: { + id: value?.id, + label: value?.metadata?.label, + value: value?.metadata?.value, + metadata: value?.metadata?.metadata, + }, + [getAttrKey('calculatorResultPostId', attributes, manifest)]: `${value?.value}`, + }); + }} + noBottomSpacing + /> + + To get started, select a form:} + help={__('If you can\'t find you output item, start typing its name while the dropdown is open.', 'eightshift-forms')} + value={outputFormSelectItemWithIcon(Object.keys(calculatorResultFormPostIdRaw).length ? calculatorResultFormPostIdRaw : {id: calculatorResultFormPostId})} + loadOptions={formSelectOptions} + onChange={(value) => { + setAttributes({ + [getAttrKey('calculatorResultFormPostIdRaw', attributes, manifest)]: { + id: value?.id, + label: value?.metadata?.label, + value: value?.metadata?.value, + metadata: value?.metadata?.metadata, + }, + [getAttrKey('calculatorResultFormPostId', attributes, manifest)]: `${value?.value}`, + }); + }} + noBottomSpacing + /> + + ); + } + + return ( + <> + + + ); +}; diff --git a/src/Blocks/custom/calculator-result/components/calculator-result-options.js b/src/Blocks/custom/calculator-result/components/calculator-result-options.js new file mode 100644 index 000000000..f2feda9fd --- /dev/null +++ b/src/Blocks/custom/calculator-result/components/calculator-result-options.js @@ -0,0 +1,65 @@ +import React from 'react'; +import { useState } from '@wordpress/element'; +import { select } from '@wordpress/data'; +import { __ } from '@wordpress/i18n'; +import { PanelBody, TextControl } from '@wordpress/components'; +import { checkAttr, + getAttrKey, + AsyncSelect, + STORE_NAME, +} from '@eightshift/frontend-libs/scripts'; +import { outputFormSelectItemWithIcon } from '../../../components/utils'; + +export const CalculatorResultOptions = ({ + attributes, + setAttributes, + formSelectOptions, + calculatorSelectOptions, +}) => { + const manifest = select(STORE_NAME).getBlock('calculator-result'); + + const calculatorResultFormPostId = checkAttr('calculatorResultFormPostId', attributes, manifest); + const calculatorResultFormPostIdRaw = checkAttr('calculatorResultFormPostIdRaw', attributes, manifest); + const calculatorResultPostId = checkAttr('calculatorResultPostId', attributes, manifest); + const calculatorResultPostIdRaw = checkAttr('calculatorResultPostIdRaw', attributes, manifest); + + return ( + + { + setAttributes({ + [getAttrKey('calculatorResultPostIdRaw', attributes, manifest)]: { + id: value?.id, + label: value?.metadata?.label, + value: value?.metadata?.value, + metadata: value?.metadata?.metadata, + }, + [getAttrKey('calculatorResultPostId', attributes, manifest)]: `${value?.value.toString()}`, + }); + }} + /> + + { + setAttributes({ + [getAttrKey('calculatorResultFormPostIdRaw', attributes, manifest)]: { + id: value?.id, + label: value?.metadata?.label, + value: value?.metadata?.value, + metadata: value?.metadata?.metadata, + }, + [getAttrKey('calculatorResultFormPostId', attributes, manifest)]: `${value?.value.toString()}`, + }); + }} + /> + + ); +}; diff --git a/src/Blocks/custom/calculator-result/manifest.json b/src/Blocks/custom/calculator-result/manifest.json new file mode 100644 index 000000000..3257f3c1c --- /dev/null +++ b/src/Blocks/custom/calculator-result/manifest.json @@ -0,0 +1,43 @@ +{ + "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", + "blockName": "calculator-result", + "title": "Calculator result", + "description" : "Calculator result block.", + "category": "eightshift-forms", + "icon": { + "src": "esf-checkbox" + }, + "keywords": [ + "calculator", + "results" + ], + "hasInnerBlocks": true, + "attributes": { + "calculatorResultName": { + "type": "string" + }, + "calculatorResultValue": { + "type": "string" + }, + "calculatorResultPostId": { + "type": "string" + }, + "calculatorResultPostIdRaw": { + "type": "object" + }, + "calculatorResultFormPostId": { + "type": "string" + }, + "calculatorResultFormPostIdRaw": { + "type": "object" + }, + "calculatorResultServerSideRender": { + "type": "boolean", + "default": false + } + }, + "attributesSsr": [ + "calculatorResultPostId", + "calculatorResultFormPostId" + ] +} diff --git a/src/Blocks/custom/calculator/calculator-block.js b/src/Blocks/custom/calculator/calculator-block.js index 56134145c..4d8b1a9fe 100644 --- a/src/Blocks/custom/calculator/calculator-block.js +++ b/src/Blocks/custom/calculator/calculator-block.js @@ -4,21 +4,12 @@ import { CalculatorEditor } from './components/calculator-editor'; import { CalculatorOptions } from './components/calculator-options'; export const Calculator = (props) => { - const itemIdKey = 'calculatorIntegrationId'; - return ( <> - + - + ); }; diff --git a/src/Blocks/custom/calculator/calculator-overrides.js b/src/Blocks/custom/calculator/calculator-overrides.js new file mode 100644 index 000000000..2c1235b37 --- /dev/null +++ b/src/Blocks/custom/calculator/calculator-overrides.js @@ -0,0 +1,15 @@ +// eslint-disable-next-line no-unused-vars + +import globalManifest from '../../manifest.json'; +import manifest from './manifest.json'; + +export const overrides = { + ...manifest, + attributes: { + ...manifest.attributes, + calculatorAllowedBlocks: { + ...manifest.attributes.calculatorAllowedBlocks, + default: globalManifest.allowedBlocksBuilderBlocksList + }, + }, +}; diff --git a/src/Blocks/custom/calculator/components/calculator-editor.js b/src/Blocks/custom/calculator/components/calculator-editor.js index 539cf6acf..ee8d65cab 100644 --- a/src/Blocks/custom/calculator/components/calculator-editor.js +++ b/src/Blocks/custom/calculator/components/calculator-editor.js @@ -1,26 +1,30 @@ import React from 'react'; import { select } from '@wordpress/data'; -import { STORE_NAME, checkAttr } from '@eightshift/frontend-libs/scripts'; -import { IntegrationsEditor } from '../../../components/integrations/components/integrations-editor'; +import { InnerBlocks } from '@wordpress/block-editor'; +import { props, checkAttr, BlockInserter, STORE_NAME } from '@eightshift/frontend-libs/scripts'; +import { FormEditor } from '../../../components/form/components/form-editor'; -export const CalculatorEditor = ({ - attributes, - setAttributes, - itemIdKey, -}) => { +export const CalculatorEditor = ({ attributes, setAttributes, clientId }) => { const manifest = select(STORE_NAME).getBlock('calculator'); const { blockClass, } = attributes; + const calculatorAllowedBlocks = checkAttr('calculatorAllowedBlocks', attributes, manifest); + return (
- } + /> + })} />
); diff --git a/src/Blocks/custom/calculator/components/calculator-options.js b/src/Blocks/custom/calculator/components/calculator-options.js index 31f854dad..c007b2af8 100644 --- a/src/Blocks/custom/calculator/components/calculator-options.js +++ b/src/Blocks/custom/calculator/components/calculator-options.js @@ -1,30 +1,25 @@ import React from 'react'; import { select } from '@wordpress/data'; -import { STORE_NAME, checkAttr } from '@eightshift/frontend-libs/scripts'; -import { IntegrationsOptions } from '../../../components/integrations/components/integrations-options'; +import { IntegrationsInternalOptions } from '../../../components/integrations/components/integrations-internal-options'; +import { STORE_NAME } from '@eightshift/frontend-libs/scripts'; export const CalculatorOptions = ({ attributes, setAttributes, clientId, - itemIdKey, }) => { const manifest = select(STORE_NAME).getBlock('calculator'); const { title, - blockName, } = manifest; return ( - ); }; diff --git a/src/Blocks/custom/calculator/manifest.json b/src/Blocks/custom/calculator/manifest.json index f662be896..d4592eb8c 100644 --- a/src/Blocks/custom/calculator/manifest.json +++ b/src/Blocks/custom/calculator/manifest.json @@ -2,37 +2,35 @@ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", "blockName": "calculator", "title": "Calculator form", - "description" : "Calculator form", + "description" : "A form with calculator", "category": "eightshift-forms", "icon": { - "src": "esf-infobip" + "src": "esf-form" }, "keywords": [ "calculator" ], - "example": { - }, + "hasInnerBlocks": true, "components": { "form": "form", "step": "step" }, - "hasInnerBlocks": true, + "parent": [ + "eightshift-forms/form-selector" + ], "attributes": { - "calculatorIntegrationId": { - "type": "string" + "calculatorAllowedBlocks": { + "type": "array", + "default": [] }, "calculatorFormPostId": { "type": "string" }, - "calculatorFormDataTypeSelector": { + "calculatorDataTypeSelector": { "type": "string" }, - "calculatorAllowedBlocks": { - "type": "array", - "default": [] + "calculatorFormAction": { + "type": "string" } - }, - "parent": [ - "eightshift-forms/form-selector" - ] + } } diff --git a/src/Blocks/custom/field/field-hooks.js b/src/Blocks/custom/field/field-hooks.js index cc074e055..6f18ede19 100644 --- a/src/Blocks/custom/field/field-hooks.js +++ b/src/Blocks/custom/field/field-hooks.js @@ -16,7 +16,7 @@ const setNoneEightshiftFormsBlocksField = createHigherOrderComponent((BlockEdit) } = innerProps; // Change only none forms blocks in forms post type. - if (postType === 'eightshift-forms' && !name.includes('eightshift-forms')) { + if (postType === esFormsLocalization?.postTypes?.forms && !name.includes(esFormsLocalization?.postTypes?.forms)) { return ( @@ -34,7 +34,7 @@ const setNoneEightshiftFormsBlocksField = createHigherOrderComponent((BlockEdit) function setNoneEightshiftBlocksFieldAttributes( settings, name ) { // Change only none forms blocks in forms post type. - if (esFormsLocalization?.postType === 'eightshift-forms' && !name.includes('eightshift-forms')) { + if (esFormsLocalization?.currentPostType === esFormsLocalization?.postTypes?.forms && !name.includes(esFormsLocalization?.postTypes?.forms)) { return { ...settings, attributes: { diff --git a/src/Blocks/custom/forms/components/forms-editor.js b/src/Blocks/custom/forms/components/forms-editor.js index 1af604862..07db36576 100644 --- a/src/Blocks/custom/forms/components/forms-editor.js +++ b/src/Blocks/custom/forms/components/forms-editor.js @@ -17,7 +17,7 @@ export const FormsEditor = ({ attributes, setAttributes, preview, - formSelectOptions + formSelectOptions, }) => { const manifest = select(STORE_NAME).getBlock('forms'); diff --git a/src/Blocks/custom/forms/components/forms-options.js b/src/Blocks/custom/forms/components/forms-options.js index 926944419..42873f493 100644 --- a/src/Blocks/custom/forms/components/forms-options.js +++ b/src/Blocks/custom/forms/components/forms-options.js @@ -25,7 +25,8 @@ import { STORE_NAME, } from '@eightshift/frontend-libs/scripts'; import { ConditionalTagsFormsOptions } from '../../../components/conditional-tags/components/conditional-tags-forms-options'; -import { FormEditButton, +import { + FormEditButton, LocationsButton, SettingsButton, getSettingsJsonOptions, diff --git a/src/Blocks/custom/forms/forms-block.js b/src/Blocks/custom/forms/forms-block.js index 750c551d6..5b7d251cc 100644 --- a/src/Blocks/custom/forms/forms-block.js +++ b/src/Blocks/custom/forms/forms-block.js @@ -1,27 +1,18 @@ +/* global esFormsLocalization */ + import React from 'react'; import { useState } from '@wordpress/element'; -import { select } from '@wordpress/data'; import { InspectorControls } from '@wordpress/block-editor'; import { FormsEditor } from './components/forms-editor'; import { FormsOptions } from './components/forms-options'; -import { - getFetchWpApi, - STORE_NAME, -} from '@eightshift/frontend-libs/scripts'; -import { - outputFormSelectItemWithIcon, -} from '../../components/utils'; +import { getFetchWpApi } from '@eightshift/frontend-libs/scripts'; +import { outputFormSelectItemWithIcon } from '../../components/utils'; export const Forms = (props) => { - const manifest = select(STORE_NAME).getBlock('forms'); - const { - postType, - } = manifest; - const [isGeoPreview, setIsGeoPreview] = useState(false); const formSelectOptions = getFetchWpApi( - postType, + esFormsLocalization?.postTypes?.forms, { noCache: true, processLabel: ({ title: { rendered: label }, integration_type: metadata, id }) => { diff --git a/src/Blocks/custom/forms/manifest.json b/src/Blocks/custom/forms/manifest.json index 804338b3a..8a51fdffe 100644 --- a/src/Blocks/custom/forms/manifest.json +++ b/src/Blocks/custom/forms/manifest.json @@ -74,7 +74,6 @@ "conditionalTags": "conditionalTags", "progressBar": "progressBar" }, - "postType": "eightshift-forms", "attributesSsr": [ "formsFormPostId", "formsStyle" diff --git a/src/Blocks/manifest.json b/src/Blocks/manifest.json index 1561de978..152386fcc 100644 --- a/src/Blocks/manifest.json +++ b/src/Blocks/manifest.json @@ -17,7 +17,8 @@ "useWrapper": false }, "allowedBlocksNoneBuilderBlocksList": [ - "eightshift-forms/forms" + "eightshift-forms/forms", + "eightshift-forms/calculator-result" ], "allowedBlocksBuilderIntegrationAdditionalBlocksList": [ "eightshift-forms/step" diff --git a/src/CustomPostType/Calculator.php b/src/CustomPostType/Calculator.php new file mode 100644 index 000000000..0094c52d0 --- /dev/null +++ b/src/CustomPostType/Calculator.php @@ -0,0 +1,103 @@ + Array of arguments. + */ + protected function getPostTypeArguments(): array + { + return [ + 'label' => \esc_html__('Calculator', 'eightshift-forms'), + 'public' => true, + 'menu_position' => static::MENU_POSITION, + 'menu_icon' => static::MENU_ICON, + 'supports' => ['title', 'editor', 'revisions'], + 'has_archive' => false, + 'show_in_rest' => true, + 'publicly_queryable' => false, + 'show_in_menu' => false, + 'show_in_nav_menus' => false, + 'can_export' => true, + 'capability_type' => self::POST_CAPABILITY_TYPE, + 'rest_base' => static::REST_API_ENDPOINT_SLUG, + ]; + } +} diff --git a/src/Enqueue/Blocks/EnqueueBlocks.php b/src/Enqueue/Blocks/EnqueueBlocks.php index 527ceed60..e50ffa870 100644 --- a/src/Enqueue/Blocks/EnqueueBlocks.php +++ b/src/Enqueue/Blocks/EnqueueBlocks.php @@ -16,6 +16,8 @@ use EightshiftForms\Enrichment\SettingsEnrichment; use EightshiftForms\Settings\Settings\SettingsSettings; use EightshiftForms\Captcha\SettingsCaptcha; +use EightshiftForms\CustomPostType\Calculator; +use EightshiftForms\CustomPostType\Forms; use EightshiftForms\Enqueue\SharedEnqueue; use EightshiftForms\Enqueue\Theme\EnqueueTheme; use EightshiftForms\Geolocation\SettingsGeolocation; @@ -165,7 +167,11 @@ public function enqueueBlockEditorScript(string $hook): void $output['validationPatternsOptions'] = $this->validationPatterns->getValidationPatternsEditor(); $output['mediaBreakpoints'] = \apply_filters($breakpointsFilterName, []); $output['formsSelectorTemplates'] = \apply_filters($formSelectorTemplatesFilterName, []); - $output['postType'] = \get_post_type() ? \get_post_type() : ''; + $output['currentPostType'] = \get_post_type() ? \get_post_type() : ''; + $output['postTypes'] = [ + 'calculator' => Calculator::POST_TYPE_SLUG, + 'forms' => Forms::POST_TYPE_SLUG, + ]; $output['settings'] = [ 'successRedirectVariations' => FiltersOuputMock::getSuccessRedirectVariationOptionsFilterValue()['data'], diff --git a/src/Hooks/Filters.php b/src/Hooks/Filters.php index 1675f173c..182c75047 100644 --- a/src/Hooks/Filters.php +++ b/src/Hooks/Filters.php @@ -30,6 +30,7 @@ use EightshiftForms\Troubleshooting\SettingsDebug; use EightshiftForms\Troubleshooting\SettingsFallback; use EightshiftForms\Captcha\SettingsCaptcha; +use EightshiftForms\Integrations\Calculator\SettingsCalculator; use EightshiftForms\Integrations\Pipedrive\SettingsPipedrive; use EightshiftForms\Misc\SettingsCloudflare; use EightshiftForms\Misc\SettingsWpml; @@ -233,6 +234,11 @@ private static function getPublicFilters(): array SettingsPipedrive::SETTINGS_TYPE_KEY => [ 'prePostParams', ], + SettingsCalculator::SETTINGS_TYPE_KEY => [ + 'prePostParams', + 'output', + 'outputItems', + ], ], 'entries' => [ 'prePostParams', diff --git a/src/Hooks/FiltersSettingsBuilder.php b/src/Hooks/FiltersSettingsBuilder.php index 7ab6fefbc..5004ffe00 100644 --- a/src/Hooks/FiltersSettingsBuilder.php +++ b/src/Hooks/FiltersSettingsBuilder.php @@ -54,6 +54,7 @@ use EightshiftForms\Troubleshooting\SettingsFallback; use EightshiftForms\Captcha\SettingsCaptcha; use EightshiftForms\Entries\SettingsEntries; +use EightshiftForms\Integrations\Calculator\SettingsCalculator; use EightshiftForms\Integrations\Pipedrive\PipedriveClient; use EightshiftForms\Integrations\Pipedrive\SettingsPipedrive; use EightshiftForms\Misc\SettingsCloudflare; @@ -436,6 +437,19 @@ public function getSettingsFiltersData(): array 'externalLink' => 'https://www.pipedrive.com/', ], ], + SettingsCalculator::SETTINGS_TYPE_KEY => [ + 'settings' => SettingsCalculator::FILTER_SETTINGS_NAME, + 'settingsGlobal' => SettingsCalculator::FILTER_SETTINGS_GLOBAL_NAME, + 'type' => UtilsConfig::SETTINGS_INTERNAL_TYPE_INTEGRATION, + 'integrationType' => UtilsConfig::INTEGRATION_TYPE_NO_BUILDER, + 'use' => SettingsCalculator::SETTINGS_CALCULATOR_USE_KEY, + 'labels' => [ + 'title' => \__('Calculator', 'eightshift-forms'), + 'desc' => \__('Calculator form type settings.', 'eightshift-forms'), + 'detail' => \__('Calculator', 'eightshift-forms'), + 'externalLink' => '', + ], + ], // ------------------------------ // MISCELLANEOUS. // ------------------------------ diff --git a/src/Integrations/Calculator/SettingsCalculator.php b/src/Integrations/Calculator/SettingsCalculator.php new file mode 100644 index 000000000..dd41b422c --- /dev/null +++ b/src/Integrations/Calculator/SettingsCalculator.php @@ -0,0 +1,134 @@ +> + */ + public function getSettingsData(string $formId): array + { + // Bailout if feature is not active. + if (!$this->isSettingsGlobalValid()) { + return UtilsSettingsOutputHelper::getNoActiveFeature(); + } + + return [ + UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), + [ + 'component' => 'tabs', + 'tabsFull' => true, + 'tabsContent' => [ + ], + ], + ]; + } + + /** + * Get global settings array for building settings page. + * + * @return array> + */ + public function getSettingsGlobalData(): array + { + // Bailout if feature is not active. + if (!UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_CALCULATOR_USE_KEY, self::SETTINGS_CALCULATOR_USE_KEY)) { + return UtilsSettingsOutputHelper::getNoActiveFeature(); + } + + return [ + UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), + [ + 'component' => 'tabs', + 'tabsContent' => [ + [ + 'component' => 'tab', + 'tabLabel' => \__('General', 'eightshift-forms'), + 'tabContent' => [ + ], + ], + ], + ], + ]; + } +} diff --git a/src/Labels/Labels.php b/src/Labels/Labels.php index 56a4e22ae..247c7b5fe 100644 --- a/src/Labels/Labels.php +++ b/src/Labels/Labels.php @@ -22,6 +22,7 @@ use EightshiftForms\Integrations\Workable\SettingsWorkable; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; use EightshiftForms\Captcha\SettingsCaptcha; +use EightshiftForms\Integrations\Calculator\SettingsCalculator; use EightshiftForms\Integrations\Pipedrive\SettingsPipedrive; /** @@ -46,6 +47,7 @@ class Labels implements LabelsInterface 'workableSuccess', 'jiraSuccess', 'pipedriveSuccess', + 'calculatorSuccess', ]; /** @@ -122,6 +124,11 @@ public function getLabels(): array $output = \array_merge($output, $this->getPipedriveLabels()); } + // Calculator. + if (UtilsSettingsHelper::isOptionCheckboxChecked(SettingsCalculator::SETTINGS_CALCULATOR_USE_KEY, SettingsCalculator::SETTINGS_CALCULATOR_USE_KEY)) { + $output = \array_merge($output, $this->getCalculatorLabels()); + } + return $output; } @@ -485,4 +492,18 @@ private function getPipedriveLabels(): array 'pipedriveSuccess' => \__('Application submitted successfully. Thank you!', 'eightshift-forms'), ]; } + + /** + * Return labels - Calculator + * + * @return array + */ + private function getCalculatorLabels(): array + { + return [ + 'calculatorErrorSettingsMissing' => \__('Calculator integration is not configured correctly. Please try again.', 'eightshift-forms'), + 'calculatorBadRequestError' => \__('Something is not right with the subscription. Please check all the fields and try again.', 'eightshift-forms'), + 'calculatorSuccess' => \__('The newsletter subscription was successful. Thank you!', 'eightshift-forms'), + ]; + } } diff --git a/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php b/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php new file mode 100644 index 000000000..27b544bda --- /dev/null +++ b/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php @@ -0,0 +1,114 @@ +validator = $validator; + $this->validationPatterns = $validationPatterns; + $this->labels = $labels; + $this->captcha = $captcha; + $this->security = $security; + $this->formSubmitMailer = $formSubmitMailer; + } + + /** + * Get the base url of the route + * + * @return string The base URL for route you are adding. + */ + protected function getRouteName(): string + { + return '/' . UtilsConfig::ROUTE_PREFIX_FORM_SUBMIT . '/' . self::ROUTE_SLUG; + } + + /** + * Implement submit action. + * + * @param array $formDetails Data passed from the `getFormDetailsApi` function. + * + * @return mixed + */ + protected function submitAction(array $formDetails) + { + $formId = $formDetails[UtilsConfig::FD_FORM_ID]; + + $debug = [ + 'formDetails' => $formDetails, + ]; + + // Filter params. + $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'prePostParams']); + if (\has_filter($filterName)) { + $formDetails[UtilsConfig::FD_PARAMS] = \apply_filters($filterName, $formDetails[UtilsConfig::FD_PARAMS], $formId) ?? []; + } + + $additionalOutput = []; + + $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'output']); + if (\has_filter($filterName)) { + $additionalOutput[UtilsHelper::getStateResponseOutputKey('calculatorOutput')] = \apply_filters($filterName, '', $formDetails, $formId) ?? ''; + } + + $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'outputItems']); + if (\has_filter($filterName)) { + $additionalOutput[UtilsHelper::getStateResponseOutputKey('calculatorOutputItems')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; + } + + return \rest_ensure_response( + UtilsApiHelper::getApiSuccessPublicOutput( + $this->labels->getLabel('calculatorSuccess', $formId), + $additionalOutput, + $debug + ) + ); + } +} diff --git a/src/Validation/Validator.php b/src/Validation/Validator.php index 1bdffb29f..96592303e 100644 --- a/src/Validation/Validator.php +++ b/src/Validation/Validator.php @@ -15,6 +15,7 @@ use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsUploadHelper; use EightshiftForms\Integrations\Airtable\SettingsAirtable; +use EightshiftForms\Integrations\Calculator\SettingsCalculator; use EightshiftForms\Integrations\Jira\SettingsJira; use EightshiftForms\Integrations\Mailer\SettingsMailer; use EightshiftForms\Integrations\Pipedrive\SettingsPipedrive; @@ -429,6 +430,7 @@ public function validateFormManadatoryProperies(array $formDetails): bool case SettingsMailer::SETTINGS_TYPE_KEY: case SettingsJira::SETTINGS_TYPE_KEY: case SettingsPipedrive::SETTINGS_TYPE_KEY: + case SettingsCalculator::SETTINGS_TYPE_KEY: if (!$formId || !$postId) { return false; } From 3c7cdc04a1609a01c52aab89d16a67e733d9a75a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Mon, 4 Mar 2024 17:44:53 +0100 Subject: [PATCH 09/35] update --- .../custom/calculator-result/calculator-result.php | 8 +++----- .../components/calculator-result-editor.js | 3 --- .../components/calculator-result-options.js | 3 +-- src/Integrations/Calculator/SettingsCalculator.php | 9 +++------ .../Calculator/FormSubmitCalculatorRoute.php | 1 - 5 files changed, 7 insertions(+), 17 deletions(-) diff --git a/src/Blocks/custom/calculator-result/calculator-result.php b/src/Blocks/custom/calculator-result/calculator-result.php index 380e403b6..11a85d872 100644 --- a/src/Blocks/custom/calculator-result/calculator-result.php +++ b/src/Blocks/custom/calculator-result/calculator-result.php @@ -21,10 +21,8 @@ ]; $calculatorAttrsOutput = ''; -if ($calculatorAttrs) { - foreach ($calculatorAttrs as $key => $value) { - $calculatorAttrsOutput .= wp_kses_post(" {$key}='" . $value . "'"); - } +foreach ($calculatorAttrs as $key => $value) { + $calculatorAttrsOutput .= wp_kses_post(" {$key}='" . $value . "'"); } $calculatorClass = Components::classnames([ @@ -36,6 +34,6 @@
>
diff --git a/src/Blocks/custom/calculator-result/components/calculator-result-editor.js b/src/Blocks/custom/calculator-result/components/calculator-result-editor.js index f5a448818..b7b7ed735 100644 --- a/src/Blocks/custom/calculator-result/components/calculator-result-editor.js +++ b/src/Blocks/custom/calculator-result/components/calculator-result-editor.js @@ -2,7 +2,6 @@ import React from 'react'; import { select } from '@wordpress/data'; import { ServerSideRender, checkAttr, - props, icons, AsyncSelect, getAttrKey, @@ -42,7 +41,6 @@ export const CalculatorResultEditor = ({ > To get started, select a form:} help={__('If you can\'t find you output item, start typing its name while the dropdown is open.', 'eightshift-forms')} value={outputFormSelectItemWithIcon(Object.keys(calculatorResultPostIdRaw).length ? calculatorResultPostIdRaw : {id: calculatorResultPostId})} loadOptions={calculatorSelectOptions} @@ -62,7 +60,6 @@ export const CalculatorResultEditor = ({ To get started, select a form:} help={__('If you can\'t find you output item, start typing its name while the dropdown is open.', 'eightshift-forms')} value={outputFormSelectItemWithIcon(Object.keys(calculatorResultFormPostIdRaw).length ? calculatorResultFormPostIdRaw : {id: calculatorResultFormPostId})} loadOptions={formSelectOptions} diff --git a/src/Blocks/custom/calculator-result/components/calculator-result-options.js b/src/Blocks/custom/calculator-result/components/calculator-result-options.js index f2feda9fd..099328dd8 100644 --- a/src/Blocks/custom/calculator-result/components/calculator-result-options.js +++ b/src/Blocks/custom/calculator-result/components/calculator-result-options.js @@ -1,8 +1,7 @@ import React from 'react'; -import { useState } from '@wordpress/element'; import { select } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; -import { PanelBody, TextControl } from '@wordpress/components'; +import { PanelBody } from '@wordpress/components'; import { checkAttr, getAttrKey, AsyncSelect, diff --git a/src/Integrations/Calculator/SettingsCalculator.php b/src/Integrations/Calculator/SettingsCalculator.php index dd41b422c..33dba3346 100644 --- a/src/Integrations/Calculator/SettingsCalculator.php +++ b/src/Integrations/Calculator/SettingsCalculator.php @@ -10,7 +10,6 @@ namespace EightshiftForms\Integrations\Calculator; -use EightshiftForms\CustomPostType\Calculator; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingGlobalInterface; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; @@ -79,7 +78,7 @@ public function isSettingsGlobalValid(): bool return true; } - /** + /** * Get Form settings data array * * @param string $formId Form Id. @@ -98,8 +97,7 @@ public function getSettingsData(string $formId): array [ 'component' => 'tabs', 'tabsFull' => true, - 'tabsContent' => [ - ], + 'tabsContent' => [], ], ]; } @@ -124,8 +122,7 @@ public function getSettingsGlobalData(): array [ 'component' => 'tab', 'tabLabel' => \__('General', 'eightshift-forms'), - 'tabContent' => [ - ], + 'tabContent' => [], ], ], ], diff --git a/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php b/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php index 27b544bda..0bb14bd6e 100644 --- a/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php +++ b/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php @@ -12,7 +12,6 @@ use EightshiftForms\Captcha\CaptchaInterface; use EightshiftForms\Integrations\Calculator\SettingsCalculator; -use EightshiftForms\Integrations\Mailer\SettingsMailer; use EightshiftForms\Labels\LabelsInterface; use EightshiftForms\Rest\Routes\AbstractFormSubmit; use EightshiftForms\Rest\Routes\Integrations\Mailer\FormSubmitMailerInterface; From 0c0295e2818210802ecb041cdd22c8468bc5c760 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Tue, 5 Mar 2024 13:23:52 +0100 Subject: [PATCH 10/35] update --- composer.lock | 8 +- src/AdminMenus/FormAdminMenu.php | 292 +++++++++++++++--- src/AdminMenus/FormAdminTopBarMenu.php | 6 +- src/AdminMenus/FormSettingsAdminSubMenu.php | 2 +- src/Blocks/components/form/assets/form.js | 61 +++- .../calculator-result/calculator-result.php | 2 +- src/Blocks/manifest.json | 4 +- src/Editor/Editor.php | 46 ++- src/Entries/SettingsEntries.php | 2 +- .../Calculator/SettingsCalculator.php | 31 +- src/Listing/FormListingInterface.php | 7 +- src/Listing/FormsListing.php | 19 +- src/Rest/Routes/Settings/BulkRoute.php | 19 +- src/Shortcode/CalculatorItem.php | 60 ++++ src/Shortcode/{ShortcodeLink.php => Link.php} | 10 +- 15 files changed, 477 insertions(+), 92 deletions(-) create mode 100644 src/Shortcode/CalculatorItem.php rename src/Shortcode/{ShortcodeLink.php => Link.php} (85%) diff --git a/composer.lock b/composer.lock index e7cb3ef08..74dfc906c 100644 --- a/composer.lock +++ b/composer.lock @@ -62,12 +62,12 @@ "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "ca1188b2d10025027e2a72efd12bd3ac28f1a23c" + "reference": "b18cf898c010395a29c79abc0982fb527792d955" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/ca1188b2d10025027e2a72efd12bd3ac28f1a23c", - "reference": "ca1188b2d10025027e2a72efd12bd3ac28f1a23c", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/b18cf898c010395a29c79abc0982fb527792d955", + "reference": "b18cf898c010395a29c79abc0982fb527792d955", "shasum": "" }, "require": { @@ -119,7 +119,7 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-03-04T16:18:22+00:00" + "time": "2024-03-05T12:04:48+00:00" }, { "name": "infinum/eightshift-libs", diff --git a/src/AdminMenus/FormAdminMenu.php b/src/AdminMenus/FormAdminMenu.php index d736c3a28..9ad211ec2 100644 --- a/src/AdminMenus/FormAdminMenu.php +++ b/src/AdminMenus/FormAdminMenu.php @@ -10,6 +10,8 @@ namespace EightshiftForms\AdminMenus; +use EightshiftForms\CustomPostType\Calculator; +use EightshiftForms\CustomPostType\Forms; use EightshiftForms\Entries\EntriesHelper; use EightshiftFormsVendor\EightshiftLibs\Helpers\Components; use EightshiftForms\Misc\SettingsWpml; @@ -188,6 +190,7 @@ protected function processAttributes($attr): array { $type = isset($_GET['type']) ? \sanitize_text_field(\wp_unslash($_GET['type'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $formId = isset($_GET['formId']) ? \sanitize_text_field(\wp_unslash($_GET['formId'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $postType = isset($_GET['postType']) ? \sanitize_text_field(\wp_unslash($_GET['postType'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $output = []; switch ($type) { @@ -216,18 +219,38 @@ protected function processAttributes($attr): array ]; break; case 'trash': - $items = $this->formsListing->getFormsList($type); + $items = $this->formsListing->getFormsList(true, $postType); + $count = \count($items); + + if ($postType === Calculator::POST_TYPE_SLUG) { + $output = [ + // Translators: %s is the form title. + 'adminListingPageTitle' => $this->getMultilangTitle(\__('Deleted calculator outputs', 'eightshift-forms')), + // Translators: %s is the number of trashed forms. + 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 trashed calculator output.', 'eightshift-forms') : \sprintf(\__('Showing %s trashed calculator outputs.', 'eightshift-forms'), $count), + ]; + } else { + $output = [ + // Translators: %s is the form title. + 'adminListingPageTitle' => $this->getMultilangTitle(\__('Deleted forms', 'eightshift-forms')), + // Translators: %s is the number of trashed forms. + 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 trashed form.', 'eightshift-forms') : \sprintf(\__('Showing %s trashed forms.', 'eightshift-forms'), $count), + ]; + } + break; + case 'calculator': + $items = $this->formsListing->getFormsList(false, Calculator::POST_TYPE_SLUG); $count = \count($items); $output = [ // Translators: %s is the form title. - 'adminListingPageTitle' => $this->getMultilangTitle(\__('Deleted forms', 'eightshift-forms')), + 'adminListingPageTitle' => $this->getMultilangTitle(\__('Calculator outputs', 'eightshift-forms')), // Translators: %s is the number of trashed forms. - 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 trashed form.', 'eightshift-forms') : \sprintf(\__('Showing %s trashed forms.', 'eightshift-forms'), $count), + 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 calculator output.', 'eightshift-forms') : \sprintf(\__('Showing %s calculator outputs.', 'eightshift-forms'), $count), ]; break; default: - $items = $this->formsListing->getFormsList($type); + $items = $this->formsListing->getFormsList(false); $count = \count($items); $output = [ @@ -242,9 +265,9 @@ protected function processAttributes($attr): array $output, [ 'adminListingShowNoItems' => $count === 0, - 'adminListingItems' => $this->getListingItems($items, $type), - 'adminListingTopItems' => $this->getTopBarItems($type, $formId), - 'adminListingNoItems' => $this->getNoItemsMessage($type), + 'adminListingItems' => $this->getListingItems($items, $type, $postType), + 'adminListingTopItems' => $this->getTopBarItems($type, $formId, $postType), + 'adminListingNoItems' => $this->getNoItemsMessage($type, $postType), ] ); } @@ -273,12 +296,12 @@ private function getMultilangTitle(string $title): string * Get no items message output. * * @param string $type Type of the listing. + * @param string $postType Post type of the listing. * * @return array */ - private function getNoItemsMessage(string $type): array + private function getNoItemsMessage(string $type, string $postType): array { - $newUrl = UtilsGeneralHelper::getNewFormPageUrl(); $listingUrl = UtilsGeneralHelper::getListingPageUrl(); switch ($type) { @@ -295,14 +318,39 @@ private function getNoItemsMessage(string $type): array ]; break; case 'trash': + if ($postType === Calculator::POST_TYPE_SLUG) { + $output = [ + Components::render('highlighted-content', [ + 'highlightedContentTitle' => \__('Trash list is empty', 'eightshift-forms'), + // Translators: %s is the link to the forms listing page. + 'highlightedContentSubtitle' => \sprintf(\__(' + Your don\'t have any calculator outputs in trash.
+
Go to calculator outputs', 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl('calculator', '', $postType)), + 'highlightedContentIcon' => 'emptyStateTrash', + ]), + ]; + } else { + $output = [ + Components::render('highlighted-content', [ + 'highlightedContentTitle' => \__('Trash list is empty', 'eightshift-forms'), + // Translators: %s is the link to the forms listing page. + 'highlightedContentSubtitle' => \sprintf(\__(' + Your don\'t have any form in trash.
+
Go to your forms', 'eightshift-forms'), $listingUrl), + 'highlightedContentIcon' => 'emptyStateTrash', + ]), + ]; + } + break; + case 'calculator': $output = [ Components::render('highlighted-content', [ - 'highlightedContentTitle' => \__('Trash list is empty', 'eightshift-forms'), + 'highlightedContentTitle' => \__('Calculator output list is empty', 'eightshift-forms'), // Translators: %s is the link to the forms listing page. 'highlightedContentSubtitle' => \sprintf(\__(' - Your don\'t have any form in trash.
-
Go to your forms', 'eightshift-forms'), $listingUrl), - 'highlightedContentIcon' => 'emptyStateTrash', + Your don\'t have any calculator outputs.
+
Go to your forms', 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl()), + 'highlightedContentIcon' => 'emptyStateCalculator', ]), ]; break; @@ -325,7 +373,7 @@ private function getNoItemsMessage(string $type): array // Translators: %s is the link to the forms listing page. 'highlightedContentSubtitle' => \sprintf(\__(' You don\'t have any forms to show.
-
Add your first form', 'eightshift-forms'), $newUrl), +
Add your first form', 'eightshift-forms'), UtilsGeneralHelper::getNewFormPageUrl(Forms::POST_TYPE_SLUG)), 'highlightedContentIcon' => 'emptyStateFormList', ]), ]; @@ -340,10 +388,11 @@ private function getNoItemsMessage(string $type): array * * @param string $type Type of the listing. * @param string $formId Form ID. + * @param string $postType Post type of the listing. * * @return array */ - private function getTopBarItems(string $type, string $formId): array + private function getTopBarItems(string $type, string $formId, string $postType): array { $bulkSelector = UtilsHelper::getStateSelectorAdmin('listingBulk'); $filterSelector = UtilsHelper::getStateSelectorAdmin('listingFilter'); @@ -365,7 +414,7 @@ private function getTopBarItems(string $type, string $formId): array ]), ]; break; - case 'entries': + case 'calculator': $left = [ Components::render('checkbox', [ 'checkboxValue' => 'all', @@ -385,7 +434,7 @@ private function getTopBarItems(string $type, string $formId): array 'submitIsDisabled' => true, 'additionalClass' => $bulkSelector, 'submitAttrs' => [ - UtilsHelper::getStateAttribute('bulkType') => 'delete-entry', + UtilsHelper::getStateAttribute('bulkType') => 'delete', ], ]), Components::render('submit', [ @@ -394,25 +443,27 @@ private function getTopBarItems(string $type, string $formId): array 'submitIsDisabled' => true, 'additionalClass' => $bulkSelector, 'submitAttrs' => [ - UtilsHelper::getStateAttribute('bulkType') => 'duplicate-entry', + UtilsHelper::getStateAttribute('bulkType') => 'duplicate', ], ]), ]; $right = [ Components::render('submit', [ - 'submitVariant' => 'ghost', - 'submitValue' => \__('Export to CSV', 'eightshift-forms'), - 'submitIsDisabled' => true, - 'additionalClass' => "{$exportSelector} {$bulkSelector}", - 'submitAttrs' => [ - UtilsHelper::getStateAttribute('bulkType') => 'fake', - UtilsHelper::getStateAttribute('formId') => $formId, - ], + 'submitVariant' => 'outline', + 'submitButtonAsLink' => true, + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl('trash', '', Calculator::POST_TYPE_SLUG), + 'submitValue' => \__('Trashed', 'eightshift-forms'), + ]), + Components::render('submit', [ + 'submitButtonAsLink' => true, + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getNewFormPageUrl(Calculator::POST_TYPE_SLUG), + 'submitValue' => \__('Create', 'eightshift-forms'), + 'submitIcon' => UtilsHelper::getUtilsIcons('addHighContrast') ]), ]; break; - case 'trash': + case 'entries': $left = [ Components::render('checkbox', [ 'checkboxValue' => 'all', @@ -426,8 +477,72 @@ private function getTopBarItems(string $type, string $formId): array 'submitValue' => \__('Back', 'eightshift-forms'), 'submitIcon' => UtilsHelper::getUtilsIcons('arrowLeft') ]), + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitValue' => \__('Delete', 'eightshift-forms'), + 'submitIsDisabled' => true, + 'additionalClass' => $bulkSelector, + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('bulkType') => 'delete-entry', + ], + ]), + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitValue' => \__('Duplicate', 'eightshift-forms'), + 'submitIsDisabled' => true, + 'additionalClass' => $bulkSelector, + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('bulkType') => 'duplicate-entry', + ], + ]), ]; + $right = [ + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitValue' => \__('Export to CSV', 'eightshift-forms'), + 'submitIsDisabled' => true, + 'additionalClass' => "{$exportSelector} {$bulkSelector}", + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('bulkType') => 'fake', + UtilsHelper::getStateAttribute('formId') => $formId, + ], + ]), + ]; + break; + case 'trash': + if ($postType === Calculator::POST_TYPE_SLUG) { + $left = [ + Components::render('checkbox', [ + 'checkboxValue' => 'all', + 'checkboxName' => 'all', + 'additionalClass' => $selectAllSelector, + ]), + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitButtonAsLink' => true, + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl('calculator'), + 'submitValue' => \__('Back', 'eightshift-forms'), + 'submitIcon' => UtilsHelper::getUtilsIcons('arrowLeft') + ]), + ]; + } else { + $left = [ + Components::render('checkbox', [ + 'checkboxValue' => 'all', + 'checkboxName' => 'all', + 'additionalClass' => $selectAllSelector, + ]), + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitButtonAsLink' => true, + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl(), + 'submitValue' => \__('Back', 'eightshift-forms'), + 'submitIcon' => UtilsHelper::getUtilsIcons('arrowLeft') + ]), + ]; + } + $right = [ Components::render('submit', [ 'submitVariant' => 'ghost', @@ -496,12 +611,12 @@ private function getTopBarItems(string $type, string $formId): array Components::render('submit', [ 'submitVariant' => 'outline', 'submitButtonAsLink' => true, - 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getFormsTrashPageUrl(), + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl('trash', '', Forms::POST_TYPE_SLUG), 'submitValue' => \__('Trashed', 'eightshift-forms'), ]), Components::render('submit', [ 'submitButtonAsLink' => true, - 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getNewFormPageUrl(), + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getNewFormPageUrl(Forms::POST_TYPE_SLUG), 'submitValue' => \__('Create', 'eightshift-forms'), 'submitIcon' => UtilsHelper::getUtilsIcons('addHighContrast') ]), @@ -520,10 +635,11 @@ private function getTopBarItems(string $type, string $formId): array * * @param array $items Items to be rendered. * @param string $type Type of the listing. + * @param string $postType Post type of the listing. * * @return array */ - private function getListingItems(array $items, string $type): array + private function getListingItems(array $items, string $type, string $postType = ''): array { $output = []; $isDevMode = UtilsDeveloperHelper::isDeveloperModeActive(); @@ -549,6 +665,32 @@ private function getListingItems(array $items, string $type): array ]); } break; + case 'calculator': + foreach ($items as $item) { + $id = $item['id'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + $postType = $item['postType'] ?? ''; + $editLink = $item['editLink'] ?? ''; + + $title = \get_the_title($id); + + $output[] = Components::render('card-inline', [ + // Translators: %1$s is the post type, %2$s is the post title. + 'cardInlineTitle' => $title . ($isDevMode ? " ({$id})" : ''), + 'cardInlineTitleLink' => $editLink, + 'cardInlineSubTitle' => \implode(', ', $this->getSubtitle($item, ['status'])), + 'cardInlineUseHover' => true, + 'cardInlineIcon' => UtilsHelper::getUtilsIcons('calculatorOutput'), + 'cardInlineLeftContent' => Components::ensureString($this->getLeftContent($item)), + 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type)), + 'additionalAttributes' => [ + UtilsHelper::getStateAttribute('bulkId') => $id, + ], + 'additionalClass' => Components::classnames([ + UtilsHelper::getStateSelectorAdmin('listingItem'), + ]), + ]); + } + break; case 'entries': $i = 0; $count = \count($items); @@ -597,6 +739,34 @@ function ($value, $key) { $i++; } + break; + case 'trash': + foreach ($items as $item) { + $id = $item['id'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + $title = $item['title'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + + if (!$title) { + // Translators: %s is the form ID. + $title = \sprintf(\__('Form %s', 'eightshift-forms'), $id); + } + + $output[] = Components::render('card-inline', [ + 'cardInlineTitle' => $title . ($isDevMode ? " ({$id})" : ''), + 'cardInlineTitleLink' => $item['editLink'] ?? '#', + 'cardInlineSubTitle' => \implode(', ', $this->getSubtitle($item, ['all'])), + 'cardInlineIcon' => UtilsHelper::getUtilsIcons('listingGeneric'), + 'cardInlineLeftContent' => Components::ensureString($this->getLeftContent($item)), + 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type, $postType)), + 'cardInlineUseHover' => true, + 'additionalAttributes' => [ + UtilsHelper::getStateAttribute('bulkId') => $id, + ], + 'additionalClass' => Components::classnames([ + UtilsHelper::getStateSelectorAdmin('listingItem'), + ]), + ]); + } + break; default: foreach ($items as $item) { @@ -658,20 +828,27 @@ private function isIntegrationValid(array $item): bool * Get subtitle. * * @param array $item Item to be checked. + * @param array $showOnly Show only these items. * * @return array */ - private function getSubtitle(array $item): array + private function getSubtitle(array $item, array $showOnly = []): array { $output = []; + $showOnly = \array_flip($showOnly); + $showOnlyStatus = isset($showOnly['status']) || empty($showOnly); + $showOnlyIntegrationIsActive = isset($showOnly['integrationIsActive']) || empty($showOnly); + $showOnlyIntegrationIsValid = isset($showOnly['integrationIsValid']) || empty($showOnly); + $showOnlyIntegrationIsApiValid = isset($showOnly['integrationIsApiValid']) || empty($showOnly); + $status = $item['status'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $postType = $item['postType'] ?? ''; $isActive = $item['activeIntegration']['isActive'] ?? false; $isValid = $item['activeIntegration']['isValid'] ?? false; $isApiValid = $item['activeIntegration']['isApiValid'] ?? false; - if ($status !== 'publish') { + if ($status !== 'publish' && $showOnlyStatus) { $output[] = \ucfirst($status); if ($postType) { @@ -679,15 +856,15 @@ private function getSubtitle(array $item): array } } - if (!$isActive) { + if (!$isActive && $showOnlyIntegrationIsActive) { $output[] = '' . \esc_html__('Integration not enabled', 'eightshift-forms') . ''; } - if (!$isValid) { + if (!$isValid && $showOnlyIntegrationIsValid) { $output[] = '' . \esc_html__('Form configuration not valid', 'eightshift-forms') . ''; } - if (!$isApiValid) { + if (!$isApiValid && $showOnlyIntegrationIsApiValid) { $output[] = '' . \esc_html__('Missing form fields', 'eightshift-forms') . ''; } @@ -718,13 +895,16 @@ private function getLeftContent(array $item): array * * @param array $item Item to be checked. * @param string $type Type of the listing. + * @param string $postType Post type of the listing. * * @return array */ - private function getRightContent(array $item, string $type): array + private function getRightContent(array $item, string $type, string $postType = ''): array { $formId = $item['id'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited + $output = []; + switch ($type) { case 'locations': $output = [ @@ -736,9 +916,49 @@ private function getRightContent(array $item, string $type): array ]), ]; break; + case 'calculator': + $output = [ + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitButtonAsLink' => true, + 'submitButtonAsLinkUrl' => $item['editLink'] ?? '', + 'submitValue' => \__('Edit', 'eightshift-forms'), + ]), + ]; + break; case 'entries': $output = []; break; + case 'trash': + $entriesCount = EntriesHelper::getEntriesCount((string) $formId); + + if ($postType === Forms::POST_TYPE_SLUG) { + $output = [ + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitValue' => \__('Locations', 'eightshift-forms'), + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('locationsId') => $formId + ], + 'additionalClass' => UtilsHelper::getStateSelectorAdmin('listingLocations'), + ]), + ($entriesCount > 0) ? + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitButtonAsLink' => true, + 'submitButtonAsLinkUrl' => $item['entriesLink'] ?? '', + // Translators: %s is the number of entries. + 'submitValue' => \sprintf(\__('Entries (%s)', 'eightshift-forms'), $entriesCount), + ]) : null, + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitButtonAsLink' => true, + 'submitButtonAsLinkUrl' => $item['settingsLink'] ?? '', + 'submitValue' => \__('Settings', 'eightshift-forms'), + ]), + ]; + } + break; default: $entriesCount = EntriesHelper::getEntriesCount((string) $formId); diff --git a/src/AdminMenus/FormAdminTopBarMenu.php b/src/AdminMenus/FormAdminTopBarMenu.php index eb1ed7d91..09cbe2625 100644 --- a/src/AdminMenus/FormAdminTopBarMenu.php +++ b/src/AdminMenus/FormAdminTopBarMenu.php @@ -110,7 +110,7 @@ public function getTopBarMenu(WP_Admin_Bar $adminBar): void ], ); - $items = $this->formsListing->getFormsList(''); + $items = $this->formsListing->getFormsList(false); if ($items) { foreach ($items as $item) { @@ -159,7 +159,7 @@ public function getTopBarMenu(WP_Admin_Bar $adminBar): void 'id' => "{$listingPrefix}-{$id}-locations", 'parent' => $link, 'title' => \esc_html__('Locations', 'eightshift-forms'), - 'href' => UtilsGeneralHelper::getFormsLocationsPageUrl((string) $id), + 'href' => UtilsGeneralHelper::getListingPageUrl('locations', (string) $id), ], ); } @@ -170,7 +170,7 @@ public function getTopBarMenu(WP_Admin_Bar $adminBar): void 'id' => "{$prefix}-new-form", 'parent' => $prefix, 'title' => \esc_html__('Add new form', 'eightshift-forms'), - 'href' => UtilsGeneralHelper::getNewFormPageUrl(), + 'href' => UtilsGeneralHelper::getNewFormPageUrl(Forms::POST_TYPE_SLUG), ], ); diff --git a/src/AdminMenus/FormSettingsAdminSubMenu.php b/src/AdminMenus/FormSettingsAdminSubMenu.php index f3a5cbcf8..415ec468d 100644 --- a/src/AdminMenus/FormSettingsAdminSubMenu.php +++ b/src/AdminMenus/FormSettingsAdminSubMenu.php @@ -206,7 +206,7 @@ protected function processAttributes($attr): array 'adminSettingsPageTitle' => \sprintf(\esc_html__('Form settings: %s', 'eightshift-forms'), $formTitle), 'adminSettingsBackLink' => UtilsGeneralHelper::getListingPageUrl(), 'adminSettingsFormEditLink' => $formEditLink, - 'adminSettingsFormLocationsLink' => UtilsGeneralHelper::getFormsLocationsPageUrl($formId), + 'adminSettingsFormLocationsLink' => UtilsGeneralHelper::getListingPageUrl('locations', $formId), 'adminSettingsSidebar' => $this->settings->getSettingsSidebar($formId, $integrationTypeUsed), 'adminSettingsForm' => $this->settings->getSettingsForm($type, $formId), 'adminSettingsType' => $type, diff --git a/src/Blocks/components/form/assets/form.js b/src/Blocks/components/form/assets/form.js index 3112b4ca1..aa1f80660 100644 --- a/src/Blocks/components/form/assets/form.js +++ b/src/Blocks/components/form/assets/form.js @@ -296,7 +296,14 @@ export class Form { // On success state. if (response.status === 'success') { - this.formSubmitSuccess(formId, response, filter?.[this.FILTER_IS_STEPS_FINAL_SUBMIT]); + switch (formType) { + case 'calculator': + this.formSubmitCalculatorSuccess(formId, response, filter?.[this.FILTER_IS_STEPS_FINAL_SUBMIT]); + break; + default: + this.formSubmitSuccess(formId, response, filter?.[this.FILTER_IS_STEPS_FINAL_SUBMIT]); + break; + } } else { this.formSubmitError(formId, response, filter?.[this.FILTER_IS_STEPS_FINAL_SUBMIT]); } @@ -434,6 +441,58 @@ export class Form { } } + /** + * Actions to run after form submit on success - calculator. + * + * @param {string} formId Form Id. + * @param {object} response Api response. + * @param {bool} isFinalStep Check in steps if we are on final step. + * + * @returns {void} + */ + formSubmitCalculatorSuccess(formId, response, isFinalStep = false) { + const { + data, + } = response; + + // Dispatch event. + this.utils.dispatchFormEvent(formId, this.state.getStateEvent('beforeCalculatorChange'), response); + + // Check if we have output element - block. + const outputElement = document.querySelector(`${this.state.getStateSelector('calculatorOutput', true)}[${this.state.getStateAttribute('formId')}="${formId}"]`); + + if (!outputElement) { + return; + } + + // Check if we have output full content change. + const output = data?.[this.state.getStateResponseOutputKey('calculatorOutput')] ?? ''; + + if (output && outputElement) { + outputElement.innerHTML = output; + } + + // Check if we have output items change. + const outputItems = data?.[this.state.getStateResponseOutputKey('calculatorOutputItems')] ?? {}; + + if (Object.keys(outputItems).length) { + for(const [key, value] of Object.entries(outputItems)) { + const itemElement = document.querySelector(`${this.state.getStateSelector('calculatorOutputItem', true)}[${this.state.getStateAttribute('calculatorItem')}="${key}"]`); + + if (itemElement && value) { + itemElement.innerHTML = value; + } + }; + } + + if (isFinalStep) { + this.steps.resetSteps(formId); + } + + this.utils.dispatchFormEvent(formId, this.state.getStateEvent('afterCalculatorChange'), response); + } + + /** * Actions to run after form submit on error. * diff --git a/src/Blocks/custom/calculator-result/calculator-result.php b/src/Blocks/custom/calculator-result/calculator-result.php index 11a85d872..4f6d0836c 100644 --- a/src/Blocks/custom/calculator-result/calculator-result.php +++ b/src/Blocks/custom/calculator-result/calculator-result.php @@ -27,7 +27,7 @@ $calculatorClass = Components::classnames([ Components::selector($blockClass, $blockClass), - UtilsHelper::getStateSelector('calculator'), + UtilsHelper::getStateSelector('calculatorOutput'), ]); ?> diff --git a/src/Blocks/manifest.json b/src/Blocks/manifest.json index 152386fcc..459ab3a7f 100644 --- a/src/Blocks/manifest.json +++ b/src/Blocks/manifest.json @@ -424,7 +424,9 @@ "afterCaptchaInit": "esFormsAfterCaptchaInit", "stepsGoToNextStep": "esFormsGoToNextStep", "stepsGoToPrevStep": "esFormsGoToPrevStep", - "enrichmentPrefill": "esFormsEnrichmentPrefill" + "enrichmentPrefill": "esFormsEnrichmentPrefill", + "beforeCalculatorChange": "esFormsBeforeCalculatorChange", + "afterCalculatorChange": "esFormsAfterCalculatorChange" }, "typeInternal": { "input": "input", diff --git a/src/Editor/Editor.php b/src/Editor/Editor.php index 0cb4bedce..ff6c71875 100644 --- a/src/Editor/Editor.php +++ b/src/Editor/Editor.php @@ -11,6 +11,7 @@ namespace EightshiftForms\Editor; use EightshiftForms\AdminMenus\FormAdminMenu; +use EightshiftForms\CustomPostType\Calculator; use EightshiftForms\CustomPostType\Forms; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface; @@ -37,21 +38,40 @@ public function register(): void */ public function getEditorBackLink(): void { - $actialUrl = UtilsGeneralHelper::getCurrentUrl(); - $postType = Forms::POST_TYPE_SLUG; - $page = FormAdminMenu::ADMIN_MENU_SLUG; - - $links = [ - \get_admin_url(null, "edit.php?post_type={$postType}"), - \get_admin_url(null, "edit.php?post_status=publish&post_type={$postType}"), - \get_admin_url(null, "edit.php?post_status=draft&post_type={$postType}"), - \get_admin_url(null, "edit.php?post_status=trash&post_type={$postType}"), - \get_admin_url(null, "edit.php?post_status=publish&post_type={$postType}"), - \get_admin_url(null, "edit.php?post_status=future&post_type={$postType}"), + $actualUrl = UtilsGeneralHelper::getCurrentUrl(); + + $types = [ + Forms::POST_TYPE_SLUG, + Calculator::POST_TYPE_SLUG, ]; - if (\in_array($actialUrl, $links, true)) { - echo ''; // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped + foreach ($types as $type) { + $links = $this->getListOfLinks($type); + + $typeKey = $type === Forms::POST_TYPE_SLUG ? '' : 'calculator'; + + if (\in_array($actualUrl, $links, true)) { + echo ''; // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped + } } } + + /** + * Get list of links. + * + * @param string $type Type of post. + * + * @return array + */ + private function getListOfLinks(string $type): array + { + return [ + \get_admin_url(null, "edit.php?post_type={$type}"), + \get_admin_url(null, "edit.php?post_status=publish&post_type={$type}"), + \get_admin_url(null, "edit.php?post_status=draft&post_type={$type}"), + \get_admin_url(null, "edit.php?post_status=trash&post_type={$type}"), + \get_admin_url(null, "edit.php?post_status=publish&post_type={$type}"), + \get_admin_url(null, "edit.php?post_status=future&post_type={$type}"), + ]; + } } diff --git a/src/Entries/SettingsEntries.php b/src/Entries/SettingsEntries.php index 133493e02..a34820ae3 100644 --- a/src/Entries/SettingsEntries.php +++ b/src/Entries/SettingsEntries.php @@ -161,7 +161,7 @@ public function getSettingsData(string $formId): array 'component' => 'checkbox', 'checkboxLabel' => \__('Store entries in database', 'eightshift-forms'), // translators: %s is replaced with the form entries page URL. - 'checkboxHelp' => $isUsed ? \sprintf(\__("You can find all form entries here.", 'eightshift-forms'), UtilsGeneralHelper::getFormsEntriesPageUrl($formId)) : '', + 'checkboxHelp' => $isUsed ? \sprintf(\__("You can find all form entries here.", 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl('entries', $formId)) : '', 'checkboxIsChecked' => $isUsed, 'checkboxValue' => self::SETTINGS_ENTRIES_SETTINGS_USE_KEY, 'checkboxSingleSubmit' => true, diff --git a/src/Integrations/Calculator/SettingsCalculator.php b/src/Integrations/Calculator/SettingsCalculator.php index 33dba3346..e32fe2a88 100644 --- a/src/Integrations/Calculator/SettingsCalculator.php +++ b/src/Integrations/Calculator/SettingsCalculator.php @@ -10,6 +10,7 @@ namespace EightshiftForms\Integrations\Calculator; +use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingGlobalInterface; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; @@ -46,9 +47,9 @@ class SettingsCalculator implements UtilsSettingGlobalInterface, ServiceInterfac public const SETTINGS_CALCULATOR_USE_KEY = 'calculator-use'; /** - * Calculator output ID key. + * Calculator settings use single submit key. */ - public const SETTINGS_CALCULATOR_OUTPUT_ID_KEY = 'calculator-output_ID'; + public const SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY = 'calculator-use-single-submit'; /** * Register all the hooks @@ -97,7 +98,31 @@ public function getSettingsData(string $formId): array [ 'component' => 'tabs', 'tabsFull' => true, - 'tabsContent' => [], + 'tabsContent' => [ + [ + 'component' => 'tab', + 'tabLabel' => \__('Options', 'eightshift-forms'), + 'tabContent' => [ + [ + 'component' => 'checkboxes', + 'checkboxesFieldLabel' => '', + 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY), + 'checkboxesContent' => [ + [ + 'component' => 'checkbox', + 'checkboxLabel' => \__('Use single submit', 'eightshift-forms'), + // translators: %s is replaced with the form entries page URL. + 'checkboxHelp' => \sprintf(\__("You can find all calculator outputs here.", 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl('calculator')), + 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, $formId), + 'checkboxValue' => self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, + 'checkboxSingleSubmit' => true, + 'checkboxAsToggle' => true, + ] + ] + ], + ], + ] + ], ], ]; } diff --git a/src/Listing/FormListingInterface.php b/src/Listing/FormListingInterface.php index 6a2338fef..e8433ca6e 100644 --- a/src/Listing/FormListingInterface.php +++ b/src/Listing/FormListingInterface.php @@ -10,6 +10,8 @@ namespace EightshiftForms\Listing; +use EightshiftForms\CustomPostType\Forms; + /** * Interface for admin content listing */ @@ -18,9 +20,10 @@ interface FormListingInterface /** * Get Forms List. * - * @param string $status Status for listing to output. + * @param bool $showTrash Show trashed items. + * @param string $postType Post type for listing to output. * * @return array> */ - public function getFormsList(string $status): array; + public function getFormsList(bool $showTrash = false, string $postType = Forms::POST_TYPE_SLUG): array; } diff --git a/src/Listing/FormsListing.php b/src/Listing/FormsListing.php index ea9e78576..9e66e818e 100644 --- a/src/Listing/FormsListing.php +++ b/src/Listing/FormsListing.php @@ -24,25 +24,24 @@ class FormsListing implements FormListingInterface /** * Get Forms List. * - * @param string $status Status for listing to output. + * @param bool $showTrash Show trashed items. + * @param string $postType Post type for listing to output. * * @return array> */ - public function getFormsList(string $status): array + public function getFormsList(bool $showTrash = false, string $postType = Forms::POST_TYPE_SLUG): array { // Prepare query args. $args = [ - 'post_type' => Forms::POST_TYPE_SLUG, + 'post_type' => $postType, 'posts_per_page' => 5000, // phpcs:ignore WordPress.WP.PostsPerPage.posts_per_page_posts_per_page - 'post_status' => $status, + 'post_status' => $showTrash ? 'trash' : '', ]; $theQuery = new WP_Query($args); $output = []; - $permanent = $status === 'trash'; - if (!$theQuery->have_posts()) { \wp_reset_postdata(); return []; @@ -56,10 +55,10 @@ public function getFormsList(string $status): array 'id' => $id, 'title' => \get_the_title($id), 'status' => \get_post_status($id), - 'settingsLink' => !$permanent ? UtilsGeneralHelper::getSettingsPageUrl((string) $id, SettingsGeneral::SETTINGS_TYPE_KEY) : '', - 'editLink' => !$permanent ? UtilsGeneralHelper::getFormEditPageUrl((string) $id) : '', - 'trashLink' => UtilsGeneralHelper::getFormTrashActionUrl((string) $id, $permanent), - 'entriesLink' => UtilsGeneralHelper::getFormsEntriesPageUrl((string) $id), + 'settingsLink' => UtilsGeneralHelper::getSettingsPageUrl((string) $id, SettingsGeneral::SETTINGS_TYPE_KEY), + 'editLink' => !$showTrash ? UtilsGeneralHelper::getFormEditPageUrl((string) $id) : '', + 'trashLink' => UtilsGeneralHelper::getFormTrashActionUrl((string) $id, $showTrash), + 'entriesLink' => UtilsGeneralHelper::getListingPageUrl('entries', (string) $id), 'trashRestoreLink' => UtilsGeneralHelper::getFormTrashRestoreActionUrl((string) $id), 'activeIntegration' => UtilsIntegrationsHelper::getIntegrationDetailsById((string) $id), 'useSync' => true, diff --git a/src/Rest/Routes/Settings/BulkRoute.php b/src/Rest/Routes/Settings/BulkRoute.php index 5ae260dc9..803c57d38 100644 --- a/src/Rest/Routes/Settings/BulkRoute.php +++ b/src/Rest/Routes/Settings/BulkRoute.php @@ -224,7 +224,7 @@ private function output(array $details, string $type): array if (\count($details) > 1) { $msgOutput = [ // translators: %s replaces type. - \sprintf(\esc_html__('Not all forms were %s with success. Please check the following log.', 'eightshift-forms'), $intrernaType, $msg), + \sprintf(\esc_html__('Not all items were %s with success. Please check the following log.', 'eightshift-forms'), $intrernaType, $msg), ]; if ($error) { @@ -252,22 +252,20 @@ private function output(array $details, string $type): array return [ 'status' => 'success', // translators: %s replaces form msg type. - 'msg' => \sprintf(\esc_html__('Success, all selected %1$s were %2$s.', 'eightshift-forms'), $intrernaType, $msg), + 'msg' => \sprintf(\esc_html__('Success, all selected items were %s.', 'eightshift-forms'), $msg), ]; } if ($skip) { return [ 'status' => 'warning', - // translators: %s replaces form msg type. - 'msg' => \sprintf(\esc_html__('Warning, all selected %s were skipped.', 'eightshift-forms'), $intrernaType), + 'msg' => \esc_html__('Warning, all selected items were skipped.', 'eightshift-forms'), ]; } return [ 'status' => 'error', - // translators: %s replaces form msg type. - 'msg' => \sprintf(\esc_html__('There was and error on all selected %s.', 'eightshift-forms'), $intrernaType), + 'msg' => \esc_html__('There was and error on all selected items.', 'eightshift-forms'), ]; } @@ -320,7 +318,7 @@ private function delete(array $ids): array if (!$title) { // translators: %s replaces form id. - $title = \sprintf(\esc_html__('Form %s', 'eightshift-forms'), $id); + $title = \sprintf(\esc_html__('Item %s', 'eightshift-forms'), $id); } $action = \wp_trash_post((int) $id); @@ -351,7 +349,7 @@ private function deletePerminently(array $ids): array if (!$title) { // translators: %s replaces form id. - $title = \sprintf(\esc_html__('Form %s', 'eightshift-forms'), $id); + $title = \sprintf(\esc_html__('Item %s', 'eightshift-forms'), $id); } $action = \wp_delete_post((int) $id, true); @@ -413,7 +411,7 @@ private function restore(array $ids): array if (!$title) { // translators: %s replaces form id. - $title = \sprintf(\esc_html__('Form %s', 'eightshift-forms'), $id); + $title = \sprintf(\esc_html__('Item %s', 'eightshift-forms'), $id); } $action = \wp_update_post([ @@ -446,8 +444,7 @@ private function duplicate(array $ids): array $title = \get_the_title($id); if (!$title) { - // translators: %s replaces form id. - $title = \sprintf(\esc_html__('Form %s', 'eightshift-forms'), $id); + $title = \sprintf(\esc_html__('Item %s', 'eightshift-forms'), $id); } $export = $this->transfer->getExportForm((string) $id); diff --git a/src/Shortcode/CalculatorItem.php b/src/Shortcode/CalculatorItem.php new file mode 100644 index 000000000..e575b70e7 --- /dev/null +++ b/src/Shortcode/CalculatorItem.php @@ -0,0 +1,60 @@ + $atts Attributes passed to the shortcode. + * @param string $content Content inside the shortcode. + * + * @return string + */ + public function callback(array $atts, string $content): string + { + $params = \shortcode_atts( + [ + 'id' => '', + ], + $atts + ); + + $id = isset($params['id']) ? \esc_html($params['id']) : ''; + + if (!$id || !$content) { + return ''; + } + + $classSelector = UtilsHelper::getStateSelector('calculatorOutputItem'); + + $attrName = UtilsHelper::getStateAttribute('calculatorItem'); + + return "{$content}"; + } +} diff --git a/src/Shortcode/ShortcodeLink.php b/src/Shortcode/Link.php similarity index 85% rename from src/Shortcode/ShortcodeLink.php rename to src/Shortcode/Link.php index 2ed659542..216cef317 100644 --- a/src/Shortcode/ShortcodeLink.php +++ b/src/Shortcode/Link.php @@ -1,7 +1,7 @@ 'something', - 'label' => 'something else', + 'url' => '', + 'label' => '', ], $atts ); From 4932a96500d39c5b3a410d3deb0efd8076fdbfa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Tue, 5 Mar 2024 13:27:16 +0100 Subject: [PATCH 11/35] update --- src/Blocks/components/form/assets/form.js | 2 +- src/Blocks/custom/calculator-result/calculator-result-block.js | 2 ++ src/Editor/Editor.php | 3 +-- src/Rest/Routes/Settings/BulkRoute.php | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Blocks/components/form/assets/form.js b/src/Blocks/components/form/assets/form.js index aa1f80660..ee14036a7 100644 --- a/src/Blocks/components/form/assets/form.js +++ b/src/Blocks/components/form/assets/form.js @@ -482,7 +482,7 @@ export class Form { if (itemElement && value) { itemElement.innerHTML = value; } - }; + } } if (isFinalStep) { diff --git a/src/Blocks/custom/calculator-result/calculator-result-block.js b/src/Blocks/custom/calculator-result/calculator-result-block.js index 4c512baeb..53c074fd0 100644 --- a/src/Blocks/custom/calculator-result/calculator-result-block.js +++ b/src/Blocks/custom/calculator-result/calculator-result-block.js @@ -1,3 +1,5 @@ +/* global esFormsLocalization */ + import React from 'react'; import { InspectorControls } from '@wordpress/block-editor'; import { CalculatorResultEditor } from './components/calculator-result-editor'; diff --git a/src/Editor/Editor.php b/src/Editor/Editor.php index ff6c71875..d373b11c0 100644 --- a/src/Editor/Editor.php +++ b/src/Editor/Editor.php @@ -10,7 +10,6 @@ namespace EightshiftForms\Editor; -use EightshiftForms\AdminMenus\FormAdminMenu; use EightshiftForms\CustomPostType\Calculator; use EightshiftForms\CustomPostType\Forms; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; @@ -61,7 +60,7 @@ public function getEditorBackLink(): void * * @param string $type Type of post. * - * @return array + * @return array List of links. */ private function getListOfLinks(string $type): array { diff --git a/src/Rest/Routes/Settings/BulkRoute.php b/src/Rest/Routes/Settings/BulkRoute.php index 803c57d38..e5430c0f4 100644 --- a/src/Rest/Routes/Settings/BulkRoute.php +++ b/src/Rest/Routes/Settings/BulkRoute.php @@ -444,6 +444,7 @@ private function duplicate(array $ids): array $title = \get_the_title($id); if (!$title) { + // translators: %s replaces form id. $title = \sprintf(\esc_html__('Item %s', 'eightshift-forms'), $id); } From 4e75c995a46832044bfc8633039791ae6d6b69a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Thu, 7 Mar 2024 13:27:17 +0100 Subject: [PATCH 12/35] update --- composer.lock | 8 +- src/AdminMenus/FormAdminMenu.php | 118 +++++++++--------- src/AdminMenus/FormAdminTopBarMenu.php | 5 +- src/AdminMenus/FormListingAdminSubMenu.php | 30 +++++ src/AdminMenus/FormSettingsAdminSubMenu.php | 23 +--- src/Blocks/Blocks.php | 4 + src/Blocks/assets/scripts/blocks-editor.js | 11 +- src/Blocks/components/form/assets/form.js | 62 +-------- .../components/form/assets/state-init.js | 2 + src/Blocks/components/form/assets/state.js | 3 + src/Blocks/components/form/assets/utils.js | 89 +++++++++++++ src/Blocks/components/form/form.php | 5 + src/Blocks/components/form/manifest.json | 4 + .../calculator-result/calculator-result.php | 39 ------ .../components/calculator-result-options.js | 64 ---------- .../form-selector/form-selector-editor.scss | 11 +- src/Blocks/custom/form-selector/manifest.json | 3 + .../components/result-output-item-editor.js | 31 +++++ .../components/result-output-item-options.js | 29 +++++ .../custom/result-output-item/manifest.json | 24 ++++ .../result-output-item-block.js | 15 +++ .../result-output-item-editor.scss | 24 ++++ .../result-output-item/result-output-item.php | 43 +++++++ .../components/result-output-editor.js} | 42 +++---- .../components/result-output-options.js | 75 +++++++++++ .../manifest.json | 31 +++-- .../result-output-block.js} | 22 ++-- .../result-output-editor.scss} | 2 +- .../custom/result-output/result-output.php | 41 ++++++ src/Blocks/manifest.json | 9 +- .../{Calculator.php => Result.php} | 18 +-- src/Editor/Editor.php | 7 +- src/Enqueue/Blocks/EnqueueBlocks.php | 4 +- src/Entries/SettingsEntries.php | 3 +- src/Form/Form.php | 3 + src/General/SettingsGeneral.php | 24 ++++ src/Hooks/Filters.php | 4 +- .../Calculator/SettingsCalculator.php | 2 - src/Listing/FormListingInterface.php | 8 +- src/Listing/FormsListing.php | 30 ++++- .../Calculator/FormSubmitCalculatorRoute.php | 8 +- ...latorItem.php => ResultOutputItemPart.php} | 15 +-- src/Transfer/SettingsTransfer.php | 1 + 43 files changed, 658 insertions(+), 338 deletions(-) delete mode 100644 src/Blocks/custom/calculator-result/calculator-result.php delete mode 100644 src/Blocks/custom/calculator-result/components/calculator-result-options.js create mode 100644 src/Blocks/custom/result-output-item/components/result-output-item-editor.js create mode 100644 src/Blocks/custom/result-output-item/components/result-output-item-options.js create mode 100644 src/Blocks/custom/result-output-item/manifest.json create mode 100644 src/Blocks/custom/result-output-item/result-output-item-block.js create mode 100644 src/Blocks/custom/result-output-item/result-output-item-editor.scss create mode 100644 src/Blocks/custom/result-output-item/result-output-item.php rename src/Blocks/custom/{calculator-result/components/calculator-result-editor.js => result-output/components/result-output-editor.js} (51%) create mode 100644 src/Blocks/custom/result-output/components/result-output-options.js rename src/Blocks/custom/{calculator-result => result-output}/manifest.json (51%) rename src/Blocks/custom/{calculator-result/calculator-result-block.js => result-output/result-output-block.js} (61%) rename src/Blocks/custom/{calculator-result/calculator-result-editor.scss => result-output/result-output-editor.scss} (94%) create mode 100644 src/Blocks/custom/result-output/result-output.php rename src/CustomPostType/{Calculator.php => Result.php} (75%) rename src/Shortcode/{CalculatorItem.php => ResultOutputItemPart.php} (60%) diff --git a/composer.lock b/composer.lock index 74dfc906c..ccb54b67b 100644 --- a/composer.lock +++ b/composer.lock @@ -62,12 +62,12 @@ "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "b18cf898c010395a29c79abc0982fb527792d955" + "reference": "ed0b9f553083ccbd3d5bcfb5ae377d40583225cc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/b18cf898c010395a29c79abc0982fb527792d955", - "reference": "b18cf898c010395a29c79abc0982fb527792d955", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/ed0b9f553083ccbd3d5bcfb5ae377d40583225cc", + "reference": "ed0b9f553083ccbd3d5bcfb5ae377d40583225cc", "shasum": "" }, "require": { @@ -119,7 +119,7 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-03-05T12:04:48+00:00" + "time": "2024-03-07T12:23:48+00:00" }, { "name": "infinum/eightshift-libs", diff --git a/src/AdminMenus/FormAdminMenu.php b/src/AdminMenus/FormAdminMenu.php index 9ad211ec2..15c5373fc 100644 --- a/src/AdminMenus/FormAdminMenu.php +++ b/src/AdminMenus/FormAdminMenu.php @@ -10,7 +10,7 @@ namespace EightshiftForms\AdminMenus; -use EightshiftForms\CustomPostType\Calculator; +use EightshiftForms\CustomPostType\Result; use EightshiftForms\CustomPostType\Forms; use EightshiftForms\Entries\EntriesHelper; use EightshiftFormsVendor\EightshiftLibs\Helpers\Components; @@ -22,6 +22,8 @@ use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsIntegrationsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper; use EightshiftFormsVendor\EightshiftLibs\AdminMenus\AbstractAdminMenu; +use Faker\Provider\bn_BD\Utils; +use Hamcrest\Util; /** * FormAdminMenu class. @@ -190,11 +192,11 @@ protected function processAttributes($attr): array { $type = isset($_GET['type']) ? \sanitize_text_field(\wp_unslash($_GET['type'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $formId = isset($_GET['formId']) ? \sanitize_text_field(\wp_unslash($_GET['formId'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended - $postType = isset($_GET['postType']) ? \sanitize_text_field(\wp_unslash($_GET['postType'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended + $parent = isset($_GET['parent']) ? \sanitize_text_field(\wp_unslash($_GET['parent'])) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended $output = []; switch ($type) { - case 'locations': + case UtilsConfig::SLUG_ADMIN_LISTING_LOCATIONS: $items = UtilsGeneralHelper::getBlockLocations($formId); $count = \count($items); $formTitle = \get_the_title((int) $formId); @@ -206,7 +208,7 @@ protected function processAttributes($attr): array 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 form location.', 'eightshift-forms') : \sprintf(\__('Showing %s form locations.', 'eightshift-forms'), $count), ]; break; - case 'entries': + case UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES: $items = EntriesHelper::getEntries($formId); $count = \count($items); $formTitle = \get_the_title((int) $formId); @@ -218,16 +220,16 @@ protected function processAttributes($attr): array 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 form entry.', 'eightshift-forms') : \sprintf(\__('Showing %s form entries.', 'eightshift-forms'), $count), ]; break; - case 'trash': - $items = $this->formsListing->getFormsList(true, $postType); + case UtilsConfig::SLUG_ADMIN_LISTING_TRASH: + $items = $this->formsListing->getFormsList($type, $parent); $count = \count($items); - if ($postType === Calculator::POST_TYPE_SLUG) { + if ($parent === UtilsConfig::SLUG_ADMIN_LISTING_RESULTS) { $output = [ // Translators: %s is the form title. - 'adminListingPageTitle' => $this->getMultilangTitle(\__('Deleted calculator outputs', 'eightshift-forms')), + 'adminListingPageTitle' => $this->getMultilangTitle(\__('Deleted result outputs', 'eightshift-forms')), // Translators: %s is the number of trashed forms. - 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 trashed calculator output.', 'eightshift-forms') : \sprintf(\__('Showing %s trashed calculator outputs.', 'eightshift-forms'), $count), + 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 trashed result output.', 'eightshift-forms') : \sprintf(\__('Showing %s trashed result outputs.', 'eightshift-forms'), $count), ]; } else { $output = [ @@ -238,19 +240,19 @@ protected function processAttributes($attr): array ]; } break; - case 'calculator': - $items = $this->formsListing->getFormsList(false, Calculator::POST_TYPE_SLUG); + case UtilsConfig::SLUG_ADMIN_LISTING_RESULTS: + $items = $this->formsListing->getFormsList($type, $parent); $count = \count($items); $output = [ // Translators: %s is the form title. - 'adminListingPageTitle' => $this->getMultilangTitle(\__('Calculator outputs', 'eightshift-forms')), + 'adminListingPageTitle' => $this->getMultilangTitle(\__('Result outputs', 'eightshift-forms')), // Translators: %s is the number of trashed forms. - 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 calculator output.', 'eightshift-forms') : \sprintf(\__('Showing %s calculator outputs.', 'eightshift-forms'), $count), + 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 result output.', 'eightshift-forms') : \sprintf(\__('Showing %s result outputs.', 'eightshift-forms'), $count), ]; break; default: - $items = $this->formsListing->getFormsList(false); + $items = $this->formsListing->getFormsList($type, $parent); $count = \count($items); $output = [ @@ -265,9 +267,9 @@ protected function processAttributes($attr): array $output, [ 'adminListingShowNoItems' => $count === 0, - 'adminListingItems' => $this->getListingItems($items, $type, $postType), - 'adminListingTopItems' => $this->getTopBarItems($type, $formId, $postType), - 'adminListingNoItems' => $this->getNoItemsMessage($type, $postType), + 'adminListingItems' => $this->getListingItems($items, $type, $parent), + 'adminListingTopItems' => $this->getTopBarItems($type, $formId, $parent), + 'adminListingNoItems' => $this->getNoItemsMessage($type, $parent), ] ); } @@ -296,16 +298,16 @@ private function getMultilangTitle(string $title): string * Get no items message output. * * @param string $type Type of the listing. - * @param string $postType Post type of the listing. + * @param string $parent Post type of the listing. * * @return array */ - private function getNoItemsMessage(string $type, string $postType): array + private function getNoItemsMessage(string $type, string $parent): array { $listingUrl = UtilsGeneralHelper::getListingPageUrl(); switch ($type) { - case 'locations': + case UtilsConfig::SLUG_ADMIN_LISTING_LOCATIONS: $output = [ Components::render('highlighted-content', [ 'highlightedContentTitle' => \__('Location list is empty', 'eightshift-forms'), @@ -317,15 +319,15 @@ private function getNoItemsMessage(string $type, string $postType): array ]), ]; break; - case 'trash': - if ($postType === Calculator::POST_TYPE_SLUG) { + case UtilsConfig::SLUG_ADMIN_LISTING_TRASH: + if ($parent === UtilsConfig::SLUG_ADMIN_LISTING_RESULTS) { $output = [ Components::render('highlighted-content', [ 'highlightedContentTitle' => \__('Trash list is empty', 'eightshift-forms'), // Translators: %s is the link to the forms listing page. 'highlightedContentSubtitle' => \sprintf(\__(' - Your don\'t have any calculator outputs in trash.
-
Go to calculator outputs', 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl('calculator', '', $postType)), + Your don\'t have any result outputs in trash.
+
Go to result outputs', 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_RESULTS, '', $parent)), 'highlightedContentIcon' => 'emptyStateTrash', ]), ]; @@ -342,19 +344,19 @@ private function getNoItemsMessage(string $type, string $postType): array ]; } break; - case 'calculator': + case UtilsConfig::SLUG_ADMIN_LISTING_RESULTS: $output = [ Components::render('highlighted-content', [ - 'highlightedContentTitle' => \__('Calculator output list is empty', 'eightshift-forms'), + 'highlightedContentTitle' => \__('Result output list is empty', 'eightshift-forms'), // Translators: %s is the link to the forms listing page. 'highlightedContentSubtitle' => \sprintf(\__(' - Your don\'t have any calculator outputs.
+ Your don\'t have any result outputs.

Go to your forms', 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl()), - 'highlightedContentIcon' => 'emptyStateCalculator', + 'highlightedContentIcon' => 'emptyStateResults', ]), ]; break; - case 'entries': + case UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES: $output = [ Components::render('highlighted-content', [ 'highlightedContentTitle' => \__('Entrie list is empty', 'eightshift-forms'), @@ -388,11 +390,11 @@ private function getNoItemsMessage(string $type, string $postType): array * * @param string $type Type of the listing. * @param string $formId Form ID. - * @param string $postType Post type of the listing. + * @param string $parent Parent type of the listing. * * @return array */ - private function getTopBarItems(string $type, string $formId, string $postType): array + private function getTopBarItems(string $type, string $formId, string $parent): array { $bulkSelector = UtilsHelper::getStateSelectorAdmin('listingBulk'); $filterSelector = UtilsHelper::getStateSelectorAdmin('listingFilter'); @@ -403,7 +405,7 @@ private function getTopBarItems(string $type, string $formId, string $postType): $right = []; switch ($type) { - case 'locations': + case UtilsConfig::SLUG_ADMIN_LISTING_LOCATIONS: $left = [ Components::render('submit', [ 'submitVariant' => 'ghost', @@ -414,7 +416,7 @@ private function getTopBarItems(string $type, string $formId, string $postType): ]), ]; break; - case 'calculator': + case UtilsConfig::SLUG_ADMIN_LISTING_RESULTS: $left = [ Components::render('checkbox', [ 'checkboxValue' => 'all', @@ -452,18 +454,18 @@ private function getTopBarItems(string $type, string $formId, string $postType): Components::render('submit', [ 'submitVariant' => 'outline', 'submitButtonAsLink' => true, - 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl('trash', '', Calculator::POST_TYPE_SLUG), + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_TRASH, '', UtilsConfig::SLUG_ADMIN_LISTING_RESULTS), 'submitValue' => \__('Trashed', 'eightshift-forms'), ]), Components::render('submit', [ 'submitButtonAsLink' => true, - 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getNewFormPageUrl(Calculator::POST_TYPE_SLUG), + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getNewFormPageUrl(Result::POST_TYPE_SLUG), 'submitValue' => \__('Create', 'eightshift-forms'), 'submitIcon' => UtilsHelper::getUtilsIcons('addHighContrast') ]), ]; break; - case 'entries': + case UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES: $left = [ Components::render('checkbox', [ 'checkboxValue' => 'all', @@ -510,8 +512,8 @@ private function getTopBarItems(string $type, string $formId, string $postType): ]), ]; break; - case 'trash': - if ($postType === Calculator::POST_TYPE_SLUG) { + case UtilsConfig::SLUG_ADMIN_LISTING_TRASH: + if ($parent === UtilsConfig::SLUG_ADMIN_LISTING_RESULTS) { $left = [ Components::render('checkbox', [ 'checkboxValue' => 'all', @@ -521,7 +523,7 @@ private function getTopBarItems(string $type, string $formId, string $postType): Components::render('submit', [ 'submitVariant' => 'ghost', 'submitButtonAsLink' => true, - 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl('calculator'), + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_RESULTS), 'submitValue' => \__('Back', 'eightshift-forms'), 'submitIcon' => UtilsHelper::getUtilsIcons('arrowLeft') ]), @@ -611,7 +613,7 @@ private function getTopBarItems(string $type, string $formId, string $postType): Components::render('submit', [ 'submitVariant' => 'outline', 'submitButtonAsLink' => true, - 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl('trash', '', Forms::POST_TYPE_SLUG), + 'submitButtonAsLinkUrl' => UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_TRASH), 'submitValue' => \__('Trashed', 'eightshift-forms'), ]), Components::render('submit', [ @@ -635,17 +637,17 @@ private function getTopBarItems(string $type, string $formId, string $postType): * * @param array $items Items to be rendered. * @param string $type Type of the listing. - * @param string $postType Post type of the listing. + * @param string $parent Parent type of the listing. * * @return array */ - private function getListingItems(array $items, string $type, string $postType = ''): array + private function getListingItems(array $items, string $type, string $parent): array { $output = []; $isDevMode = UtilsDeveloperHelper::isDeveloperModeActive(); switch ($type) { - case 'locations': + case UtilsConfig::SLUG_ADMIN_LISTING_LOCATIONS: foreach ($items as $item) { $id = $item['id'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $postType = $item['postType'] ?? ''; @@ -661,11 +663,11 @@ private function getListingItems(array $items, string $type, string $postType = 'cardInlineUseHover' => true, 'cardInlineIcon' => UtilsHelper::getUtilsIcons('post'), 'cardInlineLeftContent' => Components::ensureString($this->getLeftContent($item)), - 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type)), + 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type, $parent)), ]); } break; - case 'calculator': + case UtilsConfig::SLUG_ADMIN_LISTING_RESULTS: foreach ($items as $item) { $id = $item['id'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $postType = $item['postType'] ?? ''; @@ -679,9 +681,9 @@ private function getListingItems(array $items, string $type, string $postType = 'cardInlineTitleLink' => $editLink, 'cardInlineSubTitle' => \implode(', ', $this->getSubtitle($item, ['status'])), 'cardInlineUseHover' => true, - 'cardInlineIcon' => UtilsHelper::getUtilsIcons('calculatorOutput'), + 'cardInlineIcon' => UtilsHelper::getUtilsIcons('resultOutput'), 'cardInlineLeftContent' => Components::ensureString($this->getLeftContent($item)), - 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type)), + 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type, $parent)), 'additionalAttributes' => [ UtilsHelper::getStateAttribute('bulkId') => $id, ], @@ -691,7 +693,7 @@ private function getListingItems(array $items, string $type, string $postType = ]); } break; - case 'entries': + case UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES: $i = 0; $count = \count($items); foreach (\array_reverse($items) as $item) { @@ -740,7 +742,7 @@ function ($value, $key) { $i++; } break; - case 'trash': + case UtilsConfig::SLUG_ADMIN_LISTING_TRASH: foreach ($items as $item) { $id = $item['id'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $title = $item['title'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited @@ -756,7 +758,7 @@ function ($value, $key) { 'cardInlineSubTitle' => \implode(', ', $this->getSubtitle($item, ['all'])), 'cardInlineIcon' => UtilsHelper::getUtilsIcons('listingGeneric'), 'cardInlineLeftContent' => Components::ensureString($this->getLeftContent($item)), - 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type, $postType)), + 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type, $parent)), 'cardInlineUseHover' => true, 'additionalAttributes' => [ UtilsHelper::getStateAttribute('bulkId') => $id, @@ -790,7 +792,7 @@ function ($value, $key) { 'cardInlineSubTitle' => \implode(', ', $this->getSubtitle($item)), 'cardInlineIcon' => $cardIcon, 'cardInlineLeftContent' => Components::ensureString($this->getLeftContent($item)), - 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type)), + 'cardInlineRightContent' => Components::ensureString($this->getRightContent($item, $type, $parent)), 'cardInlineInvalid' => !$isValid, 'cardInlineUseHover' => true, 'additionalAttributes' => [ @@ -895,18 +897,18 @@ private function getLeftContent(array $item): array * * @param array $item Item to be checked. * @param string $type Type of the listing. - * @param string $postType Post type of the listing. + * @param string $parent Parent type of the listing. * * @return array */ - private function getRightContent(array $item, string $type, string $postType = ''): array + private function getRightContent(array $item, string $type, string $parent): array { $formId = $item['id'] ?? ''; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited $output = []; switch ($type) { - case 'locations': + case UtilsConfig::SLUG_ADMIN_LISTING_LOCATIONS: $output = [ Components::render('submit', [ 'submitVariant' => 'ghost', @@ -916,7 +918,7 @@ private function getRightContent(array $item, string $type, string $postType = ' ]), ]; break; - case 'calculator': + case UtilsConfig::SLUG_ADMIN_LISTING_RESULTS: $output = [ Components::render('submit', [ 'submitVariant' => 'ghost', @@ -926,13 +928,13 @@ private function getRightContent(array $item, string $type, string $postType = ' ]), ]; break; - case 'entries': + case UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES: $output = []; break; - case 'trash': + case UtilsConfig::SLUG_ADMIN_LISTING_TRASH: $entriesCount = EntriesHelper::getEntriesCount((string) $formId); - if ($postType === Forms::POST_TYPE_SLUG) { + if ($parent === '') { $output = [ Components::render('submit', [ 'submitVariant' => 'ghost', diff --git a/src/AdminMenus/FormAdminTopBarMenu.php b/src/AdminMenus/FormAdminTopBarMenu.php index 09cbe2625..42f24e77a 100644 --- a/src/AdminMenus/FormAdminTopBarMenu.php +++ b/src/AdminMenus/FormAdminTopBarMenu.php @@ -16,6 +16,7 @@ use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftForms\Listing\FormListingInterface; use EightshiftForms\Troubleshooting\SettingsDebug; +use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsDeveloperHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper; @@ -110,7 +111,7 @@ public function getTopBarMenu(WP_Admin_Bar $adminBar): void ], ); - $items = $this->formsListing->getFormsList(false); + $items = $this->formsListing->getFormsList(); if ($items) { foreach ($items as $item) { @@ -159,7 +160,7 @@ public function getTopBarMenu(WP_Admin_Bar $adminBar): void 'id' => "{$listingPrefix}-{$id}-locations", 'parent' => $link, 'title' => \esc_html__('Locations', 'eightshift-forms'), - 'href' => UtilsGeneralHelper::getListingPageUrl('locations', (string) $id), + 'href' => UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_LOCATIONS, (string) $id), ], ); } diff --git a/src/AdminMenus/FormListingAdminSubMenu.php b/src/AdminMenus/FormListingAdminSubMenu.php index 30330b23e..c833e7239 100644 --- a/src/AdminMenus/FormListingAdminSubMenu.php +++ b/src/AdminMenus/FormListingAdminSubMenu.php @@ -10,7 +10,11 @@ namespace EightshiftForms\AdminMenus; +use EightshiftForms\CustomPostType\Forms; +use EightshiftForms\CustomPostType\Result; use EightshiftForms\Listing\FormListingInterface; +use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; +use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftLibs\AdminMenus\AbstractAdminSubMenu; /** @@ -56,6 +60,8 @@ function () { }, 20 ); + + \add_action('admin_menu', [$this, 'addCustomLinkIntoAppearnaceMenu'], 32); } /** @@ -170,4 +176,28 @@ protected function processAttributes($attr): array { return []; } + + /** + * Add additional links to sidebar menu. + * + * @return void + */ + public function addCustomLinkIntoAppearnaceMenu(): void + { + global $submenu; + + // phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited + $submenu[FormAdminMenu::ADMIN_MENU_SLUG][] = [ + \esc_html__('Add new form', 'eightshift-forms'), + FormAdminMenu::ADMIN_MENU_CAPABILITY, + UtilsGeneralHelper::getNewFormPageUrl(Forms::URL_SLUG) + ]; + + $submenu[FormAdminMenu::ADMIN_MENU_SLUG][] = [ + \esc_html__('Result outputs', 'eightshift-forms'), + UtilsConfig::CAP_RESULTS, + UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_RESULTS, '', Result::POST_TYPE_SLUG) + ]; + // phpcs:enable + } } diff --git a/src/AdminMenus/FormSettingsAdminSubMenu.php b/src/AdminMenus/FormSettingsAdminSubMenu.php index 415ec468d..9e844b47b 100644 --- a/src/AdminMenus/FormSettingsAdminSubMenu.php +++ b/src/AdminMenus/FormSettingsAdminSubMenu.php @@ -10,7 +10,6 @@ namespace EightshiftForms\AdminMenus; -use EightshiftForms\CustomPostType\Forms; use EightshiftFormsVendor\EightshiftLibs\Helpers\Components; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftForms\Settings\Settings\SettingsBuilderInterface; @@ -65,7 +64,7 @@ function () { \add_filter('parent_file', [$this, 'changeHighlightParent'], 31); \add_filter('admin_title', [$this, 'fixPageTitle'], 10, 2); - \add_action('admin_menu', [$this, 'addCustomLinkIntoAppearnaceMenu'], 32); + } /** @@ -206,7 +205,7 @@ protected function processAttributes($attr): array 'adminSettingsPageTitle' => \sprintf(\esc_html__('Form settings: %s', 'eightshift-forms'), $formTitle), 'adminSettingsBackLink' => UtilsGeneralHelper::getListingPageUrl(), 'adminSettingsFormEditLink' => $formEditLink, - 'adminSettingsFormLocationsLink' => UtilsGeneralHelper::getListingPageUrl('locations', $formId), + 'adminSettingsFormLocationsLink' => UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_LOCATIONS, $formId), 'adminSettingsSidebar' => $this->settings->getSettingsSidebar($formId, $integrationTypeUsed), 'adminSettingsForm' => $this->settings->getSettingsForm($type, $formId), 'adminSettingsType' => $type, @@ -249,22 +248,4 @@ public function fixPageTitle(string $adminTitle, string $title): string return $adminTitle; } - - /** - * Add additional links to sidebar menu. - * - * @return void - */ - public function addCustomLinkIntoAppearnaceMenu(): void - { - global $submenu; - - // phpcs:disable WordPress.WP.GlobalVariablesOverride.Prohibited - $submenu[FormAdminMenu::ADMIN_MENU_SLUG][] = [ - \esc_html__('Add new form', 'eightshift-forms'), - FormAdminMenu::ADMIN_MENU_CAPABILITY, - \get_admin_url(null, 'post-new.php?post_type=' . Forms::URL_SLUG) - ]; - // phpcs:enable - } } diff --git a/src/Blocks/Blocks.php b/src/Blocks/Blocks.php index 18f400306..1fe4112f2 100644 --- a/src/Blocks/Blocks.php +++ b/src/Blocks/Blocks.php @@ -68,6 +68,10 @@ public function getAllBlocksList($allowedBlockTypes, WP_Block_Editor_Context $bl $allowedBlockTypes[] = $value; } + foreach (Components::getSettings()['allowedBlocksResultOutputBlocksList'] as $value) { + $allowedBlockTypes[] = $value; + } + // Merge addon blocks to the list. $filterName = UtilsHooksHelper::getFilterName(['blocks', 'allowedBlocks']); if (\has_filter($filterName)) { diff --git a/src/Blocks/assets/scripts/blocks-editor.js b/src/Blocks/assets/scripts/blocks-editor.js index 182713165..350508e58 100644 --- a/src/Blocks/assets/scripts/blocks-editor.js +++ b/src/Blocks/assets/scripts/blocks-editor.js @@ -37,8 +37,17 @@ registerBlocks( outputCssVariablesGlobal(); // Remove form-selector block from anywhere else other than form CPT. -if (esFormsLocalization?.currentPostType !== esFormsLocalization?.postTypes?.forms) { +if ( + esFormsLocalization?.currentPostType !== esFormsLocalization?.postTypes?.forms || + esFormsLocalization?.currentPostType === esFormsLocalization?.postTypes?.result +) { const namespace = select(STORE_NAME).getSettingsNamespace(); unregisterBlockType(`${namespace}/form-selector`); } + +if (esFormsLocalization?.currentPostType === esFormsLocalization?.postTypes?.result) { + [...select(STORE_NAME).getSettings().allowedBlocksNoneBuilderBlocksList].forEach((block) => { + unregisterBlockType(block); + }); +} diff --git a/src/Blocks/components/form/assets/form.js b/src/Blocks/components/form/assets/form.js index ee14036a7..afba84a1a 100644 --- a/src/Blocks/components/form/assets/form.js +++ b/src/Blocks/components/form/assets/form.js @@ -296,14 +296,7 @@ export class Form { // On success state. if (response.status === 'success') { - switch (formType) { - case 'calculator': - this.formSubmitCalculatorSuccess(formId, response, filter?.[this.FILTER_IS_STEPS_FINAL_SUBMIT]); - break; - default: - this.formSubmitSuccess(formId, response, filter?.[this.FILTER_IS_STEPS_FINAL_SUBMIT]); - break; - } + this.formSubmitSuccess(formId, response, filter?.[this.FILTER_IS_STEPS_FINAL_SUBMIT]); } else { this.formSubmitError(formId, response, filter?.[this.FILTER_IS_STEPS_FINAL_SUBMIT]); } @@ -437,61 +430,12 @@ export class Form { if (isFinalStep) { this.steps.resetSteps(formId); } - } - } - } - - /** - * Actions to run after form submit on success - calculator. - * - * @param {string} formId Form Id. - * @param {object} response Api response. - * @param {bool} isFinalStep Check in steps if we are on final step. - * - * @returns {void} - */ - formSubmitCalculatorSuccess(formId, response, isFinalStep = false) { - const { - data, - } = response; - // Dispatch event. - this.utils.dispatchFormEvent(formId, this.state.getStateEvent('beforeCalculatorChange'), response); - - // Check if we have output element - block. - const outputElement = document.querySelector(`${this.state.getStateSelector('calculatorOutput', true)}[${this.state.getStateAttribute('formId')}="${formId}"]`); - - if (!outputElement) { - return; - } - - // Check if we have output full content change. - const output = data?.[this.state.getStateResponseOutputKey('calculatorOutput')] ?? ''; - - if (output && outputElement) { - outputElement.innerHTML = output; - } - - // Check if we have output items change. - const outputItems = data?.[this.state.getStateResponseOutputKey('calculatorOutputItems')] ?? {}; - - if (Object.keys(outputItems).length) { - for(const [key, value] of Object.entries(outputItems)) { - const itemElement = document.querySelector(`${this.state.getStateSelector('calculatorOutputItem', true)}[${this.state.getStateAttribute('calculatorItem')}="${key}"]`); - - if (itemElement && value) { - itemElement.innerHTML = value; - } + // Set output results. + this.utils.setResultsOutput(formId, data); } } - - if (isFinalStep) { - this.steps.resetSteps(formId); - } - - this.utils.dispatchFormEvent(formId, this.state.getStateEvent('afterCalculatorChange'), response); } - /** * Actions to run after form submit on error. diff --git a/src/Blocks/components/form/assets/state-init.js b/src/Blocks/components/form/assets/state-init.js index fa4361224..d129ebe9d 100644 --- a/src/Blocks/components/form/assets/state-init.js +++ b/src/Blocks/components/form/assets/state-init.js @@ -49,6 +49,7 @@ export const StateEnum = { ELEMENT: 'element', HEADING_SUCCESS: 'headingSuccess', HEADING_ERROR: 'headingError', + HIDE_ON_SUCCESS: 'hideOnSuccess', IS_SINGLE_SUBMIT: 'isSingleSubmit', SAVE_AS_JSON: 'saveAsJson', IS_ADMIN: 'isAdmin', @@ -332,6 +333,7 @@ export function setStateFormInitial(formId) { setState([StateEnum.FORM, StateEnum.CONFIG, StateEnum.CONFIG_SUCCESS_REDIRECT_DOWNLOADS], JSON.parse(formElement?.getAttribute(getStateAttribute('successRedirectDownloads')) ?? '{}'), formId); const globalMsg = formElement?.querySelector(getStateSelector('globalMsg', true)); + setState([StateEnum.FORM, StateEnum.GLOBAL_MSG, StateEnum.HIDE_ON_SUCCESS], Boolean(formElement?.getAttribute(getStateAttribute('globalMsgHideOnSuccess'))), formId); setState([StateEnum.FORM, StateEnum.GLOBAL_MSG, StateEnum.ELEMENT], globalMsg, formId); setState([StateEnum.FORM, StateEnum.GLOBAL_MSG, StateEnum.HEADING_SUCCESS], globalMsg?.getAttribute(getStateAttribute('globalMsgHeadingSuccess')), formId); setState([StateEnum.FORM, StateEnum.GLOBAL_MSG, StateEnum.HEADING_ERROR], globalMsg?.getAttribute(getStateAttribute('globalMsgHeadingError')), formId); diff --git a/src/Blocks/components/form/assets/state.js b/src/Blocks/components/form/assets/state.js index d2a57d92c..4b1a0f445 100644 --- a/src/Blocks/components/form/assets/state.js +++ b/src/Blocks/components/form/assets/state.js @@ -134,6 +134,9 @@ export class State { getStateFormGlobalMsgHeadingError = (formId) => { return getState([StateEnum.FORM, StateEnum.GLOBAL_MSG, StateEnum.HEADING_ERROR], formId); }; + getStateFormGlobalMsgHideOnSuccess = (formId) => { + return getState([StateEnum.FORM, StateEnum.GLOBAL_MSG, StateEnum.HIDE_ON_SUCCESS], formId); + }; //////////////////////////////////////////////////////////////// // Config getters. diff --git a/src/Blocks/components/form/assets/utils.js b/src/Blocks/components/form/assets/utils.js index 0e4c2d527..39f4f62e6 100644 --- a/src/Blocks/components/form/assets/utils.js +++ b/src/Blocks/components/form/assets/utils.js @@ -277,6 +277,10 @@ export class Utils { // Scroll to msg if the condition is right. if (status === 'success') { + if (this.state.getStateFormGlobalMsgHideOnSuccess(formId)) { + return; + } + if (!this.state.getStateSettingsDisableScrollToGlobalMsgOnSuccess(formId)) { this.scrollToGlobalMsg(formId); } @@ -1247,6 +1251,91 @@ export class Utils { this.conditionalTags.setField(formId, name); } + /** + * Set output results. + * + * @param {string} formId Form Id. + * @param {object} response Api response. + * + * @returns {void} + */ + setResultsOutput(formId, data) { + // Check if we have output element - block. + const outputElement = document.querySelector(`${this.state.getStateSelector('resultOutput', true)}[${this.state.getStateAttribute('formId')}="${formId}"]`); + + // If no output element, bailout. + if (!outputElement) { + return; + } + + this.resetResultsOutput(formId); + + // Check if we have output items. + const outputItems = data?.[this.state.getStateResponseOutputKey('resultOutputItems')] ?? {}; + + if (Object.keys(outputItems).length) { + for(const [key, value] of Object.entries(outputItems)) { + const itemElement = outputElement.querySelectorAll(`${this.state.getStateSelector('resultOutputItem', true)}[${this.state.getStateAttribute('resultOutputItemKey')}="${key}"][${this.state.getStateAttribute('resultOutputItemValue')}="${value}"]`); + + if (itemElement.length) { + itemElement.forEach((item) => { + item.classList.remove(this.state.getStateSelector('isHidden')); + }); + } + } + } + + // Check if we have output parts. + const outputParts = data?.[this.state.getStateResponseOutputKey('resultOutputParts')] ?? {}; + + if (Object.keys(outputParts).length) { + for(const [key, value] of Object.entries(outputParts)) { + const partElement = outputElement.querySelectorAll(`${this.state.getStateSelector('resultOutputPart', true)}[${this.state.getStateAttribute('resultOutputPart')}="${key}"]`); + + if (partElement.length && value) { + partElement.forEach((item) => { + item.classList.remove(this.state.getStateSelector('isHidden')); + item.innerHTML = value; + }); + } + } + } + + // Check if output block is hidden. + const outputElementIsHidden = outputElement.classList.contains(this.state.getStateSelector('isHidden')); + + // If hidden, show it. + if (outputElementIsHidden) { + outputElement.classList.remove(this.state.getStateSelector('isHidden')); + } + } + + resetResultsOutput(formId) { + // Check if we have output element - block. + const outputElement = document.querySelector(`${this.state.getStateSelector('resultOutput', true)}[${this.state.getStateAttribute('formId')}="${formId}"]`); + if (!outputElement) { + return; + } + + // Reset items. + const itemElements = outputElement.querySelectorAll(this.state.getStateSelector('resultOutputItem', true)); + if (itemElements.length) { + itemElements.forEach((item) => { + item.classList.add(this.state.getStateSelector('isHidden')); + }); + } + + // Reset parts. + const partElements = outputElement.querySelectorAll(this.state.getStateSelector('resultOutputPart', true)); + if (partElements.length) { + partElements.forEach((item) => { + if (item.hasAttribute(this.state.getStateAttribute('resultOutputPartDefault'))) { + item.innerHTML = item.getAttribute(this.state.getStateAttribute('resultOutputPartDefault')); + } + }); + } + } + //////////////////////////////////////////////////////////////// // Private methods - not shared to the public window object. //////////////////////////////////////////////////////////////// diff --git a/src/Blocks/components/form/form.php b/src/Blocks/components/form/form.php index 9c023be95..49d4322ff 100644 --- a/src/Blocks/components/form/form.php +++ b/src/Blocks/components/form/form.php @@ -52,6 +52,7 @@ $formDisabledDefaultStyles = Components::checkAttr('formDisabledDefaultStyles', $attributes, $manifest); $formHasSteps = Components::checkAttr('formHasSteps', $attributes, $manifest); $formCustomName = Components::checkAttr('formCustomName', $attributes, $manifest); +$formHideGlobalMsgOnSuccess = Components::checkAttr('formHideGlobalMsgOnSuccess', $attributes, $manifest); $formDataTypeSelectorFilterName = UtilsHooksHelper::getFilterName(['block', 'form', 'dataTypeSelector']); $formDataTypeSelector = apply_filters( @@ -110,6 +111,10 @@ $formAttrs[UtilsHelper::getStateAttribute('formType')] = esc_html($formType); } +if ($formHideGlobalMsgOnSuccess) { + $formAttrs[UtilsHelper::getStateAttribute('globalMsgHideOnSuccess')] = 'true'; +} + if ($formConditionalTags) { // Extract just the field name from the given data, if needed. $rawConditionalTagData = $formConditionalTags; diff --git a/src/Blocks/components/form/manifest.json b/src/Blocks/components/form/manifest.json index d87f2dc8b..d976e3b86 100644 --- a/src/Blocks/components/form/manifest.json +++ b/src/Blocks/components/form/manifest.json @@ -50,6 +50,10 @@ "formPostId": { "type": "string" }, + "formHideGlobalMsgOnSuccess": { + "type": "boolean", + "default": false + }, "formSuccessRedirect": { "type": "string" }, diff --git a/src/Blocks/custom/calculator-result/calculator-result.php b/src/Blocks/custom/calculator-result/calculator-result.php deleted file mode 100644 index 4f6d0836c..000000000 --- a/src/Blocks/custom/calculator-result/calculator-result.php +++ /dev/null @@ -1,39 +0,0 @@ - esc_attr($calculatorResultFormPostId), -]; - -$calculatorAttrsOutput = ''; -foreach ($calculatorAttrs as $key => $value) { - $calculatorAttrsOutput .= wp_kses_post(" {$key}='" . $value . "'"); -} - -$calculatorClass = Components::classnames([ - Components::selector($blockClass, $blockClass), - UtilsHelper::getStateSelector('calculatorOutput'), -]); - -?> - -
> - -
diff --git a/src/Blocks/custom/calculator-result/components/calculator-result-options.js b/src/Blocks/custom/calculator-result/components/calculator-result-options.js deleted file mode 100644 index 099328dd8..000000000 --- a/src/Blocks/custom/calculator-result/components/calculator-result-options.js +++ /dev/null @@ -1,64 +0,0 @@ -import React from 'react'; -import { select } from '@wordpress/data'; -import { __ } from '@wordpress/i18n'; -import { PanelBody } from '@wordpress/components'; -import { checkAttr, - getAttrKey, - AsyncSelect, - STORE_NAME, -} from '@eightshift/frontend-libs/scripts'; -import { outputFormSelectItemWithIcon } from '../../../components/utils'; - -export const CalculatorResultOptions = ({ - attributes, - setAttributes, - formSelectOptions, - calculatorSelectOptions, -}) => { - const manifest = select(STORE_NAME).getBlock('calculator-result'); - - const calculatorResultFormPostId = checkAttr('calculatorResultFormPostId', attributes, manifest); - const calculatorResultFormPostIdRaw = checkAttr('calculatorResultFormPostIdRaw', attributes, manifest); - const calculatorResultPostId = checkAttr('calculatorResultPostId', attributes, manifest); - const calculatorResultPostIdRaw = checkAttr('calculatorResultPostIdRaw', attributes, manifest); - - return ( - - { - setAttributes({ - [getAttrKey('calculatorResultPostIdRaw', attributes, manifest)]: { - id: value?.id, - label: value?.metadata?.label, - value: value?.metadata?.value, - metadata: value?.metadata?.metadata, - }, - [getAttrKey('calculatorResultPostId', attributes, manifest)]: `${value?.value.toString()}`, - }); - }} - /> - - { - setAttributes({ - [getAttrKey('calculatorResultFormPostIdRaw', attributes, manifest)]: { - id: value?.id, - label: value?.metadata?.label, - value: value?.metadata?.value, - metadata: value?.metadata?.metadata, - }, - [getAttrKey('calculatorResultFormPostId', attributes, manifest)]: `${value?.value.toString()}`, - }); - }} - /> - - ); -}; diff --git a/src/Blocks/custom/form-selector/form-selector-editor.scss b/src/Blocks/custom/form-selector/form-selector-editor.scss index 1d6716b15..4cb21f075 100644 --- a/src/Blocks/custom/form-selector/form-selector-editor.scss +++ b/src/Blocks/custom/form-selector/form-selector-editor.scss @@ -35,7 +35,8 @@ } } -.post-type-eightshift-forms { +.post-type-eightshift-forms, +.post-type-es-forms-res { h1 { span[data-rich-text-placeholder]::after { content: 'Form name'; @@ -54,3 +55,11 @@ background-position: center left; } } + +.post-type-es-forms-res { + h1 { + span[data-rich-text-placeholder]::after { + content: 'Result output name'; + } + } +} diff --git a/src/Blocks/custom/form-selector/manifest.json b/src/Blocks/custom/form-selector/manifest.json index 00f0a26d8..362a746bb 100644 --- a/src/Blocks/custom/form-selector/manifest.json +++ b/src/Blocks/custom/form-selector/manifest.json @@ -231,6 +231,9 @@ "inputInputName": "range", "inputInputIsNumber": true } + ], + [ + "eightshift-forms/submit" ] ] } diff --git a/src/Blocks/custom/result-output-item/components/result-output-item-editor.js b/src/Blocks/custom/result-output-item/components/result-output-item-editor.js new file mode 100644 index 000000000..d0fe11077 --- /dev/null +++ b/src/Blocks/custom/result-output-item/components/result-output-item-editor.js @@ -0,0 +1,31 @@ +import React from 'react'; +import { __ } from '@wordpress/i18n'; +import { InnerBlocks } from '@wordpress/block-editor'; +import { checkAttr, BlockInserter, selector } from '@eightshift/frontend-libs/scripts'; +import manifest from '../manifest.json'; + +export const ResultOutputItemEditor = ({ attributes, clientId }) => { + const { + blockClass, + } = attributes; + + const resultOutputItemName = checkAttr('resultOutputItemName', attributes, manifest); + const resultOutputItemValue = checkAttr('resultOutputItemValue', attributes, manifest); + + return ( +
+
+
+ {__('Show if the following condition match:', 'eightshift-forms')} +
+
+ {resultOutputItemName} = {resultOutputItemValue} +
+
+ + } + /> +
+ ); +}; diff --git a/src/Blocks/custom/result-output-item/components/result-output-item-options.js b/src/Blocks/custom/result-output-item/components/result-output-item-options.js new file mode 100644 index 000000000..81aced4a9 --- /dev/null +++ b/src/Blocks/custom/result-output-item/components/result-output-item-options.js @@ -0,0 +1,29 @@ +import React from 'react'; +import { __ } from '@wordpress/i18n'; +import { PanelBody, TextControl } from '@wordpress/components'; +import { checkAttr, getAttrKey, icons, IconLabel } from '@eightshift/frontend-libs/scripts'; +import manifest from '../manifest.json'; + +export const ResultOutputItemOptions = ({ + attributes, + setAttributes, +}) => { + + const resultOutputItemName = checkAttr('resultOutputItemName', attributes, manifest); + const resultOutputItemValue = checkAttr('resultOutputItemValue', attributes, manifest); + + return ( + + } + value={resultOutputItemName} + onChange={(value) => setAttributes({ [getAttrKey('resultOutputItemName', attributes, manifest)]: value })} + /> + } + value={resultOutputItemValue} + onChange={(value) => setAttributes({ [getAttrKey('resultOutputItemValue', attributes, manifest)]: value })} + /> + + ); +}; diff --git a/src/Blocks/custom/result-output-item/manifest.json b/src/Blocks/custom/result-output-item/manifest.json new file mode 100644 index 000000000..70c5c6a5a --- /dev/null +++ b/src/Blocks/custom/result-output-item/manifest.json @@ -0,0 +1,24 @@ +{ + "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", + "blockName": "result-output-item", + "title": "Result output item", + "description" : "Result output item block.", + "category": "eightshift-forms", + "icon": { + "src": "esf-checkbox" + }, + "keywords": [ + "result", + "output", + "item" + ], + "hasInnerBlocks": true, + "attributes": { + "resultOutputItemName": { + "type": "string" + }, + "resultOutputItemValue": { + "type": "string" + } + } +} diff --git a/src/Blocks/custom/result-output-item/result-output-item-block.js b/src/Blocks/custom/result-output-item/result-output-item-block.js new file mode 100644 index 000000000..0957974ae --- /dev/null +++ b/src/Blocks/custom/result-output-item/result-output-item-block.js @@ -0,0 +1,15 @@ +import React from 'react'; +import { InspectorControls } from '@wordpress/block-editor'; +import { ResultOutputItemEditor } from './components/result-output-item-editor'; +import { ResultOutputItemOptions } from './components/result-output-item-options'; + +export const ResultOutputItem = (props) => { + return ( + <> + + + + + + ); +}; diff --git a/src/Blocks/custom/result-output-item/result-output-item-editor.scss b/src/Blocks/custom/result-output-item/result-output-item-editor.scss new file mode 100644 index 000000000..b0409f0db --- /dev/null +++ b/src/Blocks/custom/result-output-item/result-output-item-editor.scss @@ -0,0 +1,24 @@ +.es-block-result-output-item { + &__intro { + text-align: center; + transform: translateY(50%); + + &::before { + content: ''; + width: 100%; + height: 1px; + display: block; + background-color: var(--global-colors-esf-gray-300); + } + + &-inner { + border: 1px solid var(--global-colors-esf-gray-300); + padding: 0.3125rem 1.25rem; + display: inline-block; + border-radius: var(--es-input-radius); + font-weight: 500; + transform: translateY(-50%); + background-color: var(--global-colors-esf-white); + } + } +} diff --git a/src/Blocks/custom/result-output-item/result-output-item.php b/src/Blocks/custom/result-output-item/result-output-item.php new file mode 100644 index 000000000..a4c2f8c0d --- /dev/null +++ b/src/Blocks/custom/result-output-item/result-output-item.php @@ -0,0 +1,43 @@ + esc_attr($resultOutputItemName), + UtilsHelper::getStateAttribute('resultOutputItemValue') => esc_attr($resultOutputItemValue), +]; + +$resultAttrsOutput = ''; +foreach ($resultAttrs as $key => $value) { + $resultAttrsOutput .= wp_kses_post(" {$key}='" . $value . "'"); +} + +$resultClass = Components::classnames([ + Components::selector($blockClass, $blockClass), + UtilsHelper::getStateSelector('isHidden'), + UtilsHelper::getStateSelector('resultOutputItem'), +]); + +?> + +
> + +
diff --git a/src/Blocks/custom/calculator-result/components/calculator-result-editor.js b/src/Blocks/custom/result-output/components/result-output-editor.js similarity index 51% rename from src/Blocks/custom/calculator-result/components/calculator-result-editor.js rename to src/Blocks/custom/result-output/components/result-output-editor.js index b7b7ed735..b1c457f01 100644 --- a/src/Blocks/custom/calculator-result/components/calculator-result-editor.js +++ b/src/Blocks/custom/result-output/components/result-output-editor.js @@ -11,13 +11,13 @@ import { __ } from '@wordpress/i18n'; import { Placeholder } from '@wordpress/components'; import { getFilteredAttributes, outputFormSelectItemWithIcon } from '../../../components/utils'; -export const CalculatorResultEditor = ({ +export const ResultOutputEditor = ({ attributes, setAttributes, formSelectOptions, - calculatorSelectOptions, + resultSelectOptions, }) => { - const manifest = select(STORE_NAME).getBlock('calculator-result'); + const manifest = select(STORE_NAME).getBlock('result-output'); const { blockFullName @@ -27,51 +27,51 @@ export const CalculatorResultEditor = ({ attributesSsr, } = manifest; - const calculatorResultFormPostId = checkAttr('calculatorResultFormPostId', attributes, manifest); - const calculatorResultFormPostIdRaw = checkAttr('calculatorResultFormPostIdRaw', attributes, manifest); - const calculatorResultPostIdRaw = checkAttr('calculatorResultPostIdRaw', attributes, manifest); - const calculatorResultPostId = checkAttr('calculatorResultPostId', attributes, manifest); + const resultOutputFormPostId = checkAttr('resultOutputFormPostId', attributes, manifest); + const resultOutputFormPostIdRaw = checkAttr('resultOutputFormPostIdRaw', attributes, manifest); + const resultOutputPostIdRaw = checkAttr('resultOutputPostIdRaw', attributes, manifest); + const resultOutputPostId = checkAttr('resultOutputPostId', attributes, manifest); - if (calculatorResultPostId?.length < 1) { + if (resultOutputPostId?.length < 1 || resultOutputFormPostId?.length < 1) { return ( {__('Eightshift Forms - Calculator result', 'productive')}} + label={{__('Eightshift Forms - Result output', 'productive')}} className='es-max-w-80 es-rounded-3! es-mx-auto! es-font-weight-400 es-color-cool-gray-500! es-nested-color-current!' > { setAttributes({ - [getAttrKey('calculatorResultPostIdRaw', attributes, manifest)]: { + [getAttrKey('resultOutputPostIdRaw', attributes, manifest)]: { id: value?.id, label: value?.metadata?.label, value: value?.metadata?.value, metadata: value?.metadata?.metadata, }, - [getAttrKey('calculatorResultPostId', attributes, manifest)]: `${value?.value}`, + [getAttrKey('resultOutputPostId', attributes, manifest)]: `${value?.value}`, }); }} noBottomSpacing /> { setAttributes({ - [getAttrKey('calculatorResultFormPostIdRaw', attributes, manifest)]: { + [getAttrKey('resultOutputFormPostIdRaw', attributes, manifest)]: { id: value?.id, label: value?.metadata?.label, value: value?.metadata?.value, metadata: value?.metadata?.metadata, }, - [getAttrKey('calculatorResultFormPostId', attributes, manifest)]: `${value?.value}`, + [getAttrKey('resultOutputFormPostId', attributes, manifest)]: `${value?.value}`, }); }} noBottomSpacing @@ -89,7 +89,7 @@ export const CalculatorResultEditor = ({ attributes, attributesSsr, { - calculatorResultServerSideRender: true + resultOutputServerSideRender: true } ) } diff --git a/src/Blocks/custom/result-output/components/result-output-options.js b/src/Blocks/custom/result-output/components/result-output-options.js new file mode 100644 index 000000000..5001a6d79 --- /dev/null +++ b/src/Blocks/custom/result-output/components/result-output-options.js @@ -0,0 +1,75 @@ +import React from 'react'; +import { select } from '@wordpress/data'; +import { __ } from '@wordpress/i18n'; +import { PanelBody } from '@wordpress/components'; +import { checkAttr, + getAttrKey, + AsyncSelect, + STORE_NAME, + IconToggle, + icons, +} from '@eightshift/frontend-libs/scripts'; +import { outputFormSelectItemWithIcon } from '../../../components/utils'; + +export const ResultOutputOptions = ({ + attributes, + setAttributes, + formSelectOptions, + resultSelectOptions, +}) => { + const manifest = select(STORE_NAME).getBlock('result-output'); + + const resultOutputFormPostId = checkAttr('resultOutputFormPostId', attributes, manifest); + const resultOutputFormPostIdRaw = checkAttr('resultOutputFormPostIdRaw', attributes, manifest); + const resultOutputPostId = checkAttr('resultOutputPostId', attributes, manifest); + const resultOutputPostIdRaw = checkAttr('resultOutputPostIdRaw', attributes, manifest); + const resultOutputHide = checkAttr('resultOutputHide', attributes, manifest); + + return ( + + { + setAttributes({ + [getAttrKey('resultOutputPostIdRaw', attributes, manifest)]: { + id: value?.id, + label: value?.metadata?.label, + value: value?.metadata?.value, + metadata: value?.metadata?.metadata, + }, + [getAttrKey('resultOutputPostId', attributes, manifest)]: `${value?.value.toString()}`, + }); + }} + /> + + { + setAttributes({ + [getAttrKey('resultOutputFormPostIdRaw', attributes, manifest)]: { + id: value?.id, + label: value?.metadata?.label, + value: value?.metadata?.value, + metadata: value?.metadata?.metadata, + }, + [getAttrKey('resultOutputFormPostId', attributes, manifest)]: `${value?.value.toString()}`, + }); + }} + /> + + setAttributes({ [getAttrKey('resultOutputHide', attributes, manifest)]: value })} + /> + + ); +}; diff --git a/src/Blocks/custom/calculator-result/manifest.json b/src/Blocks/custom/result-output/manifest.json similarity index 51% rename from src/Blocks/custom/calculator-result/manifest.json rename to src/Blocks/custom/result-output/manifest.json index 3257f3c1c..934a7fd3c 100644 --- a/src/Blocks/custom/calculator-result/manifest.json +++ b/src/Blocks/custom/result-output/manifest.json @@ -1,43 +1,48 @@ { "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", - "blockName": "calculator-result", - "title": "Calculator result", - "description" : "Calculator result block.", + "blockName": "result-output", + "title": "Result output", + "description" : "Result output block.", "category": "eightshift-forms", "icon": { "src": "esf-checkbox" }, "keywords": [ - "calculator", + "result", + "output", "results" ], "hasInnerBlocks": true, "attributes": { - "calculatorResultName": { + "resultOutputName": { "type": "string" }, - "calculatorResultValue": { + "resultOutputValue": { "type": "string" }, - "calculatorResultPostId": { + "resultOutputPostId": { "type": "string" }, - "calculatorResultPostIdRaw": { + "resultOutputPostIdRaw": { "type": "object" }, - "calculatorResultFormPostId": { + "resultOutputFormPostId": { "type": "string" }, - "calculatorResultFormPostIdRaw": { + "resultOutputFormPostIdRaw": { "type": "object" }, - "calculatorResultServerSideRender": { + "resultOutputServerSideRender": { + "type": "boolean", + "default": false + }, + "resultOutputHide": { "type": "boolean", "default": false } }, "attributesSsr": [ - "calculatorResultPostId", - "calculatorResultFormPostId" + "resultOutputPostId", + "resultOutputFormPostId" ] } diff --git a/src/Blocks/custom/calculator-result/calculator-result-block.js b/src/Blocks/custom/result-output/result-output-block.js similarity index 61% rename from src/Blocks/custom/calculator-result/calculator-result-block.js rename to src/Blocks/custom/result-output/result-output-block.js index 53c074fd0..a9421a988 100644 --- a/src/Blocks/custom/calculator-result/calculator-result-block.js +++ b/src/Blocks/custom/result-output/result-output-block.js @@ -2,12 +2,12 @@ import React from 'react'; import { InspectorControls } from '@wordpress/block-editor'; -import { CalculatorResultEditor } from './components/calculator-result-editor'; -import { CalculatorResultOptions } from './components/calculator-result-options'; +import { ResultOutputEditor } from './components/result-output-editor'; +import { ResultOutputOptions } from './components/result-output-options'; import { getFetchWpApi } from '@eightshift/frontend-libs/scripts'; import { outputFormSelectItemWithIcon } from '../../components/utils'; -const formSelectOptions = function(postType) { +const dynamicItemSelectOptions = function(postType) { return getFetchWpApi( postType, { @@ -30,25 +30,25 @@ const formSelectOptions = function(postType) { ); }; -export const CalculatorResult = (props) => { +export const ResultOutput = (props) => { const { forms, - calculator, + results, } = esFormsLocalization?.postTypes; return ( <> - - ); diff --git a/src/Blocks/custom/calculator-result/calculator-result-editor.scss b/src/Blocks/custom/result-output/result-output-editor.scss similarity index 94% rename from src/Blocks/custom/calculator-result/calculator-result-editor.scss rename to src/Blocks/custom/result-output/result-output-editor.scss index 09e4d1b50..d7a6b2926 100644 --- a/src/Blocks/custom/calculator-result/calculator-result-editor.scss +++ b/src/Blocks/custom/result-output/result-output-editor.scss @@ -1,4 +1,4 @@ -.es-block-calculator-result { +.es-block-result-output { &__intro { text-align: center; transform: translateY(50%); diff --git a/src/Blocks/custom/result-output/result-output.php b/src/Blocks/custom/result-output/result-output.php new file mode 100644 index 000000000..af3b36bc2 --- /dev/null +++ b/src/Blocks/custom/result-output/result-output.php @@ -0,0 +1,41 @@ + esc_attr($resultOutputFormPostId), +]; + +$resultAttrsOutput = ''; +foreach ($resultAttrs as $key => $value) { + $resultAttrsOutput .= wp_kses_post(" {$key}='" . $value . "'"); +} + +$resultClass = Components::classnames([ + Components::selector($blockClass, $blockClass), + Components::selector($resultOutputHide, UtilsHelper::getStateSelector('isHidden')), + UtilsHelper::getStateSelector('resultOutput'), +]); + +?> + +
> + +
diff --git a/src/Blocks/manifest.json b/src/Blocks/manifest.json index 459ab3a7f..5e885605c 100644 --- a/src/Blocks/manifest.json +++ b/src/Blocks/manifest.json @@ -18,7 +18,10 @@ }, "allowedBlocksNoneBuilderBlocksList": [ "eightshift-forms/forms", - "eightshift-forms/calculator-result" + "eightshift-forms/result-output" + ], + "allowedBlocksResultOutputBlocksList": [ + "eightshift-forms/result-output-item" ], "allowedBlocksBuilderIntegrationAdditionalBlocksList": [ "eightshift-forms/step" @@ -424,9 +427,7 @@ "afterCaptchaInit": "esFormsAfterCaptchaInit", "stepsGoToNextStep": "esFormsGoToNextStep", "stepsGoToPrevStep": "esFormsGoToPrevStep", - "enrichmentPrefill": "esFormsEnrichmentPrefill", - "beforeCalculatorChange": "esFormsBeforeCalculatorChange", - "afterCalculatorChange": "esFormsAfterCalculatorChange" + "enrichmentPrefill": "esFormsEnrichmentPrefill" }, "typeInternal": { "input": "input", diff --git a/src/CustomPostType/Calculator.php b/src/CustomPostType/Result.php similarity index 75% rename from src/CustomPostType/Calculator.php rename to src/CustomPostType/Result.php index 0094c52d0..94b6391e5 100644 --- a/src/CustomPostType/Calculator.php +++ b/src/CustomPostType/Result.php @@ -1,7 +1,7 @@ \esc_html__('Calculator', 'eightshift-forms'), + 'label' => \esc_html__('Result outputs', 'eightshift-forms'), 'public' => true, 'menu_position' => static::MENU_POSITION, 'menu_icon' => static::MENU_ICON, diff --git a/src/Editor/Editor.php b/src/Editor/Editor.php index d373b11c0..0ac4bba7e 100644 --- a/src/Editor/Editor.php +++ b/src/Editor/Editor.php @@ -10,8 +10,9 @@ namespace EightshiftForms\Editor; -use EightshiftForms\CustomPostType\Calculator; +use EightshiftForms\CustomPostType\Result; use EightshiftForms\CustomPostType\Forms; +use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface; @@ -41,13 +42,13 @@ public function getEditorBackLink(): void $types = [ Forms::POST_TYPE_SLUG, - Calculator::POST_TYPE_SLUG, + Result::POST_TYPE_SLUG, ]; foreach ($types as $type) { $links = $this->getListOfLinks($type); - $typeKey = $type === Forms::POST_TYPE_SLUG ? '' : 'calculator'; + $typeKey = $type === Forms::POST_TYPE_SLUG ? '' : UtilsConfig::SLUG_ADMIN_LISTING_RESULTS; if (\in_array($actualUrl, $links, true)) { echo ''; // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped diff --git a/src/Enqueue/Blocks/EnqueueBlocks.php b/src/Enqueue/Blocks/EnqueueBlocks.php index e50ffa870..b73faae57 100644 --- a/src/Enqueue/Blocks/EnqueueBlocks.php +++ b/src/Enqueue/Blocks/EnqueueBlocks.php @@ -16,7 +16,7 @@ use EightshiftForms\Enrichment\SettingsEnrichment; use EightshiftForms\Settings\Settings\SettingsSettings; use EightshiftForms\Captcha\SettingsCaptcha; -use EightshiftForms\CustomPostType\Calculator; +use EightshiftForms\CustomPostType\Result; use EightshiftForms\CustomPostType\Forms; use EightshiftForms\Enqueue\SharedEnqueue; use EightshiftForms\Enqueue\Theme\EnqueueTheme; @@ -169,7 +169,7 @@ public function enqueueBlockEditorScript(string $hook): void $output['formsSelectorTemplates'] = \apply_filters($formSelectorTemplatesFilterName, []); $output['currentPostType'] = \get_post_type() ? \get_post_type() : ''; $output['postTypes'] = [ - 'calculator' => Calculator::POST_TYPE_SLUG, + 'results' => Result::POST_TYPE_SLUG, 'forms' => Forms::POST_TYPE_SLUG, ]; diff --git a/src/Entries/SettingsEntries.php b/src/Entries/SettingsEntries.php index a34820ae3..fc9d6c4c0 100644 --- a/src/Entries/SettingsEntries.php +++ b/src/Entries/SettingsEntries.php @@ -10,6 +10,7 @@ namespace EightshiftForms\Entries; +use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingInterface; @@ -161,7 +162,7 @@ public function getSettingsData(string $formId): array 'component' => 'checkbox', 'checkboxLabel' => \__('Store entries in database', 'eightshift-forms'), // translators: %s is replaced with the form entries page URL. - 'checkboxHelp' => $isUsed ? \sprintf(\__("You can find all form entries here.", 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl('entries', $formId)) : '', + 'checkboxHelp' => $isUsed ? \sprintf(\__("You can find all form entries here.", 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES, $formId)) : '', 'checkboxIsChecked' => $isUsed, 'checkboxValue' => self::SETTINGS_ENTRIES_SETTINGS_USE_KEY, 'checkboxSingleSubmit' => true, diff --git a/src/Form/Form.php b/src/Form/Form.php index f5b624323..a3da58edc 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -102,6 +102,9 @@ public function updateFormComponentAttributesOutput(array $attributes): array $attributes["{$prefix}CustomName"] = $customFormName; } + // Custom form name. + $attributes["{$prefix}HideGlobalMsgOnSuccess"] = !!UtilsSettingsHelper::isSettingCheckboxChecked(SettingsGeneral::SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY, SettingsGeneral::SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY, $formId); + // Phone sync with country block. $attributes["{$prefix}PhoneSync"] = ''; $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'phoneSync']); diff --git a/src/General/SettingsGeneral.php b/src/General/SettingsGeneral.php index d26a52b63..f78fcf762 100644 --- a/src/General/SettingsGeneral.php +++ b/src/General/SettingsGeneral.php @@ -69,6 +69,11 @@ class SettingsGeneral implements UtilsSettingGlobalInterface, UtilsSettingInterf */ public const SETTINGS_GENERAL_FORM_CUSTOM_NAME_KEY = 'form-custom-name'; + /** + * Hide global message on success key. + */ + public const SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY = 'hide-global-msg-on-success'; + /** * Register all the hooks * @@ -167,6 +172,25 @@ function ($selectOption) use ($successRedirectVariation) { ) ), ], + [ + 'component' => 'divider', + 'dividerExtraVSpacing' => true, + ], + [ + 'component' => 'checkboxes', + 'checkboxesFieldLabel' => '', + 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY), + 'checkboxesContent' => [ + [ + 'component' => 'checkbox', + 'checkboxLabel' => \__('Hide global message on success', 'eightshift-forms'), + 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY, self::SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY, $formId), + 'checkboxValue' => self::SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY, + 'checkboxSingleSubmit' => true, + 'checkboxAsToggle' => true, + ] + ] + ], ], ], [ diff --git a/src/Hooks/Filters.php b/src/Hooks/Filters.php index 182c75047..b3fb37290 100644 --- a/src/Hooks/Filters.php +++ b/src/Hooks/Filters.php @@ -236,8 +236,8 @@ private static function getPublicFilters(): array ], SettingsCalculator::SETTINGS_TYPE_KEY => [ 'prePostParams', - 'output', - 'outputItems', + 'resultOutputItems', + 'resultOutputParts', ], ], 'entries' => [ diff --git a/src/Integrations/Calculator/SettingsCalculator.php b/src/Integrations/Calculator/SettingsCalculator.php index e32fe2a88..92eb2fd08 100644 --- a/src/Integrations/Calculator/SettingsCalculator.php +++ b/src/Integrations/Calculator/SettingsCalculator.php @@ -111,8 +111,6 @@ public function getSettingsData(string $formId): array [ 'component' => 'checkbox', 'checkboxLabel' => \__('Use single submit', 'eightshift-forms'), - // translators: %s is replaced with the form entries page URL. - 'checkboxHelp' => \sprintf(\__("You can find all calculator outputs here.", 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl('calculator')), 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, $formId), 'checkboxValue' => self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, 'checkboxSingleSubmit' => true, diff --git a/src/Listing/FormListingInterface.php b/src/Listing/FormListingInterface.php index e8433ca6e..132ca3ec7 100644 --- a/src/Listing/FormListingInterface.php +++ b/src/Listing/FormListingInterface.php @@ -10,8 +10,6 @@ namespace EightshiftForms\Listing; -use EightshiftForms\CustomPostType\Forms; - /** * Interface for admin content listing */ @@ -20,10 +18,10 @@ interface FormListingInterface /** * Get Forms List. * - * @param bool $showTrash Show trashed items. - * @param string $postType Post type for listing to output. + * @param string $type Type of listing to output. + * @param string $parent Parent type for listing to output. * * @return array> */ - public function getFormsList(bool $showTrash = false, string $postType = Forms::POST_TYPE_SLUG): array; + public function getFormsList(string $type = '', string $parent = ''): array; } diff --git a/src/Listing/FormsListing.php b/src/Listing/FormsListing.php index 9e66e818e..7ab616212 100644 --- a/src/Listing/FormsListing.php +++ b/src/Listing/FormsListing.php @@ -11,7 +11,9 @@ namespace EightshiftForms\Listing; use EightshiftForms\CustomPostType\Forms; +use EightshiftForms\CustomPostType\Result; use EightshiftForms\General\SettingsGeneral; +use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsIntegrationsHelper; use WP_Query; @@ -24,13 +26,33 @@ class FormsListing implements FormListingInterface /** * Get Forms List. * - * @param bool $showTrash Show trashed items. - * @param string $postType Post type for listing to output. + * @param string $type Type of listing to output. + * @param string $parent Parent type for listing to output. * * @return array> */ - public function getFormsList(bool $showTrash = false, string $postType = Forms::POST_TYPE_SLUG): array + public function getFormsList(string $type = '', string $parent = ''): array { + $postType = Forms::POST_TYPE_SLUG; + $showTrash = false; + + switch ($type) { + case UtilsConfig::SLUG_ADMIN_LISTING_TRASH: + $postType = Forms::POST_TYPE_SLUG; + + if ($parent === UtilsConfig::SLUG_ADMIN_LISTING_RESULTS) { + $postType = Result::POST_TYPE_SLUG; + } + $showTrash = true; + break; + case UtilsConfig::SLUG_ADMIN_LISTING_RESULTS: + $postType = Result::POST_TYPE_SLUG; + break; + default: + $postType = Forms::POST_TYPE_SLUG; + break; + } + // Prepare query args. $args = [ 'post_type' => $postType, @@ -58,7 +80,7 @@ public function getFormsList(bool $showTrash = false, string $postType = Forms:: 'settingsLink' => UtilsGeneralHelper::getSettingsPageUrl((string) $id, SettingsGeneral::SETTINGS_TYPE_KEY), 'editLink' => !$showTrash ? UtilsGeneralHelper::getFormEditPageUrl((string) $id) : '', 'trashLink' => UtilsGeneralHelper::getFormTrashActionUrl((string) $id, $showTrash), - 'entriesLink' => UtilsGeneralHelper::getListingPageUrl('entries', (string) $id), + 'entriesLink' => UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_ENTRIES, (string) $id), 'trashRestoreLink' => UtilsGeneralHelper::getFormTrashRestoreActionUrl((string) $id), 'activeIntegration' => UtilsIntegrationsHelper::getIntegrationDetailsById((string) $id), 'useSync' => true, diff --git a/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php b/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php index 0bb14bd6e..b9335f8f4 100644 --- a/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php +++ b/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php @@ -92,14 +92,14 @@ protected function submitAction(array $formDetails) $additionalOutput = []; - $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'output']); + $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'resultOutputItems']); if (\has_filter($filterName)) { - $additionalOutput[UtilsHelper::getStateResponseOutputKey('calculatorOutput')] = \apply_filters($filterName, '', $formDetails, $formId) ?? ''; + $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputItems')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; } - $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'outputItems']); + $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'resultOutputParts']); if (\has_filter($filterName)) { - $additionalOutput[UtilsHelper::getStateResponseOutputKey('calculatorOutputItems')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; + $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputParts')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; } return \rest_ensure_response( diff --git a/src/Shortcode/CalculatorItem.php b/src/Shortcode/ResultOutputItemPart.php similarity index 60% rename from src/Shortcode/CalculatorItem.php rename to src/Shortcode/ResultOutputItemPart.php index e575b70e7..084ad9298 100644 --- a/src/Shortcode/CalculatorItem.php +++ b/src/Shortcode/ResultOutputItemPart.php @@ -1,7 +1,7 @@ {$content}"; + return "{$content}"; } } diff --git a/src/Transfer/SettingsTransfer.php b/src/Transfer/SettingsTransfer.php index 3b380a7a8..9e00ebbee 100644 --- a/src/Transfer/SettingsTransfer.php +++ b/src/Transfer/SettingsTransfer.php @@ -11,6 +11,7 @@ namespace EightshiftForms\Transfer; use EightshiftForms\CustomPostType\Forms; +use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsDeveloperHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingGlobalInterface; From 47743b2f56e302e5ec977fe318a42730f1545a55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Thu, 7 Mar 2024 14:20:23 +0100 Subject: [PATCH 13/35] update --- composer.lock | 8 ++--- src/Blocks/components/form/assets/form.js | 30 ++++++++++++++++--- .../components/form/assets/state-init.js | 2 ++ src/Blocks/components/form/assets/state.js | 3 ++ src/Blocks/components/form/form.php | 5 ++++ src/Blocks/components/form/manifest.json | 4 +++ src/Blocks/components/input/input.php | 2 +- src/Blocks/components/textarea/manifest.json | 4 --- src/Blocks/components/textarea/textarea.php | 2 -- src/Form/Form.php | 4 +++ src/General/SettingsGeneral.php | 20 +++++++++++++ .../Calculator/SettingsCalculator.php | 21 ------------- 12 files changed, 69 insertions(+), 36 deletions(-) diff --git a/composer.lock b/composer.lock index ccb54b67b..b67094de1 100644 --- a/composer.lock +++ b/composer.lock @@ -62,12 +62,12 @@ "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "ed0b9f553083ccbd3d5bcfb5ae377d40583225cc" + "reference": "e5dc0a10a0912f721885bace94c8ecaa8297f9e2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/ed0b9f553083ccbd3d5bcfb5ae377d40583225cc", - "reference": "ed0b9f553083ccbd3d5bcfb5ae377d40583225cc", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/e5dc0a10a0912f721885bace94c8ecaa8297f9e2", + "reference": "e5dc0a10a0912f721885bace94c8ecaa8297f9e2", "shasum": "" }, "require": { @@ -119,7 +119,7 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-03-07T12:23:48+00:00" + "time": "2024-03-07T12:39:21+00:00" }, { "name": "infinum/eightshift-libs", diff --git a/src/Blocks/components/form/assets/form.js b/src/Blocks/components/form/assets/form.js index afba84a1a..f3ac9e3b7 100644 --- a/src/Blocks/components/form/assets/form.js +++ b/src/Blocks/components/form/assets/form.js @@ -1003,7 +1003,16 @@ export class Form { input.addEventListener('keydown', this.onFocusEvent); input.addEventListener('focus', this.onFocusEvent); input.addEventListener('blur', this.onBlurEvent); - input.addEventListener('input', this.onInputEvent); + + if ( + (this.state.getStateConfigIsAdmin() && this.state.getStateElementIsSingleSubmit(name, formId)) || + (this.state.getStateFormConfigUseSingleSubmit(formId) && (this.state.getStateElementTypeCustom(name, formId) === 'range')) + ) { + input.addEventListener('input', debounce(this.onInputEvent, 500)); + } else { + input.addEventListener('input', this.onInputEvent); + + } } /** @@ -1621,7 +1630,10 @@ export class Form { this.utils.unsetFilledState(formId, name); } - if (this.state.getStateConfigIsAdmin() && this.state.getStateElementIsSingleSubmit(name, formId)) { + if ( + (this.state.getStateConfigIsAdmin() && this.state.getStateElementIsSingleSubmit(name, formId)) || + this.state.getStateFormConfigUseSingleSubmit(formId) + ) { debounce( this.formSubmit( formId, { @@ -1645,7 +1657,14 @@ export class Form { this.utils.setOnUserChangeInput(event.target); - if (this.state.getStateConfigIsAdmin() && this.state.getStateElementIsSingleSubmit(name, formId)) { + if ( + (this.state.getStateConfigIsAdmin() && this.state.getStateElementIsSingleSubmit(name, formId)) || + (this.state.getStateFormConfigUseSingleSubmit(formId) && ( + this.state.getStateElementTypeCustom(name, formId) === 'range') || + this.state.getStateElementTypeCustom(name, formId) === 'checkbox' || + this.state.getStateElementTypeCustom(name, formId) === 'radio' + ) + ) { debounce( this.formSubmit( formId, { @@ -1673,7 +1692,10 @@ export class Form { this.utils.setOnUserChangeInput(input); - if (this.state.getStateConfigIsAdmin() && this.state.getStateElementIsSingleSubmit(name, formId)) { + if ( + (this.state.getStateConfigIsAdmin() && this.state.getStateElementIsSingleSubmit(name, formId)) || + this.state.getStateFormConfigUseSingleSubmit(formId) + ) { debounce( this.formSubmit( formId, { diff --git a/src/Blocks/components/form/assets/state-init.js b/src/Blocks/components/form/assets/state-init.js index d129ebe9d..2e1f7aaea 100644 --- a/src/Blocks/components/form/assets/state-init.js +++ b/src/Blocks/components/form/assets/state-init.js @@ -80,6 +80,7 @@ export const StateEnum = { CONFIG_SUCCESS_REDIRECT: 'successRedirect', CONFIG_SUCCESS_REDIRECT_VARIATION: 'successRedirectVariation', CONFIG_SUCCESS_REDIRECT_DOWNLOADS: 'successRedirectDownloads', + CONFIG_USE_SINGLE_SUBMIT: 'useSingleSubmit', SETTINGS: 'settings', SETTINGS_DISABLE_SCROLL_TO_GLOBAL_MSG_ON_SUCCESS: 'disableScrollToGlobalMsgOnSuccess', @@ -331,6 +332,7 @@ export function setStateFormInitial(formId) { setState([StateEnum.FORM, StateEnum.CONFIG, StateEnum.CONFIG_SUCCESS_REDIRECT], formElement?.getAttribute(getStateAttribute('successRedirect')), formId); setState([StateEnum.FORM, StateEnum.CONFIG, StateEnum.CONFIG_SUCCESS_REDIRECT_VARIATION], formElement?.getAttribute(getStateAttribute('successRedirectVariation')), formId); setState([StateEnum.FORM, StateEnum.CONFIG, StateEnum.CONFIG_SUCCESS_REDIRECT_DOWNLOADS], JSON.parse(formElement?.getAttribute(getStateAttribute('successRedirectDownloads')) ?? '{}'), formId); + setState([StateEnum.FORM, StateEnum.CONFIG, StateEnum.CONFIG_USE_SINGLE_SUBMIT], Boolean(formElement?.getAttribute(getStateAttribute('singleSubmit'))), formId); const globalMsg = formElement?.querySelector(getStateSelector('globalMsg', true)); setState([StateEnum.FORM, StateEnum.GLOBAL_MSG, StateEnum.HIDE_ON_SUCCESS], Boolean(formElement?.getAttribute(getStateAttribute('globalMsgHideOnSuccess'))), formId); diff --git a/src/Blocks/components/form/assets/state.js b/src/Blocks/components/form/assets/state.js index 4b1a0f445..87de8789e 100644 --- a/src/Blocks/components/form/assets/state.js +++ b/src/Blocks/components/form/assets/state.js @@ -157,6 +157,9 @@ export class State { getStateFormConfigSuccessRedirectDownloads = (formId) => { return getState([StateEnum.FORM, StateEnum.CONFIG, StateEnum.CONFIG_SUCCESS_REDIRECT_DOWNLOADS], formId); }; + getStateFormConfigUseSingleSubmit = (formId) => { + return getState([StateEnum.FORM, StateEnum.CONFIG, StateEnum.CONFIG_USE_SINGLE_SUBMIT], formId); + }; //////////////////////////////////////////////////////////////// // Steps getters. diff --git a/src/Blocks/components/form/form.php b/src/Blocks/components/form/form.php index 49d4322ff..7af510098 100644 --- a/src/Blocks/components/form/form.php +++ b/src/Blocks/components/form/form.php @@ -53,6 +53,7 @@ $formHasSteps = Components::checkAttr('formHasSteps', $attributes, $manifest); $formCustomName = Components::checkAttr('formCustomName', $attributes, $manifest); $formHideGlobalMsgOnSuccess = Components::checkAttr('formHideGlobalMsgOnSuccess', $attributes, $manifest); +$formUseSingleSubmit = Components::checkAttr('formUseSingleSubmit', $attributes, $manifest); $formDataTypeSelectorFilterName = UtilsHooksHelper::getFilterName(['block', 'form', 'dataTypeSelector']); $formDataTypeSelector = apply_filters( @@ -115,6 +116,10 @@ $formAttrs[UtilsHelper::getStateAttribute('globalMsgHideOnSuccess')] = 'true'; } +if ($formUseSingleSubmit) { + $formAttrs[UtilsHelper::getStateAttribute('singleSubmit')] = 'true'; +} + if ($formConditionalTags) { // Extract just the field name from the given data, if needed. $rawConditionalTagData = $formConditionalTags; diff --git a/src/Blocks/components/form/manifest.json b/src/Blocks/components/form/manifest.json index d976e3b86..076f83cee 100644 --- a/src/Blocks/components/form/manifest.json +++ b/src/Blocks/components/form/manifest.json @@ -103,6 +103,10 @@ "type": "boolean", "default": false }, + "formUseSingleSubmit": { + "type": "boolean", + "default": false + }, "formDownloads": { "type": "array", "items": { diff --git a/src/Blocks/components/input/input.php b/src/Blocks/components/input/input.php index 3b0901a63..7cf46620b 100644 --- a/src/Blocks/components/input/input.php +++ b/src/Blocks/components/input/input.php @@ -44,7 +44,7 @@ $inputClass = Components::classnames([ Components::selector($componentClass, $componentClass), Components::selector($additionalClass, $additionalClass), - Components::selector($inputSingleSubmit, UtilsHelper::getStateSelectorAdmin('singleSubmit')), + Components::selector($inputSingleSubmit && $inputType === 'range', UtilsHelper::getStateSelectorAdmin('singleSubmit')), ]); if ($inputValue) { diff --git a/src/Blocks/components/textarea/manifest.json b/src/Blocks/components/textarea/manifest.json index aa053d7d5..9fe9b015c 100644 --- a/src/Blocks/components/textarea/manifest.json +++ b/src/Blocks/components/textarea/manifest.json @@ -89,10 +89,6 @@ "textareaIsPreventSubmit": { "type": "boolean", "default": false - }, - "textareaSingleSubmit": { - "type": "boolean", - "default": false } }, "options": { diff --git a/src/Blocks/components/textarea/textarea.php b/src/Blocks/components/textarea/textarea.php index a9eab2744..0936ffeaf 100644 --- a/src/Blocks/components/textarea/textarea.php +++ b/src/Blocks/components/textarea/textarea.php @@ -36,7 +36,6 @@ $textareaLimitHeight = Components::checkAttr('textareaLimitHeight', $attributes, $manifest); $textareaIsPreventSubmit = Components::checkAttr('textareaIsPreventSubmit', $attributes, $manifest); $textareaUseLabelAsPlaceholder = Components::checkAttr('textareaUseLabelAsPlaceholder', $attributes, $manifest); -$textareaSingleSubmit = Components::checkAttr('textareaSingleSubmit', $attributes, $manifest); // Fix for getting attribute that is part of the child component. $textareaHideLabel = false; @@ -48,7 +47,6 @@ Components::selector($textareaIsMonospace, $componentClass, '', 'monospace'), Components::selector($textareaSize, $componentClass, 'size', $textareaSize), Components::selector($textareaLimitHeight, $componentClass, '', 'limit-height'), - Components::selector($textareaSingleSubmit, UtilsHelper::getStateSelectorAdmin('singleSubmit')), ]); if ($textareaSaveAsJson) { diff --git a/src/Form/Form.php b/src/Form/Form.php index a3da58edc..85c1deeef 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -17,6 +17,7 @@ use EightshiftForms\Settings\Settings\SettingsSettings; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; use EightshiftForms\Hooks\FiltersOuputMock; +use EightshiftForms\Integrations\Calculator\SettingsCalculator; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper; use EightshiftFormsVendor\EightshiftLibs\Helpers\Components; use EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface; @@ -105,6 +106,9 @@ public function updateFormComponentAttributesOutput(array $attributes): array // Custom form name. $attributes["{$prefix}HideGlobalMsgOnSuccess"] = !!UtilsSettingsHelper::isSettingCheckboxChecked(SettingsGeneral::SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY, SettingsGeneral::SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY, $formId); + // Use single submit. + $attributes["{$prefix}UseSingleSubmit"] = UtilsSettingsHelper::isSettingCheckboxChecked(SettingsGeneral::SETTINGS_USE_SINGLE_SUBMIT_KEY, SettingsGeneral::SETTINGS_USE_SINGLE_SUBMIT_KEY, $formId); + // Phone sync with country block. $attributes["{$prefix}PhoneSync"] = ''; $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'phoneSync']); diff --git a/src/General/SettingsGeneral.php b/src/General/SettingsGeneral.php index f78fcf762..0c263166f 100644 --- a/src/General/SettingsGeneral.php +++ b/src/General/SettingsGeneral.php @@ -74,6 +74,11 @@ class SettingsGeneral implements UtilsSettingGlobalInterface, UtilsSettingInterf */ public const SETTINGS_HIDE_GLOBAL_MSG_ON_SUCCESS_KEY = 'hide-global-msg-on-success'; + /** + * Use single submit key. + */ + public const SETTINGS_USE_SINGLE_SUBMIT_KEY = 'use-single-submit'; + /** * Register all the hooks * @@ -191,6 +196,21 @@ function ($selectOption) use ($successRedirectVariation) { ] ] ], + [ + 'component' => 'checkboxes', + 'checkboxesFieldLabel' => '', + 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_USE_SINGLE_SUBMIT_KEY), + 'checkboxesContent' => [ + [ + 'component' => 'checkbox', + 'checkboxLabel' => \__('Use single submit', 'eightshift-forms'), + 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_USE_SINGLE_SUBMIT_KEY, self::SETTINGS_USE_SINGLE_SUBMIT_KEY, $formId), + 'checkboxValue' => self::SETTINGS_USE_SINGLE_SUBMIT_KEY, + 'checkboxSingleSubmit' => true, + 'checkboxAsToggle' => true, + ] + ] + ], ], ], [ diff --git a/src/Integrations/Calculator/SettingsCalculator.php b/src/Integrations/Calculator/SettingsCalculator.php index 92eb2fd08..134d8d40a 100644 --- a/src/Integrations/Calculator/SettingsCalculator.php +++ b/src/Integrations/Calculator/SettingsCalculator.php @@ -10,7 +10,6 @@ namespace EightshiftForms\Integrations\Calculator; -use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingGlobalInterface; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; @@ -46,11 +45,6 @@ class SettingsCalculator implements UtilsSettingGlobalInterface, ServiceInterfac */ public const SETTINGS_CALCULATOR_USE_KEY = 'calculator-use'; - /** - * Calculator settings use single submit key. - */ - public const SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY = 'calculator-use-single-submit'; - /** * Register all the hooks * @@ -103,21 +97,6 @@ public function getSettingsData(string $formId): array 'component' => 'tab', 'tabLabel' => \__('Options', 'eightshift-forms'), 'tabContent' => [ - [ - 'component' => 'checkboxes', - 'checkboxesFieldLabel' => '', - 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY), - 'checkboxesContent' => [ - [ - 'component' => 'checkbox', - 'checkboxLabel' => \__('Use single submit', 'eightshift-forms'), - 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, $formId), - 'checkboxValue' => self::SETTINGS_CALCULATOR_USE_SINGLE_SUBMIT_KEY, - 'checkboxSingleSubmit' => true, - 'checkboxAsToggle' => true, - ] - ] - ], ], ] ], From 625c22342ac56e9afcef8d484ef81bade84289dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Thu, 7 Mar 2024 15:36:19 +0100 Subject: [PATCH 14/35] update --- src/AdminMenus/FormAdminMenu.php | 2 - src/AdminMenus/FormListingAdminSubMenu.php | 2 +- src/AdminMenus/FormSettingsAdminSubMenu.php | 5 +- src/Blocks/Blocks.php | 4 -- src/Blocks/assets/scripts/blocks-editor.js | 8 +-- .../components/result-output-item-options.js | 8 ++- src/Blocks/manifest.json | 3 - src/General/SettingsGeneral.php | 62 ++++++++++++++----- 8 files changed, 59 insertions(+), 35 deletions(-) diff --git a/src/AdminMenus/FormAdminMenu.php b/src/AdminMenus/FormAdminMenu.php index 15c5373fc..7a42cf67a 100644 --- a/src/AdminMenus/FormAdminMenu.php +++ b/src/AdminMenus/FormAdminMenu.php @@ -22,8 +22,6 @@ use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsIntegrationsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper; use EightshiftFormsVendor\EightshiftLibs\AdminMenus\AbstractAdminMenu; -use Faker\Provider\bn_BD\Utils; -use Hamcrest\Util; /** * FormAdminMenu class. diff --git a/src/AdminMenus/FormListingAdminSubMenu.php b/src/AdminMenus/FormListingAdminSubMenu.php index c833e7239..c308e198a 100644 --- a/src/AdminMenus/FormListingAdminSubMenu.php +++ b/src/AdminMenus/FormListingAdminSubMenu.php @@ -196,7 +196,7 @@ public function addCustomLinkIntoAppearnaceMenu(): void $submenu[FormAdminMenu::ADMIN_MENU_SLUG][] = [ \esc_html__('Result outputs', 'eightshift-forms'), UtilsConfig::CAP_RESULTS, - UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_RESULTS, '', Result::POST_TYPE_SLUG) + UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_RESULTS) ]; // phpcs:enable } diff --git a/src/AdminMenus/FormSettingsAdminSubMenu.php b/src/AdminMenus/FormSettingsAdminSubMenu.php index 9e844b47b..703f0cf44 100644 --- a/src/AdminMenus/FormSettingsAdminSubMenu.php +++ b/src/AdminMenus/FormSettingsAdminSubMenu.php @@ -10,6 +10,8 @@ namespace EightshiftForms\AdminMenus; +use EightshiftForms\CustomPostType\Forms; +use EightshiftForms\CustomPostType\Result; use EightshiftFormsVendor\EightshiftLibs\Helpers\Components; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftForms\Settings\Settings\SettingsBuilderInterface; @@ -226,9 +228,8 @@ public function changeHighlightParent($parentFile) global $plugin_page; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps if ($plugin_page === UtilsConfig::SLUG_ADMIN_SETTINGS) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps - $plugin_page = UtilsConfig::SLUG_ADMIN; // phpcs:ignore + $plugin_page = Forms::POST_TYPE_SLUG; } - return $parentFile ?? ''; } diff --git a/src/Blocks/Blocks.php b/src/Blocks/Blocks.php index 1fe4112f2..18f400306 100644 --- a/src/Blocks/Blocks.php +++ b/src/Blocks/Blocks.php @@ -68,10 +68,6 @@ public function getAllBlocksList($allowedBlockTypes, WP_Block_Editor_Context $bl $allowedBlockTypes[] = $value; } - foreach (Components::getSettings()['allowedBlocksResultOutputBlocksList'] as $value) { - $allowedBlockTypes[] = $value; - } - // Merge addon blocks to the list. $filterName = UtilsHooksHelper::getFilterName(['blocks', 'allowedBlocks']); if (\has_filter($filterName)) { diff --git a/src/Blocks/assets/scripts/blocks-editor.js b/src/Blocks/assets/scripts/blocks-editor.js index 350508e58..cfb17e2a1 100644 --- a/src/Blocks/assets/scripts/blocks-editor.js +++ b/src/Blocks/assets/scripts/blocks-editor.js @@ -39,15 +39,9 @@ outputCssVariablesGlobal(); // Remove form-selector block from anywhere else other than form CPT. if ( esFormsLocalization?.currentPostType !== esFormsLocalization?.postTypes?.forms || - esFormsLocalization?.currentPostType === esFormsLocalization?.postTypes?.result + esFormsLocalization?.currentPostType === esFormsLocalization?.postTypes?.results ) { const namespace = select(STORE_NAME).getSettingsNamespace(); unregisterBlockType(`${namespace}/form-selector`); } - -if (esFormsLocalization?.currentPostType === esFormsLocalization?.postTypes?.result) { - [...select(STORE_NAME).getSettings().allowedBlocksNoneBuilderBlocksList].forEach((block) => { - unregisterBlockType(block); - }); -} diff --git a/src/Blocks/custom/result-output-item/components/result-output-item-options.js b/src/Blocks/custom/result-output-item/components/result-output-item-options.js index 81aced4a9..6599d4957 100644 --- a/src/Blocks/custom/result-output-item/components/result-output-item-options.js +++ b/src/Blocks/custom/result-output-item/components/result-output-item-options.js @@ -1,7 +1,7 @@ import React from 'react'; import { __ } from '@wordpress/i18n'; import { PanelBody, TextControl } from '@wordpress/components'; -import { checkAttr, getAttrKey, icons, IconLabel } from '@eightshift/frontend-libs/scripts'; +import { checkAttr, getAttrKey, icons, IconLabel, Notification } from '@eightshift/frontend-libs/scripts'; import manifest from '../manifest.json'; export const ResultOutputItemOptions = ({ @@ -24,6 +24,12 @@ export const ResultOutputItemOptions = ({ value={resultOutputItemValue} onChange={(value) => setAttributes({ [getAttrKey('resultOutputItemValue', attributes, manifest)]: value })} /> + + + ); }; diff --git a/src/Blocks/manifest.json b/src/Blocks/manifest.json index 5e885605c..2b7ab11b8 100644 --- a/src/Blocks/manifest.json +++ b/src/Blocks/manifest.json @@ -20,9 +20,6 @@ "eightshift-forms/forms", "eightshift-forms/result-output" ], - "allowedBlocksResultOutputBlocksList": [ - "eightshift-forms/result-output-item" - ], "allowedBlocksBuilderIntegrationAdditionalBlocksList": [ "eightshift-forms/step" ], diff --git a/src/General/SettingsGeneral.php b/src/General/SettingsGeneral.php index 0c263166f..254c8396b 100644 --- a/src/General/SettingsGeneral.php +++ b/src/General/SettingsGeneral.php @@ -196,21 +196,6 @@ function ($selectOption) use ($successRedirectVariation) { ] ] ], - [ - 'component' => 'checkboxes', - 'checkboxesFieldLabel' => '', - 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_USE_SINGLE_SUBMIT_KEY), - 'checkboxesContent' => [ - [ - 'component' => 'checkbox', - 'checkboxLabel' => \__('Use single submit', 'eightshift-forms'), - 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_USE_SINGLE_SUBMIT_KEY, self::SETTINGS_USE_SINGLE_SUBMIT_KEY, $formId), - 'checkboxValue' => self::SETTINGS_USE_SINGLE_SUBMIT_KEY, - 'checkboxSingleSubmit' => true, - 'checkboxAsToggle' => true, - ] - ] - ], ], ], [ @@ -305,6 +290,53 @@ function ($selectOption) use ($successRedirectVariation) { ] ], ], + [ + 'component' => 'tab', + 'tabLabel' => \__('Single submit', 'eightshift-forms'), + 'tabContent' => [ + [ + 'component' => 'checkboxes', + 'checkboxesFieldLabel' => '', + 'checkboxesName' => UtilsSettingsHelper::getSettingName(self::SETTINGS_USE_SINGLE_SUBMIT_KEY), + 'checkboxesContent' => [ + [ + 'component' => 'checkbox', + 'checkboxLabel' => \__('Use single submit', 'eightshift-forms'), + 'checkboxIsChecked' => UtilsSettingsHelper::isSettingCheckboxChecked(self::SETTINGS_USE_SINGLE_SUBMIT_KEY, self::SETTINGS_USE_SINGLE_SUBMIT_KEY, $formId), + 'checkboxValue' => self::SETTINGS_USE_SINGLE_SUBMIT_KEY, + 'checkboxSingleSubmit' => true, + 'checkboxAsToggle' => true, + ] + ] + ], + [ + 'component' => 'divider', + 'dividerExtraVSpacing' => true, + ], + [ + 'component' => 'intro', + 'introSubtitle' => \__('This option may create a large number of request to your server.
Use with caution!', 'eightshift-forms'), + 'introIsHighlighted' => true, + 'introIsHighlightedImportant' => true, + ], + [ + 'component' => 'intro', + 'introSubtitle' => \__(' + By selecting single submit form your form will not wait for the click on the submit button. + The form will submit data to the server as soon as the user changes are made. +

+ Not all fields are supported with this option. Supported fields: +
    +
  • Input range
  • +
  • Checkbox
  • +
  • Radio
  • +
  • Rating
  • +
  • Select
  • +
+ ', 'eightshift-forms'), + ], + ], + ], ] ], ]; From 08dd36d9d431ddcd186cdf5016afc3e8a7506ce5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 8 Mar 2024 09:28:04 +0100 Subject: [PATCH 15/35] update --- src/AdminMenus/FormListingAdminSubMenu.php | 1 - src/AdminMenus/FormSettingsAdminSubMenu.php | 4 +- src/Blocks/assets/scripts/blocks-editor.js | 19 +++++--- .../admin-settings/admin-settings-admin.scss | 4 +- .../form-selector/form-selector-editor.scss | 4 ++ .../result-output/result-output-block.js | 13 ++---- src/Blocks/manifest.json | 4 +- src/Form/Form.php | 1 - src/Hooks/FiltersSettingsBuilder.php | 3 -- .../Calculator/SettingsCalculator.php | 44 +++---------------- src/Transfer/SettingsTransfer.php | 1 - 11 files changed, 34 insertions(+), 64 deletions(-) diff --git a/src/AdminMenus/FormListingAdminSubMenu.php b/src/AdminMenus/FormListingAdminSubMenu.php index c308e198a..1c7855912 100644 --- a/src/AdminMenus/FormListingAdminSubMenu.php +++ b/src/AdminMenus/FormListingAdminSubMenu.php @@ -11,7 +11,6 @@ namespace EightshiftForms\AdminMenus; use EightshiftForms\CustomPostType\Forms; -use EightshiftForms\CustomPostType\Result; use EightshiftForms\Listing\FormListingInterface; use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; diff --git a/src/AdminMenus/FormSettingsAdminSubMenu.php b/src/AdminMenus/FormSettingsAdminSubMenu.php index 703f0cf44..d82281d31 100644 --- a/src/AdminMenus/FormSettingsAdminSubMenu.php +++ b/src/AdminMenus/FormSettingsAdminSubMenu.php @@ -11,7 +11,6 @@ namespace EightshiftForms\AdminMenus; use EightshiftForms\CustomPostType\Forms; -use EightshiftForms\CustomPostType\Result; use EightshiftFormsVendor\EightshiftLibs\Helpers\Components; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsGeneralHelper; use EightshiftForms\Settings\Settings\SettingsBuilderInterface; @@ -66,7 +65,6 @@ function () { \add_filter('parent_file', [$this, 'changeHighlightParent'], 31); \add_filter('admin_title', [$this, 'fixPageTitle'], 10, 2); - } /** @@ -228,7 +226,7 @@ public function changeHighlightParent($parentFile) global $plugin_page; // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps if ($plugin_page === UtilsConfig::SLUG_ADMIN_SETTINGS) { // phpcs:ignore Squiz.NamingConventions.ValidVariableName.NotCamelCaps - $plugin_page = Forms::POST_TYPE_SLUG; + $plugin_page = Forms::POST_TYPE_SLUG; // phpcs:ignore } return $parentFile ?? ''; } diff --git a/src/Blocks/assets/scripts/blocks-editor.js b/src/Blocks/assets/scripts/blocks-editor.js index cfb17e2a1..011b580f9 100644 --- a/src/Blocks/assets/scripts/blocks-editor.js +++ b/src/Blocks/assets/scripts/blocks-editor.js @@ -37,11 +37,18 @@ registerBlocks( outputCssVariablesGlobal(); // Remove form-selector block from anywhere else other than form CPT. -if ( - esFormsLocalization?.currentPostType !== esFormsLocalization?.postTypes?.forms || - esFormsLocalization?.currentPostType === esFormsLocalization?.postTypes?.results -) { - const namespace = select(STORE_NAME).getSettingsNamespace(); +const namespace = select(STORE_NAME).getSettingsNamespace(); - unregisterBlockType(`${namespace}/form-selector`); +switch (esFormsLocalization?.currentPostType) { + case esFormsLocalization?.postTypes?.forms: + unregisterBlockType(`${namespace}/result-output-input`); + break; + case esFormsLocalization?.postTypes?.results: + unregisterBlockType(`${namespace}/form-selector`); + unregisterBlockType(`${namespace}/result-output`); + break; + default: + unregisterBlockType(`${namespace}/form-selector`); + unregisterBlockType(`${namespace}/result-output-item`); + break; } diff --git a/src/Blocks/components/admin-settings/admin-settings-admin.scss b/src/Blocks/components/admin-settings/admin-settings-admin.scss index 68b850864..102a3bc98 100644 --- a/src/Blocks/components/admin-settings/admin-settings-admin.scss +++ b/src/Blocks/components/admin-settings/admin-settings-admin.scss @@ -12,7 +12,9 @@ .es-form[data-form-type='settingsGlobal'][data-settings-type='geolocation'], .es-form[data-form-type='settingsGlobal'][data-settings-type='cloudflare'], .es-form[data-form-type='settingsGlobal'][data-settings-type='wp'], - .es-form[data-form-type='settingsGlobal'][data-settings-type='settings'] { + .es-form[data-form-type='settingsGlobal'][data-settings-type='settings'], + .es-form[data-form-type='settingsGlobal'][data-settings-type='wpml'], + .es-form[data-form-type='settingsGlobal'][data-settings-type='calculator'] { .es-submit--global { display: none; } diff --git a/src/Blocks/custom/form-selector/form-selector-editor.scss b/src/Blocks/custom/form-selector/form-selector-editor.scss index 4cb21f075..8fbb0afec 100644 --- a/src/Blocks/custom/form-selector/form-selector-editor.scss +++ b/src/Blocks/custom/form-selector/form-selector-editor.scss @@ -43,6 +43,10 @@ } } + .edit-post-header { + background-color: var(--global-colors-esf-sky-50); + } + .edit-post-header-toolbar::after { content: ''; background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyMDggMzYnIHdpZHRoPScyMDgnIGhlaWdodD0nMzYnIGZpbGw9J25vbmUnPjxwYXRoIGQ9J00xNC42NjcgMTUuMzMzaDEuMzN2LTIuNjY3aC01LjMzM3YyLjY2N0gxMnYzLjk5OWgt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TQtMS4xNDQgMC0xLjc4Mi45NDYtMS43ODIgMi4yODhWMjVoLTMuNTg2di02LjY4OGMwLTEuMjEtLjUwNi0xLjkxNC0xLjU4NC0xLjkxNC0xLjEyMiAwLTEuNzgyLjk0Ni0xLjc4MiAyLjI4OFYyNWgtMy41ODZabTIzLjkxNy4zNTJjLTMuMyAwLTUuMzY4LTEuNTE4LTUuNDc4LTQuMDA0aDMuMzg4Yy4xMzIgMS4xMjIuODggMS42NzIgMi4wNjggMS42NzIgMS4wNzggMCAxLjc2LS4zOTYgMS43Ni0xLjEyMiAwLTEuMDEyLTEuMzY0LTEuMTIyLTIuODYtMS4zODYtMS45NTgtLjMzLTQuMDQ4LS44NTgtNC4wNDgtMy40OTggMC0yLjM3NiAyLjItMy42MDggNC44NjItMy42MDggMy4xOSAwIDQuOTA2IDEuMzg2IDUuMDgyIDMuNjA4aC0zLjNjLS4xMzItMS4wMTItLjgxNC0xLjMyLTEuODA0LTEuMzItLjg4IDAtMS41NjIuMzMtMS41NjIgMS4wMzQgMCAuNzkyIDEuMjc2LjkwMiAyLjcwNiAxLjE2NiAxLjk4LjMzIDQuMzEyLjgzNiA0LjMxMiAzLjcxOCAwIDIuNDY0LTIuMTc4IDMuNzQtNS4xMjYgMy43NFonIGZpbGw9JyMwMDAnLz48L3N2Zz4='); diff --git a/src/Blocks/custom/result-output/result-output-block.js b/src/Blocks/custom/result-output/result-output-block.js index a9421a988..facd5d5a2 100644 --- a/src/Blocks/custom/result-output/result-output-block.js +++ b/src/Blocks/custom/result-output/result-output-block.js @@ -31,24 +31,19 @@ const dynamicItemSelectOptions = function(postType) { }; export const ResultOutput = (props) => { - const { - forms, - results, - } = esFormsLocalization?.postTypes; - return ( <> ); diff --git a/src/Blocks/manifest.json b/src/Blocks/manifest.json index 2b7ab11b8..95bb27a11 100644 --- a/src/Blocks/manifest.json +++ b/src/Blocks/manifest.json @@ -17,8 +17,10 @@ "useWrapper": false }, "allowedBlocksNoneBuilderBlocksList": [ + "eightshift-forms/form-selector", "eightshift-forms/forms", - "eightshift-forms/result-output" + "eightshift-forms/result-output", + "eightshift-forms/result-output-item" ], "allowedBlocksBuilderIntegrationAdditionalBlocksList": [ "eightshift-forms/step" diff --git a/src/Form/Form.php b/src/Form/Form.php index 85c1deeef..858729ad2 100644 --- a/src/Form/Form.php +++ b/src/Form/Form.php @@ -17,7 +17,6 @@ use EightshiftForms\Settings\Settings\SettingsSettings; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; use EightshiftForms\Hooks\FiltersOuputMock; -use EightshiftForms\Integrations\Calculator\SettingsCalculator; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper; use EightshiftFormsVendor\EightshiftLibs\Helpers\Components; use EightshiftFormsVendor\EightshiftLibs\Services\ServiceInterface; diff --git a/src/Hooks/FiltersSettingsBuilder.php b/src/Hooks/FiltersSettingsBuilder.php index 5004ffe00..2df6dd3d2 100644 --- a/src/Hooks/FiltersSettingsBuilder.php +++ b/src/Hooks/FiltersSettingsBuilder.php @@ -438,7 +438,6 @@ public function getSettingsFiltersData(): array ], ], SettingsCalculator::SETTINGS_TYPE_KEY => [ - 'settings' => SettingsCalculator::FILTER_SETTINGS_NAME, 'settingsGlobal' => SettingsCalculator::FILTER_SETTINGS_GLOBAL_NAME, 'type' => UtilsConfig::SETTINGS_INTERNAL_TYPE_INTEGRATION, 'integrationType' => UtilsConfig::INTEGRATION_TYPE_NO_BUILDER, @@ -446,8 +445,6 @@ public function getSettingsFiltersData(): array 'labels' => [ 'title' => \__('Calculator', 'eightshift-forms'), 'desc' => \__('Calculator form type settings.', 'eightshift-forms'), - 'detail' => \__('Calculator', 'eightshift-forms'), - 'externalLink' => '', ], ], // ------------------------------ diff --git a/src/Integrations/Calculator/SettingsCalculator.php b/src/Integrations/Calculator/SettingsCalculator.php index 134d8d40a..c7d89eeea 100644 --- a/src/Integrations/Calculator/SettingsCalculator.php +++ b/src/Integrations/Calculator/SettingsCalculator.php @@ -20,11 +20,6 @@ */ class SettingsCalculator implements UtilsSettingGlobalInterface, ServiceInterface { - /** - * Filter settings key. - */ - public const FILTER_SETTINGS_NAME = 'es_forms_settings_calculator'; - /** * Filter global settings key. */ @@ -52,7 +47,6 @@ class SettingsCalculator implements UtilsSettingGlobalInterface, ServiceInterfac */ public function register(): void { - \add_filter(self::FILTER_SETTINGS_NAME, [$this, 'getSettingsData']); \add_filter(self::FILTER_SETTINGS_GLOBAL_NAME, [$this, 'getSettingsGlobalData']); \add_filter(self::FILTER_SETTINGS_GLOBAL_IS_VALID_NAME, [$this, 'isSettingsGlobalValid']); } @@ -73,37 +67,6 @@ public function isSettingsGlobalValid(): bool return true; } - /** - * Get Form settings data array - * - * @param string $formId Form Id. - * - * @return array> - */ - public function getSettingsData(string $formId): array - { - // Bailout if feature is not active. - if (!$this->isSettingsGlobalValid()) { - return UtilsSettingsOutputHelper::getNoActiveFeature(); - } - - return [ - UtilsSettingsOutputHelper::getIntro(self::SETTINGS_TYPE_KEY), - [ - 'component' => 'tabs', - 'tabsFull' => true, - 'tabsContent' => [ - [ - 'component' => 'tab', - 'tabLabel' => \__('Options', 'eightshift-forms'), - 'tabContent' => [ - ], - ] - ], - ], - ]; - } - /** * Get global settings array for building settings page. * @@ -124,7 +87,12 @@ public function getSettingsGlobalData(): array [ 'component' => 'tab', 'tabLabel' => \__('General', 'eightshift-forms'), - 'tabContent' => [], + 'tabContent' => [ + [ + 'component' => 'intro', + 'introSubtitle' => \__('Calculator is uses to output dinamic data to the user, it doesn\'t send any emails or is not integrated with any integration.', 'eightshift-forms'), + ], + ], ], ], ], diff --git a/src/Transfer/SettingsTransfer.php b/src/Transfer/SettingsTransfer.php index 9e00ebbee..3b380a7a8 100644 --- a/src/Transfer/SettingsTransfer.php +++ b/src/Transfer/SettingsTransfer.php @@ -11,7 +11,6 @@ namespace EightshiftForms\Transfer; use EightshiftForms\CustomPostType\Forms; -use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsDeveloperHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsOutputHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Settings\UtilsSettingGlobalInterface; From 13457469df8b667481a15dcecb7b219ab50a6608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 8 Mar 2024 12:42:16 +0100 Subject: [PATCH 16/35] update --- composer.lock | 8 +++--- src/AdminMenus/FormAdminMenu.php | 27 ++++++++++++------- src/Blocks/assets/scripts/blocks-editor.js | 2 +- .../active-campaign-overrides.js | 12 +++++++++ .../custom/airtable/airtable-overrides.js | 12 +++++++++ .../custom/calculator/calculator-overrides.js | 4 +++ .../custom/checkbox/checkbox-overrides.js | 12 +++++++++ .../custom/checkboxes/checkboxes-overrides.js | 12 +++++++++ .../custom/country/country-overrides.js | 12 +++++++++ src/Blocks/custom/date/date-overrides.js | 12 +++++++++ .../custom/dynamic/dynamic-overrides.js | 12 +++++++++ src/Blocks/custom/field/field-overrides.js | 12 +++++++++ src/Blocks/custom/file/file-overrides.js | 12 +++++++++ .../form-selector/form-selector-overrides.js | 4 +++ src/Blocks/custom/forms/forms-overrides.js | 12 +++++++++ .../custom/goodbits/goodbits-overrides.js | 12 +++++++++ .../custom/greenhouse/greenhouse-overrides.js | 12 +++++++++ .../custom/hubspot/hubspot-overrides.js | 12 +++++++++ src/Blocks/custom/input/input-overrides.js | 12 +++++++++ src/Blocks/custom/jira/jira-overrides.js | 4 +++ .../custom/mailchimp/mailchimp-overrides.js | 12 +++++++++ src/Blocks/custom/mailer/mailer-overrides.js | 4 +++ .../custom/mailerlite/mailerlite-overrides.js | 12 +++++++++ .../custom/moments/moments-overrides.js | 12 +++++++++ src/Blocks/custom/phone/phone-overrides.js | 12 +++++++++ .../custom/pipedrive/pipedrive-overrides.js | 4 +++ src/Blocks/custom/radio/radio-overrides.js | 12 +++++++++ src/Blocks/custom/radios/radios-overrides.js | 12 +++++++++ src/Blocks/custom/rating/rating-overrides.js | 12 +++++++++ .../result-output-item-overrides.js | 12 +++++++++ .../result-output/result-output-overrides.js | 12 +++++++++ .../select-option/select-option-overrides.js | 12 +++++++++ src/Blocks/custom/select/select-overrides.js | 12 +++++++++ src/Blocks/custom/step/step-overrides.js | 12 +++++++++ src/Blocks/custom/submit/submit-overrides.js | 12 +++++++++ .../custom/textarea/textarea-overrides.js | 12 +++++++++ .../custom/workable/workable-overrides.js | 12 +++++++++ 37 files changed, 391 insertions(+), 14 deletions(-) create mode 100644 src/Blocks/custom/active-campaign/active-campaign-overrides.js create mode 100644 src/Blocks/custom/airtable/airtable-overrides.js create mode 100644 src/Blocks/custom/checkbox/checkbox-overrides.js create mode 100644 src/Blocks/custom/checkboxes/checkboxes-overrides.js create mode 100644 src/Blocks/custom/country/country-overrides.js create mode 100644 src/Blocks/custom/date/date-overrides.js create mode 100644 src/Blocks/custom/dynamic/dynamic-overrides.js create mode 100644 src/Blocks/custom/field/field-overrides.js create mode 100644 src/Blocks/custom/file/file-overrides.js create mode 100644 src/Blocks/custom/forms/forms-overrides.js create mode 100644 src/Blocks/custom/goodbits/goodbits-overrides.js create mode 100644 src/Blocks/custom/greenhouse/greenhouse-overrides.js create mode 100644 src/Blocks/custom/hubspot/hubspot-overrides.js create mode 100644 src/Blocks/custom/input/input-overrides.js create mode 100644 src/Blocks/custom/mailchimp/mailchimp-overrides.js create mode 100644 src/Blocks/custom/mailerlite/mailerlite-overrides.js create mode 100644 src/Blocks/custom/moments/moments-overrides.js create mode 100644 src/Blocks/custom/phone/phone-overrides.js create mode 100644 src/Blocks/custom/radio/radio-overrides.js create mode 100644 src/Blocks/custom/radios/radios-overrides.js create mode 100644 src/Blocks/custom/rating/rating-overrides.js create mode 100644 src/Blocks/custom/result-output-item/result-output-item-overrides.js create mode 100644 src/Blocks/custom/result-output/result-output-overrides.js create mode 100644 src/Blocks/custom/select-option/select-option-overrides.js create mode 100644 src/Blocks/custom/select/select-overrides.js create mode 100644 src/Blocks/custom/step/step-overrides.js create mode 100644 src/Blocks/custom/submit/submit-overrides.js create mode 100644 src/Blocks/custom/textarea/textarea-overrides.js create mode 100644 src/Blocks/custom/workable/workable-overrides.js diff --git a/composer.lock b/composer.lock index b67094de1..e428cd90a 100644 --- a/composer.lock +++ b/composer.lock @@ -62,12 +62,12 @@ "source": { "type": "git", "url": "https://github.com/infinum/eightshift-forms-utils.git", - "reference": "e5dc0a10a0912f721885bace94c8ecaa8297f9e2" + "reference": "50ff7303e80c6f9f7a21b404eaf1e4d9d0c564eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/e5dc0a10a0912f721885bace94c8ecaa8297f9e2", - "reference": "e5dc0a10a0912f721885bace94c8ecaa8297f9e2", + "url": "https://api.github.com/repos/infinum/eightshift-forms-utils/zipball/50ff7303e80c6f9f7a21b404eaf1e4d9d0c564eb", + "reference": "50ff7303e80c6f9f7a21b404eaf1e4d9d0c564eb", "shasum": "" }, "require": { @@ -119,7 +119,7 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "time": "2024-03-07T12:39:21+00:00" + "time": "2024-03-08T11:35:03+00:00" }, { "name": "infinum/eightshift-libs", diff --git a/src/AdminMenus/FormAdminMenu.php b/src/AdminMenus/FormAdminMenu.php index 7a42cf67a..26f8da08b 100644 --- a/src/AdminMenus/FormAdminMenu.php +++ b/src/AdminMenus/FormAdminMenu.php @@ -525,6 +525,15 @@ private function getTopBarItems(string $type, string $formId, string $parent): a 'submitValue' => \__('Back', 'eightshift-forms'), 'submitIcon' => UtilsHelper::getUtilsIcons('arrowLeft') ]), + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitValue' => \__('Restore', 'eightshift-forms'), + 'submitIsDisabled' => true, + 'additionalClass' => $bulkSelector, + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('bulkType') => 'restore', + ], + ]), ]; } else { $left = [ @@ -540,19 +549,19 @@ private function getTopBarItems(string $type, string $formId, string $parent): a 'submitValue' => \__('Back', 'eightshift-forms'), 'submitIcon' => UtilsHelper::getUtilsIcons('arrowLeft') ]), + Components::render('submit', [ + 'submitVariant' => 'ghost', + 'submitValue' => \__('Restore', 'eightshift-forms'), + 'submitIsDisabled' => true, + 'additionalClass' => $bulkSelector, + 'submitAttrs' => [ + UtilsHelper::getStateAttribute('bulkType') => 'restore', + ], + ]), ]; } $right = [ - Components::render('submit', [ - 'submitVariant' => 'ghost', - 'submitValue' => \__('Restore', 'eightshift-forms'), - 'submitIsDisabled' => true, - 'additionalClass' => $bulkSelector, - 'submitAttrs' => [ - UtilsHelper::getStateAttribute('bulkType') => 'restore', - ], - ]), Components::render('submit', [ 'submitVariant' => 'ghost', 'submitValue' => \__('Delete permanently', 'eightshift-forms'), diff --git a/src/Blocks/assets/scripts/blocks-editor.js b/src/Blocks/assets/scripts/blocks-editor.js index 011b580f9..35dc75c5f 100644 --- a/src/Blocks/assets/scripts/blocks-editor.js +++ b/src/Blocks/assets/scripts/blocks-editor.js @@ -41,7 +41,7 @@ const namespace = select(STORE_NAME).getSettingsNamespace(); switch (esFormsLocalization?.currentPostType) { case esFormsLocalization?.postTypes?.forms: - unregisterBlockType(`${namespace}/result-output-input`); + unregisterBlockType(`${namespace}/result-output-item`); break; case esFormsLocalization?.postTypes?.results: unregisterBlockType(`${namespace}/form-selector`); diff --git a/src/Blocks/custom/active-campaign/active-campaign-overrides.js b/src/Blocks/custom/active-campaign/active-campaign-overrides.js new file mode 100644 index 000000000..1146e3cab --- /dev/null +++ b/src/Blocks/custom/active-campaign/active-campaign-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('activeCampaign') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/airtable/airtable-overrides.js b/src/Blocks/custom/airtable/airtable-overrides.js new file mode 100644 index 000000000..f0a6ef31a --- /dev/null +++ b/src/Blocks/custom/airtable/airtable-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('airtable') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/calculator/calculator-overrides.js b/src/Blocks/custom/calculator/calculator-overrides.js index 2c1235b37..323f20e4d 100644 --- a/src/Blocks/custom/calculator/calculator-overrides.js +++ b/src/Blocks/custom/calculator/calculator-overrides.js @@ -2,9 +2,13 @@ import globalManifest from '../../manifest.json'; import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; export const overrides = { ...manifest, + icon:{ + src: getUtilsIcons('calculate') ?? manifest.icon.src, + }, attributes: { ...manifest.attributes, calculatorAllowedBlocks: { diff --git a/src/Blocks/custom/checkbox/checkbox-overrides.js b/src/Blocks/custom/checkbox/checkbox-overrides.js new file mode 100644 index 000000000..9b4055ea3 --- /dev/null +++ b/src/Blocks/custom/checkbox/checkbox-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('checkbox') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/checkboxes/checkboxes-overrides.js b/src/Blocks/custom/checkboxes/checkboxes-overrides.js new file mode 100644 index 000000000..7d03d0a2d --- /dev/null +++ b/src/Blocks/custom/checkboxes/checkboxes-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('checkboxes') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/country/country-overrides.js b/src/Blocks/custom/country/country-overrides.js new file mode 100644 index 000000000..26a9bf3f5 --- /dev/null +++ b/src/Blocks/custom/country/country-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('country') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/date/date-overrides.js b/src/Blocks/custom/date/date-overrides.js new file mode 100644 index 000000000..5aa52ac10 --- /dev/null +++ b/src/Blocks/custom/date/date-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('date') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/dynamic/dynamic-overrides.js b/src/Blocks/custom/dynamic/dynamic-overrides.js new file mode 100644 index 000000000..41cb036f1 --- /dev/null +++ b/src/Blocks/custom/dynamic/dynamic-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('dynamic') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/field/field-overrides.js b/src/Blocks/custom/field/field-overrides.js new file mode 100644 index 000000000..7592930d2 --- /dev/null +++ b/src/Blocks/custom/field/field-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('field') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/file/file-overrides.js b/src/Blocks/custom/file/file-overrides.js new file mode 100644 index 000000000..ed41b899d --- /dev/null +++ b/src/Blocks/custom/file/file-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('file') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/form-selector/form-selector-overrides.js b/src/Blocks/custom/form-selector/form-selector-overrides.js index 08ab2ab04..305e1547d 100644 --- a/src/Blocks/custom/form-selector/form-selector-overrides.js +++ b/src/Blocks/custom/form-selector/form-selector-overrides.js @@ -3,6 +3,7 @@ import globalManifest from '../../manifest.json'; import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; const forms = [ ...manifest.forms, @@ -24,4 +25,7 @@ forms.forEach((form) => { export const overrides = { ...manifest, forms: outputForms, + icon:{ + src: getUtilsIcons('formPicker') ?? manifest.icon.src, + } }; diff --git a/src/Blocks/custom/forms/forms-overrides.js b/src/Blocks/custom/forms/forms-overrides.js new file mode 100644 index 000000000..e6dedd39b --- /dev/null +++ b/src/Blocks/custom/forms/forms-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('form') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/goodbits/goodbits-overrides.js b/src/Blocks/custom/goodbits/goodbits-overrides.js new file mode 100644 index 000000000..95b27e2cd --- /dev/null +++ b/src/Blocks/custom/goodbits/goodbits-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('goodbits') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/greenhouse/greenhouse-overrides.js b/src/Blocks/custom/greenhouse/greenhouse-overrides.js new file mode 100644 index 000000000..4d8599a9f --- /dev/null +++ b/src/Blocks/custom/greenhouse/greenhouse-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('greenhouse') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/hubspot/hubspot-overrides.js b/src/Blocks/custom/hubspot/hubspot-overrides.js new file mode 100644 index 000000000..5b4118dab --- /dev/null +++ b/src/Blocks/custom/hubspot/hubspot-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('hubspot') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/input/input-overrides.js b/src/Blocks/custom/input/input-overrides.js new file mode 100644 index 000000000..b751036ea --- /dev/null +++ b/src/Blocks/custom/input/input-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('input') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/jira/jira-overrides.js b/src/Blocks/custom/jira/jira-overrides.js index 64222d1d9..6d62cd80b 100644 --- a/src/Blocks/custom/jira/jira-overrides.js +++ b/src/Blocks/custom/jira/jira-overrides.js @@ -2,9 +2,13 @@ import globalManifest from '../../manifest.json'; import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; export const overrides = { ...manifest, + icon:{ + src: getUtilsIcons('jira') ?? manifest.icon.src, + }, attributes: { ...manifest.attributes, jiraAllowedBlocks: { diff --git a/src/Blocks/custom/mailchimp/mailchimp-overrides.js b/src/Blocks/custom/mailchimp/mailchimp-overrides.js new file mode 100644 index 000000000..daa3c541f --- /dev/null +++ b/src/Blocks/custom/mailchimp/mailchimp-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('mailchimp') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/mailer/mailer-overrides.js b/src/Blocks/custom/mailer/mailer-overrides.js index 071618d1e..0f91871ef 100644 --- a/src/Blocks/custom/mailer/mailer-overrides.js +++ b/src/Blocks/custom/mailer/mailer-overrides.js @@ -2,9 +2,13 @@ import globalManifest from './../../manifest.json'; import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; export const overrides = { ...manifest, + icon:{ + src: getUtilsIcons('form') ?? manifest.icon.src, + }, attributes: { ...manifest.attributes, mailerAllowedBlocks: { diff --git a/src/Blocks/custom/mailerlite/mailerlite-overrides.js b/src/Blocks/custom/mailerlite/mailerlite-overrides.js new file mode 100644 index 000000000..ce3edca2a --- /dev/null +++ b/src/Blocks/custom/mailerlite/mailerlite-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('mailerlite') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/moments/moments-overrides.js b/src/Blocks/custom/moments/moments-overrides.js new file mode 100644 index 000000000..109e51cb9 --- /dev/null +++ b/src/Blocks/custom/moments/moments-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('moments') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/phone/phone-overrides.js b/src/Blocks/custom/phone/phone-overrides.js new file mode 100644 index 000000000..52d74abc7 --- /dev/null +++ b/src/Blocks/custom/phone/phone-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('phone') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/pipedrive/pipedrive-overrides.js b/src/Blocks/custom/pipedrive/pipedrive-overrides.js index a50432494..b57bfb830 100644 --- a/src/Blocks/custom/pipedrive/pipedrive-overrides.js +++ b/src/Blocks/custom/pipedrive/pipedrive-overrides.js @@ -2,9 +2,13 @@ import globalManifest from '../../manifest.json'; import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; export const overrides = { ...manifest, + icon:{ + src: getUtilsIcons('pipedrive') ?? manifest.icon.src, + }, attributes: { ...manifest.attributes, pipedriveAllowedBlocks: { diff --git a/src/Blocks/custom/radio/radio-overrides.js b/src/Blocks/custom/radio/radio-overrides.js new file mode 100644 index 000000000..f0ce805a5 --- /dev/null +++ b/src/Blocks/custom/radio/radio-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('radio') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/radios/radios-overrides.js b/src/Blocks/custom/radios/radios-overrides.js new file mode 100644 index 000000000..ba31b1f2f --- /dev/null +++ b/src/Blocks/custom/radios/radios-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('radios') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/rating/rating-overrides.js b/src/Blocks/custom/rating/rating-overrides.js new file mode 100644 index 000000000..6e23e9b69 --- /dev/null +++ b/src/Blocks/custom/rating/rating-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('starRating') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/result-output-item/result-output-item-overrides.js b/src/Blocks/custom/result-output-item/result-output-item-overrides.js new file mode 100644 index 000000000..cf8b09c9b --- /dev/null +++ b/src/Blocks/custom/result-output-item/result-output-item-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('resultOutputItem') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/result-output/result-output-overrides.js b/src/Blocks/custom/result-output/result-output-overrides.js new file mode 100644 index 000000000..b0c0eedf1 --- /dev/null +++ b/src/Blocks/custom/result-output/result-output-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('resultOutput') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/select-option/select-option-overrides.js b/src/Blocks/custom/select-option/select-option-overrides.js new file mode 100644 index 000000000..be0b43698 --- /dev/null +++ b/src/Blocks/custom/select-option/select-option-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('selectOption') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/select/select-overrides.js b/src/Blocks/custom/select/select-overrides.js new file mode 100644 index 000000000..7009aab07 --- /dev/null +++ b/src/Blocks/custom/select/select-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('select') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/step/step-overrides.js b/src/Blocks/custom/step/step-overrides.js new file mode 100644 index 000000000..04ebe7e6e --- /dev/null +++ b/src/Blocks/custom/step/step-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('steps') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/submit/submit-overrides.js b/src/Blocks/custom/submit/submit-overrides.js new file mode 100644 index 000000000..83b558d07 --- /dev/null +++ b/src/Blocks/custom/submit/submit-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('submit') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/textarea/textarea-overrides.js b/src/Blocks/custom/textarea/textarea-overrides.js new file mode 100644 index 000000000..e7a8b9821 --- /dev/null +++ b/src/Blocks/custom/textarea/textarea-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('textarea') ?? manifest.icon.src, + } +}; diff --git a/src/Blocks/custom/workable/workable-overrides.js b/src/Blocks/custom/workable/workable-overrides.js new file mode 100644 index 000000000..04503af51 --- /dev/null +++ b/src/Blocks/custom/workable/workable-overrides.js @@ -0,0 +1,12 @@ +// eslint-disable-next-line no-unused-vars +/* global esFormsLocalization */ + +import manifest from './manifest.json'; +import { getUtilsIcons } from '../../components/form/assets/state-init'; + +export const overrides = { + ...manifest, + icon:{ + src: getUtilsIcons('workable') ?? manifest.icon.src, + } +}; From 8235e7d41f689abed90e97e3e1155881450eed5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 8 Mar 2024 12:46:24 +0100 Subject: [PATCH 17/35] update --- src/Blocks/custom/date/manifest.json | 2 +- src/Blocks/custom/result-output-item/manifest.json | 2 +- src/Blocks/custom/result-output/manifest.json | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Blocks/custom/date/manifest.json b/src/Blocks/custom/date/manifest.json index b9fbf3f63..0b793b8fd 100644 --- a/src/Blocks/custom/date/manifest.json +++ b/src/Blocks/custom/date/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", "blockName": "date", "title": "Date", - "description" : "Date picker field", + "description" : "Date/time picker field", "category": "eightshift-forms", "icon": { "src": "esf-date" diff --git a/src/Blocks/custom/result-output-item/manifest.json b/src/Blocks/custom/result-output-item/manifest.json index 70c5c6a5a..36cfbd048 100644 --- a/src/Blocks/custom/result-output-item/manifest.json +++ b/src/Blocks/custom/result-output-item/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", "blockName": "result-output-item", "title": "Result output item", - "description" : "Result output item block.", + "description" : "Display the result output variable blocks based on the users form submission", "category": "eightshift-forms", "icon": { "src": "esf-checkbox" diff --git a/src/Blocks/custom/result-output/manifest.json b/src/Blocks/custom/result-output/manifest.json index 934a7fd3c..b91da7f13 100644 --- a/src/Blocks/custom/result-output/manifest.json +++ b/src/Blocks/custom/result-output/manifest.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/infinum/eightshift-frontend-libs/develop/schemas/block.json", "blockName": "result-output", "title": "Result output", - "description" : "Result output block.", + "description" : "Display the result output of the form after success", "category": "eightshift-forms", "icon": { "src": "esf-checkbox" From c657a05af24452304970c6cc66c5b602f0b08c61 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 8 Mar 2024 12:59:03 +0100 Subject: [PATCH 18/35] update --- CHANGELOG.md | 14 ++++++++++++-- composer.json | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index da7771499..31a40c4c8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,12 +4,21 @@ 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/). +## [3.1.0] + ### Added -- New `range` field for the forms. -- New `singleSubmit` attribute on all fields to allow only one submit per form to be used as calculation form. +- `range` field for the forms. +- `singleSubmit` attribute on all fields to allow only one submit per form to be used as calculation form. +- Result output custom post type. +- Blocks for the result output. +- Calculator form type and necessary filters. +- Forms can now use `single submit` option to send data without submit button. +- Setting for single form to hide global msg on submit success. ### Changed - `Input` field now output email and url as a correct type so it can be user on mobile devices. +- Admin listing url can now support additional type. +- All icons are now used from utils lib. ### Fixed - Js errors when missing data. @@ -264,6 +273,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - Initial production release. +[3.1.0]: https://github.com/infinum/eightshift-forms/compare/3.0.4...3.1.0 [3.0.4]: https://github.com/infinum/eightshift-forms/compare/3.0.3...3.0.4 [3.0.3]: https://github.com/infinum/eightshift-forms/compare/3.0.2...3.0.3 [3.0.2]: https://github.com/infinum/eightshift-forms/compare/3.0.0...3.0.2 diff --git a/composer.json b/composer.json index 94910126b..803ca29c8 100644 --- a/composer.json +++ b/composer.json @@ -46,7 +46,7 @@ "require": { "php": "^7.4 || >=8.0", "erusev/parsedown": "^1.7.4", - "infinum/eightshift-forms-utils": "dev-feature/calculator" + "infinum/eightshift-forms-utils": "1.3.0" }, "suggest": { "ext-pcov": "* || This extension is used for code coverage generation. Use either pcov, or xdebug, but not both.", From 636186c9ca348ab0cc67d2cfb2b7b1c539ea7c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 8 Mar 2024 13:03:47 +0100 Subject: [PATCH 19/35] update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2fadb9e47..60fc8fd90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a ### Fixed - Js errors when missing data. +- Broken url for admin listing when using custom post type. ### Removed - Unnecessary options in the `rating` field. From 6254037d9cb25b9c6c2736adc8621b674827c33d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Fri, 8 Mar 2024 13:04:39 +0100 Subject: [PATCH 20/35] Update CHANGELOG.md Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60fc8fd90..7852275dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - Setting for single form to hide global msg on submit success. ### Changed -- `Input` field now output email and url as a correct type so it can be user on mobile devices. +- `Input` fields now output email and URL as a correct type so it can be user on mobile devices. - Admin listing url can now support additional type. - All icons are now used from utils lib. From 5124389a4d19037e1a020d77d925d3d0a5bbc267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Fri, 8 Mar 2024 13:04:54 +0100 Subject: [PATCH 21/35] Update src/Blocks/custom/calculator/calculator-hooks.js Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> --- src/Blocks/custom/calculator/calculator-hooks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blocks/custom/calculator/calculator-hooks.js b/src/Blocks/custom/calculator/calculator-hooks.js index 6b254364e..958711658 100644 --- a/src/Blocks/custom/calculator/calculator-hooks.js +++ b/src/Blocks/custom/calculator/calculator-hooks.js @@ -10,7 +10,7 @@ export const hooks = () => { const { blockName } = select(STORE_NAME).getBlock('calculator'); const namespace = select(STORE_NAME).getSettingsNamespace(); - // All adding additional blocks to the custom form builder. + // Adding all additional blocks to the custom form builder. addFilter('blocks.registerBlockType', `${namespace}/${blockName}`, (settings, name) => { if (name === `${namespace}/${blockName}`) { if (typeof esFormsLocalization !== 'undefined' && isArray(esFormsLocalization?.additionalBlocks)) { From 188b18261eb4fb4ea17bd654f2ede0c34ffb52b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Fri, 8 Mar 2024 13:05:01 +0100 Subject: [PATCH 22/35] Update CHANGELOG.md Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7852275dc..63fb8f3b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,7 +21,7 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a - All icons are now used from utils lib. ### Fixed -- Js errors when missing data. +- JS errors when missing data. - Broken url for admin listing when using custom post type. ### Removed From c3b018a09d2c52b4cb0e81f27827010af08c8ce0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Fri, 8 Mar 2024 13:05:07 +0100 Subject: [PATCH 23/35] Update src/Blocks/components/input/components/input-options.js Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> --- src/Blocks/components/input/components/input-options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blocks/components/input/components/input-options.js b/src/Blocks/components/input/components/input-options.js index 99010e2fc..bc6dfe499 100644 --- a/src/Blocks/components/input/components/input-options.js +++ b/src/Blocks/components/input/components/input-options.js @@ -81,7 +81,7 @@ export const InputOptions = (attributes) => { inputValidationPatternOptions = esFormsLocalization.validationPatternsOptions; } - // Output number to 2 decimal places if it's a float if not output to fixed number. + // Output number to 2 decimal places if it's a float, otherwise output to fixed number. const formatNumber = (number) => (Number.isInteger(number) ? number.toString() : number.toFixed(2)); return ( From 1a0684fa2f04b2402e69ac0c83d9037bf9a56564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Fri, 8 Mar 2024 13:05:14 +0100 Subject: [PATCH 24/35] Update src/Blocks/components/input/input-style.scss Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> --- src/Blocks/components/input/input-style.scss | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Blocks/components/input/input-style.scss b/src/Blocks/components/input/input-style.scss index 01d6e0347..605b7fc14 100644 --- a/src/Blocks/components/input/input-style.scss +++ b/src/Blocks/components/input/input-style.scss @@ -10,8 +10,8 @@ input.es-input { &::-webkit-slider-thumb, &::-moz-range-thumb { appearance: none; - height: 1.45rem; - width: 1.45rem; + block-size: 1.45rem; + inline-size: 1.45rem; cursor: pointer; background-color: var(--global-colors-esf-admin-accent); border-radius: 50%; From 432df7da377e98fb418089dfc7e2d4c4cad7e25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 8 Mar 2024 13:56:36 +0100 Subject: [PATCH 25/35] update --- src/Hooks/Filters.php | 4 ++-- src/Labels/Labels.php | 2 +- src/Rest/Routes/AbstractFormSubmit.php | 12 ++++++++++ .../Calculator/FormSubmitCalculatorRoute.php | 6 +++-- .../Mailer/FormSubmitCustomRoute.php | 17 +++++++++++++- .../Integrations/Mailer/FormSubmitMailer.php | 22 ++++++++++++++++++- 6 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/Hooks/Filters.php b/src/Hooks/Filters.php index b3fb37290..574097197 100644 --- a/src/Hooks/Filters.php +++ b/src/Hooks/Filters.php @@ -83,6 +83,8 @@ private static function getPublicFilters(): array 'preResponseAddonData', 'preResponseSuccessRedirectData', 'additionalHiddenFields', + 'resultOutputItems', + 'resultOutputParts', ], 'formSelector' => [ 'formTemplates', @@ -236,8 +238,6 @@ private static function getPublicFilters(): array ], SettingsCalculator::SETTINGS_TYPE_KEY => [ 'prePostParams', - 'resultOutputItems', - 'resultOutputParts', ], ], 'entries' => [ diff --git a/src/Labels/Labels.php b/src/Labels/Labels.php index 247c7b5fe..5679d36ef 100644 --- a/src/Labels/Labels.php +++ b/src/Labels/Labels.php @@ -503,7 +503,7 @@ private function getCalculatorLabels(): array return [ 'calculatorErrorSettingsMissing' => \__('Calculator integration is not configured correctly. Please try again.', 'eightshift-forms'), 'calculatorBadRequestError' => \__('Something is not right with the subscription. Please check all the fields and try again.', 'eightshift-forms'), - 'calculatorSuccess' => \__('The newsletter subscription was successful. Thank you!', 'eightshift-forms'), + 'calculatorSuccess' => \__('Calculator result success. Thank you!', 'eightshift-forms'), ]; } } diff --git a/src/Rest/Routes/AbstractFormSubmit.php b/src/Rest/Routes/AbstractFormSubmit.php index cb76c4afe..223a6e0d6 100644 --- a/src/Rest/Routes/AbstractFormSubmit.php +++ b/src/Rest/Routes/AbstractFormSubmit.php @@ -403,6 +403,18 @@ protected function getIntegrationCommonSubmitOutput(array $formDetails, string $ $this->getFormSubmitMailer()->sendEmails($formDetails); } + // Output result output items as a response key. + $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputItems']); + if (\has_filter($filterName)) { + $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputItems')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; + } + + // Output result output parts as a response key. + $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputParts']); + if (\has_filter($filterName)) { + $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputParts')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; + } + $additionalOutput = \array_merge( $additionalOutput, UtilsApiHelper::getApiPublicAdditionalDataOutput($formDetails) diff --git a/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php b/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php index b9335f8f4..668ebc697 100644 --- a/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php +++ b/src/Rest/Routes/Integrations/Calculator/FormSubmitCalculatorRoute.php @@ -92,12 +92,14 @@ protected function submitAction(array $formDetails) $additionalOutput = []; - $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'resultOutputItems']); + // Output result output items as a response key. + $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputItems']); if (\has_filter($filterName)) { $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputItems')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; } - $filterName = UtilsHooksHelper::getFilterName(['integrations', SettingsCalculator::SETTINGS_TYPE_KEY, 'resultOutputParts']); + // Output result output parts as a response key. + $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputParts']); if (\has_filter($filterName)) { $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputParts')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; } diff --git a/src/Rest/Routes/Integrations/Mailer/FormSubmitCustomRoute.php b/src/Rest/Routes/Integrations/Mailer/FormSubmitCustomRoute.php index 3d8422c02..a1d918306 100644 --- a/src/Rest/Routes/Integrations/Mailer/FormSubmitCustomRoute.php +++ b/src/Rest/Routes/Integrations/Mailer/FormSubmitCustomRoute.php @@ -22,6 +22,7 @@ use EightshiftForms\Security\SecurityInterface; use EightshiftForms\Validation\ValidationPatternsInterface; use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; +use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper; /** @@ -147,11 +148,25 @@ protected function submitAction(array $formDetails) ); } + $additionalOutput = []; + + // Output result output items as a response key. + $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputItems']); + if (\has_filter($filterName)) { + $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputItems')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; + } + + // Output result output parts as a response key. + $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputParts']); + if (\has_filter($filterName)) { + $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputParts')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; + } + // Finish. return \rest_ensure_response( UtilsApiHelper::getApiSuccessPublicOutput( $this->labels->getLabel('customSuccess', $formId), - [], + $additionalOutput, $debug ) ); diff --git a/src/Rest/Routes/Integrations/Mailer/FormSubmitMailer.php b/src/Rest/Routes/Integrations/Mailer/FormSubmitMailer.php index 2a16a094c..e8fb224d3 100644 --- a/src/Rest/Routes/Integrations/Mailer/FormSubmitMailer.php +++ b/src/Rest/Routes/Integrations/Mailer/FormSubmitMailer.php @@ -19,6 +19,7 @@ use EightshiftFormsVendor\EightshiftFormsUtils\Config\UtilsConfig; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsApiHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsEncryption; +use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsHooksHelper; use EightshiftFormsVendor\EightshiftFormsUtils\Helpers\UtilsSettingsHelper; @@ -127,10 +128,29 @@ public function sendEmails(array $formDetails, bool $useSuccessAction = false): $this->sendConfirmationEmail($formId, $params, $files); + $additionalOutput = []; + + // Output result output items as a response key. + $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputItems']); + if (\has_filter($filterName)) { + $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputItems')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; + } + + // Output result output parts as a response key. + $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputParts']); + if (\has_filter($filterName)) { + $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputParts')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; + } + + $additionalOutput = \array_merge( + $additionalOutput, + UtilsApiHelper::getApiPublicAdditionalDataOutput($formDetails) + ); + // Finish. return UtilsApiHelper::getApiSuccessPublicOutput( $this->labels->getLabel('mailerSuccess', $formId), - UtilsApiHelper::getApiPublicAdditionalDataOutput($formDetails), + $additionalOutput, $debug ); } From f7b4318987b5e71e784eedbe371d5f359cb73d16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 8 Mar 2024 15:03:01 +0100 Subject: [PATCH 26/35] update --- .../custom/form-selector/form-selector-editor.scss | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/Blocks/custom/form-selector/form-selector-editor.scss b/src/Blocks/custom/form-selector/form-selector-editor.scss index 8fbb0afec..daa46b52b 100644 --- a/src/Blocks/custom/form-selector/form-selector-editor.scss +++ b/src/Blocks/custom/form-selector/form-selector-editor.scss @@ -36,7 +36,7 @@ } .post-type-eightshift-forms, -.post-type-es-forms-res { +.post-type-eightshift-forms-res { h1 { span[data-rich-text-placeholder]::after { content: 'Form name'; @@ -49,7 +49,7 @@ .edit-post-header-toolbar::after { content: ''; - background-image: url('data:image/svg+xml;base64,PHN2ZyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHZpZXdCb3g9JzAgMCAyMDggMzYnIHdpZHRoPScyMDgnIGhlaWdodD0nMzYnIGZpbGw9J25vbmUnPjxwYXRoIGQ9J00xNC42NjcgMTUuMzMzaDEuMzN2LTIuNjY3aC01LjMzM3YyLjY2N0gxMnYzLjk5OWgtMS4zMzZ2Mi42NjdoNS4zMzN2LTIuNjY3aC0xLjMzdi00WicgZmlsbD0nI0Q5MjMyNycvPjxwYXRoIGNsaXAtcnVsZT0nZXZlbm9kZCcgZmlsbFJ1bGU9J2V2ZW5vZGQnIGQ9J001LjMyOCA4LjY2NmgyNS4zMzN2MTcuMzMzSDUuMzI4VjguNjY2Wm0yLjY2NyAyLjY2N3YxMmgyMHYtMTJoLTIwWicgZmlsbD0nI0Q5MjMyNycvPjxwYXRoIGNsaXAtcnVsZT0nZXZlbm9kZCcgZmlsbFJ1bGU9J2V2ZW5vZGQnIGQ9J001LjUgMEE1LjUwMiA1LjUwMiAwIDAgMCAwIDUuNXYyNUMwIDMzLjUzNiAyLjQ2NCAzNiA1LjUgMzZoMjVjMy4wMzYgMCA1LjUtMi40NjQgNS41LTUuNXYtMjVDMzYgMi40NjQgMzMuNTM2IDAgMzAuNSAwaC0yNVpNMi42NjcgNS41QTIuODM1IDIuODM1IDAgMCAxIDUuNSAyLjY2N2gyNUEyLjgzNSAyLjgzNSAwIDAgMSAzMy4zMzMgNS41djI1YTIuODM1IDIuODM1IDAgMCAxLTIuODMzIDIuODMzaC0yNUEyLjgzNSAyLjgzNSAwIDAgMSAyLjY2NyAzMC41di0yNVonIGZpbGw9JyNEOTIzMjcnLz48cGF0aCBkP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iAzMC4yODc2IDEzNC40OTYgMzAuMjg3NkgxMzEuOTdWMjguODY1OEgxMzQuMjY1QzEzNC42ODkgMjguODY1OCAxMzUuMDM3IDI4LjgwNzMgMTM1LjMwOCAyOC42OTAzQzEzNS41NzkgMjguNTcwMyAxMzUuNzc5IDI4LjM5NjQgMTM1LjkwOCAyOC4xNjg3QzEzNi4wNDEgMjcuOTM3OSAxMzYuMTA3IDI3LjY1NDcgMTM2LjEwNyAyNy4zMTkyQzEzNi4xMDcgMjYuOTgzOCAxMzYuMDQxIDI2LjY5NzYgMTM1LjkwOCAyNi40NjA2QzEzNS43NzYgMjYuMjIwNSAxMzUuNTc0IDI2LjAzODkgMTM1LjMwMyAyNS45MTU4QzEzNS4wMzMgMjUuNzg5NyAxMzQuNjgzIDI1LjcyNjYgMTM0LjI1NiAyNS43MjY2SDEzMi42ODZWMzMuNzVIMTMwLjk3M1pNMTM1Ljg1NyAyOS40NjU5TDEzOC4xOTggMzMuNzVIMTM2LjI4N0wxMzMuOTg4IDI5LjQ2NTlIMTM1Ljg1N1oiIGZpbGw9IiM4NDg3OTQiLz4KPC9zdmc+Cg=='); background-repeat: no-repeat; display: block; inline-size: 208px; @@ -60,10 +60,14 @@ } } -.post-type-es-forms-res { +.post-type-eightshift-forms-res { h1 { span[data-rich-text-placeholder]::after { content: 'Result output name'; } } + + .edit-post-header-toolbar::after { + background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjA4IiBoZWlnaHQ9IjM2IiB2aWV3Qm94PSIwIDAgMjA4IDM2IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTQuNjY3MSAxNS4zMzNIMTUuOTk3MVYxMi42NjZIMTAuNjY0MVYxNS4zMzNIMTIuMDAwMVYxOS4zMzJIMTAuNjY0MVYyMS45OTlIMTUuOTk3MVYxOS4zMzJIMTQuNjY3MVYxNS4zMzJWMTUuMzMzWiIgZmlsbD0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5IDMzLjQ2MzhDMTMzLjU4MyAzMy4xNzQ1IDEzMy4xMzcgMzIuNzcyOCAxMzIuODIgMzIuMjU4OUMxMzIuNTAzIDMxLjc0NDkgMTMyLjM0NCAzMS4xNDk0IDEzMi4zNDQgMzAuNDcyM1YyNC4yOTU1SDEzNC4wNTdWMzAuMzI5MkMxMzQuMDU3IDMwLjcyMzEgMTM0LjE0MyAzMS4wNzQgMTM0LjMxNiAzMS4zODE3QzEzNC40OTEgMzEuNjg5NSAxMzQuNzM3IDMxLjkzMTEgMTM1LjA1NCAzMi4xMDY1QzEzNS4zNzEgMzIuMjc4OSAxMzUuNzQ3IDMyLjM2NTEgMTM2LjE4MSAzMi4zNjUxQzEzNi42MTUgMzIuMzY1MSAxMzYuOTkgMzIuMjc4OSAxMzcuMzA3IDMyLjEwNjVDMTM3LjYyNyAzMS45MzExIDEzNy44NzMgMzEuNjg5NSAxMzguMDQ2IDMxLjM4MTdDMTM4LjIxOCAzMS4wNzQgMTM4LjMwNCAzMC43MjMxIDEzOC4zMDQgMzAuMzI5MlYyNC4yOTU1Wk0xNDEuMzMzIDI1LjczMTJWMjQuMjk1NUgxNDguODc2VjI1LjczMTJIMTQ1Ljk1NFYzMy43NUgxNDQuMjU1VjI1LjczMTJIMTQxLjMzM1oiIGZpbGw9IiM4NDg3OTQiLz4KPC9zdmc+Cg=='); + } } From e309b8cc2945073140069f840add27fc7ece981b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Fri, 8 Mar 2024 16:05:42 +0100 Subject: [PATCH 27/35] update --- src/Shortcode/ResultOutputItemPart.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Shortcode/ResultOutputItemPart.php b/src/Shortcode/ResultOutputItemPart.php index 084ad9298..e9b312b58 100644 --- a/src/Shortcode/ResultOutputItemPart.php +++ b/src/Shortcode/ResultOutputItemPart.php @@ -40,14 +40,14 @@ public function callback(array $atts, string $content): string { $params = \shortcode_atts( [ - 'id' => '', + 'name' => '', ], $atts ); - $id = isset($params['id']) ? \esc_html($params['id']) : ''; + $name = isset($params['name']) ? \esc_html($params['name']) : ''; - if (!$id || !$content) { + if (!$name || !$content) { return ''; } @@ -56,6 +56,6 @@ public function callback(array $atts, string $content): string $attrPartName = UtilsHelper::getStateAttribute('resultOutputPart'); $attrPartDefaultName = UtilsHelper::getStateAttribute('resultOutputPartDefault'); - return "{$content}"; + return "{$content}"; } } From 2b188e90b989c78e546028af845b53904f0d97c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Mon, 11 Mar 2024 08:30:19 +0100 Subject: [PATCH 28/35] update --- composer.json | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/composer.json b/composer.json index 803ca29c8..34453edb3 100644 --- a/composer.json +++ b/composer.json @@ -26,12 +26,6 @@ "issues": "https://github.com/infinum/eightshift-forms/issues", "source": "https://github.com/infinum/eightshift-forms" }, - "repositories": [ - { - "type": "vcs", - "url": "https://github.com/infinum/eightshift-libs.git" - } - ], "require-dev": { "brain/faker": "dev-master", "brain/monkey": "^2.6.1", @@ -46,7 +40,7 @@ "require": { "php": "^7.4 || >=8.0", "erusev/parsedown": "^1.7.4", - "infinum/eightshift-forms-utils": "1.3.0" + "infinum/eightshift-forms-utils": "^1.3.0" }, "suggest": { "ext-pcov": "* || This extension is used for code coverage generation. Use either pcov, or xdebug, but not both.", From 058e1dc9670c370600c4f56ece47771738095cfd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Mon, 11 Mar 2024 08:36:46 +0100 Subject: [PATCH 29/35] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Goran Alković <77000136+goranalkovic-infinum@users.noreply.github.com> --- CHANGELOG.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63fb8f3b0..5ffd5e38d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,20 +9,20 @@ This projects adheres to [Semantic Versioning](https://semver.org/) and [Keep a ### Added - `range` field for the forms. - `singleSubmit` attribute on all fields to allow only one submit per form to be used as calculation form. -- Result output custom post type. +- "Result output" custom post type. - Blocks for the result output. - Calculator form type and necessary filters. - Forms can now use `single submit` option to send data without submit button. - Setting for single form to hide global msg on submit success. ### Changed -- `Input` fields now output email and URL as a correct type so it can be user on mobile devices. -- Admin listing url can now support additional type. +- `Input` fields now output correct types for e-mail and URL fields, so the experience on mobile devices should be much better. +- Admin listing URLs can now support additional types. - All icons are now used from utils lib. ### Fixed - JS errors when missing data. -- Broken url for admin listing when using custom post type. +- Broken URLs for admin listing when using custom post types. ### Removed - Unnecessary options in the `rating` field. From cc4ce007ec023a1fb9b6857286cd145086b2ed89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Mon, 11 Mar 2024 08:37:38 +0100 Subject: [PATCH 30/35] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Denis Žoljom --- src/AdminMenus/FormAdminMenu.php | 39 +++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/src/AdminMenus/FormAdminMenu.php b/src/AdminMenus/FormAdminMenu.php index 26f8da08b..c9ca9f4e6 100644 --- a/src/AdminMenus/FormAdminMenu.php +++ b/src/AdminMenus/FormAdminMenu.php @@ -227,14 +227,30 @@ protected function processAttributes($attr): array // Translators: %s is the form title. 'adminListingPageTitle' => $this->getMultilangTitle(\__('Deleted result outputs', 'eightshift-forms')), // Translators: %s is the number of trashed forms. - 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 trashed result output.', 'eightshift-forms') : \sprintf(\__('Showing %s trashed result outputs.', 'eightshift-forms'), $count), + 'adminListingPageSubTitle' => \sprintf( + _n( + 'Showing %d trashed result output.', + 'Showing %d trashed result outputs.', + $count, + 'eightshift-forms' + ), + $count + ), ]; } else { $output = [ // Translators: %s is the form title. 'adminListingPageTitle' => $this->getMultilangTitle(\__('Deleted forms', 'eightshift-forms')), // Translators: %s is the number of trashed forms. - 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 trashed form.', 'eightshift-forms') : \sprintf(\__('Showing %s trashed forms.', 'eightshift-forms'), $count), + 'adminListingPageSubTitle' => \sprintf( + _n( + 'Showing %d trashed form.', + 'Showing %d trashed forms.', + $count, + 'eightshift-forms' + ), + $count + ), ]; } break; @@ -246,7 +262,15 @@ protected function processAttributes($attr): array // Translators: %s is the form title. 'adminListingPageTitle' => $this->getMultilangTitle(\__('Result outputs', 'eightshift-forms')), // Translators: %s is the number of trashed forms. - 'adminListingPageSubTitle' => $count === 1 ? \__('Showing 1 result output.', 'eightshift-forms') : \sprintf(\__('Showing %s result outputs.', 'eightshift-forms'), $count), + 'adminListingPageSubTitle' => \sprintf( + _n( + 'Showing %d result output.', + 'Showing %d result outputs.', + $count, + 'eightshift-forms' + ), + $count + ), ]; break; default: @@ -325,7 +349,7 @@ private function getNoItemsMessage(string $type, string $parent): array // Translators: %s is the link to the forms listing page. 'highlightedContentSubtitle' => \sprintf(\__(' Your don\'t have any result outputs in trash.
-
Go to result outputs', 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_RESULTS, '', $parent)), +
Go to result outputs', 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl(UtilsConfig::SLUG_ADMIN_LISTING_RESULTS, '', esc_url($parent))), 'highlightedContentIcon' => 'emptyStateTrash', ]), ]; @@ -336,7 +360,7 @@ private function getNoItemsMessage(string $type, string $parent): array // Translators: %s is the link to the forms listing page. 'highlightedContentSubtitle' => \sprintf(\__(' Your don\'t have any form in trash.
-
Go to your forms', 'eightshift-forms'), $listingUrl), +
Go to your forms', 'eightshift-forms'), esc_url($listingUrl)), 'highlightedContentIcon' => 'emptyStateTrash', ]), ]; @@ -349,7 +373,7 @@ private function getNoItemsMessage(string $type, string $parent): array // Translators: %s is the link to the forms listing page. 'highlightedContentSubtitle' => \sprintf(\__(' Your don\'t have any result outputs.
-
Go to your forms', 'eightshift-forms'), UtilsGeneralHelper::getListingPageUrl()), +
Go to your forms', 'eightshift-forms'), esc_url(UtilsGeneralHelper::getListingPageUrl())), 'highlightedContentIcon' => 'emptyStateResults', ]), ]; @@ -373,7 +397,7 @@ private function getNoItemsMessage(string $type, string $parent): array // Translators: %s is the link to the forms listing page. 'highlightedContentSubtitle' => \sprintf(\__(' You don\'t have any forms to show.
-
Add your first form', 'eightshift-forms'), UtilsGeneralHelper::getNewFormPageUrl(Forms::POST_TYPE_SLUG)), +
Add your first form', 'eightshift-forms'), esc_url(UtilsGeneralHelper::getNewFormPageUrl(Forms::POST_TYPE_SLUG))), 'highlightedContentIcon' => 'emptyStateFormList', ]), ]; @@ -683,7 +707,6 @@ private function getListingItems(array $items, string $type, string $parent): ar $title = \get_the_title($id); $output[] = Components::render('card-inline', [ - // Translators: %1$s is the post type, %2$s is the post title. 'cardInlineTitle' => $title . ($isDevMode ? " ({$id})" : ''), 'cardInlineTitleLink' => $editLink, 'cardInlineSubTitle' => \implode(', ', $this->getSubtitle($item, ['status'])), From 7a98d44e725019485c9cf0fc97c076165686193f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Mon, 11 Mar 2024 08:43:15 +0100 Subject: [PATCH 31/35] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Denis Žoljom Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> Co-authored-by: Goran Alković <77000136+goranalkovic-infinum@users.noreply.github.com> --- src/AdminMenus/FormListingAdminSubMenu.php | 4 ++-- src/Blocks/components/form/assets/utils.js | 2 +- .../components/result-output-item-editor.js | 2 +- .../components/result-output-item-options.js | 8 ++++---- .../result-output-item/result-output-item-editor.scss | 4 ++-- .../result-output/components/result-output-editor.js | 6 ++---- .../result-output/components/result-output-options.js | 7 ++++--- src/Blocks/custom/result-output/result-output-editor.scss | 4 ++-- src/CustomPostType/Result.php | 2 +- src/Editor/Editor.php | 2 +- src/General/SettingsGeneral.php | 4 +++- src/Integrations/Calculator/SettingsCalculator.php | 2 +- src/Listing/FormsListing.php | 6 +----- src/Rest/Routes/AbstractFormSubmit.php | 2 +- src/Rest/Routes/Settings/BulkRoute.php | 4 ++-- 15 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/AdminMenus/FormListingAdminSubMenu.php b/src/AdminMenus/FormListingAdminSubMenu.php index 1c7855912..5f333d845 100644 --- a/src/AdminMenus/FormListingAdminSubMenu.php +++ b/src/AdminMenus/FormListingAdminSubMenu.php @@ -60,7 +60,7 @@ function () { 20 ); - \add_action('admin_menu', [$this, 'addCustomLinkIntoAppearnaceMenu'], 32); + \add_action('admin_menu', [$this, 'addCustomLinkIntoAppearanceMenu'], 32); } /** @@ -181,7 +181,7 @@ protected function processAttributes($attr): array * * @return void */ - public function addCustomLinkIntoAppearnaceMenu(): void + public function addCustomLinkIntoAppearanceMenu(): void { global $submenu; diff --git a/src/Blocks/components/form/assets/utils.js b/src/Blocks/components/form/assets/utils.js index def6164b7..67d07a849 100644 --- a/src/Blocks/components/form/assets/utils.js +++ b/src/Blocks/components/form/assets/utils.js @@ -275,7 +275,7 @@ export class Utils { messageContainer?.classList?.add(this.state.getStateSelector('isActive')); messageContainer.dataset.status = status; - // Scroll to msg if the condition is right. + // Scroll to msg if the condition is matched. if (status === 'success') { if (this.state.getStateFormGlobalMsgHideOnSuccess(formId)) { return; diff --git a/src/Blocks/custom/result-output-item/components/result-output-item-editor.js b/src/Blocks/custom/result-output-item/components/result-output-item-editor.js index d0fe11077..77e772749 100644 --- a/src/Blocks/custom/result-output-item/components/result-output-item-editor.js +++ b/src/Blocks/custom/result-output-item/components/result-output-item-editor.js @@ -16,7 +16,7 @@ export const ResultOutputItemEditor = ({ attributes, clientId }) => {
- {__('Show if the following condition match:', 'eightshift-forms')} + {__('Show if the following condition matches:', 'eightshift-forms')}

{resultOutputItemName} = {resultOutputItemValue} diff --git a/src/Blocks/custom/result-output-item/components/result-output-item-options.js b/src/Blocks/custom/result-output-item/components/result-output-item-options.js index 6599d4957..c8e1fb4f9 100644 --- a/src/Blocks/custom/result-output-item/components/result-output-item-options.js +++ b/src/Blocks/custom/result-output-item/components/result-output-item-options.js @@ -15,19 +15,19 @@ export const ResultOutputItemOptions = ({ return ( } + label={} value={resultOutputItemName} onChange={(value) => setAttributes({ [getAttrKey('resultOutputItemName', attributes, manifest)]: value })} /> } + label={} value={resultOutputItemValue} onChange={(value) => setAttributes({ [getAttrKey('resultOutputItemValue', attributes, manifest)]: value })} /> diff --git a/src/Blocks/custom/result-output-item/result-output-item-editor.scss b/src/Blocks/custom/result-output-item/result-output-item-editor.scss index b0409f0db..77dac6948 100644 --- a/src/Blocks/custom/result-output-item/result-output-item-editor.scss +++ b/src/Blocks/custom/result-output-item/result-output-item-editor.scss @@ -5,8 +5,8 @@ &::before { content: ''; - width: 100%; - height: 1px; + inline-size: 100%; + block-size: 1px; display: block; background-color: var(--global-colors-esf-gray-300); } diff --git a/src/Blocks/custom/result-output/components/result-output-editor.js b/src/Blocks/custom/result-output/components/result-output-editor.js index b1c457f01..ad3059c06 100644 --- a/src/Blocks/custom/result-output/components/result-output-editor.js +++ b/src/Blocks/custom/result-output/components/result-output-editor.js @@ -41,7 +41,7 @@ export const ResultOutputEditor = ({ > { @@ -60,7 +60,7 @@ export const ResultOutputEditor = ({ { @@ -81,7 +81,6 @@ export const ResultOutputEditor = ({ } return ( - <> - ); }; diff --git a/src/Blocks/custom/result-output/components/result-output-options.js b/src/Blocks/custom/result-output/components/result-output-options.js index 5001a6d79..0cbba3528 100644 --- a/src/Blocks/custom/result-output/components/result-output-options.js +++ b/src/Blocks/custom/result-output/components/result-output-options.js @@ -29,7 +29,7 @@ export const ResultOutputOptions = ({ { @@ -47,7 +47,7 @@ export const ResultOutputOptions = ({ { @@ -66,9 +66,10 @@ export const ResultOutputOptions = ({ setAttributes({ [getAttrKey('resultOutputHide', attributes, manifest)]: value })} + noBottomSpacing /> ); diff --git a/src/Blocks/custom/result-output/result-output-editor.scss b/src/Blocks/custom/result-output/result-output-editor.scss index d7a6b2926..a755b73ee 100644 --- a/src/Blocks/custom/result-output/result-output-editor.scss +++ b/src/Blocks/custom/result-output/result-output-editor.scss @@ -5,8 +5,8 @@ &::before { content: ''; - width: 100%; - height: 1px; + inline-size: 100%; + block-size: 1px; display: block; background-color: var(--global-colors-esf-gray-300); } diff --git a/src/CustomPostType/Result.php b/src/CustomPostType/Result.php index 94b6391e5..fc73f932a 100644 --- a/src/CustomPostType/Result.php +++ b/src/CustomPostType/Result.php @@ -1,7 +1,7 @@ getListOfLinks($type); - $typeKey = $type === Forms::POST_TYPE_SLUG ? '' : UtilsConfig::SLUG_ADMIN_LISTING_RESULTS; + $typeKey = ($type === Forms::POST_TYPE_SLUG) ? '' : UtilsConfig::SLUG_ADMIN_LISTING_RESULTS; if (\in_array($actualUrl, $links, true)) { echo ''; // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped diff --git a/src/General/SettingsGeneral.php b/src/General/SettingsGeneral.php index 254c8396b..78e18a484 100644 --- a/src/General/SettingsGeneral.php +++ b/src/General/SettingsGeneral.php @@ -325,7 +325,9 @@ function ($selectOption) use ($successRedirectVariation) { By selecting single submit form your form will not wait for the click on the submit button. The form will submit data to the server as soon as the user changes are made.

- Not all fields are supported with this option. Supported fields: + Not all fields are supported with this option. +
+ Supported fields are:
  • Input range
  • Checkbox
  • diff --git a/src/Integrations/Calculator/SettingsCalculator.php b/src/Integrations/Calculator/SettingsCalculator.php index c7d89eeea..7f16bdd8f 100644 --- a/src/Integrations/Calculator/SettingsCalculator.php +++ b/src/Integrations/Calculator/SettingsCalculator.php @@ -90,7 +90,7 @@ public function getSettingsGlobalData(): array 'tabContent' => [ [ 'component' => 'intro', - 'introSubtitle' => \__('Calculator is uses to output dinamic data to the user, it doesn\'t send any emails or is not integrated with any integration.', 'eightshift-forms'), + 'introSubtitle' => \__('Calculator is used to output dynamic data to the user, it doesn\'t send any emails nor is implemented in any integration.', 'eightshift-forms'), ], ], ], diff --git a/src/Listing/FormsListing.php b/src/Listing/FormsListing.php index 7ab616212..9a8a465d4 100644 --- a/src/Listing/FormsListing.php +++ b/src/Listing/FormsListing.php @@ -38,11 +38,7 @@ public function getFormsList(string $type = '', string $parent = ''): array switch ($type) { case UtilsConfig::SLUG_ADMIN_LISTING_TRASH: - $postType = Forms::POST_TYPE_SLUG; - - if ($parent === UtilsConfig::SLUG_ADMIN_LISTING_RESULTS) { - $postType = Result::POST_TYPE_SLUG; - } + $postType = ($parent === UtilsConfig::SLUG_ADMIN_LISTING_RESULTS) ? Result::POST_TYPE_SLUG : Forms::POST_TYPE_SLUG; $showTrash = true; break; case UtilsConfig::SLUG_ADMIN_LISTING_RESULTS: diff --git a/src/Rest/Routes/AbstractFormSubmit.php b/src/Rest/Routes/AbstractFormSubmit.php index 223a6e0d6..1a6c32be4 100644 --- a/src/Rest/Routes/AbstractFormSubmit.php +++ b/src/Rest/Routes/AbstractFormSubmit.php @@ -403,7 +403,7 @@ protected function getIntegrationCommonSubmitOutput(array $formDetails, string $ $this->getFormSubmitMailer()->sendEmails($formDetails); } - // Output result output items as a response key. + // Return result output items as a response key. $filterName = UtilsHooksHelper::getFilterName(['block', 'form', 'resultOutputItems']); if (\has_filter($filterName)) { $additionalOutput[UtilsHelper::getStateResponseOutputKey('resultOutputItems')] = \apply_filters($filterName, [], $formDetails, $formId) ?? []; diff --git a/src/Rest/Routes/Settings/BulkRoute.php b/src/Rest/Routes/Settings/BulkRoute.php index e5430c0f4..c44c4e8b5 100644 --- a/src/Rest/Routes/Settings/BulkRoute.php +++ b/src/Rest/Routes/Settings/BulkRoute.php @@ -224,7 +224,7 @@ private function output(array $details, string $type): array if (\count($details) > 1) { $msgOutput = [ // translators: %s replaces type. - \sprintf(\esc_html__('Not all items were %s with success. Please check the following log.', 'eightshift-forms'), $intrernaType, $msg), + \sprintf(\esc_html__('Not all items were %s with success. Please check the following log.', 'eightshift-forms'), $intrernaType), ]; if ($error) { @@ -265,7 +265,7 @@ private function output(array $details, string $type): array return [ 'status' => 'error', - 'msg' => \esc_html__('There was and error on all selected items.', 'eightshift-forms'), + 'msg' => \esc_html__('There was an error on all selected items.', 'eightshift-forms'), ]; } From 9c70861593fe3f5415089213ef2576fffb14ab3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Mon, 11 Mar 2024 09:02:26 +0100 Subject: [PATCH 32/35] update --- composer.json | 4 ---- src/Integrations/Calculator/SettingsCalculator.php | 10 ++-------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/composer.json b/composer.json index 34453edb3..424ffacf5 100644 --- a/composer.json +++ b/composer.json @@ -42,10 +42,6 @@ "erusev/parsedown": "^1.7.4", "infinum/eightshift-forms-utils": "^1.3.0" }, - "suggest": { - "ext-pcov": "* || This extension is used for code coverage generation. Use either pcov, or xdebug, but not both.", - "ext-xdebug": "^3.0.0 || This extension is used for code coverage generation. Use either pcov, or xdebug, but not both." - }, "autoload": { "psr-4": { "EightshiftForms\\": "src/" diff --git a/src/Integrations/Calculator/SettingsCalculator.php b/src/Integrations/Calculator/SettingsCalculator.php index 7f16bdd8f..8af7e9695 100644 --- a/src/Integrations/Calculator/SettingsCalculator.php +++ b/src/Integrations/Calculator/SettingsCalculator.php @@ -58,13 +58,7 @@ public function register(): void */ public function isSettingsGlobalValid(): bool { - $isUsed = UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_CALCULATOR_USE_KEY, self::SETTINGS_CALCULATOR_USE_KEY); - - if (!$isUsed) { - return false; - } - - return true; + return UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_CALCULATOR_USE_KEY, self::SETTINGS_CALCULATOR_USE_KEY); } /** @@ -75,7 +69,7 @@ public function isSettingsGlobalValid(): bool public function getSettingsGlobalData(): array { // Bailout if feature is not active. - if (!UtilsSettingsHelper::isOptionCheckboxChecked(self::SETTINGS_CALCULATOR_USE_KEY, self::SETTINGS_CALCULATOR_USE_KEY)) { + if (!$this->isSettingsGlobalValid()) { return UtilsSettingsOutputHelper::getNoActiveFeature(); } From e285efa6219cf0c9289ac3ebf803fbde5a217251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ruz=CC=8Cevic=CC=81?= Date: Mon, 11 Mar 2024 09:05:06 +0100 Subject: [PATCH 33/35] update --- src/Editor/Editor.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Editor/Editor.php b/src/Editor/Editor.php index d0ba914cc..caa16b97d 100644 --- a/src/Editor/Editor.php +++ b/src/Editor/Editor.php @@ -50,7 +50,7 @@ public function getEditorBackLink(): void $typeKey = ($type === Forms::POST_TYPE_SLUG) ? '' : UtilsConfig::SLUG_ADMIN_LISTING_RESULTS; - if (\in_array($actualUrl, $links, true)) { + if (isset($links[$actualUrl])) { echo ''; // phpcs:ignore Eightshift.Security.ComponentsEscape.OutputNotEscaped } } @@ -66,12 +66,12 @@ public function getEditorBackLink(): void private function getListOfLinks(string $type): array { return [ - \get_admin_url(null, "edit.php?post_type={$type}"), - \get_admin_url(null, "edit.php?post_status=publish&post_type={$type}"), - \get_admin_url(null, "edit.php?post_status=draft&post_type={$type}"), - \get_admin_url(null, "edit.php?post_status=trash&post_type={$type}"), - \get_admin_url(null, "edit.php?post_status=publish&post_type={$type}"), - \get_admin_url(null, "edit.php?post_status=future&post_type={$type}"), + \get_admin_url(null, "edit.php?post_type={$type}") => '', + \get_admin_url(null, "edit.php?post_status=publish&post_type={$type}") => '', + \get_admin_url(null, "edit.php?post_status=draft&post_type={$type}") => '', + \get_admin_url(null, "edit.php?post_status=trash&post_type={$type}") => '', + \get_admin_url(null, "edit.php?post_status=publish&post_type={$type}") => '', + \get_admin_url(null, "edit.php?post_status=future&post_type={$type}") => '', ]; } } From d44467728af09610aa32aaf8f80e3efc89364af8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ivan=20Ru=C5=BEevi=C4=87?= Date: Mon, 11 Mar 2024 09:58:47 +0100 Subject: [PATCH 34/35] Update src/Blocks/custom/result-output/components/result-output-options.js Co-authored-by: Ivan Ramljak <22823970+piqusy@users.noreply.github.com> --- .../custom/result-output/components/result-output-options.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Blocks/custom/result-output/components/result-output-options.js b/src/Blocks/custom/result-output/components/result-output-options.js index 0cbba3528..390c50314 100644 --- a/src/Blocks/custom/result-output/components/result-output-options.js +++ b/src/Blocks/custom/result-output/components/result-output-options.js @@ -26,7 +26,7 @@ export const ResultOutputOptions = ({ const resultOutputHide = checkAttr('resultOutputHide', attributes, manifest); return ( - + Date: Mon, 11 Mar 2024 10:12:43 +0100 Subject: [PATCH 35/35] update --- src/Blocks/components/form/assets/utils.js | 8 ++-- .../input/components/input-editor.js | 38 +++++++++---------- .../components/form-selector-editor.js | 4 +- .../custom/forms/components/forms-editor.js | 2 +- .../components/result-output-item-options.js | 2 +- .../components/result-output-editor.js | 2 +- 6 files changed, 27 insertions(+), 29 deletions(-) diff --git a/src/Blocks/components/form/assets/utils.js b/src/Blocks/components/form/assets/utils.js index 67d07a849..9523794a5 100644 --- a/src/Blocks/components/form/assets/utils.js +++ b/src/Blocks/components/form/assets/utils.js @@ -1277,11 +1277,9 @@ export class Utils { for(const [key, value] of Object.entries(outputItems)) { const itemElement = outputElement.querySelectorAll(`${this.state.getStateSelector('resultOutputItem', true)}[${this.state.getStateAttribute('resultOutputItemKey')}="${key}"][${this.state.getStateAttribute('resultOutputItemValue')}="${value}"]`); - if (itemElement.length) { - itemElement.forEach((item) => { - item.classList.remove(this.state.getStateSelector('isHidden')); - }); - } + itemElement.forEach((item) => { + item.classList.remove(this.state.getStateSelector('isHidden')); + }); } } diff --git a/src/Blocks/components/input/components/input-editor.js b/src/Blocks/components/input/components/input-editor.js index 57f15b76a..2ae3984c6 100644 --- a/src/Blocks/components/input/components/input-editor.js +++ b/src/Blocks/components/input/components/input-editor.js @@ -35,27 +35,27 @@ export const InputEditor = (attributes) => { selector(additionalClass, additionalClass), ]); + let additionalProps = {}; + + if (inputType === 'range') { + additionalProps = { + min: inputMin, + max: inputMax, + step: inputStep, + value: inputValue ?? inputMin, + }; + } + const input = ( <> - {inputType === 'range' ? - : - - } + diff --git a/src/Blocks/custom/form-selector/components/form-selector-editor.js b/src/Blocks/custom/form-selector/components/form-selector-editor.js index 00f71bbed..4b398d39e 100644 --- a/src/Blocks/custom/form-selector/components/form-selector-editor.js +++ b/src/Blocks/custom/form-selector/components/form-selector-editor.js @@ -26,10 +26,10 @@ export const FormSelectorEditor = ({ {!hasInnerBlocks && {__('Eightshift Forms', 'productive')}} + label={{__('Eightshift Forms', 'eightshift-forms')}} className='es-max-w-108 es-rounded-3! es-mx-auto! es-font-weight-400 es-color-cool-gray-500! es-nested-color-current!' > -

    {__('What type is your new form?', 'productive')}

    +

    {__('What type is your new form?', 'eightshift-forms')}

    {forms.length > 0 &&
    {forms.map((form, index) => { diff --git a/src/Blocks/custom/forms/components/forms-editor.js b/src/Blocks/custom/forms/components/forms-editor.js index 07db36576..2a8efed07 100644 --- a/src/Blocks/custom/forms/components/forms-editor.js +++ b/src/Blocks/custom/forms/components/forms-editor.js @@ -41,7 +41,7 @@ export const FormsEditor = ({ return ( {__('Eightshift Forms', 'productive')}} + label={{__('Eightshift Forms', 'eightshift-forms')}} className='es-max-w-80 es-rounded-3! es-mx-auto! es-font-weight-400 es-color-cool-gray-500! es-nested-color-current!' > + } value={resultOutputItemName} diff --git a/src/Blocks/custom/result-output/components/result-output-editor.js b/src/Blocks/custom/result-output/components/result-output-editor.js index ad3059c06..5cfc89468 100644 --- a/src/Blocks/custom/result-output/components/result-output-editor.js +++ b/src/Blocks/custom/result-output/components/result-output-editor.js @@ -36,7 +36,7 @@ export const ResultOutputEditor = ({ return ( {__('Eightshift Forms - Result output', 'productive')}} + label={{__('Eightshift Forms - Result output', 'eightshift-forms')}} className='es-max-w-80 es-rounded-3! es-mx-auto! es-font-weight-400 es-color-cool-gray-500! es-nested-color-current!' >