diff --git a/app/components/agent_search_input_component.rb b/app/components/agent_search_input_component.rb new file mode 100644 index 000000000..3cf7a2ec4 --- /dev/null +++ b/app/components/agent_search_input_component.rb @@ -0,0 +1,10 @@ +# frozen_string_literal: true + +class AgentSearchInputComponent < ViewComponent::Base + + def initialize(id:, organization_only: false ) + super + @id = id + @organization_only = organization_only + end +end diff --git a/app/components/agent_search_input_component/agent_search_input_component.html.haml b/app/components/agent_search_input_component/agent_search_input_component.html.haml new file mode 100644 index 000000000..8f14ff5c2 --- /dev/null +++ b/app/components/agent_search_input_component/agent_search_input_component.html.haml @@ -0,0 +1,10 @@ += render SearchInputComponent.new(name:'agent' + @id, ajax_url: "/ajax/agents?organization_only=#{@organization_only}&name=", + item_base_url:"/agents/fake_id?parent_id=#{@id}&name=", id_key: 'name', + use_cache: false, + actions_links: {create_new_agent: {link: "/agents/new?name=&parent_id=#{@id}&new_agent=false&type=organization", target:'_self'}}) do |s| + - s.template do + %a{href: "LINK", class: "home-search-ontology-content", 'data-turbo-frame': '_self'} + %p#seached-ontology.home-searched-ontology + NAME (IDENTIFIERS) + %p.home-result-type + TYPE \ No newline at end of file diff --git a/app/controllers/agents_controller.rb b/app/controllers/agents_controller.rb index 8fb6406e6..ddd8122c9 100644 --- a/app/controllers/agents_controller.rb +++ b/app/controllers/agents_controller.rb @@ -6,6 +6,11 @@ def index @agents = LinkedData::Client::Models::Agent.all end + def show + id = params[:id]&.eql?('fake_id') ? params[:name] : params[:id] + @agent = LinkedData::Client::Models::Agent.all(name: id).find { |x| x.name.eql?(id) } + @name_prefix = params[:parent_id] ? "[affiliations][#{params[:parent_id]}]" : '' + end def ajax_agents @agents = LinkedData::Client::Models::Agent.all(name: params[:name], agentType: params[:organization_only]&.eql?('true') ? 'organization' : '') diff --git a/app/views/agents/_agent_show.html.haml b/app/views/agents/_agent_show.html.haml new file mode 100644 index 000000000..c73f15729 --- /dev/null +++ b/app/views/agents/_agent_show.html.haml @@ -0,0 +1,3 @@ +- if agent.id + = hidden_field_tag agent_field_name(:id, name_prefix), agent.id += text_field_tag '', agent.name + '(' + agent.identifiers.map {|i| i.schemaAgency+':'+i.notation}.join(', ') + ')', class: "form-control", disabled: true \ No newline at end of file diff --git a/app/views/agents/show.html.haml b/app/views/agents/show.html.haml new file mode 100644 index 000000000..e6385281a --- /dev/null +++ b/app/views/agents/show.html.haml @@ -0,0 +1,2 @@ += turbo_frame_tag params[:parent_id] || 'application_modal_content' do + = render partial: 'agents/agent_show', locals: {agent: @agent, name_prefix: @name_prefix} \ No newline at end of file