Skip to content

make keywords available for controlled vocabulary#1291

Open
mikesndrs wants to merge 1 commit into
ElixirTeSS:masterfrom
DaanVanVugt:feature/keywords_controlled_vocabulary
Open

make keywords available for controlled vocabulary#1291
mikesndrs wants to merge 1 commit into
ElixirTeSS:masterfrom
DaanVanVugt:feature/keywords_controlled_vocabulary

Conversation

@mikesndrs
Copy link
Copy Markdown
Contributor

@mikesndrs mikesndrs commented Apr 24, 2026

Summary of changes
Enable controlled vocabulary dropdown for keywords

Checklist

  • I have read and followed the CONTRIBUTING guide.
  • I confirm that I have the authority necessary to make this contribution on behalf of its copyright owner and agree to license it to the TeSS codebase under the BSD license.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds optional controlled-vocabulary support for keywords so events and materials can use the same dictionary-backed dropdown pattern already used for other vocabularies.

Changes:

  • Add a new KeywordsDictionary class and default config/dictionaries/keywords.yml.
  • Enable keywords as a supported controlled_vocabulary_vars feature in config comments.
  • Switch event/material keyword fields to use f.dropdown when the controlled-vocabulary feature is enabled, and update the shared dropdown button label logic.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
config/tess.example.yml Documents keywords as an allowed controlled-vocabulary feature flag.
config/dictionaries/keywords.yml Adds the default keyword dictionary file.
app/views/materials/_form.html.erb Uses dictionary-backed dropdown keywords for materials when enabled.
app/views/events/_form.html.erb Uses dictionary-backed dropdown keywords for events when enabled.
app/views/common/_dropdown.html.erb Changes default dropdown button text generation to use the field label.
app/dictionaries/keywords_dictionary.rb Adds the dictionary wrapper used to load keyword options.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to +95
<%= f.dropdown :keywords,
options: KeywordsDictionary.instance.options_for_select,
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' %>
<%= f.dropdown :keywords,
options: KeywordsDictionary.instance.options_for_select,
label: t('activerecord.attributes.event.keywords'),
Comment on lines +41 to +46
<%= 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'] %>
<% if TeSS::Config.feature['controlled_vocabulary_vars'].include? 'keywords' %>
<%= f.dropdown :keywords,
options: KeywordsDictionary.instance.options_for_select,
label: t('activerecord.attributes.event.keywords'),
options: KeywordsDictionary.instance.options_for_select,
label: t('activerecord.attributes.event.keywords'),
errors: @material.errors[:keywords],
title: t('events.hints.keywords'),
Comment on lines +40 to +48
<% 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'] %>
<% else %>
<%= f.multi_input :keywords, title: t('materials.hints.keywords'), visibility_toggle: TeSS::Config.feature['materials_disabled'] %>
Comment on lines +1 to +10
# Dictionary of Keywords
class KeywordsDictionary < Dictionary

DEFAULT_FILE = 'keywords.yml'

private

def dictionary_filepath
get_file_path 'keywords', DEFAULT_FILE
end
Copy link
Copy Markdown
Member

@fbacall fbacall left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned on slack, maybe remove the keywords.yml dictionary since it just has placeholders

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants