Feat/template views - #23
Merged
Merged
Conversation
There was a problem hiding this comment.
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
/adminnavigation (Avaliações/Gerenciamento) with a newgerenciamentolayout and stylesheet. - Moved Templates CRUD to admin-scoped routes (
/admin/templates) and updated controller/views accordingly. - Implemented a dynamic nested form for
Template -> elementos -> camposwith 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 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" }, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
template feature