From b5542456b9d9850e53d4d2f1603870bba3b13b29 Mon Sep 17 00:00:00 2001 From: andrewshuba Date: Thu, 18 Jun 2020 13:28:38 +0300 Subject: [PATCH] -fix conditional logic after image/file upload/remove --- assets/js/um-conditional.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/assets/js/um-conditional.js b/assets/js/um-conditional.js index f694af55..8fbc2adb 100644 --- a/assets/js/um-conditional.js +++ b/assets/js/um-conditional.js @@ -221,6 +221,9 @@ function um_apply_conditions( $dom, is_single_update ) { var field_type = um_get_field_type( $dom.parents('.um-field[data-key]') ); var live_field_value = um_get_field_data( $dom ); + if (live_field_value === 'empty_file') { + live_field_value = ''; + } var $owners = {}; var $owners_values = {}; @@ -628,6 +631,27 @@ jQuery(document).ready( function (){ um_apply_conditions(me, false); }); + jQuery(document).on('change', '.um-field-image input[type="hidden"],.um-field-file input[type="hidden"]', function () { + var me = jQuery(this); + um_apply_conditions(me, false); + }); + + jQuery(document).on('click', '.um-finish-upload', function () { + var key = jQuery(this).attr('data-key'); + var me = jQuery('.um-field-'+key+' input'); + setTimeout(function () { + um_apply_conditions(me, false); + }, 100); + }); + + jQuery(document).on('click', '.um-field .cancel', function () { + var key = jQuery(this).parent().attr('data-key'); + var me = jQuery('.um-field-'+key+' input'); + setTimeout(function () { + um_apply_conditions(me, false); + }, 1000); + }); + jQuery(document).on('um_fields_change', function () { um_field_hide_siblings(); um_field_hide_siblings(); // dupes, issue with false field wrapper's visiblity validations. requires optimization.