Skip to content

Commit 70d6272

Browse files
committed
copilot comments
1 parent 53c162f commit 70d6272

8 files changed

Lines changed: 14 additions & 15 deletions

File tree

app/dictionaries/dictionary.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,11 @@ def keys
7878
private
7979

8080
def load_dictionary
81-
YAML.safe_load(File.read(dictionary_filepath)).with_indifferent_access
81+
if File.exist?(dictionary_filepath)
82+
YAML.safe_load(File.read(dictionary_filepath)).with_indifferent_access
83+
else
84+
{}
85+
end
8286
end
8387

8488
def get_file_path(config_file, default_file)

app/dictionaries/keywords_dictionary.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ class KeywordsDictionary < Dictionary
33

44
DEFAULT_FILE = 'keywords.yml'
55

6-
private
7-
86
def dictionary_filepath
97
get_file_path 'keywords', DEFAULT_FILE
108
end

app/dictionaries/target_audience_dictionary.rb

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ class TargetAudienceDictionary < Dictionary
33

44
DEFAULT_FILE = 'target_audience.yml'
55

6-
private
7-
86
def dictionary_filepath
97
get_file_path 'target_audience', DEFAULT_FILE
108
end

app/helpers/application_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,7 @@ def field_lock(name, _options = {})
362362
def dropdown(name, options = {})
363363
existing_values = object.send(name.to_sym)
364364
existing = options[:options].select { |_label, value| existing_values.include?(value) }
365+
visibility_toggle = options[:visibility_toggle] || []
365366
@template.render(partial: 'common/dropdown', locals: { field_name: name, f: self,
366367
model_name: options[:model_name],
367368
resource: object,
@@ -370,7 +371,8 @@ def dropdown(name, options = {})
370371
field_label: options[:label],
371372
required: options[:required],
372373
errors: options[:errors],
373-
title: options[:title] })
374+
title: options[:title],
375+
hidden: hidden?(name, visibility_toggle) })
374376
end
375377

376378
def hidden?(name, visibility_toggle)

app/views/common/_dropdown.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ render :partial => 'common/dropdown',
4646

4747
%>
4848

49-
<div class="form-group<%= ' has-error' if errors.size > 0 %>">
49+
<div class="form-group<%= ' has-error' if errors.size > 0 %><%= ' hidden' if hidden %>">
5050

5151
<% if required %><label class="control-label string required"><abbr title="required">*</abbr></label><% end %>
5252
<%= f.label field_label, class: 'control-label' %>

app/views/events/_form.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,10 +90,10 @@
9090
title: t('events.hints.hosts') %>
9191

9292
<!-- Field: Keywords -->
93-
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' %>
93+
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' && File.exist?(KeywordsDictionary.instance.dictionary_filepath) %>
9494
<%= f.dropdown :keywords,
9595
options: KeywordsDictionary.instance.options_for_select,
96-
label: t('activerecord.attributes.event.keywords'),
96+
label: t('activerecord.attributes.event.keywords', default: 'Keywords'),
9797
errors: @event.errors[:keywords],
9898
title: t('events.hints.keywords') %>
9999
<% else %>
@@ -113,7 +113,7 @@
113113
<% end %>
114114

115115
<!-- Field: Target Audience -->
116-
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'target_audience' %>
116+
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'target_audience' && File.exist?(TargetAudienceDictionary.instance.dictionary_filepath) %>
117117
<%= f.dropdown :target_audience,
118118
options: TargetAudienceDictionary.instance.options_for_select,
119119
label: 'Target audiences',

app/views/materials/_form.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@
4040
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' %>
4141
<%= f.dropdown :keywords,
4242
options: KeywordsDictionary.instance.options_for_select,
43-
label: t('activerecord.attributes.event.keywords'),
43+
label: t('activerecord.attributes.event.keywords', default: 'Keywords'),
4444
errors: @material.errors[:keywords],
45-
title: t('events.hints.keywords'),
45+
title: t('materials.hints.keywords'),
4646
visibility_toggle: TeSS::Config.feature['materials_disabled'] %>
4747
<% else %>
4848
<%= f.multi_input :keywords, title: t('materials.hints.keywords'), visibility_toggle: TeSS::Config.feature['materials_disabled'] %>

config/dictionaries/keywords.yml

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)