Skip to content

Commit

Permalink
Updated front JS
Browse files Browse the repository at this point in the history
  • Loading branch information
Krzysztof Piątkowski committed Jul 24, 2022
1 parent 6a8084c commit f8117ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
6 changes: 3 additions & 3 deletions assets/js/wckalkulator.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

if (wck_ajax_object.hasOwnProperty("_wck_visibility_rules") && wck_ajax_object._wck_visibility_rules !== null) {
$.each(wck_ajax_object._wck_visibility_rules, function (fieldName, options) {
$("[name*='wck[" + fieldName + "]']").hide().closest('tr').hide();
$("[name*='wck[" + fieldName + "]']").prop("disabled", true).hide().closest('tr').hide();
CV[fieldName] = options;
});
}
Expand Down Expand Up @@ -64,12 +64,12 @@
return state !== false;
});
if (state === true) {
$("[name*='wck[" + fieldName + "]']").show().closest('tr').show();
$("[name*='wck[" + fieldName + "]']").prop("disabled", false).show().closest('tr').show();
return false;
}
});
if (state !== true) {
$("[name*='wck[" + fieldName + "]']").hide().closest('tr').hide();
$("[name*='wck[" + fieldName + "]']").prop("disabled", true).hide().closest('tr').hide();
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion assets/js/wckalkulator.min.js

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions src/Fields/CheckboxgroupField.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public function render_for_product($selected_name = "")
*/
public function validate($value)
{
if (!$this->is_required() && empty($value)) {
return true;
}

if (is_array($value)) {

if (((int)$this->data('select_limit') > 0 && count($value) > $this->data('select_limit')) || ($this->is_required() && count($value) === 0)) {
Expand Down
6 changes: 3 additions & 3 deletions src/FieldsetProduct.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,9 +633,9 @@ public function register_extra_input_parameters($field, $input)
break;
case 'checkboxgroup':
$input = array_map('floatval', $input);
$this->user_input[$name . ':max'] = max($input);
$this->user_input[$name . ':min'] = min($input);
$this->user_input[$name . ':sum'] = array_sum($input);
$this->user_input[$name . ':max'] = count($input) > 0 ? max($input) : 0;
$this->user_input[$name . ':min'] = count($input) > 0 ? min($input) : 0;
$this->user_input[$name . ':sum'] = count($input) > 0 ? array_sum($input) : 0;
break;
case 'text':
case 'textarea':
Expand Down

0 comments on commit f8117ba

Please sign in to comment.