Skip to content

A Hydra (Hyrax) application demonstrating a linked data cache for controlled vocabularies.

Notifications You must be signed in to change notification settings

curationexperts/ldc-qa-demo

Repository files navigation

Controlled Vocabulary Demo

This is a demonstration of linked controlled vocabularies in Hyrax. This application uses a Linked Data Fragments based caching approach to support query of both web-based and local controlled vocabularies.

Adding Controlled Vocabulary Dropdown Options

To create your own dropdown with authorities you extend the QASelectService class. In this project it's done at: /chf/app/services/hyrax/name_authorities.rb

module Hyrax
  # Provide select options for the copyright status (edm:rights) field
  class NameAuthorities < QaSelectService
    def initialize
      super('names')
    end
  end
end

You initialize the service with the name of a YAML file names.yml that contains a list of authorities:

terms:
    - id: /authorities/search/loc/names
      term: LOC Names
      active: true
    - id: /authorities/search/assign_fast/all
      term: FAST
      active: true

Then in the partials for the input field at /app/views/records/edit_fields/_creator.html.erb:

<% name_authorities = Hyrax::NameAuthorities.new %>

<%=
  f.input key,
  as: :multi_value,
  input_html: {
  class: 'form-control',
  data: { 'autocomplete-url' => "/authorities/search/loc/names",
'autocomplete' => key }
} ,
required: f.object.required?(key) %>

<%= f.input key, collection: name_authorities.select_active_options, label: false %>

About

A Hydra (Hyrax) application demonstrating a linked data cache for controlled vocabularies.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published