Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions app/dictionaries/keywords_dictionary.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Dictionary of Keywords
class KeywordsDictionary < Dictionary

DEFAULT_FILE = 'keywords.yml'

private

def dictionary_filepath
get_file_path 'keywords', DEFAULT_FILE
end
Comment on lines +1 to +10

end
15 changes: 8 additions & 7 deletions app/views/common/_dropdown.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ render :partial => 'common/dropdown',
options ||= format_for_dropdown(field_name.capitalize.constantize.all)
existing ||= format_for_dropdown(resource.send(field_name.pluralize))

# Remove existing objects from the pool of options
options = options - existing
dropdown_toggle_button_name ||= ''
if dropdown_toggle_button_name.blank?
dropdown_toggle_button_name = "Add #{field_name.to_s.sub(/_ids?\z/, '').humanize}"
end

# show the required label?
required ||= false

Expand All @@ -43,6 +36,14 @@ render :partial => 'common/dropdown',

# check title
title ||= ''

# Remove existing objects from the pool of options
options = options - existing
dropdown_toggle_button_name ||= ''
if dropdown_toggle_button_name.blank?
dropdown_toggle_button_name = "Add #{field_label.to_s.sub(/_ids?\z/, '').humanize}"
end

%>

<div class="form-group<%= ' has-error' if errors.size > 0 %>">
Expand Down
12 changes: 10 additions & 2 deletions app/views/events/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,16 @@
title: t('events.hints.hosts') %>

<!-- Field: Keywords -->
<%= f.multi_input :keywords, errors: @event.errors[:keywords],
title: t('events.hints.keywords') %>
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' %>
<%= f.dropdown :keywords,
options: KeywordsDictionary.instance.options_for_select,
Comment on lines +94 to +95
label: t('activerecord.attributes.event.keywords'),
errors: @event.errors[:keywords],
title: t('events.hints.keywords') %>
<% else %>
<%= f.multi_input :keywords, errors: @event.errors[:keywords],
title: t('events.hints.keywords') %>
<% end %>

<!-- Field: Fields -->
<% if !TeSS::Config.feature['disabled'].include? 'ardc_fields_of_research' %>
Expand Down
11 changes: 10 additions & 1 deletion app/views/materials/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,16 @@
<hr>

<!-- Field: Keywords -->
<%= f.multi_input :keywords, title: t('materials.hints.keywords'), visibility_toggle: TeSS::Config.feature['materials_disabled'] %>
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' %>
<%= f.dropdown :keywords,
options: KeywordsDictionary.instance.options_for_select,
label: t('activerecord.attributes.event.keywords'),
errors: @material.errors[:keywords],
title: t('events.hints.keywords'),
visibility_toggle: TeSS::Config.feature['materials_disabled'] %>
Comment on lines +41 to +46
<% else %>
<%= f.multi_input :keywords, title: t('materials.hints.keywords'), visibility_toggle: TeSS::Config.feature['materials_disabled'] %>
Comment on lines +40 to +48
<% end %>

<!-- Field: Licence -->
<%= f.input :licence, collection: licence_options_for_select, as: :grouped_select, group_method: :last, group_label_method: :first,
Expand Down
3 changes: 3 additions & 0 deletions config/dictionaries/keywords.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
placeholder:
title: placeholder
description: 'Placeholder'
2 changes: 1 addition & 1 deletion config/tess.example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ default: &default
bioschemas_testing: false
collection_curation: true
auto_parse_vars: [] # available features to auto parse from description: ['keywords', 'target_audience']
controlled_vocabulary_vars: [] # available features: ['target_audience']
controlled_vocabulary_vars: [] # available features: ['keywords', 'target_audience']

# User login
invitation: false
Expand Down
Loading