(function() {
  var $page;

<% if @old_page_layout != @page.page_layout -%>
  Alchemy.ElementsWindow.reload();
  Alchemy.growl('<%= j Alchemy.t(:page_layout_changed_notice) %>');
<% end -%>

<% if @while_page_edit -%>

  Alchemy.reloadPreview();
  $('#page_<%= @page.id %>_status').replaceWith('<%= j render("page_status", page: @page) %>');

<% else -%>

  var page_html = "<%= j render('page', page: @page) %>";
  var compiler = Handlebars.compile(page_html);
  var tree = JSON.parse('<%== @tree.to_json %>');
  var html = compiler(tree.pages[0]);
  $('#page_<%= @page.id %>').replaceWith(html);
  $page = $('#page_<%= @page.id %>');

  <% if @page.locked? && @page.locker == current_alchemy_user -%>
    $('#locked_page_<%= @page.id %> > a').html('<%= @page.name %>');
  <% end -%>

  <% if @page.restricted? -%>
    $('.page_status:nth-child(3)', $page).addClass('restricted', 'not_restricted').removeClass('not_restricted');
  <% elsif @page.redirects_to_external? -%>
    $('span.redirect_url', $page).html('&raquo; <%= Alchemy.t("Redirects to") %>: <%= h @page.external_urlname %>');
  <% else -%>
    $('.page_status:nth-child(3)', $page).addClass('not_restricted').removeClass('restricted');
  <% end -%>

<% end -%>

  Alchemy.growl("<%= j @notice %>");
  Alchemy.closeCurrentDialog();
})()

(function() {
  var $page;

<% if @old_page_layout != @page.page_layout -%>
  Alchemy.ElementsWindow.reload();
  Alchemy.growl('<%= j Alchemy.t(:page_layout_changed_notice) %>');
<% end -%>

<% if @while_page_edit -%>

  Alchemy.reloadPreview();
  $('#page_<%= @page.id %>_status').replaceWith('<%= j render("current_page", current_page: @page) %>');

<% else -%>

  var page_html = "<%= j render('page', page: @page) %>";
  var compiler = Handlebars.compile(page_html);
  var tree = JSON.parse('<%== @tree.to_json %>');
  var html = compiler(tree.pages[0]);
  $('#page_<%= @page.id %>').replaceWith(html);

<% end -%>

  Alchemy.growl("<%= j @notice %>");
  Alchemy.closeCurrentDialog();
})()

Fix GUI update of page status
Fix GUI update of page status

1. In 9fb2fe58ad2caa2bb0d00a5f7e5331f77a4a15e5 we introduced a partial for page status, but forgot to properly replace the current page tab.

2. In 1a5b982a8563ec2ac28a6947dc834e656640969a we introduced to replace the current page in the sitemap with a compiled Handlebars template. Since the whole line gets replaced, we don't need to update each page status DOM element any more.
