Skip to content

Commit

Permalink
🚧 Add files from PALs Hyku not in other repos
Browse files Browse the repository at this point in the history
This is a first pass of the PALs work.  There was a lot of head
scratching and copying things into Hyku Prime.  Together this is a
rough process.
  • Loading branch information
jeremyf committed Apr 5, 2024
1 parent 17bf6cf commit 3595d6f
Show file tree
Hide file tree
Showing 181 changed files with 149,839 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/actors/hyrax/actors/cdl_actor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated via
# `rails generate hyrax:work Cdl`
module Hyrax
module Actors
class CdlActor < Hyrax::Actors::BaseActor
end
end
end
8 changes: 8 additions & 0 deletions app/actors/hyrax/actors/etd_actor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Generated via
# `rails generate hyrax:work Etd`
module Hyrax
module Actors
class EtdActor < Hyrax::Actors::BaseActor
end
end
end
90 changes: 90 additions & 0 deletions app/actors/hyrax/actors/oer_actor.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# Generated via
# `rails generate hyrax:work Oer`
module Hyrax
module Actors
class OerActor < Hyrax::Actors::BaseActor
def create(env)
attributes_collection = env.attributes.delete(:related_members_attributes)
env = add_custom_relations(env, attributes_collection)
super
end

def update(env)
attributes_collection = env.attributes.delete(:related_members_attributes)
env = add_custom_relations(env, attributes_collection)
super
end

private

def add_custom_relations(env, attributes_collection)
return env unless attributes_collection
attributes = attributes_collection&.sort_by { |i, _| i.to_i }&.map { |_, attributes| attributes }

# checking for existing works to avoid rewriting/loading works that are already attached
existing_previous_works = env.curation_concern.previous_version_id
existing_newer_works = env.curation_concern.newer_version_id
existing_alternate_works = env.curation_concern.alternate_version_id
existing_related_items = env.curation_concern.related_item_id

attributes&.each do |attributes|
next if attributes['id'].blank?
if existing_previous_works&.include?(attributes['id']) ||
existing_newer_works&.include?(attributes['id']) ||
existing_alternate_works&.include?(attributes['id']) ||
existing_related_items&.include?(attributes['id'])

if existing_previous_works&.include?(attributes['id'])
env = remove(env, attributes['id'], attributes['relationship']) if
ActiveModel::Type::Boolean.new.cast(attributes['_destroy']) && attributes['relationship'] == 'previous-version'
elsif existing_newer_works&.include?(attributes['id'])
env = remove(env, attributes['id'], attributes['relationship']) if
ActiveModel::Type::Boolean.new.cast(attributes['_destroy']) && attributes['relationship'] == 'newer-version'
elsif existing_alternate_works&.include?(attributes['id'])
env = remove(env, attributes['id'], attributes['relationship']) if
ActiveModel::Type::Boolean.new.cast(attributes['_destroy']) && attributes['relationship'] == 'alternate-version'
elsif existing_related_items&.include?(attributes['id'])
env = remove(env, attributes['id'], attributes['relationship']) if
ActiveModel::Type::Boolean.new.cast(attributes['_destroy']) && attributes['relationship'] == 'related-item'
end
else
env = add(env, attributes['id'], attributes['relationship'])
end
end
env
end

def add(env, id, relationship)
rel = "#{relationship.underscore}_id"
case rel
when "previous_version_id"
env.curation_concern.previous_version_id = (env.curation_concern.previous_version_id.to_a << id)
when "newer_version_id"
env.curation_concern.newer_version_id = (env.curation_concern.newer_version_id.to_a << id)
when "alternate_version_id"
env.curation_concern.alternate_version_id = (env.curation_concern.alternate_version_id.to_a << id)
when "related_item_id"
env.curation_concern.related_item_id = (env.curation_concern.related_item_id.to_a << id)
end
env.curation_concern.save
env
end

