Skip to content

Commit

Permalink
add selected argument to LanguageSelector component
Browse files Browse the repository at this point in the history
  • Loading branch information
syphax-bouazzouni committed Sep 5, 2023
1 parent 7478c14 commit dbb8213
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 21 deletions.
7 changes: 4 additions & 3 deletions app/assets/stylesheets/upload_ontology.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
display: flex;
justify-content: center;
padding: 40px 0;
.show {
display: block;
}
}

.upload-ontology-card {
Expand Down Expand Up @@ -50,9 +53,7 @@
display: none;
}

.show {
display: block;
}


.upload-ontology-desc {
font-size: 12px;
Expand Down
5 changes: 3 additions & 2 deletions app/components/input/language_selector_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

class Input::LanguageSelectorComponent < ViewComponent::Base

def initialize(languages:, id: '', name: '' )
def initialize(languages:, selected: nil, id: '', name: '' )
super
@languages = languages
@id = id
@name = languages
@selected = selected
end

def languages_options
Expand All @@ -20,6 +21,6 @@ def languages_options
end

def call
render SelectInputComponent.new(id: @id, name: @name, values: languages_options, placeholder: 'Select a language')
render SelectInputComponent.new(id: @id, name: @name, values: languages_options, selected: @selected, placeholder: 'Select a language')
end
end
2 changes: 1 addition & 1 deletion 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:, multiple: false, open_to_add_values: false, data: {}, placeholder: '')
def initialize(id:, name:, values:, selected: nil, multiple: false, open_to_add_values: false, data: {}, placeholder: '')
super
@id = id || ''
@name = name
Expand Down
37 changes: 24 additions & 13 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
require "active_support/core_ext/integer/time"

Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# In the development environment your application's code is reloaded on
# every request. This slows down response time but is perfect for development
config.assets.debug = true
# In the development environment your application's code is reloaded any time
# it changes. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.
config.cache_classes = false

Expand All @@ -11,15 +14,18 @@
# Show full error reports.
config.consider_all_requests_local = true

# Enable server timing
config.server_timing = true

# Enable/disable caching. By default caching is disabled.
# Run rails dev:cache to toggle caching.
if Rails.root.join('tmp', 'caching-dev.txt').exist?
if Rails.root.join("tmp/caching-dev.txt").exist?
config.action_controller.perform_caching = true
config.action_controller.enable_fragment_cache_logging = true

config.cache_store = :memory_store
config.public_file_server.headers = {
'Cache-Control' => "public, max-age=#{2.days.to_i}"
"Cache-Control" => "public, max-age=#{2.days.to_i}"
}
else
config.action_controller.perform_caching = false
Expand All @@ -38,37 +44,42 @@
# Print deprecation notices to the Rails logger.
config.active_support.deprecation = :log

# Raise exceptions for disallowed deprecations.
config.active_support.disallowed_deprecation = :raise

# Tell Active Support which deprecation messages to disallow.
config.active_support.disallowed_deprecation_warnings = []

# Raise an error on page load if there are pending migrations.
config.active_record.migration_error = :page_load

# Highlight code that triggered database queries in logs.
config.active_record.verbose_query_logs = true

# Debug mode disables concatenation and preprocessing of assets.
# This option may cause significant delays in view rendering with a large
# number of complex assets.
config.assets.debug = true
# Suppress logger output for asset requests.
config.assets.quiet = true

# memcache setup
config.cache_store = ActiveSupport::Cache::MemCacheStore.new('cache', namespace: 'BioPortal')
config.cache_store = ActiveSupport::Cache::MemCacheStore.new('cache:11211', namespace: 'BioPortal')

# Silence cache output
config.cache_store.logger = Logger.new("/dev/null") if config.cache_store.respond_to?(:logger)

# Add custom data attributes to sanitize allowed list
config.action_view.sanitized_allowed_attributes = ['id', 'class', 'style', 'data-cls', 'data-ont']
config.view_component.generate.sidecar = true

config.file_watcher = ActiveSupport::FileUpdateChecker

# Include BioPortal-specific configuration options
require Rails.root.join('config', "bioportal_config_#{Rails.env}.rb")

# Raises error for missing translations.
# config.action_view.raise_on_missing_translations = true
# config.i18n.raise_on_missing_translations = true

# Annotate rendered view with file names.
# config.action_view.annotate_rendered_view_with_filenames = true

# Use an evented file watcher to asynchronously detect changes in source code,
# routes, locales, etc. This feature depends on the listen gem.
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
# Uncomment if you wish to allow Action Cable access from any origin.
# config.action_cable.disable_request_forgery_protection = true
end
4 changes: 2 additions & 2 deletions test/components/previews/input/select_component_preview.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ def open_to_add(id: "", name: "", values: ["choices 1", "choices 2", "choices 3"
def with_icon
values = [
['', ''],
["<span class='f32'>\n<span class='flag fr' style='margin-right: 0.5em;'></span></span><span>FR</span>", 'fr'],
["<span class='f32'>\n<span class='flag gb' style='margin-right: 0.5em;'></span><span><span>EN</span>", 'en']
["<span class='flag-icon flag-icon-fr'></span></span></span><span>FR</span>", 'fr'],
["<span class='flag-icon flag-icon-gb'></span><span><span>EN</span>", 'en']
]
render SelectInputComponent.new(id: 'id', name: 'name', values: values, placeholder: 'Choose a language')
end
Expand Down

0 comments on commit dbb8213

Please sign in to comment.