<commit_before><div class="modal fade" id="personModal" role="dialog" tabindex='-1'>
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>               
         <h4 class="modal-title" id="personModalTitle"></h4>
      </div>    
      <div class="modal-body" id="personModalBody">
      </div>
    </div>
  </div>
</div> <!-- / modal -->

<div class="modal fade" id="personMessageModal" role="dialog" tabindex='-1'>
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>               
        <h4 class="modal-title" id="personMessageModalTitle">Send Message</h4>
      </div>    
      <div id="personmessage_modal" class="modal-body">
            <form id="person_message_form" method="POST">
            <textarea name="body" cols="40" rows="4"></textarea><br>
            <input type="radio" value="BULKSMS" name="message_type" CHECKED>SMS only</input><br>
            <input type="radio" value="BULKMAIL" name="message_type">Email only</input><br>
            <input type="radio" value="BULKALL" name="message_type">SMS and Email</input><br>
            <input class="btn btn-sm btn-dark" id="sendmessage" type="submit" name="submit" value="Send">
            </form>
      </div>
    </div>
  </div>
</div> <!-- / modal -->

<script>

$(document).ready(function() {

    var selected_crewtable = setupSortable($( '#crew_table' ), true);

    // Scope rules makes me have to put this here and not just a part of
    // openMessageModal.
    $("#person_message_form").on('submit', function(eventObj) {
        var $btn = $(document.activeElement);
        var form = this;

        var rows_selected = selected_crewtable.column('.selectcol').checkboxes.selected();

      // Iterate over all selected checkboxes
      $.each(rows_selected, function(index, rowId){
         // Create a hidden element
         $(form).append(
             $('<input>')
                .attr('type', 'hidden')
                .attr('name', 'person_list[]')
                .val(rowId)
         );
      });
      var $btn = $(document.activeElement);
        if ($btn.is('[id]') && $btn.attr("id") == "sendmessage") {
            postdata = $("#person_message_form").serialize();
            $.ajax({
                type: "POST",
                url: "{{ path('persons_send_message') }}",
                data: postdata,
                success: function(data)
                {
                    alert(data);
                    $( "#personMessageModal" ).modal("hide");
                }
            });
        }
        eventObj.preventDefault();<commit_msg>Make it possible to not end up with dublettes of the person message form.<commit_after><div class="modal fade" id="personModal" role="dialog" tabindex='-1'>
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>               
         <h4 class="modal-title" id="personModalTitle"></h4>
      </div>    
      <div class="modal-body" id="personModalBody">
      </div>
    </div>
  </div>
</div> <!-- / modal -->

{% if no_message_modal is not defined or not no_message_modal %}
<div class="modal fade" id="personMessageModal" role="dialog" tabindex='-1'>
  <div class="modal-dialog">
    <!-- Modal content-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>               
        <h4 class="modal-title" id="personMessageModalTitle">Send Message</h4>
      </div>    
      <div id="personmessage_modal" class="modal-body">
            <form id="person_message_form" method="POST">
            <textarea name="body" cols="40" rows="4"></textarea><br>
            <input type="radio" value="BULKSMS" name="message_type" CHECKED>SMS only</input><br>
            <input type="radio" value="BULKMAIL" name="message_type">Email only</input><br>
            <input type="radio" value="BULKALL" name="message_type">SMS and Email</input><br>
            <input class="btn btn-sm btn-dark" id="sendPersonMessage" type="submit" name="submit" value="Send">
            </form>
      </div>
    </div>
  </div>
</div> <!-- / modal -->
{% endif %}

<script>

$(document).ready(function() {

    var selected_crewtable = setupSortable($( '#crew_table' ), true);

    // Scope rules makes me have to put this here and not just a part of
    // openMessageModal.
    $("#person_message_form").on('submit', function(eventObj) {
        var $btn = $(document.activeElement);
        var form = this;

        if (selected_crewtable) {
            var rows_selected = selected_crewtable.column('.selectcol').checkboxes.selected();

            // Iterate over all selected checkboxes
            $.each(rows_selected, function(index, rowId){
               // Create a hidden element
               $(form).append(
                   $('<input>')
                      .attr('type', 'hidden')
                      .attr('name', 'person_list[]')
                      .val(rowId)
               );
            });
        }
        var $btn = $(document.activeElement);
        if ($btn.is('[id]') && $btn.attr("id") == "sendPersonMessage") {
            postdata = $("#person_message_form").serialize();
            $.ajax({
                type: "POST",
                url: "{{ path('persons_send_message') }}",
                data: postdata,
                success: function(data)
                {
                    alert(data);
                    $( "#personMessageModal" ).modal("hide");
                }
            });
        }
        eventObj.preventDefault();
{'fraction_non_alphanumeric': 0.17038777908343125, 'fraction_numerical': 0.003021655195568239, 'mean_word_length': 2.206673842841765, 'pattern_counts': {'":': 0, '<': 101, '<?xml version=': 0, '>': 101, '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': '1677160', 'n_tokens_mistral': 1735, 'n_tokens_neox': 1690, 'n_words': 361}