def remove(env, id, relationship)
rel = "#{relationship.underscore}_id"
case rel
when "previous_version_id"
env.curation_concern.previous_version_id = (env.curation_concern.previous_version_id.to_a - [id])
when "newer_version_id"
env.curation_concern.newer_version_id = (env.curation_concern.newer_version_id.to_a - [id])
when "alternate_version_id"
env.curation_concern.alternate_version_id = (env.curation_concern.alternate_version_id.to_a - [id])
when "related_item_id"
env.curation_concern.related_item_id = (env.curation_concern.related_item_id.to_a - [id])
end
env.curation_concern.save
env
end
end
end
end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/Hyku_Commons_Logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/imls.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/louis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/palci.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/palni.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/viva.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
31 changes: 31 additions & 0 deletions app/assets/stylesheets/themes/image_show.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.image_show {
.show-actions {
.btn.btn-default, .btn.btn-danger, .btn-group {
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
.btn-group {
padding: 0;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
}
.mb-1 {
margin-bottom: 1em;
}
.work-show dt, .work-show dd {
padding: 0;
}
.work-show ul.tabular {
padding-inline-start: 20px;
}
dl.work-show {
font-weight: 700;
ul.tabular {
font-weight: 400;
}
}
}
35 changes: 35 additions & 0 deletions app/assets/stylesheets/themes/text_show.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
.text_show {
dl.work-show dd {
border-bottom: 1px solid #ddd;
.tabular {
border-bottom: none;
}
}
dl.work-show {
font-weight: 700;
.tabular {
border-bottom: 1px solid #ddd;
font-size: 18px;
font-weight: 400;
}
}

li.attribute, td.attribute {
font-size: 18px;
}
.relationships-box {
border: 1px solid #ddd;
background-color: #f8f8f8;
}
.table-striped > tbody > tr:nth-of-type(odd) {
background-color: #ffffff;
}
tr.file_set.attributes td {
padding-top: 18px;
}
.representative-media {
display: block;
max-width: 100%;
height: auto;
}
}
14 changes: 14 additions & 0 deletions app/controllers/hyrax/cdls_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated via
# `rails generate hyrax:work Cdl`
module Hyrax
# Generated controller for Cdl
class CdlsController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::Cdl

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::CdlPresenter
end
end
14 changes: 14 additions & 0 deletions app/controllers/hyrax/etds_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated via
# `rails generate hyrax:work Etd`
module Hyrax
# Generated controller for Etd
class EtdsController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::Etd

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::EtdPresenter
end
end
14 changes: 14 additions & 0 deletions app/controllers/hyrax/oers_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated via
# `rails generate hyrax:work Oer`
module Hyrax
# Generated controller for Oer
class OersController < ApplicationController
# Adds Hyrax behaviors to the controller.
include Hyrax::WorksControllerBehavior
include Hyrax::BreadcrumbsForWorks
self.curation_concern_type = ::Oer

# Use this line if you want to use a custom presenter
self.show_presenter = Hyrax::OerPresenter
end
end
34 changes: 34 additions & 0 deletions app/controllers/roles_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: true

##
# CRUD actions for assigning exhibit roles to
# existing users
class RolesController < ApplicationController
load_and_authorize_resource :user, parent: false
layout 'hyrax/dashboard'

before_action do
authorize! :manage, Role
end

def index
@users = User.all
add_breadcrumb t(:'hyrax.controls.home'), root_path
add_breadcrumb t(:'hyrax.dashboard.breadcrumbs.admin'), hyrax.dashboard_path
add_breadcrumb t(:'hyrax.admin.sidebar.roles_and_permissions'), site_roles_path
end

def update
if @user.update(user_params)
redirect_to site_roles_path, notice: notice
else
render action: 'index'
end
end

protected

def user_params
params.require(:user).permit(site_roles: [])
end
end
10 changes: 10 additions & 0 deletions app/factories/bulkrax/related_member_object_factory.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# frozen_string_literal: true

module Bulkrax
class RelatedMemberObjectFactory < ObjectFactory
# TODO: We handle this for the new ValkyrieObjectFactory
def permitted_attributes
%i[related_members_attributes] + super
end
end
end
17 changes: 17 additions & 0 deletions app/forms/hyrax/cdl_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated via
# `rails generate hyrax:work Cdl`
module Hyrax
# Generated form for Cdl
class CdlForm < Hyrax::Forms::WorkForm
include Hyrax::FormTerms
self.model_class = ::Cdl
include HydraEditor::Form::Permissions
include PdfFormBehavior
include VideoEmbedFormBehavior
# List these terms first after the "Additional fields" divider
self.terms = %i[contributing_library library_catalog_identifier admin_note] + self.terms # rubocop:disable Style/RedundantSelf
self.terms += %i[resource_type additional_information bibliographic_citation chronology_note]
self.terms -= %i[based_near]
self.required_fields = %i[title creator keyword rights_statement resource_type]
end
end
41 changes: 41 additions & 0 deletions app/forms/hyrax/etd_form.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Generated via
# `rails generate hyrax:work Etd`
module Hyrax
# Generated form for Etd
class EtdForm < Hyrax::Forms::WorkForm
include Hyrax::FormTerms
self.model_class = ::Etd
include HydraEditor::Form::Permissions
include PdfFormBehavior
include VideoEmbedFormBehavior

self.terms = [:admin_note] + self.terms # rubocop:disable Style/RedundantSelf
self.terms += [
:resource_type,
:format,
:degree_name,
:degree_level,
:degree_discipline,
:degree_grantor,
:advisor,
:committee_member,
:department,
:creator,
:additional_information,
:bibliographic_citation,
]

self.required_fields = [
:title,
:creator,
:keyword,
:rights_statement,
:date_created,
:degree_name,
:degree_level,
:degree_discipline,
:degree_grantor,
:resource_type
]
end
end
33 changes: 33 additions & 0 deletions app/forms/hyrax/forms/collection_form_decorator.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# frozen_string_literal: true

module Hyrax
module Forms
# Add new method to filter out access_grants for Collection Roles and Work Roles
# for Collections and AdminSets, respectively. We do this because access_grants
# for Roles should never be allowed to be removed.
#
# @see app/views/hyrax/dashboard/collections/_form_share_table.html.erb
module CollectionFormDecorator
def self.decorate(base)
base.prepend(self)

# Using += results in a duplicate :collection_subtitle being added
base.terms |= [:collection_subtitle]
end

def primary_terms
[:title, :collection_subtitle, :description]
end

def filter_access_grants_by_access(access)
roles_to_filter = ::RolesService::COLLECTION_ROLES + ::RolesService::WORK_ROLES
filtered_access_grants = permission_template.access_grants.select(&access)
filtered_access_grants.reject! { |ag| roles_to_filter.include?(ag.agent_id) }

filtered_access_grants || []
end
end
end
end

Hyrax::Forms::CollectionFormDecorator.decorate(Hyrax::Forms::CollectionForm)
Loading

0 comments on commit 3595d6f

Please sign in to comment.