Skip to content

Commit

Permalink
FIX: incorrect calculated value after form load
Browse files Browse the repository at this point in the history
Crocoblock/issues-tracker#9529
  • Loading branch information
girafffee committed May 30, 2024
1 parent 1661928 commit 54a606b
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 17 deletions.
2 changes: 1 addition & 1 deletion assets/js/frontend/calculated.field.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '1e68fa6acb1d10d32eb5');
<?php return array('dependencies' => array(), 'version' => '0eb9d00c7daf73dd6cb8');
2 changes: 1 addition & 1 deletion assets/js/frontend/calculated.field.js

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

2 changes: 1 addition & 1 deletion assets/js/frontend/media.field.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => '8612f7a0ea7ccd0c8acf');
<?php return array('dependencies' => array(), 'version' => '13db00400395be9becb9');
2 changes: 1 addition & 1 deletion assets/js/frontend/media.field.js

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

2 changes: 2 additions & 0 deletions assets/src/frontend/calculated.field/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ function CalculatedData() {

// calculated field can't be validated
this.report = () => {};

this.reQueryValue = () => {};
}

CalculatedData.prototype = Object.create( InputData.prototype );
Expand Down
2 changes: 2 additions & 0 deletions assets/src/frontend/media.field/input.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ function FileData() {
};

this.initNotifyValue = () => {};

this.reQueryValue = () => {};
}

FileData.prototype = Object.create( InputData.prototype );
Expand Down
19 changes: 15 additions & 4 deletions includes/blocks/types/calculated-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,24 @@ public function register_block_type() {
}

public function register_scripts() {
$script_asset = require_once jet_form_builder()->plugin_dir(
'assets/js/frontend/calculated.field.asset.php'
);

if ( true === $script_asset ) {
return;
}

array_push(
$script_asset['dependencies'],
Manager::MAIN_SCRIPT_HANDLE
);

wp_register_script(
self::HANDLE,
Plugin::instance()->plugin_url( 'assets/js/frontend/calculated.field.js' ),
array(
Manager::MAIN_SCRIPT_HANDLE,
),
Plugin::instance()->get_version(),
$script_asset['dependencies'],
$script_asset['version'],
true
);
}
Expand Down
37 changes: 28 additions & 9 deletions includes/blocks/types/media-field.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,20 @@ public function register_block_type() {
}

public function register_scripts() {
$script_asset = require_once jet_form_builder()->plugin_dir(
'assets/js/frontend/media.field.asset.php'
);

if ( true === $script_asset ) {
return;
}

array_push(
$script_asset['dependencies'],
Module::MAIN_SCRIPT_HANDLE,
'jet-form-builder-sortable'
);

wp_register_script(
'jet-form-builder-sortable',
Plugin::instance()->plugin_url( 'assets/lib/jquery-sortable/sortable.js' ),
Expand All @@ -133,20 +147,25 @@ public function register_scripts() {
wp_register_script(
self::HANDLE,
Plugin::instance()->plugin_url( 'assets/js/frontend/media.field.js' ),
array(
Module::MAIN_SCRIPT_HANDLE,
'jet-form-builder-sortable',
),
Plugin::instance()->get_version(),
$script_asset['dependencies'],
$script_asset['version'],
true
);

$script_asset = require_once jet_form_builder()->plugin_dir(
'assets/js/frontend/media.field.restrictions.asset.php'
);

array_push(
$script_asset['dependencies'],
\JFB_Modules\Validation\Module::HANDLE
);

wp_register_script(
self::RESTRICTIONS,
Plugin::instance()->plugin_url( 'assets/js/frontend/media.field.restrictions.js' ),
array(
\JFB_Modules\Validation\Module::HANDLE,
),
Plugin::instance()->get_version(),
$script_asset['dependencies'],
$script_asset['version'],
true
);
}
Expand Down

0 comments on commit 54a606b

Please sign in to comment.