Skip to content

Commit

Permalink
Merge branch 'development' into feature/improve-search-input-component
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Mar 15, 2024
2 parents 543fcee + a88898c commit 4bd5038
Show file tree
Hide file tree
Showing 84 changed files with 976 additions and 504 deletions.
2 changes: 1 addition & 1 deletion app/assets/stylesheets/home.scss
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ i.fa.fa-caret-square-o-down {

}

.home-bubble h5{
.home-bubble .h5{
color: white;
font-size: 18px;
margin: 0;
Expand Down
30 changes: 9 additions & 21 deletions app/assets/stylesheets/search.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@
}

.search-page-input{
position: relative;
padding-bottom: 80px;
display: flex;
margin-bottom: 25px;
}
.search-page-input input{
position: absolute;
border-radius: 100px;
border-radius: 8px;
box-shadow: rgba(100, 100, 111, 0.1) 0 7px 29px 0;
border: none;
outline: none;
Expand All @@ -43,26 +42,15 @@
color: #888888;
font-size: 14px;
}




.search-page-options{

}
.search-page-button{
position: absolute;
top: 14px;
left: 1104px;
border: none;
background: none;
}
.search-page-button svg path{
fill: var(--primary-color)
width: 120px;
margin-left: 20px;
}
.search-page-button:hover{
cursor: pointer;

.search-page-button svg{
width: 14px;
}

.search-page-options{
display: flex;
justify-content: space-between;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
- s.template do
%a{href: "LINK", class: "search-content", 'data-turbo-frame': '_self'}
%p.search-element.home-searched-ontology
NAME (IDENTIFIERS)
= t('components.name_identifiers')
%p.home-result-type
TYPE
= t('components.type')
2 changes: 1 addition & 1 deletion app/components/field_container_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class FieldContainerComponent < ViewComponent::Base

renders_one :label
def initialize(label: nil, value: nil)
def initialize(label: nil, value: nil, truncate: false)
super
@label = label
@value = value
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.file_uploader{data: {controller: "file-input"}}
.file-drop-area.w-100
= inline_svg_tag "upload-file.svg"
%span.file-message{data:{'file-input': {target: 'message'}}} Drop your file here or, browse files on your device.
%span.file-message{data:{'file-input': {target: 'message'}}}= t('components.file_input_message')
= file_field_tag @name, class: 'file-input', data:{'file-input-target': 'input', action: 'file-input#updateMessage'}
4 changes: 2 additions & 2 deletions app/components/input/language_selector_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(languages:, selected: nil, id: '', name: '' , enable_all: false,

def languages
values = []
values = [["<div>#{render(LanguageFieldComponent.new(label: 'All languages', icon: 'icons/earth.svg', value: 'en'))}</div>", 'all']] if @enable_all
values = [["<div>#{render(LanguageFieldComponent.new(label: t('components.all_languages'), icon: 'icons/earth.svg', value: 'en'))}</div>", 'all']] if @enable_all

@languages.each do |key, label|
option = "<div>#{render(LanguageFieldComponent.new(value: key.to_s.downcase, label: label, auto_label: true))}</div>"
Expand All @@ -30,6 +30,6 @@ def call
data: @data,
required: true,
open_to_add_values: false,
placeholder: 'Select a language', **@html_options)
placeholder: t('components.select_anguage'), **@html_options)
end
end
6 changes: 5 additions & 1 deletion app/components/layout/horizontal_list_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,17 @@
class Layout::HorizontalListComponent < ViewComponent::Base
renders_many :elements

def initialize(truncate: true)
@truncate = truncate ? 'text-truncate' : ''
end

def call
return if elements.empty?

content_tag(:div, class: 'd-flex flex-wrap align-items-center') do
out = ''
elements.each do |element|
out = out + content_tag(:div, element, class: 'mr-1 mb-1 text-truncate')
out = out + content_tag(:div, element, class: "mr-1 mb-1 #{@truncate}")
end
raw out
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@

.progress-pages-actions
.progress-pages-back-button.hide{'data-action': "click->progress-pages#navigateBack", 'data-progress-pages-target': 'backBtn'}
= render Buttons::RegularButtonComponent.new(id: 'progress-pages-back-button', value: "Back", variant: "secondary", size: 'slim',state: 'regular') do |btn|
= render Buttons::RegularButtonComponent.new(id: 'progress-pages-back-button', value: t('components.back'), variant: "secondary", size: 'slim',state: 'regular') do |btn|
- btn.icon_left do
= inline_svg "icons/arrow-left.svg"
.progress-pages-next-button{'data-action': "click->progress-pages#navigateNext", 'data-progress-pages-target': 'nextBtn'}
= render Buttons::RegularButtonComponent.new(id: 'progress-pages-next-button', value: "Next", size: 'slim', state: 'regular') do |btn|
= render Buttons::RegularButtonComponent.new(id: 'progress-pages-next-button', value: t('components.next'), size: 'slim', state: 'regular') do |btn|
- btn.icon_right do
= inline_svg "arrow-right.svg"
.progress-pages-next-button.hide{ 'data-progress-pages-target': 'finishBtn'}
= render Buttons::RegularButtonComponent.new(id: 'progress-pages-finish-button', value: "Finish", size: 'slim', type: 'submit') do |btn|
= render Buttons::RegularButtonComponent.new(id: 'progress-pages-finish-button', value: t('components.finish'), size: 'slim', type: 'submit') do |btn|
- btn.icon_right do
= inline_svg "icons/white-check.svg"
2 changes: 1 addition & 1 deletion app/components/layout/reveal_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Layout::RevealComponent < ViewComponent::Base

def initialize(selected: nil, possible_values: [], hidden_class: 'd-none', toggle: false)
@hidden_class = hidden_class
@possible_values = possible_values
@possible_values = toggle && possible_values.empty? ? [true] : possible_values
@selected = selected
@toggle = toggle
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
- if @value.to_s.start_with?("http://creativecommons.org/licenses") || @value.to_s.start_with?("https://creativecommons.org/licenses")
%a{:rel => "license", :alt => "Creative Commons License", :href => "#{@value}", :target => "_blank", :style => "border-width:0", :title => "#{@value}"}
%img{:rel => "license", :alt => "Creative Commons License", :title => "#{@value}", :style => "border-width:0", :src => "https://i.creativecommons.org/l/by/4.0/88x31.png"}
%a{:rel => "license", :alt => t('components.creative_commons_license'), :href => "#{@value}", :target => "_blank", :style => "border-width:0", :title => "#{@value}"}
%img{:rel => "license", :alt => t('components.creative_commons_license'), :title => "#{@value}", :style => "border-width:0", :src => "https://i.creativecommons.org/l/by/4.0/88x31.png"}
- elsif @value.to_s.start_with?("http://opensource.org/licenses") || @value.to_s.start_with?("https://opensource.org/licenses")
%a{:rel => "license", :alt => "Open Source License", :href => "#{@value}", :title => "#{@value}", :target => "_blank", :style => "border-width:0;", :src => "https://opensource.org/files/osi_logo_bold_100X133_90ppi.png"}
%img{:rel => "license", :alt => "Open Source License", :title => "#{@value}", :style => "height: 80px; border-width:0;", :src => "https://opensource.org/files/osi_logo_bold_100X133_90ppi.png"}
%a{:rel => "license", :alt => t('components.open_source_license'), :href => "#{@value}", :title => "#{@value}", :target => "_blank", :style => "border-width:0;", :src => "https://opensource.org/files/osi_logo_bold_100X133_90ppi.png"}
%img{:rel => "license", :alt => t('components.open_source_license'), :title => "#{@value}", :style => "height: 80px; border-width:0;", :src => "https://opensource.org/files/osi_logo_bold_100X133_90ppi.png"}
- else
%a{:rel => "license", :href => "#{@value}", :target => "_blank"}= @value
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- if internal_link?
= render ChipButtonComponent.new(type: "clickable") do
= link_tag
- elsif @value.to_s =~ /\A#{URI::regexp(%w[http https])}\z/
- elsif link?(@value.to_s)
= render ChipButtonComponent.new(type: "clickable") do
= link_tag
- else
Expand Down
4 changes: 2 additions & 2 deletions app/components/loader_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ def call
content_tag(:div, class: 'd-flex align-items-center flex-column') do
content_tag(:div, class: "spinner-border #{small_class}") do
content_tag(:span) do
'Loading'
t('components.loading')
end
content_tag(:div, class: 'spinner-text my-2') do
'Loading'
t('components.loading')
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,40 +9,40 @@
- if session[:user]&.admin?
- ontology_status = status_string(ontology)
= render Display::InfoTooltipComponent.new(text: ontology_status, icon: submission_status_icons(ontology_status))
.browse-desc-container{data:{controller:"text-truncate", 'text-truncate-more-text-value': '+ Show more ...' , 'text-truncate-less-text-value': '- Show less ...'}}
.browse-desc-container{data:{controller:"text-truncate", 'text-truncate-more-text-value': t('components.show_more') , 'text-truncate-less-text-value': t('components.show_less')}}
%p.browse-desc-text{'data-text-truncate-target': 'content'}
= ontology[:description]
.browse-show-more-button{data:{'text-truncate-target': 'button', 'action':"click->text-truncate#toggle"}}
+ Show more ...
= t('components.show_more')


- unless ontology[:fairScore].nil? || ontology[:acronym] == 'AGROVOC'
.browse-fair
%p.browse-fair-title
FAIR score
= t('components.fair_score')
.browse-progress-bar
.browse-faire-progress{:style => "width: #{ontology[:normalizedFairScore].to_s+"%"}"}
%p.browse-fair-score
= ontology[:fairScore]
%a.browse-fair-details{:href => "/ontologies/#{ontology[:acronym]}#fair-details", 'data-turbo': 'false'} FAIR details ...
%a.browse-fair-details{:href => "/ontologies/#{ontology[:acronym]}#fair-details", 'data-turbo': 'false'}= t('components.details_details')

.browse-ontology-cards
= render SquareBadgeComponent.new(label: 'classes', count: ontology[:class_count_formatted], link: "/ontologies/#{ontology[:acronym]}?p=classes" )
= render SquareBadgeComponent.new(label: t('components.classes'), count: ontology[:class_count_formatted], link: "/ontologies/#{ontology[:acronym]}?p=classes" )

= render SquareBadgeComponent.new(label: ontology[:format] == 'SKOS' ? "concepts" : "instances",
= render SquareBadgeComponent.new(label: ontology[:format] == 'SKOS' ? t('components.concepts') : t('components.instances'),
count: ontology[:individual_count_formatted],
link: "/ontologies/#{ontology[:acronym]}?p=#{ontology[:format] == 'SKOS' ? "classes" : "instances"}")

= render SquareBadgeComponent.new(label: 'projects', count: ontology[:project_count], link: "/ontologies/#{ontology[:acronym]}#projects_section" )
= render SquareBadgeComponent.new(label: t('components.projects'), count: ontology[:project_count], link: "/ontologies/#{ontology[:acronym]}#projects_section" )

= render SquareBadgeComponent.new(label: 'notes', count: ontology[:note_count], link: "/ontologies/#{ontology[:acronym]}?p=notes" )
= render SquareBadgeComponent.new(label: t('components.notes'), count: ontology[:note_count], link: "/ontologies/#{ontology[:acronym]}?p=notes" )


.d-flex.align-items-baseline.mt-1
- if ontology[:creationDate]
%span.mr-1
= render ChipButtonComponent.new(type: "clickable") do
%span.mr-1 Submitted
%span.mr-1= t('components.submitted')
%span.browse-uploaded-date{data:{controller: 'timeago', 'timeago-datetime-value': ontology[:creationDate], 'timeago-add-suffix-value': 'true'}}
- if ontology[:contact]
%span.mx-1 by
Expand All @@ -51,7 +51,7 @@

- if ontology[:released]
- date = render DateTimeFieldComponent.new(value: ontology[:released])
%span{data:{controller:'tooltip'}, title: "Creation date #{date}"}
%span{data:{controller:'tooltip'}, title: t('components.creation_date', date: date)}
= render ChipButtonComponent.new(type: "clickable") do
= DateTime.parse(date).year rescue date

Expand All @@ -63,12 +63,12 @@
%span.mx-1
= ontology_retired_badge(ontology)
- if ontology[:viewOfOnt]
%span.mx-1{data:{controller:'tooltip'}, title: "View of the ontology #{ontology[:viewOfOnt].split('/').last}"}
= render ChipButtonComponent.new(type: "clickable", text: "View")
%span.mx-1{data:{controller:'tooltip'}, title: t('components.view_of_the_ontology', ontology: ontology[:viewOfOnt].split('/').last )}
= render ChipButtonComponent.new(type: "clickable", text: t('components.view'))

- if session[:user]&.admin?
%div.mx-1{title: content_tag(:div, debug(ontology), style: 'height: 300px; overflow: scroll'), data:{controller: 'tooltip', 'tooltip-interactive-value': 'true'}}
= render ChipButtonComponent.new(type: "clickable", text: "Debug" , class: 'admin-background')
= render ChipButtonComponent.new(type: "clickable", text: t('components.debug') , class: 'admin-background')
- else
.browse-ontology-container
.browse-sket
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
- s.template do
%a{href: "LINK", class: "search-content", 'data-turbo-frame': '_top'}
%p.search-element.home-searched-ontology
NAME(ACRONYM)
= t('components.name_acronym')
%p.home-result-type
TYPE
= t('components.type')
8 changes: 4 additions & 4 deletions app/components/ontology_subscribe_button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ def initialize(id: '', ontology_id:, subscribed:, user_id:, count: 0, link: 'jav
super
@id = id
@subscribed = subscribed
@sub_text = subscribed ? 'UnWatch' : 'Watch'
@sub_text = subscribed ? t('components.unwatch') : t('components.watch')
@link = link
@count = count
@controller_params = {
Expand All @@ -22,11 +22,11 @@ def initialize(id: '', ontology_id:, subscribed:, user_id:, count: 0, link: 'jav

def title
if @subscribed
"#{@sub_text} this resource"
t('components.resource', sub_text: @sub_text)
elsif @count.zero?
"Be the first to watch this resource and be notified of all its updates"
t('components.notified_of_all_updates')
else
"Join the #{@count} users, watching this resource and be notified of all its updates"
t('components.join_the_count', count: @count)
end
end
end
2 changes: 1 addition & 1 deletion app/components/text_area_field_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class TextAreaFieldComponent < ViewComponent::Base

def initialize(value: , see_more_text:'See more...' , see_less_text: 'See less...')
def initialize(value: , see_more_text: t('components.see_more') , see_less_text: t('components.see_less'))
super
@value = value
@see_more_text = see_more_text
Expand Down
14 changes: 7 additions & 7 deletions app/controllers/admin/categories_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,16 @@ def create
if response_error?(category_saved)
response[:errors] = response_errors(category_saved)
else
response[:success] = "category successfully created in #{Time.now - start}s"
response[:success] = t('admin.categories.category_created', time: Time.now - start)
end
rescue Exception => e
response[:errors] = "Problem creating the category - #{e.message}"
response[:errors] = t('admin.categories.category_error_creation', message: e.message)
end

if response[:errors]
render_turbo_stream alert_error(id: 'category') { response[:errors] }
else
success_message = 'New Category added successfully'
success_message = t('admin.categories.category_added_successfully')
streams = [alert_success(id: 'category') { success_message }]

streams << prepend('admin_categories_table_body', partial: 'admin/categories/category', locals: { category: category_saved })
Expand All @@ -71,10 +71,10 @@ def update
if response_error?(category_updated)
response[:errors] = response_errors(category_updated)
else
response[:success] = "category successfully updated in #{Time.now - start}s"
response[:success] = t('admin.categories.category_updated_successfully', time: Time.now - start)
end
rescue Exception => e
response[:errors] = "Problem updating the category - #{e.message}"
response[:errors] = t('admin.categories.problem_of_updating', message: e.message)
end

if response[:errors]
Expand All @@ -98,10 +98,10 @@ def destroy
if response_error?(error_response)
response[:errors] = response_errors(error_response)
else
response[:success] = "category successfully deleted in #{Time.now - start}s"
response[:success] = t('admin.categories.category_deleted_successfully', time: Time.now - start)
end
rescue Exception => e
response[:errors] = "Problem deleting the category - #{e.message}"
response[:errors] = t('admin.categories.problem_of_deleting', message: e.message)
end
respond_to do |format|
format.turbo_stream do
Expand Down
Loading

0 comments on commit 4bd5038

Please sign in to comment.