Skip to content
Snippets Groups Projects
Commit 1121da76 authored by pabois's avatar pabois
Browse files

wip menu

parent 8ec70873
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,6 @@ window.osuny.communication.menuItems = {
this.switchUrl = this.kindInput.dataset.url;
this.kindInput.addEventListener('change', this.onKindChange.bind(this));
this.onKindChange();
},
onKindChange: function () {
......
......@@ -80,6 +80,10 @@ class Communication::Website::Menu::Item < ApplicationRecord
}
end
def has_about?
kind_page? || kind_program? || kind_news_category? || kind_news_article
end
protected
def set_position
......
......@@ -15,12 +15,24 @@
class: 'js-kind-input',
data: { url: kind_switch_admin_communication_website_menu_items_path }
} %>
<div class="d-none js-url-field">
<div class="<%= 'd-none' unless item.url? %> js-url-field">
<%= f.input :url, as: :string %>
</div>
<div class="d-none js-about-fields">
<%= f.input :about_type, as: :hidden, input_html: { class: 'js-about-id' } %>
<%= f.association :about, collection: @website.list_of_pages, label_method: ->(p) { sanitize p[:label] }, value_method: ->(p) { p[:id] }, input_html: { class: 'js-about-id' } %>
<div class="<%= 'd-none' unless item.has_about? %> js-about-fields">
<%
if item.has_about?
if item.kind_page?
about_collection = @website.list_of_pages
elsif item.kind_program?
elsif item.kind_news_category?
elsif item.kind_news_article?
end
else
about_collection = nil
end
%>
<%= f.input :about_type, as: :hidden, input_html: { class: 'js-about-type' } %>
<%= f.association :about, collection: about_collection, label_method: ->(p) { sanitize p[:label] }, value_method: ->(p) { p[:id] }, input_html: { class: 'js-about-id' } %>
</div>
</div>
</div>
......
function displayAbout(options) {
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);
}
......@@ -18,7 +19,7 @@ function hideAbout() {
options << "<option value=\"#{page[:id]}\">#{page[:label]}</option>"
end
%>
displayAbout("<%= j(raw(options.join(''))) %>");
displayAbout('Communication::Website::Page', "<%= j(raw(options.join(''))) %>");
<% elsif @kind == 'program' %>
displayAbout();
<% elsif @kind == 'news_category' %>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment