Skip to content

Commit

Permalink
Introduce (missing) render_custom_editable_block_or_default
Browse files Browse the repository at this point in the history
  • Loading branch information
skelz0r committed Dec 17, 2024
1 parent 4b80584 commit e5a4021
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/helpers/authorization_requests_helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ def authorization_request_can_be_updated?(authorization_request)
authorization_request.filling?
end

def render_custom_editable_block_or_default(authorization_request, block_id, locals = {})
render partial: "authorization_request_forms/blocks/#{authorization_request.definition.id}/#{block_id}", locals:
rescue ActionView::MissingTemplate
render partial: "authorization_request_forms/blocks/default/#{block_id}", locals:
end

def render_custom_block_or_default(authorization_request, block, locals = {})
render partial: "authorization_requests/blocks/#{authorization_request.definition.id}/#{block}", locals:
rescue ActionView::MissingTemplate
Expand Down
2 changes: 1 addition & 1 deletion app/views/authorization_requests/blocks/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<%= authorization_request_form(@authorization_request, url: authorization_request_block_path([@authorization_request, block_id]), form_options: { data: { action: 'modified-form#submit form-dirtied->modified-form#update form-cleaned->modified-form#update', controller: 'modified-form' } }) do |f| %>
<%= render partial: "authorization_request_forms/blocks/default/#{block_id}", locals: { f: } %>
<%= render_custom_editable_block_or_default(@authorization_request, block_id, { f: }) %>

<% content_for :sticky_bar do %>
<div class="fr-container fr-grid-row">
Expand Down

0 comments on commit e5a4021

Please sign in to comment.