Skip to content

Commit

Permalink
fix agent input been removed from submission after edited
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Nov 30, 2023
1 parent 4ec1556 commit db40f13
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions app/controllers/agents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ def create

def edit
@agent = LinkedData::Client::Models::Agent.find("#{rest_url}/Agents/#{params[:id]}")
@name_prefix = params[:parent_id] || ''
@name_prefix = params[:name_prefix] || ''
@show_affiliations = params[:show_affiliations].nil? || params[:show_affiliations].eql?('true')
@deletable = params[:deletable].to_s.eql?('true')
end
Expand Down Expand Up @@ -104,7 +104,7 @@ def update
replace(table_line_id, partial: 'agents/show_line', locals: { agent: agent })
]

streams << replace_agent_form(agent, parent_id: parent_id, deletable: deletable) if params[:parent_id]
streams << replace_agent_form(agent, agent_id: agent_id(agent.id), name_prefix: params[:name_prefix] , parent_id: parent_id, deletable: deletable) if params[:parent_id]

render_turbo_stream(*streams)
end
Expand Down
6 changes: 3 additions & 3 deletions app/helpers/agent_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ def agent_id(agent)

def link_to_agent_edit_modal(agent, parent_id = nil)

link_to_modal(nil, edit_agent_path(agent_id(agent), parent_id: parent_id, show_affiliations: parent_id.nil? || parent_id.empty?), class: 'btn btn-sm btn-light', data: { show_modal_title_value: "Edit agent #{agent.id}" }) do
link_to_modal(nil, edit_agent_path(agent_id(agent), parent_id: parent_id, show_affiliations: parent_id.nil? || parent_id.empty?), class: 'btn btn-sm btn-light', data: { show_modal_title_value: "Edit agent #{agent.name}" }) do
content_tag(:i, '', class: 'far fa-edit')
end
end

def link_to_agent_edit(agent, parent_id = nil, deletable: false, show_affiliations: true)
link_to(edit_agent_path(agent_id(agent), deletable: deletable, parent_id: parent_id, show_affiliations: show_affiliations), class: 'btn btn-sm btn-light') do
def link_to_agent_edit(agent, parent_id, name_prefix, deletable: false, show_affiliations: true)
link_to(edit_agent_path(agent_id(agent), name_prefix: name_prefix, deletable: deletable, parent_id: parent_id, show_affiliations: show_affiliations), class: 'btn btn-sm btn-light') do
content_tag(:i, '', class: 'far fa-edit')
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/views/agents/_agent_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@
- if edit_on_modal
= link_to_agent_edit_modal(agent, parent_id)
- else
= link_to_agent_edit(agent, parent_id, deletable: deletable)
= link_to_agent_edit(agent, parent_id, name_prefix, deletable: deletable)
- if deletable
= link_to_search_agent(agent_id, parent_id, name_prefix ,agent.agentType, deletable)

0 comments on commit db40f13

Please sign in to comment.