<commit_before>%fieldset
  .action_btns{:"data-inclusion-grid" => panel.params["inclusion_grid"], :"data-exclusion-grid" => panel.params["exclusion_grid"]}
    = button_tag '❮❮ Add', type: 'button', class: 'btn success', id: 'add_btn', disabled: true
    = button_tag 'Remove ❯❯', type: 'button', class: 'btn danger', id: 'remove_btn', disabled: true

:javascript
  $(function(){
    // Include record
    $(".action_btns #add_btn").off('click').on('click', function(){
      btnHander('add');
    });
    
    // Exclude record
    $(".action_btns #remove_btn").off('click').on('click', function(){
      btnHander('remove');
    });

    function btnHander(type) {
      var ids;
      var inclusionGridName = $(".action_btns").data("inclusion-grid");
      var exclusionGridName = $(".action_btns").data("exclusion-grid");

      var inclusionGrid = gridManager.getGrid(inclusionGridName);
      var exclusionGrid = gridManager.getGrid(exclusionGridName);

      if(!inclusionGrid || !exclusionGrid) return false;

      if (type == 'add') {
        ids = exclusionGrid.getSelectedIds(); 
      } else if (type == 'remove') {
        ids = inclusionGrid.getSelectedIds();
      }
      
      if (ids.length > 0) {
        setupRequest(type, ids, inclusionGrid, exclusionGrid);
      }
    }
    
    function setupRequest(type, ids, inclusionGrid, exclusionGrid) {
      var groupGrid;
      for(var i in inclusionGrid.behaviors) {
        if(inclusionGrid.behaviors[i].name == 'affiliation') {
          groupGrid = gridManager.getGrid(inclusionGrid.behaviors[i].master_grid_name);
          break;
        }
      }
      if(!groupGrid) return false;

      var groupId = groupGrid.getSelectedIds()[0];
      if(!groupId) return false;
      
      // Start the request
      $('.action_btns button').attr('disabled', 'disabled');

      var url;
      if(type == 'add') {
        url = '/wulin_master/include';
      } else {
        url = '/wulin_master/exclude';
      }
      var data = {group_model: groupGrid.model, group_id: groupId, include_model: inclusionGrid.model, exclude_model: exclusionGrid.model,
                  ids: ids, authenticity_token: window._token};

      $.post(url, data, function(response) {
        if(response.status == 'OK') {
          inclusionGrid.loader.reloadData();
          exclusionGrid.loader.reloadData();
          inclusionGrid.resetActiveCell();
          exclusionGrid.resetActiveCell();
          displayNewNotification(response.message);
        } else {
          displayErrorMessage(response.message);
        }
     });
    }
  })<commit_msg>BUG #10945 - Master Detail- Add / Remove icon not displaying in Chrome PC (and probably other PC browsers as well)<commit_after>%fieldset
  .action_btns{:"data-inclusion-grid" => panel.params["inclusion_grid"], :"data-exclusion-grid" => panel.params["exclusion_grid"]}
    = button_tag '<< Add', type: 'button', class: 'btn success', id: 'add_btn', disabled: true
    = button_tag 'Remove >>', type: 'button', class: 'btn danger', id: 'remove_btn', disabled: true

:javascript
  $(function(){
    // Include record
    $(".action_btns #add_btn").off('click').on('click', function(){
      btnHander('add');
    });
    
    // Exclude record
    $(".action_btns #remove_btn").off('click').on('click', function(){
      btnHander('remove');
    });

    function btnHander(type) {
      var ids;
      var inclusionGridName = $(".action_btns").data("inclusion-grid");
      var exclusionGridName = $(".action_btns").data("exclusion-grid");

      var inclusionGrid = gridManager.getGrid(inclusionGridName);
      var exclusionGrid = gridManager.getGrid(exclusionGridName);

      if(!inclusionGrid || !exclusionGrid) return false;

      if (type == 'add') {
        ids = exclusionGrid.getSelectedIds(); 
      } else if (type == 'remove') {
        ids = inclusionGrid.getSelectedIds();
      }
      
      if (ids.length > 0) {
        setupRequest(type, ids, inclusionGrid, exclusionGrid);
      }
    }
    
    function setupRequest(type, ids, inclusionGrid, exclusionGrid) {
      var groupGrid;
      for(var i in inclusionGrid.behaviors) {
        if(inclusionGrid.behaviors[i].name == 'affiliation') {
          groupGrid = gridManager.getGrid(inclusionGrid.behaviors[i].master_grid_name);
          break;
        }
      }
      if(!groupGrid) return false;

      var groupId = groupGrid.getSelectedIds()[0];
      if(!groupId) return false;
      
      // Start the request
      $('.action_btns button').attr('disabled', 'disabled');

      var url;
      if(type == 'add') {
        url = '/wulin_master/include';
      } else {
        url = '/wulin_master/exclude';
      }
      var data = {group_model: groupGrid.model, group_id: groupId, include_model: inclusionGrid.model, exclude_model: exclusionGrid.model,
                  ids: ids, authenticity_token: window._token};

      $.post(url, data, function(response) {
        if(response.status == 'OK') {
          inclusionGrid.loader.reloadData();
          exclusionGrid.loader.reloadData();
          inclusionGrid.resetActiveCell();
          exclusionGrid.resetActiveCell();
          displayNewNotification(response.message);
        } else {
          displayErrorMessage(response.message);
        }
     });
    }
  })
{'fraction_non_alphanumeric': 0.14552309142318567, 'fraction_numerical': 0.0016965127238454288, 'mean_word_length': 2.7954220314735334, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 11, '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': '375779', 'n_tokens_mistral': 1597, 'n_tokens_neox': 1555, 'n_words': 310}