<% add_decidim_page_title(t("categories.index.categories_title", scope: "decidim.admin")) %>

<%= t("categories.index.categories_title", scope: "decidim.admin") %> <% if allowed_to? :create, :category %> <%= link_to t("actions.category.new", scope: "decidim.admin"), new_category_path(current_participatory_space), class: "button button__sm button__secondary new ml-auto" %> <% end %>

<% if current_participatory_space.categories.any? %>
<% current_participatory_space.categories.first_class.each do |category| %> <% category.subcategories.each do |subcategory| %> <% end %> <% end %>
<%= t("activemodel.attributes.category.name") %>
<%= link_to translated_attribute(category.name), edit_category_path(current_participatory_space, category) %>
<% if allowed_to? :update, :category, category: category %> <%= icon_link_to "pencil-line", edit_category_path(current_participatory_space, category), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %> <% end %> <% if allowed_to? :destroy, :category, category: category %> <% if category.unused? %> <%= icon_link_to "delete-bin-line", category_path(current_participatory_space, category), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %> <% else %> <%= icon "delete-bin-line", class: "action-icon action-icon--disabled", role: "img", "aria-hidden": true %> <% end %> <% end %>
<%= link_to translated_attribute(subcategory.name), edit_category_path(current_participatory_space, subcategory) %>
<% if allowed_to? :update, :category, category: subcategory %> <%= icon_link_to "pencil-line", edit_category_path(current_participatory_space, subcategory), t("actions.edit", scope: "decidim.admin"), class: "action-icon--edit" %> <% end %> <% if allowed_to? :destroy, :category, category: subcategory %> <% if subcategory.unused? %> <%= icon_link_to "delete-bin-line", category_path(current_participatory_space, subcategory), t("actions.destroy", scope: "decidim.admin"), class: "action-icon--remove", method: :delete, data: { confirm: t("actions.confirm_destroy", scope: "decidim.admin") } %> <% else %> <%= icon "delete-bin-line", class: "action-icon action-icon--disabled", role: "img", "aria-hidden": true %> <% end %> <% end %>
<% end %>