<commit_before>- if @grid.action_names.include?('add') || @grid.action_names.include?('hotkey_add') 
  :ruby
    model_name = @grid.model.name.underscore
    columns = @grid.columns.dup.delete_if {|x| x.name.to_s == 'id' }
    datepicker_str = ''
    object = @grid.model.new
  .create_form{:id => "#{@grid.name}_form", :title => "Create new #{model_name.titleize}", data: {action: 'create'}}
    = form_for object, :url => @grid.path do |form|
      .base_error
      - columns.each do |column|
        - if new_form_able?(column)
          :ruby
            column_name = get_column_name(column)
            label = column.options[:form_label] || column.label
          .field{:name => column_name}
            %label{:for => "#{model_name}_#{column_name}"}= label
            - if column.sql_type.to_s == 'belongs_to'
              = form.select column_name,                            |
                select_options(column),                             |
                { include_blank: !column.presence_required? },      |
                :class             => 'chzn-select',                |
                :style             => "width:250px",                |
                :disabled          => column.options[:auto_fill],   |
                "data-required"    => column.presence_required?,    |
                "data-text-attr"   => column.option_text_attribute, |
                "data-target"      => "#{column_name}_target_flag", |
                "data-column"       => column.name                  |

            - elsif column.sql_type.to_s == 'has_and_belongs_to_many' or column.sql_type.to_s == 'has_many'
              = form.select column.reflection.name.to_s,            |
                select_options(column),                             |
                { include_blank: !column.presence_required? },      |
                :multiple          => true,                         |
                :class             => 'chzn-select',                |
                :style             => "width:250px",                |
                "data-required"    => column.presence_required?,    |
                "data-text-attr"   => column.option_text_attribute, |
                "data-target"      => "#{column_name}_target_flag", |
                "data-column"      => column.name,                  |
                :disabled          => column.options[:auto_fill]    |

            - elsif select_tag_field?(column)
              = select_tag "#{model_name}[#{column_name}]",          |
                select_tag_options(column),                          |
                :style             => "width:250px",                 |
                :class             => 'chzn-select',                 |
                :disabled          => column.options[:auto_fill],    |
                :include_blank     => !column.presence_required?,    |
                "data-required"    => column.presence_required?,     |
                "data-target"      => "#{column_name}_target_flag",  |
                "data-text-attr"   => column.option_text_attribute,  |
                "data-column"      => column.name                    |
              - if column.options[:depend_column].present?
                :javascript
                  $(function(){
                    var depend_select_id = "#{model_name}_#{column.options[:depend_column]}";
                    var depend_select = $("select#" + depend_select_id);

                    depend_select.live('change', function(){
                      var current_select_id = "#{model_name}_#{column_name}";
                      var current_select = $("select#" + current_select_id);
                      var key = $(this).val();
                      current_select.find("option").hide().trigger("liszt:updated");
                      current_select.val("").trigger("liszt:updated");
                      current_select.find("option[data-key='" + key + "']").show().css("display", "").trigger("liszt:updated");
                    });
                  });
                  
            - elsif column.options[:file]
              = form.file_field column_name, "data-target" => "#{column_name}_target_flag", "data-column" => column.name, :style => 'width: 250px'
            - elsif column.options[:password]
              = form.password_field column_name, "data-target" => "#{column_name}_target_flag", "data-column" => column.name, :style => 'width: 250px'
            - else
              - if column.sql_type.to_s.downcase == 'boolean'
                = form.check_box column_name, :readonly => column.options[:auto_fill], "data-target" => "#{column_name}_target_flag", "data-column" => column.name
              - elsif column.sql_type.to_s.downcase == 'text'
                = form.text_area column_name, :readonly => column.options[:auto_fill], "data-target" => "#{column_name}_target_flag", "data-column" => column.name, :style => 'width: 260px; height: 4em;'
              - else
                = form.text_field column_name, :style => 'width: 250px', :value => column.value(object), :readonly => column.options[:auto_fill], "data-target" => "#{column_name}_target_flag", 'data-date' => date_column?(column), 'data-datetime' => datetime_column?(column), 'data-time' => time_column?(column), "data-column" => column.name
            .field_error
      .submit
        %input.btn.success{:id => "#{@grid.name}_submit", :name => "commit", :type => "submit", :value => " Create "}/
        %input.btn{:id => "#{@grid.name}_submit_continue", :name => "commit", :type => "submit", :value => " Create and Continue "}/
  :javascript
    $('##{@grid.name}_form select[data-required="true"]').chosen();
    $('##{@grid.name}_form select[data-required="false"]').chosen({allow_single_deselect: true});
    $('input[data-date]').datepicker({ dateFormat: 'yy-mm-dd' });
    $('input[data-datetime]').datetimepicker({
      onlyTime: false,
      dateFormat: "yy-mm-dd",
      timeFormat: 'HH:mm',
      timeOnly: false,
      stepMinute: 1,
      minuteGrid: 0,
      beforeShow: function() { calendarOpen = true },
      onClose: function() { calendarOpen = false }
    });
    $('input[data-time]').timepicker({});<commit_msg>BUG - Grid and screen name needs to be passed in the parameters when creating objects<commit_after>- if @grid.action_names.include?('add') || @grid.action_names.include?('hotkey_add') 
  :ruby
    model_name = @grid.model.name.underscore
    columns = @grid.columns.dup.delete_if {|x| x.name.to_s == 'id' }
    datepicker_str = ''
    object = @grid.model.new
  .create_form{:id => "#{@grid.name}_form", :title => "Create new #{model_name.titleize}", data: {action: 'create'}}
    = form_for object, :url => @grid.path do |form|
      = hidden_field_tag :grid, @grid.class.to_s
      = hidden_field_tag :screen, @screen.class.to_s
      .base_error
      - columns.each do |column|
        - if new_form_able?(column)
          :ruby
            column_name = get_column_name(column)
            label = column.options[:form_label] || column.label
          .field{:name => column_name}
            %label{:for => "#{model_name}_#{column_name}"}= label
            - if column.sql_type.to_s == 'belongs_to'
              = form.select column_name,                            |
                select_options(column),                             |
                { include_blank: !column.presence_required? },      |
                :class             => 'chzn-select',                |
                :style             => "width:250px",                |
                :disabled          => column.options[:auto_fill],   |
                "data-required"    => column.presence_required?,    |
                "data-text-attr"   => column.option_text_attribute, |
                "data-target"      => "#{column_name}_target_flag", |
                "data-column"       => column.name                  |

            - elsif column.sql_type.to_s == 'has_and_belongs_to_many' or column.sql_type.to_s == 'has_many'
              = form.select column.reflection.name.to_s,            |
                select_options(column),                             |
                { include_blank: !column.presence_required? },      |
                :multiple          => true,                         |
                :class             => 'chzn-select',                |
                :style             => "width:250px",                |
                "data-required"    => column.presence_required?,    |
                "data-text-attr"   => column.option_text_attribute, |
                "data-target"      => "#{column_name}_target_flag", |
                "data-column"      => column.name,                  |
                :disabled          => column.options[:auto_fill]    |

            - elsif select_tag_field?(column)
              = select_tag "#{model_name}[#{column_name}]",          |
                select_tag_options(column),                          |
                :style             => "width:250px",                 |
                :class             => 'chzn-select',                 |
                :disabled          => column.options[:auto_fill],    |
                :include_blank     => !column.presence_required?,    |
                "data-required"    => column.presence_required?,     |
                "data-target"      => "#{column_name}_target_flag",  |
                "data-text-attr"   => column.option_text_attribute,  |
                "data-column"      => column.name                    |
              - if column.options[:depend_column].present?
                :javascript
                  $(function(){
                    var depend_select_id = "#{model_name}_#{column.options[:depend_column]}";
                    var depend_select = $("select#" + depend_select_id);

                    depend_select.live('change', function(){
                      var current_select_id = "#{model_name}_#{column_name}";
                      var current_select = $("select#" + current_select_id);
                      var key = $(this).val();
                      current_select.find("option").hide().trigger("liszt:updated");
                      current_select.val("").trigger("liszt:updated");
                      current_select.find("option[data-key='" + key + "']").show().css("display", "").trigger("liszt:updated");
                    });
                  });
                  
            - elsif column.options[:file]
              = form.file_field column_name, "data-target" => "#{column_name}_target_flag", "data-column" => column.name, :style => 'width: 250px'
            - elsif column.options[:password]
              = form.password_field column_name, "data-target" => "#{column_name}_target_flag", "data-column" => column.name, :style => 'width: 250px'
            - else
              - if column.sql_type.to_s.downcase == 'boolean'
                = form.check_box column_name, :readonly => column.options[:auto_fill], "data-target" => "#{column_name}_target_flag", "data-column" => column.name
              - elsif column.sql_type.to_s.downcase == 'text'
                = form.text_area column_name, :readonly => column.options[:auto_fill], "data-target" => "#{column_name}_target_flag", "data-column" => column.name, :style => 'width: 260px; height: 4em;'
              - else
                = form.text_field column_name, :style => 'width: 250px', :value => column.value(object), :readonly => column.options[:auto_fill], "data-target" => "#{column_name}_target_flag", 'data-date' => date_column?(column), 'data-datetime' => datetime_column?(column), 'data-time' => time_column?(column), "data-column" => column.name
            .field_error
      .submit
        %input.btn.success{:id => "#{@grid.name}_submit", :name => "commit", :type => "submit", :value => " Create "}/
        %input.btn{:id => "#{@grid.name}_submit_continue", :name => "commit", :type => "submit", :value => " Create and Continue "}/
  :javascript
    $('##{@grid.name}_form select[data-required="true"]').chosen();
    $('##{@grid.name}_form select[data-required="false"]').chosen({allow_single_deselect: true});
    $('input[data-date]').datepicker({ dateFormat: 'yy-mm-dd' });
    $('input[data-datetime]').datetimepicker({
      onlyTime: false,
      dateFormat: "yy-mm-dd",
      timeFormat: 'HH:mm',
      timeOnly: false,
      stepMinute: 1,
      minuteGrid: 0,
      beforeShow: function() { calendarOpen = true },
      onClose: function() { calendarOpen = false }
    });
    $('input[data-time]').timepicker({});
{'fraction_non_alphanumeric': 0.15258141382049245, 'fraction_numerical': 0.003812549642573471, 'mean_word_length': 1.7727372825368861, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 117, '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': '4525590', 'n_tokens_mistral': 3656, 'n_tokens_neox': 3503, 'n_words': 553}