Skip to content

Commit

Permalink
Add concept details component to schemes and collections and fix code
Browse files Browse the repository at this point in the history
  • Loading branch information
imadbourouche authored and syphax-bouazzouni committed Apr 5, 2024
1 parent feee391 commit f3e0b5c
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,29 +3,30 @@
= header
%div.my-3
%div.raw-table
- if @bottom_keys.present?
.concepts-content-format
= render TabsContainerComponent.new(type: 'outline') do |c|
- if @bottom_keys.present?
- c.item(title: "Raw Data", selected: true)
- c.item_content do
- top_set, leftover_set, bottom_set = filter_properties(@top_keys, @bottom_keys, @exclude_keys, prefix_properties(@concept_properties))
- leftover_set = convert_dates(leftover_set)
= render TableComponent.new(stripped: true) do |t|

= render TabsContainerComponent.new(type: 'outline') do |c|
- c.item(title: "Raw Data", selected: true)
- c.item_content do
- top_set, leftover_set, bottom_set = filter_properties(@top_keys, @bottom_keys, @exclude_keys, prefix_properties(@concept_properties))
- leftover_set = convert_dates(leftover_set)
= render TableComponent.new(stripped: true) do |t|

- row_hash_properties(top_set, @acronym).each do |row|
- t.add_row(*row)
- row_hash_properties(top_set, @acronym).each do |row|
- t.add_row(*row)

- row_hash_properties(leftover_set, @acronym).each do |row|
- t.add_row(*row)
- row_hash_properties(leftover_set, @acronym).each do |row|
- t.add_row(*row)


- sections.each do |section|
- t.row do
= section
- sections.each do |section|
- t.row do
= section


- row_hash_properties(bottom_set, @acronym).each do |row|
- t.add_row(*row)

= content_formats(concept_id: @concept_id, acronym: @acronym, c: c)
- row_hash_properties(bottom_set, @acronym).each do |row|
- t.add_row(*row)
- if @concept_id
- ['json', 'xml', 'ntriples', 'turtle'].each do |format|
- c.item(title: format, selected: (format=="json" && @bottom_keys.empty?))
- c.item_content do
= render TurboFrameComponent.new(id: "resource_content_frame_#{format}", src: "/ontologies/#{@acronym}/#{CGI.escape(@concept_id)}/serialize/#{format}", loading: "lazy")
3 changes: 1 addition & 2 deletions app/javascript/controllers/metadata_downloader_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ export default class extends Controller {
break
case 'ntriples':
hljs.registerLanguage('ntriples', function (hljs) {
var URL_PATTERN = /<[^>]+>/; // Regex pattern for matching URLs in angle brackets
return {
case_insensitive: true,
contains: [
Expand All @@ -57,7 +56,7 @@ export default class extends Controller {
break
case 'turtle':
hljs.registerLanguage('turtle', function (hljs) {
var URL_PATTERN = /(?:<[^>]*>)|(?:https?:\/\/[^\s]+)/;
let URL_PATTERN = /(?:<[^>]*>)|(?:https?:\/\/[^\s]+)/;

return {
case_insensitive: true,
Expand Down
2 changes: 1 addition & 1 deletion app/views/collections/_collection.html.haml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
= turbo_frame_tag 'collection' do
= render ConceptDetailsComponent.new(id:'collection-label', acronym: @ontology.acronym,
= render ConceptDetailsComponent.new(id:'collection-label', acronym: @ontology.acronym, concept_id: collection.id,
properties: collection.properties,
top_keys: %w[created modified comment note],
bottom_keys: [],
Expand Down
10 changes: 2 additions & 8 deletions app/views/properties/_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
- if @property.errors
= render Display::AlertComponent.new(type:'info', message: @property.errors.join)
- else
= render ConceptDetailsComponent.new(id:'property-details', acronym: @acronym,
= render ConceptDetailsComponent.new(id:'property-details', acronym: @acronym, concept_id: @property.id,
properties: OpenStruct.new(LinkedData::Client::Models::Property.properties_to_hash(@property).first),
top_keys: [],
bottom_keys: [],
Expand All @@ -12,10 +12,4 @@
- t.add_row({th: t('properties.id')}, {td: link_to_with_actions(c.concept_properties[:id][:values])}) if c.concept_properties[:id][:values].present?
- t.add_row({th: t('properties.preferred_name')}, {td: display_in_multiple_languages(c.concept_properties[:label][:values])}) if c.concept_properties[:label][:values].present?
- t.add_row({th: t('properties.definitions')}, {td: display_in_multiple_languages(c.concept_properties[:definition][:values])}) if c.concept_properties[:definition][:values].present?
- t.add_row({th: t('properties.parent')}, {td: display_in_multiple_languages(c.concept_properties[:parents][:values])}) if c.concept_properties[:parents][:values].present?

.property-content-format
- property = OpenStruct.new(LinkedData::Client::Models::Property.properties_to_hash(@property).first)

= render TabsContainerComponent.new(type: 'outline') do |c|
= content_formats(concept_id: property.id, acronym: @acronym, c: c, selected_format: 'json')
- t.add_row({th: t('properties.parent')}, {td: display_in_multiple_languages(c.concept_properties[:parents][:values])}) if c.concept_properties[:parents][:values].present?
2 changes: 1 addition & 1 deletion app/views/schemes/_scheme.html.haml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
= turbo_frame_tag 'scheme' do
- if @scheme && !@scheme.empty?
= render ConceptDetailsComponent.new(id:'scheme-label', acronym: @ontology.acronym,
= render ConceptDetailsComponent.new(id:'scheme-label', acronym: @ontology.acronym, concept_id: @scheme.id,
properties: scheme.properties,
top_keys: %w[description comment],
bottom_keys: %w[disjoint subclass is_a has_part],
Expand Down

0 comments on commit f3e0b5c

Please sign in to comment.