Skip to content

Commit

Permalink
Merge branch '5.0/checkbox-cf-indeterminate-state' into 5.0-trunk
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrandtbuffalo committed Feb 16, 2024
2 parents 5d9b751 + 589138d commit 2c3f9c0
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions share/html/Elements/EditCustomFieldSelect
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,24 @@
<div class="custom-control custom-checkbox">
<input id="<% $name . '-Display' %>" type="checkbox" class="custom-control-input" data-checked-value="<% $TrueValue %>" data-unchecked-value="<% $FalseValue %>" value-target="#<% $name %>" <% $isChecked ? "checked" : "" %> />
<label class="custom-control-label" for="<% $name . '-Display' %>"></label>
<input type="hidden" id="<% $name %>" name="<% $name %>" class="custom-control" value="<% $isChecked ? $TrueValue : $FalseValue %>" />
<input type="hidden" id="<% $name %>" name="<% $name %>" class="custom-control"
% if ( !$ARGS{ShowEmptyOption} ) {
value="<% $isChecked ? $TrueValue : $FalseValue %>"
% }
/>
</div>
<script type="text/javascript">
var id = <% $name |n,j %>;
id = id.replace(/:/g,'\\:');
jQuery('#' + id + '-Display').change(function() {
jQuery('#' + id).val(jQuery(this).is(':checked') ? jQuery(this).data('checked-value') : jQuery(this).data('unchecked-value'));
var target = jQuery(this).attr('id').replace(/-Display$/, '').replace(/:/g,'\\:');
jQuery('#' + target).val(jQuery(this).is(':checked') ? jQuery(this).data('checked-value') : jQuery(this).data('unchecked-value'));
jQuery('#' + target).prop('disabled', false);
});
%# Show indeterminate status for pages like bulk update to not update values by default.
% if ( $ARGS{ShowEmptyOption} ) {
jQuery('#' + id + '-Display').prop ('indeterminate', true);
% }
</script>
% } else {
% if (@category) {
Expand Down

0 comments on commit 2c3f9c0

Please sign in to comment.