Sha256: 554b4f6785fd8722c1b93e46a042a529ef5974b42443dbe0efc011b4b76bb108
Contents?: true
Size: 1.54 KB
Versions: 11
Compression:
Stored size: 1.54 KB
Contents
# frozen_string_literal: true module Hyrax module MembershipHelper ## # @param resource [#member_of_collection_ids, #member_of_collections_json] # # @return [String] JSON for `data-members` # # @todo optimize collection name lookup. the legacy `WorkForm` # implementation pulls all the collections already (though maybe with # instance-level caching?), but we should consider doing this more # efficiently. # # @see app/assets/javascripts/hyrax/relationships.js def member_of_collections_json(resource) return resource.member_of_collections_json if resource.respond_to?(:member_of_collections_json) resource = resource.model if resource.respond_to?(:model) Hyrax.custom_queries.find_collections_for(resource: resource).map do |collection| { id: collection.id.to_s, label: collection.title.first, path: url_for(collection) } end.to_json end ## # @param resource [#work_members_json] # # @return [String] JSON for `data-members` # # @see app/assets/javascripts/hyrax/relationships.js def work_members_json(resource) return resource.work_members_json if resource.respond_to?(:work_members_json) resource = resource.model if resource.respond_to?(:model) Hyrax.custom_queries.find_child_works(resource: resource).map do |member| { id: member.id.to_s, label: member.title.first, path: main_app.url_for([member, { only_path: true }]) } end.to_json end end end
Version data entries
11 entries across 11 versions & 1 rubygems