<commit_before>- entity_name = controller.controller_name.singularize.underscore
- @entity = instance_variable_get("@#{entity_name}")
- create_id = "create_#{entity_name}"

- if @entity.valid?
  $('##{create_id}_arrow').html(crm.COLLAPSED);
  $('##{create_id}_title').html('#{ j t(entity_name.pluralize) }');
  $('##{create_id}').slideUp(250);
  $('##{entity_name.pluralize}').prepend('#{ j render(:partial => entity_name, :collection => [ @entity ]) }');
  $('##{dom_id(@entity)}').effect("highlight", { duration:1500 });

  - if called_from_index_page?
    = refresh_sidebar(:index, :filters)
    $('#paginate').html('#{ j render(:partial => "shared/paginate_with_per_page") }');
  - elsif called_from_landing_page?("accounts") # Opportunity created on Account landing page: refresh Account summary.
    - @account.reload
    = refresh_sidebar_for(:accounts, :show, :summary)
  - elsif called_from_landing_page?("campaigns") # Opportunity created on Campaign landing page: refresh Campaign summary.
    - @campaign.reload
    = refresh_sidebar_for(:campaigns, :show, :summary)
  - else # Opportunity created on Contact landing page: refresh recent items list.
    $('#recently').html('#{ j render(:partial => "shared/recently") }');
  crm.flick('empty', 'remove');

- else
  $('##{create_id}').html('#{ j render(:partial => "new") }');
  crm.create_or_select_account(#{ request.referer =~ /\/accounts\// || @account.id.blank? });
  $('##{create_id}').effect("shake", { duration:250, distance: 6 });
  $('#new_#{entity_name} input[type!=hidden]').first().focus();
<commit_msg>Fixed bug with recent items box replacement.<commit_after>- entity_name = controller.controller_name.singularize.underscore
- @entity = instance_variable_get("@#{entity_name}")
- create_id = "create_#{entity_name}"

- if @entity.valid?
  $('##{create_id}_arrow').html(crm.COLLAPSED);
  $('##{create_id}_title').html('#{ j t(entity_name.pluralize) }');
  $('##{create_id}').slideUp(250);
  $('##{entity_name.pluralize}').prepend('#{ j render(:partial => entity_name, :collection => [ @entity ]) }');
  $('##{dom_id(@entity)}').effect("highlight", { duration:1500 });

  - if called_from_index_page?
    = refresh_sidebar(:index, :filters)
    $('#paginate').html('#{ j render(:partial => "shared/paginate_with_per_page") }');
  - elsif called_from_landing_page?("accounts") # Opportunity created on Account landing page: refresh Account summary.
    - @account.reload
    = refresh_sidebar_for(:accounts, :show, :summary)
  - elsif called_from_landing_page?("campaigns") # Opportunity created on Campaign landing page: refresh Campaign summary.
    - @campaign.reload
    = refresh_sidebar_for(:campaigns, :show, :summary)
  - else # Opportunity created on Contact landing page: refresh recent items list.
    $('#recently').replaceWith('#{ j render(:partial => "shared/recently") }');
  crm.flick('empty', 'remove');

- else
  $('##{create_id}').html('#{ j render(:partial => "new") }');
  crm.create_or_select_account(#{ request.referer =~ /\/accounts\// || @account.id.blank? });
  $('##{create_id}').effect("shake", { duration:250, distance: 6 });
  $('#new_#{entity_name} input[type!=hidden]').first().focus();

{'fraction_non_alphanumeric': 0.20520050125313283, 'fraction_numerical': 0.006892230576441102, 'mean_word_length': 5.652083333333334, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '5921656', 'n_tokens_mistral': 1080, 'n_tokens_neox': 1051, 'n_words': 190}