app/views/admin/communication/websites/menus/items/kind_switch.js.erb
function displayAbout(kind, options) {
$('.js-url-field').addClass('d-none');
$('.js-about-fields').removeClass('d-none');
$('.js-about-type').val(kind);
$('.js-about-id').html(options);
}
function hideAbout() {
$('.js-about-fields').addClass('d-none');
}
<% if @kind == 'url' %>
$('.js-url-field').removeClass('d-none');
hideAbout();
<% elsif @kind == 'page' %>
<%
options = ['<option value="" label=" "></option>']
osuny_collection_tree(@collection, localized: true).each do |object|
options << "<option value=\"#{object.last}\">#{object.first}</option>"
end
%>
displayAbout('Communication::Website::Page', "<%= j(raw(options.join(''))) %>");
<% elsif @kind == 'diploma' %>
<%
options = ['<option value="" label=" "></option>']
osuny_collection(@collection, localized: true).each do |object|
options << "<option value=\"#{object.last}\">#{object.first}</option>"
end
%>
displayAbout('Education::Diploma', "<%= j(raw(options.join(''))) %>");
<% elsif @kind == 'program' %>
<%
options = ['<option value="" label=" "></option>']
osuny_collection_tree(@collection, localized: true).each do |object|
options << "<option value=\"#{object.last}\">#{object.first}</option>"
end
%>
displayAbout('Education::Program', "<%= j(raw(options.join(''))) %>");
<% elsif @kind == 'category' %>
<%
options = ['<option value="" label=" "></option>']
osuny_collection_tree(@collection, localized: true).each do |object|
options << "<option value=\"#{object.last}\">#{object.first}</option>"
end
%>
displayAbout('Communication::Website::Post::Category', "<%= j(raw(options.join(''))) %>");
<% elsif @kind == 'post' %>
<%
options = ['<option value="" label=" "></option>']
osuny_collection(@collection, localized: true).each do |object|
options << "<option value=\"#{object.last}\">#{object.first}</option>"
end
%>
displayAbout('Communication::Website::Post', "<%= j(raw(options.join(''))) %>");
<% elsif @kind == 'volume' %>
<%
options = ['<option value="" label=" "></option>']
osuny_collection(@collection, localized: true).each do |object|
options << "<option value=\"#{object.last}\">#{object.first}</option>"
end
%>
displayAbout('Research::Journal::Volume', "<%= j(raw(options.join(''))) %>");
<% elsif @kind == 'paper' %>
<%
options = ['<option value="" label=" "></option>']
osuny_collection(@collection, localized: true).each do |object|
options << "<option value=\"#{object.last}\">#{object.first}</option>"
end
%>
displayAbout('Research::Journal::Paper', "<%= j(raw(options.join(''))) %>");
<% elsif @kind == 'location' %>
<%
options = ['<option value="" label=" "></option>']
osuny_collection(@collection, localized: true).each do |object|
options << "<option value=\"#{object.last}\">#{object.first}</option>"
end
%>
displayAbout('Administration::Location', "<%= j(raw(options.join(''))) %>");
<% else %>
$('.js-url-field').addClass('d-none');
hideAbout();
<% end %>