diff --git a/app/helpers/admin/application_helper.rb b/app/helpers/admin/application_helper.rb index 8eecec8163b92f288f2b0ad0d01f7f597964499b..91f5526ed5ad01a928e9abddfc2dac25a2465ae8 100644 --- a/app/helpers/admin/application_helper.rb +++ b/app/helpers/admin/application_helper.rb @@ -81,6 +81,21 @@ module Admin::ApplicationHelper collection end + def collection_tree_for_checkboxes(list, except = nil) + collection = collection_tree(list, except) + collection.map { |object| + [ + sanitize(object[:label]), + object[:id], + { + data: { + parent: object[:parent_id] + } + } + ] + } + end + private def polymorphic_url_param(object_or_class, **options) diff --git a/app/views/admin/communication/website/pages/static.html.erb b/app/views/admin/communication/website/pages/static.html.erb index e18d1756ccdbfd121b036017846de8dccb73cb41..58b3a4a9d61a06f73558901123a533780af55a5e 100644 --- a/app/views/admin/communication/website/pages/static.html.erb +++ b/app/views/admin/communication/website/pages/static.html.erb @@ -7,6 +7,9 @@ position: <%= @page.position %> image: "<%= @page.best_featured_image.blob.id %>" image_alt: "<%= @page.featured_image_alt %>" <% end %> +<% if @page.category %> +category: "<%= @page.category.path %>" +<% end %> description: > <%= prepare_for_github @page.description, @page.university %> --- diff --git a/app/views/admin/communication/website/posts/_form.html.erb b/app/views/admin/communication/website/posts/_form.html.erb index 953383672c28991ce41f213a991a34a0f4c85ab8..c96bd6db126780c99ed5ccd4da9cb474fbec37ae 100644 --- a/app/views/admin/communication/website/posts/_form.html.erb +++ b/app/views/admin/communication/website/posts/_form.html.erb @@ -11,6 +11,17 @@ <%= f.input :text, as: :rich_text_area %> </div> </div> + <div class="card flex-fill w-100"> + <div class="card-header"> + <h5 class="card-title mb-0"><%= t('activerecord.attributes.communication/website/post.categories') %></h5> + </div> + <div class="card-body"> + <%= f.association :categories, + label_text: false, + as: :check_boxes, + collection: collection_tree_for_checkboxes(@website.categories) if @website.categories.any? %> + </div> + </div> </div> <div class="col-md-4"> <div class="card flex-fill w-100"> @@ -28,13 +39,6 @@ <%= f.input :published_at, html5: true %> <%= f.input :pinned %> <%= f.association :author, collection: current_university.people.authors.ordered %> - <%= f.association :categories, - as: :check_boxes, - collection: collection_tree(@website.categories).map { |category| [ - sanitize(category[:label]), - category[:id], - { data: { parent: category[:parent_id] } } - ] } if @website.categories.any? %> </div> </div> <div class="card flex-fill w-100"> diff --git a/app/views/admin/education/programs/static.html.erb b/app/views/admin/education/programs/static.html.erb index 4fc644710346fc00df54796792e5f04b6a5acbba..e9396b25a1eb6e5633cc3cdda0b600827a3bab62 100644 --- a/app/views/admin/education/programs/static.html.erb +++ b/app/views/admin/education/programs/static.html.erb @@ -9,7 +9,7 @@ position: <%= @program.position %> image: "<%= @program.best_featured_image.blob.id %>" image_alt: "<%= @program.featured_image_alt %>" <% end %> -category: "<%= @website.categories.find_by(program_id: @program.id)&.id %>" +category: "<%= @website.categories.find_by(program_id: @program.id)&.path %>" teachers: <% @program.teachers.includes(:person).ordered.each do |teacher| %> - person: "<%= teacher.person.slug %>"