Skip to content

Commit

Permalink
clean the ontologies routes by defining a scope a removing duplicates
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Apr 11, 2024
1 parent d5c4ddf commit 03a7222
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def index

render_search_paginated_list(container_id: 'collections_sorted_list',
types: ['Collection'],
next_page_url: "/collections/#{@ontology.acronym}",
next_page_url: "/ontologies/#{@ontology.acronym}/collections",
child_url: "/ontologies/#{@ontology.acronym}/collections/show",
child_param: :collectionid,
child_turbo_frame: 'collection')
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/instances_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def index

render_search_paginated_list(container_id: (is_concept_instance ? 'concept_' : '') + 'instances_sorted_list',
types: Array(concept_type),
next_page_url: "/instances/#{@ontology.acronym}?type=#{helpers.escape(params[:type])}",
next_page_url: "/ontologies/#{@ontology.acronym}/instances?type=#{helpers.escape(params[:type])}",
child_url: "/ontologies/#{@ontology.acronym}/instances/show?modal=#{is_concept_instance.to_s}",
child_param: :instanceid,
child_turbo_frame: 'instance_show',
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/properties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ def index
else
render_search_paginated_list(container_id: 'properties_sorted_list',
types: %w[AnnotationProperty ObjectProperty DatatypeProperty],
next_page_url: "/properties/#{@ontology.acronym}",
next_page_url: "/ontologies/#{@ontology.acronym}/properties",
child_url: "/ontologies/#{@ontology.acronym}/properties/show",
child_param: :propertyid,
child_turbo_frame: 'property_show')
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/schemes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def index
else
render_search_paginated_list(container_id: 'schemes_sorted_list',
types: ['ConceptScheme'],
next_page_url: "/schemes/#{@ontology.acronym}",
next_page_url: "/ontologies/#{@ontology.acronym}/schemes",
child_url: "/ontologies/#{@ontology.acronym}/schemes/show",
child_param: :schemeid,
child_turbo_frame: 'scheme')
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/schemes_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def section_name(section)
end

def scheme_path(scheme_id = '', language = '')
"/ontologies/#{@ontology.acronym}/schemes/show_scheme?id=#{escape(scheme_id)}&lang=#{language}"
"/ontologies/#{@ontology.acronym}/schemes/show?id=#{escape(scheme_id)}&lang=#{language}"
end

def no_main_scheme?
Expand Down
4 changes: 2 additions & 2 deletions app/views/instances/_instances.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
%div.sidebar.w-100.position-relative.card{data: {'container-splitter-target': 'container', action: 'change->turbo-frame#updateFrame'}}
= tree_container_component(id: "#{@instance ? '' : 'concept_'}instances_sorted_list_view-page-1",
placeholder:"Search an Instance in #{@ontology.acronym}",
frame_url: "/instances/#{@ontology.acronym}#{@concept ? '?type=' + escape(@concept.id) : ''}",
tree_url: "/instances/#{@ontology.acronym}?page=1#{@concept ? '&type=' + escape(@concept.id) : ''}&#{request.original_url.split('?')[1]}")
frame_url: "/ontologies/#{@ontology.acronym}/instances#{@concept ? '?type=' + escape(@concept.id) : ''}",
tree_url: "/ontologies/#{@ontology.acronym}/instances?page=1#{@concept ? '&type=' + escape(@concept.id) : ''}&#{request.original_url.split('?')[1]}")
- if @instance
%div#prop_contents.pl-3{data: {'container-splitter-target': 'container'}}
= render partial: 'instances/details'
Expand Down
4 changes: 2 additions & 2 deletions app/views/ontologies/sections/_collections.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
%div#collectionsTree.card.sidebar{data:{'container-splitter-target': 'container'}}
= tree_container_component(id: "collections_sorted_list_view-page-1",
placeholder:"Search an collection in #{@ontology.acronym}",
frame_url: "/collections/#{@ontology.acronym}",
tree_url: "/collections/#{@ontology.acronym}?#{request.original_url.split('?')[1]}")
frame_url: "/ontologies/#{@ontology.acronym}/collections",
tree_url: "/ontologies/#{@ontology.acronym}/collections?#{request.original_url.split('?')[1]}")

