Skip to content

Commit

Permalink
Fix: Open to add values to some metadata attribute in the submission …
Browse files Browse the repository at this point in the history
…edit form (#392)

* show ontology groups in the ontology summary page

* updatr account page to show empty state  of Subscriptions,  Submitted and projects

* don't stop the API server after running the tests

* add chrome-server service to run integration test

* add users creation & login  flow tests

* add submission creation system tests

* add system tests CI

* fix development environnement not raising exception

* if submission status icon helper with the correct conditions

* not show the ontology data section if the submission is not ready

* add an alert message in summary page, to give information about this submission statueses

* add remote api of Stageportal tests CI

* add option to the ontoportal script to run test with a remote API

* fix ontologies with no submissions summary page state

* build docker images in github hub  in addition of docker

* add test coverage report

* fix ontology viewer sections order

* fix  summary icons, by  adding publication, title and enforce disabled

* add admin block helper

* add to the ontology viewer private, hasLanguage and  retired badges

* add a title to the json and subscribe button to give their usages

* fix summary usage and methodology properties not showing

* add :award to summary page "usage" block

* add :exampleIdentifier to the summary identifiers block

* add ::associatedMedia, :bugDatabase, :mailingList, :uriRegexPattern to summary links block

* add :toDoList and :notes to summary  methodology block

* add a an admin block in the summary page for the configuration metadata

* lazy load the ontology view section in development mode for better perf

* add the abstract to ontology summary description block

* update the summary page description text to integrate multiple metadata

 alternative, hasLicense, prefix, namespace, metadataVoc

* add ontology edit metadata tests

* fix browse not working in local french

* remove reset button in submission forms

* fix metrics evolution popup title

* add in summary page  show all metrics popup

* don't humanize agent name and show them as saved

* fix the new hasOntologyLanguage badge for the one that are nil

* fix landscape average metrics all NaN

* fix metadata curator returning content missing

* fix subscribe button unwatch state title

* hide topnav "Recently Viewed" if empty

* fix user edit form button style

* add useGuidelines and copyrightHolder to the ontology licenses popup

* add submission hasDomain  to the summary general information block

* fix agent input for single fields

* fix select input not removing the text written after select

* add no list agents input support

* fix missing translate for concept selector in mappings page

* fix recemender insert text missing translation

* use the select component for the relations inputs

* fix ontologies tries not opening for OWL ones

* handle the case of an ontology with no submission

* disable copryright holder editing

* add again remove images that are still used

* add rest_url helper, that clean the give $REST_URL in the configuration

* make the stop_api script also remove the volumes

* add agent creation system tests

* fix submission single agent input ( e.g copyrightHolder )

* open to add ontology relation inputs except hasPriorVersion

* fix the edition of curatedOn metadata and also the display as a list

* update submission flow tests to the remaining tests (agent, curatedOn)

* update some attribute in submission from to be open to add values

* fix switch input for boolean type as Deprecated

* update retired badge to have two state deprecated in orange or retired in red

* add codevoc  generation

* update trancate text to not be hidden but scrollable

* move the alternative and hiddenLabel as tooltip of the ontology name

* add community and content blocks in summary page

* add ontology license badge in the ontology viewer header

* add required option to select input used for hasOntologyLanguage

* auto select person type in the agent from if new

* don't show the cancel button in agent input if the agent is not a list

* add submission description filter to the browse page

* remove a slow call the tree display and fix the language all display

* fix agent input been removed from submission after edited

* add admin agents edition system tests

* fix user subscription if subscribed to a no more existent ontology
  • Loading branch information
syphax-bouazzouni committed Nov 30, 2023
1 parent dcff39f commit a5b1a2c
Show file tree
Hide file tree
Showing 38 changed files with 409 additions and 266 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ RUN bundle install

RUN echo "--modules-folder /node_modules" > .yarnrc
COPY package.json *yarn* ./
RUN yarn install && yarn build
RUN yarn install

COPY . .

Expand Down
4 changes: 4 additions & 0 deletions app/assets/images/icons/law.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions app/assets/stylesheets/bioportal.scss
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,32 @@ body{

}

.disabled-link{
color: #888888 !important;
span{
opacity: 0.6;
}
a {
color: #888888 !important;
}
svg path{
fill: #888888 !important;
}
}
.text-truncate-scroll{
overflow: scroll;
white-space: nowrap;
}


.bg-warning-light{
background-color: var(--bg-warning-light-color) !important;
}

.bg-danger-light{
background-color: var(--bg-danger-light-color) !important;
}

@keyframes gradient {
0% {
background-position: 0% 50%;
Expand Down
14 changes: 7 additions & 7 deletions app/assets/stylesheets/components/alert.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,26 @@
align-items: center;
padding: 20px;
border-radius: 5px;


}

.alert-container.alert-info-type{
background-color: rgba(59, 130, 246, 0.1);
background-color: var(--bg-info-light-color);
}
.alert-container.alert-warning-type {
background-color: rgba(234, 179, 8, 0.1);
background-color: var(--bg-warning-light-color);
}
.alert-container.alert-danger-type {
background-color: rgba(239, 68, 68, 0.1);
background-color: var(--bg-danger-light-color);
}
.alert-container.alert-success-type {
background-color: rgba(34, 197, 94, 0.1);
background-color: var(--bg-success-light-color);
}





.alert-message{
font-size: 16px;
margin: 0 10px;
Expand All @@ -43,8 +45,6 @@
}




.alert-icon svg{
width: 25px;
margin: 0 !important;
Expand Down
11 changes: 10 additions & 1 deletion app/assets/stylesheets/theme-variables.scss.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
--primary-color: #5499a4;
--hover-color: #6B96B7;
--secondary-color: #ffc107;
--light-color: #F0F5F6;
--admin-color: #145FF4;
--light-color: #F1F6FA;
--error-color: #EB4335;
Expand All @@ -44,6 +43,16 @@



// common variables
:root{
--container-max-width: 1248px;
--bg-info-light-color: rgba(59, 130, 246, 0.1);
--bg-danger-light-color: rgba(239, 68, 68, 0.1);
--bg-warning-light-color: rgba(234, 179, 8, 0.1);
--bg-success-light-color: rgba(34, 197, 94, 0.1);
}





Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
= render SearchInputComponent.new(id: 'agent' + @id, name:'agent' + @id, ajax_url: "/ajax/agents?agent_type=#{@agent_type}&name=",
item_base_url:"/agents/#{@id}?parent_id=#{@parent_id}&edit_on_modal=#{@edit_on_modal}&name_prefix=#{@name_prefix}&deletable=#{@deletable}&agent_id=", id_key: 'id',
use_cache: false,
actions_links: {create_new_agent: {link: "/agents/new?name=&id=#{@id}&parent_id=#{@parent_id}&type=#{@agent_type}&show_affiliations=#{@show_affiliations}&edit_on_modal=#{@edit_on_modal}&name_prefix=#{@name_prefix}[#{@id}]", target:'_self'}}) do |s|
actions_links: {create_new_agent: {link: "/agents/new?name=&id=#{@id}&parent_id=#{@parent_id}&type=#{@agent_type}&show_affiliations=#{@show_affiliations}&deletable=#{@deletable}&edit_on_modal=#{@edit_on_modal}&name_prefix=#{@name_prefix}[#{@id}]", target:'_self'}}) do |s|
- s.template do
%a{href: "LINK", class: "search-content", 'data-turbo-frame': '_self'}
%p.search-element.home-searched-ontology
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
- if @type == "static"
%span.chip_button_container{@html_options}
= @text || content
%span.chip_button_container{@html_options}
= @text || content
- else
%a.chip_button_container_clickable{@html_options}= @text || content
%span.chip_button_container_clickable{@html_options}
= @text || content
8 changes: 5 additions & 3 deletions app/components/input/select_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@

class Input::SelectComponent < Input::InputFieldComponent

def initialize(id: nil, label: '', name:, value: [], selected: '', placeholder: '', error_message: '', helper_text: '', multiple: false, open_to_add_values: false, data: {}, tooltip: nil)
def initialize(id: nil, label: '', name:, value: [], selected: '', placeholder: '', error_message: '', helper_text: '', multiple: false, open_to_add_values: false, required: false, data: {}, tooltip: nil)
super(label: label, name: name, value: value, placeholder: placeholder, error_message: error_message,
helper_text: helper_text, data: data)
@values = value
@selected = selected
@open_to_add_values = open_to_add_values
@multiple = multiple
@id = id
@required = required
end

def call
render Input::InputFieldComponent.new(name: @name, error_message: @error_message, helper_text: @helper_text, label: @label) do
render SelectInputComponent.new(id: @id, name: @name, values: @values, selected: @selected,
placeholder: @placeholder,
multiple: @multiple, open_to_add_values: @open_to_add_values, data: @data)
placeholder: @placeholder, required: @required,
multiple: @multiple, open_to_add_values: @open_to_add_values,
data: @data)
end
end
end
2 changes: 1 addition & 1 deletion app/components/layout/horizontal_list_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def call
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 overflow-hidden')
out = out + content_tag(:div, element, class: 'mr-1 mb-1 text-truncate-scroll')
end
raw out
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
%span.mx-1
= render ChipButtonComponent.new(type: "clickable") do
= ontology[:format]
- if ontology[:deprecated]
- if ontology_retired?(ontology)
%span.mx-1
= ontology_retired_badge(ontology)
- if ontology[:viewOfOnt]
Expand All @@ -68,8 +68,7 @@

- 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'}}
%span.admin-background
= render ChipButtonComponent.new(type: "clickable", text: "Debug")
= render ChipButtonComponent.new(type: "clickable", text: "Debug" , class: 'admin-background')
- else
.browse-ontology-container
.browse-sket
Expand Down
10 changes: 7 additions & 3 deletions app/components/select_input_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class SelectInputComponent < ViewComponent::Base

def initialize(id:, name:, values:, selected: nil, multiple: false, open_to_add_values: false, data: {}, placeholder: '')
def initialize(id:, name:, values:, selected: nil, multiple: false, open_to_add_values: false, required: false, data: {}, placeholder: '')
super
@id = id || ''
@name = name
Expand All @@ -12,21 +12,25 @@ def initialize(id:, name:, values:, selected: nil, multiple: false, open_to_add_
@open_to_add_values = open_to_add_values
@placeholder = placeholder
@data = data
@required = required
end

def call
select_input_tag(@id, @name, @values, @selected, multiple: @multiple, open_to_add_values: @open_to_add_values, placeholder: @placeholder)
select_input_tag(@id, @name, @values, @selected, multiple: @multiple, open_to_add_values: @open_to_add_values,
placeholder: @placeholder, required: @required)
end

private

def select_input_tag(id, name, values, selected, options = {})
multiple = options[:multiple] || false
open_to_add_values = options[:open_to_add_values] || false
required = options[:required] || false
placeholder = options[:placeholder] || ''
data = @data.merge({
'select-input-multiple-value': multiple,
'select-input-open-add-value': open_to_add_values
'select-input-open-add-value': open_to_add_values,
'select-input-required-value': required,
})
data[:controller] = "#{data[:controller]} select-input"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {useTomSelect} from "../../javascript/mixins/useTomSelect"
export default class extends Controller {
static values = {
multiple: {type: Boolean, default: false},
openAdd: {type: Boolean, default: false}
openAdd: {type: Boolean, default: false},
required: {type: Boolean, default: false}
};


Expand Down Expand Up @@ -34,10 +35,14 @@ export default class extends Controller {
myOptions['create'] = true;
}

useTomSelect(this.element, myOptions, this.#triggerChange.bind(this))
this.select = useTomSelect(this.element, myOptions, this.#triggerChange.bind(this))
}

#triggerChange() {
document.dispatchEvent(new Event('change', {target: this.element}))
if (this.requiredValue && !this.multipleValue && this.select.getValue() === ""){
this.select.setValue(Object.keys(this.select.options)[0])
}

document.dispatchEvent(new Event('change', { target: this.element }))
}
}
2 changes: 1 addition & 1 deletion app/components/switch_input_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(id:, name: , label: '', value: '', checked: false, boolean_switch
end

def boolean_switch_action
"this.previousElementSibling.value = this.previousElementSibling.value !== 'true'" if @boolean_switch
"this.parentElement.previousElementSibling.value = this.parentElement.previousElementSibling.value !== 'true'" if @boolean_switch
end

def check_box_name
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
%div.switch-filter
- if @boolean_switch
= hidden_field_tag @name, @value
- if content || !@label.empty?
= content_tag(:div, content || @label, style: @style)
- if @boolean_switch
= hidden_field_tag @name, @value
%label.switch{for: check_box_id}
= check_box_tag check_box_name, @value, @checked, class: '', id: check_box_id, onChange: "#{boolean_switch_action}"
%span.slider
21 changes: 13 additions & 8 deletions app/controllers/agents_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,36 @@ def new
@agent.name = params[:name]
@name_prefix = params[:name_prefix] || ''
@show_affiliations = params[:show_affiliations].nil? || params[:show_affiliations]&.eql?('true')
@deletable = params[:deletable]&.eql?('true')
end

def create
new_agent = save_agent(agent_params)
parent_id = params[:parent_id]
name_prefix = params[:name_prefix]
alert_id = agent_id_alert_container_id(params[:id], parent_id)

deletable = params[:deletable]&.eql?('true')
if new_agent.errors
render_turbo_stream alert_error(id: alert_id) { JSON.pretty_generate(response_errors(new_agent)) }
else
success_message = 'New Agent added successfully'
streams = [alert_success(id: alert_id) { success_message }]

streams << prepend('agents_table_content', partial: 'agents/show_line', locals: { agent: new_agent })
streams << replace_agent_form(new_agent, agent_id: nil, frame_id: params[:id], parent_id: parent_id, name_prefix: name_prefix) if params[:parent_id]
streams << replace_agent_form(new_agent, agent_id: nil, frame_id: params[:id],
parent_id: parent_id, name_prefix: name_prefix,
deletable: deletable
) if params[:parent_id]

render_turbo_stream(*streams)
end
end

def edit
@agent = LinkedData::Client::Models::Agent.find("#{rest_url}/Agents/#{params[:id]}")
@name_prefix = params[:parent_id] || ''
@name_prefix = params[:name_prefix] || ''
@show_affiliations = params[:show_affiliations].nil? || params[:show_affiliations].eql?('true')
@deletable = params[:deletable].to_s.eql?('true')
end

def show_search
Expand All @@ -88,18 +93,18 @@ def update

parent_id = params[:parent_id]
alert_id = agent_alert_container_id(agent, parent_id)

deletable = params[:deletable]&.eql?('true')
if response_error?(agent_update)
render_turbo_stream(alert_error(id: alert_id) { JSON.pretty_generate(response_errors(agent_update)) })
else
success_message = 'Agent successfully updated'
table_line_id = agent_table_line_id(agent_id(agent))

agent = LinkedData::Client::Models::Agent.find(agent.id)
streams = [alert_success(id: alert_id) { success_message },
replace(table_line_id, partial: 'agents/show_line', locals: { agent: agent })
]

streams << replace_agent_form(agent, parent_id: parent_id) if params[:parent_id]
streams << replace_agent_form(agent, agent_id: agent_id(agent.id), name_prefix: params[:name_prefix] , parent_id: parent_id, deletable: deletable) if params[:parent_id]

render_turbo_stream(*streams)
end
Expand Down Expand Up @@ -176,14 +181,14 @@ def destroy

private

def replace_agent_form(agent, agent_id: nil, frame_id: nil, parent_id:, partial: 'agents/agent_show', name_prefix: '')
def replace_agent_form(agent, agent_id: nil, frame_id: nil, parent_id:, partial: 'agents/agent_show', name_prefix: '', deletable: true)

frame_id = frame_id ? agent_id_frame_id(frame_id, parent_id) : agent_frame_id(agent, parent_id)

replace(frame_id, partial: partial, layout: false ,
locals: { agent_id: agent_id, agent: agent, name_prefix: name_prefix, parent_id: parent_id,
edit_on_modal: false,
deletable: true})
deletable: deletable})
end

def save_agent(params)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/concerns/submission_filter.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def filters_params(params, includes: BROWSE_ATTRIBUTES.join(','), page: 1, pages
isOfType: :isOfType,
format: :hasOntologyLanguage,
hasFormalityLevel: :hasFormalityLevel,
search: %i[name acronym],
search: %i[name acronym description],
sort_by: :order_by
}

Expand Down
12 changes: 7 additions & 5 deletions app/controllers/ontologies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -319,13 +319,15 @@ def summary
["#{helpers.attr_label(attr, attr_metadata: helpers.attr_metadata(attr), show_tooltip: false)}(#{relation})",
relation]
end
@config_properties = properties_hash_values([:obsoleteParent] + category_attributes["object description properties"])
@methodology_properties = properties_hash_values(category_attributes["methodology"] + [:toDoList, :notes])
@config_properties = properties_hash_values(category_attributes["object description properties"])
@methodology_properties = properties_hash_values(category_attributes["methodology"])
@agents_properties = properties_hash_values(category_attributes["persons and organizations"])
@dates_properties = properties_hash_values(category_attributes["dates"], custom_labels: {released: "Initially created On"})
@links_properties = properties_hash_values(category_attributes["links"] + [:associatedMedia, :bugDatabase, :mailingList, :uriRegexPattern])
@identifiers = properties_hash_values([:URI, :versionIRI, :identifier, :exampleIdentifier])
@projects_properties = properties_hash_values(category_attributes["usage"] + [:award])
@links_properties = properties_hash_values(category_attributes["links"])
@content_properties = properties_hash_values(category_attributes["content"])
@community_properties = properties_hash_values(category_attributes["community"] + [:notes])
@identifiers = properties_hash_values([:URI, :versionIRI, :identifier])
@projects_properties = properties_hash_values(category_attributes["usage"])
@ontology_icon_links = [%w[summary/download dataDump],
%w[summary/homepage homepage],
%w[summary/documentation documentation],
Expand Down
3 changes: 3 additions & 0 deletions app/controllers/subscriptions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ def create
# So here we re-generate a new subscription Array (instead of directly updating it, which causes error)
all_subs = []
u.subscription.each do |subs|
next if subs.ontology.nil?

# Add all subscription to the array, but not the one to be deleted
if !subs.ontology.split('/').last.eql?(ont.acronym)
all_subs.push({ontology: subs.ontology, notification_type: subs.notification_type})
Expand All @@ -42,6 +44,7 @@ def create
already_subscribed = false
all_subs = []
u.subscription.each do |subs|
next if subs.ontology.nil?
# add all existing subscriptions
all_subs.push({ontology: subs.ontology, notification_type: subs.notification_type})
if subs.ontology.split("/").last == ont.acronym && subs.notification_type == "NOTES"
Expand Down
Loading

0 comments on commit a5b1a2c

Please sign in to comment.