<commit_before>moj.Modules.ReAllocation = {
  $CheckedClaimIdTemplate: $('<input type="hidden" name="allocation[claim_ids][]">'),
  $form: $('#new_allocation'),

  init: function (){
    var self = this;

    //Only work on the re-allocation page
    if($('.js-reallocation-report').length > 0){
      $('.report').on('change', ':checkbox', function (){
        var $element = $(this);

        if($element.is(':checked')){
          self.addCheckedClaim($element.val());
        }else{
          //TODO investigate why this was needed?
          self.removeUnCheckedClaim($element.val());
        }
      });
    }
  },

  addCheckedClaim: function (claim_id){
    var $clonedElement = this.$CheckedClaimIdTemplate.clone();
    var id = 'allocation_claim_ids_' + claim_id;

    $clonedElement
      .attr('id', id)
      .val(claim_id);

    //Add the new element to the form
    this.$form.append($clonedElement);
  },

  removeUnCheckedClaim: function (claim_id){
    var $form = this.$form;

    $form
      .find('#allocation_claim_ids_' + claim_id)
      .remove();
  }

};
<commit_msg>Add show/hide case worker select list based on what allocation option the user selected<commit_after>moj.Modules.ReAllocation = {
  $CheckedClaimIdTemplate: $('<input type="hidden" name="allocation[claim_ids][]">'),
  $form: $('#new_allocation'),
  $ReAllocationRadioButtons: $('.js-re-allocation-options'),
  $CaseWorkerList: $('.js-case-worker-list'),

  init: function (){
    var self = this;

    //Only work on the re-allocation page
    if($('.js-re-allocation-page').length > 0){

      //Show/Hide Case Workers select lists
      self.showHideCaseWorkersList();

      this.$ReAllocationRadioButtons.on('change', ':radio', function(){
        self.showHideCaseWorkersList();
      });

      //Selecting claims to be re-allocated functionality
      $('.report').on('change', ':checkbox', function (){
        var $element = $(this);

        if($element.is(':checked')){
          self.addCheckedClaim($element.val());
        }else{
          //TODO investigate why this was needed?
          self.removeUnCheckedClaim($element.val());
        }
      });
    }
  },

  showHideCaseWorkersList: function(){
    if(this.$ReAllocationRadioButtons.find(':checked').val() === 'false' ){
      this.$CaseWorkerList.slideDown();
    }else{
      this.$CaseWorkerList.slideUp();
    }
  },

  addCheckedClaim: function (claim_id){
    var $clonedElement = this.$CheckedClaimIdTemplate.clone();
    var id = 'allocation_claim_ids_' + claim_id;

    $clonedElement
      .attr('id', id)
      .val(claim_id);

    //Add the new element to the form
    this.$form.append($clonedElement);
  },

  removeUnCheckedClaim: function (claim_id){
    var $form = this.$form;

    $form
      .find('#allocation_claim_ids_' + claim_id)
      .remove();
  }

};

{'fraction_non_alphanumeric': 0.16274165202108964, 'fraction_numerical': 0.00070298769771529, 'mean_word_length': 2.9915848527349227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6813527', 'n_tokens_mistral': 901, 'n_tokens_neox': 877, 'n_words': 176}