Skip to content

Feat/template views - #23

Merged
neatzzy merged 3 commits into
sprint-2from
feat/template-views
Jun 12, 2026
Merged

Feat/template views#23
neatzzy merged 3 commits into
sprint-2from
feat/template-views

Conversation

@gusfring41

Copy link
Copy Markdown
Owner

template feature

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces an admin “Gerenciamento” layout and new UI/UX for managing Templates, including nested “elementos/campos” editing in a modal-style form, and updates routing to expose Templates under /admin.

Changes:

  • Added /admin navigation (Avaliações/Gerenciamento) with a new gerenciamento layout and stylesheet.
  • Moved Templates CRUD to admin-scoped routes (/admin/templates) and updated controller/views accordingly.
  • Implemented a dynamic nested form for Template -> elementos -> campos with client-side add/remove behavior and SVG icon helpers.

Reviewed changes

Copilot reviewed 21 out of 24 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
features/step_definitions/template_steps.rb Adds Cucumber steps for template CRUD scenarios via admin routes.
config/routes.rb Introduces /admin pages and scopes templates under /admin.
app/views/templates/show.html.erb Removes legacy “show” page content.
app/views/templates/new.html.erb Reworks new view to render grid + modal form partials.
app/views/templates/index.html.erb Reworks index to render the new templates grid.
app/views/templates/edit.html.erb Reworks edit view to render grid + modal form partials.
app/views/templates/edit_template.html.erb Adds a view rendering _template_form partial.
app/views/templates/_template.html.erb Removes legacy template partial.
app/views/templates/_template_form.html.erb Adds a simple template form partial with custom URL helpers.
app/views/templates/_grid.html.erb Adds card-grid UI for listing/editing/deleting templates.
app/views/templates/_form.html.erb Adds modal nested form + inline JS for dynamic elementos/campos editing.
app/views/layouts/gerenciamento.html.erb Adds new admin layout shell (header/sidebar/flash area).
app/views/admin/index.html.erb Removes legacy admin index content.
app/views/admin/gerenciamento.html.erb Adds “Gerenciamento” UI with SIGAA actions + template link.
app/views/admin/avaliacoes.html.erb Adds placeholder “Avaliações” view.
app/models/template.rb Adds custom validations for title/elementos/campos completeness.
app/models/elemento.rb Enables nested attributes for campos and removes ordem validations.
app/helpers/application_helper.rb Adds svg_icon helper to render inline SVG icons.
app/controllers/templates_controller.rb Adapts templates controller for admin-scoped flow + nested params.
app/controllers/admin_controller.rb Splits admin into avaliacoes and gerenciamento actions + layout.
app/assets/stylesheets/gerenciamento.css Adds styling for the new admin layout and templates UI.
app/assets/images/icons/trash.svg Adds trash icon used in templates grid.
app/assets/images/icons/edit.svg Adds edit icon used in templates grid.
app/assets/images/icons/create.svg Adds create icon (currently not referenced in shown diffs).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +189 to +193
const optionsContainer = block.querySelector('.options-container');
const elementIndex = block.getAttribute('data-element-index');
const optionIndex = Date.now();
const tipoVal = block.querySelector('.select-tipo').value;
const orderValue = optionsContainer.querySelectorAll('.option-row:not(.deleted-option)').length + 1;
Comment on lines +152 to +166
window.toggleOptionsVisibility = function(selectElement) {
const block = selectElement.closest('.question-block');
if (!block) return;

const optionRows = block.querySelectorAll('.option-row:not(.deleted-option)');
const btnAddOption = block.querySelector('.btn-add-option');

if (selectElement.value === 'Texto') {
optionRows.forEach(row => row.style.display = 'none');
if (btnAddOption) btnAddOption.style.display = 'none';
} else {
optionRows.forEach(row => row.style.display = 'flex');
if (btnAddOption) btnAddOption.style.display = 'inline-block';
}
};
Comment on lines +1 to +3
<%= form_with model: @template,
url: @template.persisted? ? update_admin_template_path(@template) : create_admin_template_path,
method: @template.persisted? ? :patch : :post do |f| %>
Comment thread config/routes.rb
Comment on lines +34 to +37
get "/admin", to: redirect("/admin/avaliacoes")

get "/admin/avaliacoes", to: "admin#avaliacoes", as: :admin_avaliacoes
get "/admin/gerenciamento", to: "admin#gerenciamento", as: :admin_gerenciamento
Comment on lines 1 to 11
module ApplicationHelper
def svg_icon(name, options = {})
file_path = Rails.root.join('app', 'assets', 'images', 'icons', "#{name}.svg")
if File.exist?(file_path)
svg = File.read(file_path).html_safe
content_tag(:span, svg, options.merge(class: "icon-wrapper #{options[:class]}"))
else
"(ícone não encontrado)"
end
end
end
Comment on lines +19 to +22
<%= button_to admin_template_path(template), method: :delete,
form: { data: { turbo_confirm: "..." } },
class: "action-btn button-to-clean",
aria: { label: "Deletar" } do %>
Comment on lines +29 to +32
<%= link_to new_admin_template_path, class: "card-create-new" do %>
<span style="display: none;">Adicionar novo template</span>
+
<% end %>
Comment on lines +13 to +15
<%= button_to "Enviar Formulários", atualizar_sigaa_path, method: :post, class: "btn-figma" %>

<%= button_to "Resultados", importar_sigaa_path, method: :post, class: "btn-figma" %>
Comment on lines +15 to +18
<%= form_with model: @template,
url: @template.persisted? ? admin_template_path(@template) : admin_templates_path,
method: @template.persisted? ? :patch : :post,
data: { turbo_frame: "_top" },

@neatzzy neatzzy left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ta show

@neatzzy
neatzzy merged commit d2110ef into sprint-2 Jun 12, 2026
2 of 6 checks passed
@neatzzy
neatzzy deleted the feat/template-views branch June 12, 2026 00:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants