<commit_before><script type="text/javascript">

  // Form Validations
  // override jquery validate plugin defaults
  $.validator.setDefaults({
      highlight: function(element) {
          $(element).closest('.form-group').addClass('has-error');
      },
      unhighlight: function(element) {
          $(element).closest('.form-group').removeClass('has-error');
      },
      errorElement: 'span',
      errorClass: 'help-block',
      errorPlacement: function(error, element) {
          if(element.parent('.input-group').length) {
              error.insertAfter(element.parent());
          } else {
              error.insertAfter(element);
          }
      }
  }); 
  
  var user_detail_tab_key = 'assets_detail_tab_key';
  var user_profile_tab_key = 'assets_profile_tab_key';
  $(document).ready(function() {
   // Manage the tabs
    $('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
      // save the last tab selected
      var this_tab = $(this).attr('href');
      if ($(this).attr('data-panel') == 'profile') {
        transam.set_ui_key_value(user_profile_tab_key, this_tab);
      } else {
	transam.set_ui_key_value(user_detail_tab_key, this_tab);
      }
      if (this_tab == '#map') {
        invalidateMap();
      } else if (this_tab == '#chrt') {
        if (condition_chart) {
          draw_condition_chart();         
        }
        if (mileage_chart) {
          draw_mileage_chart();
        }
      }
  });


  $('[data-behavior~=component-picker]').on('change', function(event) {
      console.log({
          dependent_object_key: $(this).val(),
          dependent_subform_target: $(this).data('target'),
          dependent_subform_view: $(this).data('form-view')
      });
      if ($(this).val()) {
          $.ajax({
              url: "<%= get_dependent_subform_inventory_path(@asset) %>",
              type: 'GET',
              data: {
                  dependent_object_key: $(this).val(),
                  dependent_subform_target: $(this).data('target'),
                  dependent_subform_target_model: $(this).data('target-model'),
                  dependent_subform_view: $(this).data('form-view')
              }
          });
      }

  });

  $('[data-behavior~=component-picker]').change();

  $(function() {

    var last_detail_tab = transam.get_ui_key_value(user_detail_tab_key);
    if ((last_detail_tab) && ("<%= params[:use_last_tab] %>" == '1')) {
        $('#asset-details a[href="'+last_detail_tab+'"]').tab('show');
    } else {
        // Default to the first tab if no tab is stored
        $('#asset-details a[data-toggle="tab"]:first').tab('show');
    }

    var last_profile_tab = transam.get_ui_key_value(user_profile_tab_key);
    if ((last_profile_tab) && ("<%= params[:use_last_tab] %>" == '1')) {
        $('#profile a[href="'+last_profile_tab+'"]').tab('show');
    } else {
        // Default to the first tab if no tab is stored
        $('#profile a[data-toggle="tab"]:first').tab('show');
    }

    $('#pcnt_capital_responsibility_group').each(function() {
      if ($("input[name='direct_capital_responsibility']:checked").val() == 'no') {
        $(this).hide();
      }
    });
    
    $("input[name='direct_capital_responsibility']").on("click", function(value) {
      var pcnt_ctl = $('#pcnt_capital_responsibility');
      if ($(this).val() == 'yes') {
        $('#pcnt_capital_responsibility_group').show();
        // reset to 100
        pcnt_ctl.editable('setValue', 100);
        pcnt_ctl.editable('hide');
        pcnt_ctl.editable('show', false);
      } else {
        $('#pcnt_capital_responsibility_group').hide();
      }
    });

    $('#component_type_group').each(function() {
      if ($("input[name='facility_categorization']:checked").val() == '<%= Facility::CATEGORIZATION_COMPONENT %>') {
        $(this).show();
      } else {
        $(this).hide();
      }
    });
    $('#component_subtype_group').each(function() {
      if ($("input[name='facility_categorization']:checked").val() == '<%= Facility::CATEGORIZATION_SUBCOMPONENT %>') {
        $(this).show();
      } else {
        $(this).hide();
      }
    });

    $("input[name='facility_categorization']").on("click", function(value) {
      if ($(this).val() == '<%= Facility::CATEGORIZATION_COMPONENT %>') {
        $('#component_type_group').show();
        $('#component_subtype_group').hide();
      } else {
        $('#component_type_group').hide();
        $('#component_subtype_group').show();
      }
    });
<commit_msg>fix issue related to saving Direct Capital Responsibility option change<commit_after><script type="text/javascript">

  // Form Validations
  // override jquery validate plugin defaults
  $.validator.setDefaults({
      highlight: function(element) {
          $(element).closest('.form-group').addClass('has-error');
      },
      unhighlight: function(element) {
          $(element).closest('.form-group').removeClass('has-error');
      },
      errorElement: 'span',
      errorClass: 'help-block',
      errorPlacement: function(error, element) {
          if(element.parent('.input-group').length) {
              error.insertAfter(element.parent());
          } else {
              error.insertAfter(element);
          }
      }
  }); 
  
  var user_detail_tab_key = 'assets_detail_tab_key';
  var user_profile_tab_key = 'assets_profile_tab_key';
  $(document).ready(function() {
   // Manage the tabs
    $('a[data-toggle="tab"]').on('shown.bs.tab', function(e) {
      // save the last tab selected
      var this_tab = $(this).attr('href');
      if ($(this).attr('data-panel') == 'profile') {
        transam.set_ui_key_value(user_profile_tab_key, this_tab);
      } else {
	transam.set_ui_key_value(user_detail_tab_key, this_tab);
      }
      if (this_tab == '#map') {
        invalidateMap();
      } else if (this_tab == '#chrt') {
        if (condition_chart) {
          draw_condition_chart();         
        }
        if (mileage_chart) {
          draw_mileage_chart();
        }
      }
  });


  $('[data-behavior~=component-picker]').on('change', function(event) {
      console.log({
          dependent_object_key: $(this).val(),
          dependent_subform_target: $(this).data('target'),
          dependent_subform_view: $(this).data('form-view')
      });
      if ($(this).val()) {
          $.ajax({
              url: "<%= get_dependent_subform_inventory_path(@asset) %>",
              type: 'GET',
              data: {
                  dependent_object_key: $(this).val(),
                  dependent_subform_target: $(this).data('target'),
                  dependent_subform_target_model: $(this).data('target-model'),
                  dependent_subform_view: $(this).data('form-view')
              }
          });
      }

  });

  $('[data-behavior~=component-picker]').change();

  $(function() {

    var last_detail_tab = transam.get_ui_key_value(user_detail_tab_key);
    if ((last_detail_tab) && ("<%= params[:use_last_tab] %>" == '1')) {
        $('#asset-details a[href="'+last_detail_tab+'"]').tab('show');
    } else {
        // Default to the first tab if no tab is stored
        $('#asset-details a[data-toggle="tab"]:first').tab('show');
    }

    var last_profile_tab = transam.get_ui_key_value(user_profile_tab_key);
    if ((last_profile_tab) && ("<%= params[:use_last_tab] %>" == '1')) {
        $('#profile a[href="'+last_profile_tab+'"]').tab('show');
    } else {
        // Default to the first tab if no tab is stored
        $('#profile a[data-toggle="tab"]:first').tab('show');
    }

    $('#pcnt_capital_responsibility_group').each(function() {
      if ($("input[name='direct_capital_responsibility']:checked").val() == 'no') {
        $(this).hide();
      }
    });
    
    $("input[name='direct_capital_responsibility']").on("click", function(value) {
      var pcnt_ctl = $('#pcnt_capital_responsibility');
      if ($(this).val() == 'yes') {
        $('#pcnt_capital_responsibility_group').show();
        // reset to 100
        pcnt_ctl.editable('setValue', 100);
        pcnt_ctl.editable('hide');
        pcnt_ctl.editable('show', false);
      } else {
        pcnt_ctl.editable('setValue', '');
        pcnt_ctl.editable('hide');
        pcnt_ctl.editable('show', false);
        $('#pcnt_capital_responsibility_group').hide();
      }
    });

    $('#component_type_group').each(function() {
      if ($("input[name='facility_categorization']:checked").val() == '<%= Facility::CATEGORIZATION_COMPONENT %>') {
        $(this).show();
      } else {
        $(this).hide();
      }
    });
    $('#component_subtype_group').each(function() {
      if ($("input[name='facility_categorization']:checked").val() == '<%= Facility::CATEGORIZATION_SUBCOMPONENT %>') {
        $(this).show();
      } else {
        $(this).hide();
      }
    });

    $("input[name='facility_categorization']").on("click", function(value) {
      if ($(this).val() == '<%= Facility::CATEGORIZATION_COMPONENT %>') {
        $('#component_type_group').show();
        $('#component_subtype_group').hide();
      } else {
        $('#component_type_group').hide();
        $('#component_subtype_group').show();
      }
    });

{'fraction_non_alphanumeric': 0.18835542037801434, 'fraction_numerical': 0.0017379969585053225, 'mean_word_length': 2.6828, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5436268', 'n_tokens_mistral': 2914, 'n_tokens_neox': 2853, 'n_words': 389}