Project

General

Profile

Defect #22975 » change_the_list_of_parent_pages_when_changing_project.patch

Mizuki ISHIKAWA, 2018-03-07 06:30

View differences:

app/views/wiki/rename.html.erb
<p><%= f.check_box :is_start_page, :label => :field_start_page, :disabled => @page.is_start_page %></p>
<% end %>
<p><%= f.check_box :redirect_existing_links %></p>
<% if @page.safe_attribute? 'wiki_id' %>
<p><%= f.select :wiki_id, wiki_page_wiki_options_for_select(@page), :label => :label_project %></p>
<% end %>
<p><%= f.select :parent_id,
content_tag('option', '', :value => '') +
wiki_page_options_for_select(
......
@page.parent),
:label => :field_parent_title %></p>
<% if @page.safe_attribute? 'wiki_id' %>
<p><%= f.select :wiki_id, wiki_page_wiki_options_for_select(@page), :label => :label_project %></p>
<% end %>
</div>
<%= submit_tag l(:button_rename) %>
<% end %>
<%= javascript_tag do %>
$('#wiki_page_wiki_id').change(function() {
$.ajax({
url: '<%= rename_project_wiki_page_path(@wiki, :format => 'js') %>',
type: 'get',
data: { 'wiki_page[wiki_id]': $('#wiki_page_wiki_id').val() }
});
});
<% end %>
app/views/wiki/rename.js.erb
<% select = select_tag('wiki_page[parent_id]', (content_tag('option', '', :value => '') + wiki_page_options_for_select(@page.wiki.pages.includes(:parent).to_a - @page.self_and_descendants, @page.parent)), :label => :field_parent_title) %>
$('#wiki_page_parent_id').replaceWith('<%= escape_javascript(select) %>');
(2-2/2)