More generic rework of the project admin frame

Plus a minor fix on project edit
This commit is contained in:
2026-03-31 01:33:58 +03:00
parent 32a7b07f2d
commit 138f1c42a0
3 changed files with 19 additions and 16 deletions
+15 -3
View File
@@ -1,11 +1,23 @@
# frozen_string_literal: true
module ProjectAdminHelper
FRAME_ID = 'admin_frame'
TABS_ID = 'admin_tabs'
def project_admin_frame(project, &)
tabs_id = 'project_admin_tabs'
tabs = ProjectAdmin::TabsViewModel.new(project, frame: :project_admin, id: tabs_id)
links = {
'Data' => edit_project_path(project),
'Workflows' => project_admin_workflows_path(project)
}
title = "Project #{project.name}"
admin_frame(links, title:, &)
end
def admin_frame(links, title:, &)
tabs = ProjectAdmin::TabsViewModel.new(links, id: TABS_ID, frame: FRAME_ID)
content = capture(&) if block_given?
render partial: 'project_admin/frame', locals: { id: :project_admin, tabs:, tabs_id:, content: }
render partial: 'project_admin/frame', locals: { id: FRAME_ID, tabs:, tabs_id: TABS_ID, title:, content: }
end
end
@@ -4,8 +4,8 @@ module ProjectAdmin
class TabsViewModel
include Rails.application.routes.url_helpers
def initialize(project, id:, frame:)
@project = project
def initialize(links, id:, frame:)
@links = links
@id = id
@frame = frame
end
@@ -13,17 +13,8 @@ module ProjectAdmin
def render_in(view_context)
view_context.render(
partial: 'project_admin/tabs',
locals: { project: @project, links:, id: @id, frame: @frame }
locals: { project: @project, id: @id, frame: @frame, links: @links }
)
end
private
def links
{
'Data' => edit_project_path(@project),
'Workflows' => project_admin_workflows_path(@project)
}
end
end
end
+1 -1
View File
@@ -1,4 +1,4 @@
= form_with model: @project do |form|
= form_with model: @project, data: {'turbo-frame': '_top'} do |form|
.field
= form.label :code
= form.text_field :code