Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: propertyid param auto added to summary page URL #723

Merged
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ def self.t(*args)
end

# Sets the locale based on the locale cookie or the value returned by detect_locale.
def set_locale
def set_locale
I18n.locale = cookies[:locale] || detect_locale
cookies.permanent[:locale] = I18n.locale if cookies[:locale].nil?
logger.debug "* Locale set to '#{I18n.locale}'"
session[:locale] = I18n.locale
end

# Returns detedted locale based on the Accept-Language header of the request or the default locale if none is found.
def detect_locale
def detect_locale
languages = request.headers['Accept-Language']&.split(',')
supported_languages = I18n.available_locales

Array(languages).each do |language|
language_code = language.split(/[-;]/).first.downcase.to_sym
return language_code if supported_languages.include?(language_code)
end
return I18n.default_locale

return I18n.default_locale
end


helper :all # include all helpers, all the time
helper_method :bp_config_json, :current_license, :using_captcha?
Expand Down Expand Up @@ -367,6 +367,10 @@ def get_class(params)
@concept
end

def get_property(id, acronym = params[:acronym], lang = request_lang, include: nil)
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
LinkedData::Client::HTTP.get("/ontologies/#{acronym}/properties/#{helpers.encode_param(id)}", { lang: lang , include: include})
end

def get_ontology_submission_ready(ontology)
# Get the latest 'ready' submission
submission = ontology.explore.latest_submission({:include_status => 'ready'})
Expand All @@ -385,7 +389,7 @@ def get_apikey()

def total_mapping_count
total_count = 0

begin
stats = LinkedData::Client::HTTP.get("#{REST_URI}/mappings/statistics/ontologies")
unless stats.blank?
Expand All @@ -397,7 +401,7 @@ def total_mapping_count
rescue
LOG.add :error, e.message
end

return total_count
end

Expand All @@ -421,7 +425,7 @@ def init_trial_license
$trial_license_initialized = true
end
end

# Get the submission metadata from the REST API.
def submission_metadata
@metadata ||= helpers.submission_metadata
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 @@ -25,7 +25,7 @@ def index
child_turbo_frame: 'instance_show',
child_param: :instanceid,
show_count: is_concept_instance,
auto_click: params[:instanceid].blank? && page.eql?(1),
auto_click: false,
results: results, next_page: next_page, total_count: total_count)

if is_concept_instance && page.eql?(1)
Expand Down
16 changes: 16 additions & 0 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ def properties
@acronym = @ontology.acronym
@properties = LinkedData::Client::HTTP.get("/ontologies/#{@acronym}/properties/roots", { lang: request_lang })

unless @property
@property = get_property(@properties.first.id, @acronym, include: 'all')
end

if request.xhr?
return render 'ontologies/sections/properties', layout: false
else
Expand Down Expand Up @@ -176,6 +180,8 @@ def notes

def instances

params[:instanceid] = params[:instanceid] || instances_tree_first_id

if params[:instanceid]
@instance = helpers.get_instance_details_json(@ontology.acronym, params[:instanceid], {include: 'all'})
end
Expand Down Expand Up @@ -553,5 +559,15 @@ def determine_layout
end
end

def instances_tree_first_id
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
query, page, page_size = helpers.search_content_params
results, _, _, _ = search_ontologies_content(query: query,
page: page,
page_size: page_size,
filter_by_ontologies: [@ontology.acronym],
filter_by_types: ["NamedIndividual"])
results.shift
Bilelkihal marked this conversation as resolved.
Show resolved Hide resolved
return !results.blank? ? results.first[:name] : nil
end

end
3 changes: 0 additions & 3 deletions app/controllers/properties_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ def show_children

private

def get_property(id, acronym = params[:acronym], lang = request_lang, include: nil)
LinkedData::Client::HTTP.get("/ontologies/#{acronym}/properties/#{helpers.encode_param(id)}", { lang: lang , include: include})
end

def property_tree(id, acronym = params[:acronym], lang = request_lang)
LinkedData::Client::HTTP.get("/ontologies/#{acronym}/properties/#{helpers.encode_param(id)}/tree", { lang: lang })
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/ontologies_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def lazy_load_section(section_title, &block)
block.call
else
render TurboFrameComponent.new(id: section_title, src: "/ontologies/#{@ontology.acronym}?p=#{section_title}",
loading: Rails.env.development? ? "lazy" : "eager",
loading: Rails.env.development? ? "lazy" : "eager",
target: '_top', data: { "turbo-frame-target": "frame" })
end
end
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/properties_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def property_tree_data(acronym, child, language)
end

def property_tree_component(root, selected_concept, acronym, language, sub_tree: false, id: nil, auto_click: false, submission: @submission)
tree_component(root, selected_concept, target_frame: 'property_show', sub_tree: sub_tree, id: id, auto_click: auto_click, submission: submission) do |child|
tree_component(root, selected_concept, target_frame: 'property_show', sub_tree: sub_tree, id: id, auto_click: false, submission: submission) do |child|
property_tree_data(acronym, child, language)
end
end
Expand Down
1 change: 0 additions & 1 deletion app/javascript/controllers/history_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { HistoryService } from "../mixins/useHistory";
// Connects to data-controller="history"
export default class extends Controller {
connect() {
console.log('hello world')
this.history = new HistoryService()
}
updateURL(event) {
Expand Down
Loading