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
13 13
<p><%= f.check_box :is_start_page, :label => :field_start_page, :disabled => @page.is_start_page %></p>
14 14
<% end %>
15 15
<p><%= f.check_box :redirect_existing_links %></p>
16
<% if @page.safe_attribute? 'wiki_id' %>
17
<p><%= f.select :wiki_id, wiki_page_wiki_options_for_select(@page), :label => :label_project %></p>
18
<% end %>
16 19
<p><%= f.select :parent_id,
17 20
                content_tag('option', '', :value => '') + 
18 21
                  wiki_page_options_for_select(
......
20 23
                    @page.parent),
21 24
                :label => :field_parent_title %></p>
22 25

  
23
<% if @page.safe_attribute? 'wiki_id' %>
24
<p><%= f.select :wiki_id, wiki_page_wiki_options_for_select(@page), :label => :label_project %></p>
25
<% end %>
26

  
27 26
</div>
28 27
<%= submit_tag l(:button_rename) %>
29 28
<% end %>
29

  
30
<%= javascript_tag do %>
31
$('#wiki_page_wiki_id').change(function() {
32
  $.ajax({
33
    url: '<%= rename_project_wiki_page_path(@wiki, :format => 'js') %>',
34
    type: 'get',
35
    data: { 'wiki_page[wiki_id]': $('#wiki_page_wiki_id').val() }
36
  });
37
});
38
<% end %>
app/views/wiki/rename.js.erb
1
<% 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) %>
2
$('#wiki_page_parent_id').replaceWith('<%= escape_javascript(select) %>');
(2-2/2)