%div#collection_contents.pl-3{data:{'container-splitter-target': 'container'}}
= render TurboFrameComponent.new(id: 'collection') do
Expand Down
4 changes: 2 additions & 2 deletions app/views/ontologies/sections/_schemes.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
- else
= tree_container_component(id: "schemes_sorted_list_view-page-1",
placeholder:"Search an scheme in #{@ontology.acronym}",
frame_url: "/schemes/#{@ontology.acronym}?#{request.original_url.split('?')[1]}",
tree_url: "/schemes/#{@ontology.acronym}?#{request.original_url.split('?')[1]}")
frame_url: "/ontologies/#{@ontology.acronym}/schemes?#{request.original_url.split('?')[1]}",
tree_url: "/ontologies/#{@ontology.acronym}/schemes?#{request.original_url.split('?')[1]}")

%div#scheme_contents.pl-3{data:{'container-splitter-target': 'container'}}
= render TurboFrameComponent.new(id:'scheme') do
Expand Down
4 changes: 2 additions & 2 deletions app/views/ontologies/sections/properties.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
%div.sidebar.position-relative.card{data: {'container-splitter-target': 'container', action: 'change->turbo-frame#updateFrame'}}
= tree_container_component(id: 'properties_sorted_list_view-page-1',
placeholder:"Search a property in #{@ontology.acronym}",
frame_url: "/properties/#{@ontology.acronym}",
tree_url: "/ajax/properties/treeview?propertyid=#{escape(params[:propertyid])}&ontology=#{@ontology.acronym}&auto_click=false&language=#{request_lang}")
frame_url: "/ontologies/#{@ontology.acronym}/properties",
tree_url: "/ontologies/#{@ontology.acronym}/properties?propertyid=#{escape(params[:propertyid])}&ontology=#{@ontology.acronym}&auto_click=false&language=#{request_lang}")

%div#prop_contents.pl-3{data: {'container-splitter-target': 'container'}}
= render partial: 'properties/show'
31 changes: 18 additions & 13 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,28 +41,34 @@

resources :concepts

get 'ontologies/:ontology_id/concepts', to: 'concepts#show_concept'

scope :ontologies do
get ':ontology_id/concepts', to: 'concepts#show_concept'

get ':ontology/instances', to: 'instances#index'
get ':ontology/instances/show', to: 'instances#show'

get ':ontology/properties', to: 'properties#index'

get ':ontology/schemes', to: 'schemes#index'
get ':ontology/schemes/show', to: 'schemes#show'

get ':ontology/collections', to: 'collections#index'
get ':ontology/collections/show', to: 'collections#show'
end


resources :ontologies do
resources :submissions do
get 'edit_properties'
end

get 'instances/show', to: 'instances#show'
get 'schemes/show', to: 'schemes#show'
get 'collections/show', to: 'collections#show'

get 'instances/:instance_id', to: 'instances#show', constraints: { instance_id: /[^\/?]+/ }
get 'schemes/show_scheme', to: 'schemes#show'
get 'collections/show'
get 'metrics'
get 'metrics_evolution'
get 'subscriptions'
end

get 'instances/:ontology', to: 'instances#index'
get 'properties/:ontology', to: 'properties#index'
get 'schemes/:ontology', to: 'schemes#index'
get 'collections/:ontology', to: 'collections#index'


resources :login

Expand Down Expand Up @@ -175,7 +181,6 @@
get '/ajax/classes/treeview' => 'concepts#show_tree'
get '/ajax/classes/list' => 'collections#show_members'
get '/ajax/classes/date_sorted_list' => 'concepts#show_date_sorted_list'
get '/ajax/properties/treeview' => 'properties#index'
get '/ajax/properties/children' => 'properties#show_children'
get '/ajax/properties/tree' => 'concepts#property_tree'
get 'ajax/schemes/label', to: "schemes#show_label"
Expand Down

0 comments on commit 03a7222

Please sign in to comment.