Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Hydra Editor #5262

Merged
merged 2 commits into from
Jul 25, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ gem "graphiql-rails", "1.4.10", group: :development
gem "graphql", "1.8.2"
gem "honeybadger"
gem "hydra-access-controls"
gem "hydra-editor", "~> 6.0"
gem "hydra-head"
gem "hydra-role-management"
gem "iiif_manifest", git: "https://github.com/samvera-labs/iiif_manifest"
Expand Down
20 changes: 0 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ GEM
afm (0.2.2)
airbrussh (1.4.0)
sshkit (>= 1.6.1, != 1.7.0)
almond-rails (0.3.0)
rails (>= 4.2)
amazing_print (1.4.0)
amq-protocol (2.3.2)
arabic-letter-connector (0.1.1)
Expand Down Expand Up @@ -185,10 +183,6 @@ GEM
aws-sigv4 (~> 1.4)
aws-sigv4 (1.5.0)
aws-eventstream (~> 1, >= 1.0.2)
babel-source (5.8.35)
babel-transpiler (0.7.0)
babel-source (>= 4.0, < 6)
execjs (~> 2.0)
backport (1.2.0)
bagit (0.4.4)
docopt (~> 0.5.0)
Expand Down Expand Up @@ -495,15 +489,6 @@ GEM
deprecation
mime-types (> 2.0, < 4.0)
mini_magick (>= 3.2, < 5)
hydra-editor (6.0.0)
active-fedora (>= 9.0.0)
activerecord (>= 5.2, < 6.1)
almond-rails (~> 0.1)
cancancan (~> 1.8)
rails (>= 5.2, < 6.1)
simple_form (>= 4.1.0, < 6.0)
sprockets (>= 3.7)
sprockets-es6
hydra-head (12.0.1)
hydra-access-controls (= 12.0.1)
hydra-core (= 12.0.1)
Expand Down Expand Up @@ -899,10 +884,6 @@ GEM
sprockets (4.1.1)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
sprockets-es6 (0.9.2)
babel-source (>= 5.8.11)
babel-transpiler
sprockets (>= 3.0.0)
sprockets-rails (3.4.2)
actionpack (>= 5.2)
activesupport (>= 5.2)
Expand Down Expand Up @@ -1046,7 +1027,6 @@ DEPENDENCIES
graphql (= 1.8.2)
honeybadger
hydra-access-controls
hydra-editor (~> 6.0)
hydra-head
hydra-role-management
iiif_manifest!
Expand Down
6 changes: 0 additions & 6 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@
//= require openseadragon/openseadragon
//= require openseadragon/jquery
//= require bootstrap_select_dropdown
//= //require bootstrap/affix
//= require babel/polyfill
//= require hydra-editor/hydra-editor
//= require cocoon
//= require blacklight_range_limit
//= require_tree .
$(document).ready(function() {
$('.multi_value.form-group').manage_fields();
});
2 changes: 1 addition & 1 deletion app/assets/stylesheets/application.scss
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,9 @@
@import 'components/thumbnail';
@import 'components/vue_select';
@import 'components/facets';
@import 'components/inputs';

@import 'blacklight/blacklight';
@import "hydra-editor/hydra-editor";
@import "openseadragon/openseadragon";

@import 'components/pagination';
79 changes: 79 additions & 0 deletions app/assets/stylesheets/components/inputs.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
.multi_value {
.btn.remove {
color: $brand-danger;
}

.btn.remove, .btn.add {
text-decoration: underline;
}

.btn.add {
padding-left: 0;
}

.field-wrapper {
list-style-type:none;
}

.listing {
margin-left: 0;
max-width: 40em;
padding-left: 0px;
margin-bottom: 0;
}

.field-controls {
margin-left: 2em;
}

.remove .glyphicon-remove,
.add .glyphicon-plus {
margin-right: 0.3rem
}

.message {
background-size: 40px 40px;
background-image: linear-gradient(135deg, rgba(255, 255, 255, .05) 25%, transparent 25%,
transparent 50%, rgba(255, 255, 255, .05) 50%, rgba(255, 255, 255, .05) 75%,
transparent 75%, transparent);
box-shadow: inset 0 -1px 0 rgba(255,255,255,.4);
width: 100%;
border: 1px solid;
color: #fff;
padding: 10px;
text-shadow: 0 1px 0 rgba(0,0,0,.5);
animation: animate-bg 5s linear infinite;
border-radius: $border-radius-base;
}

.has-error {
background-color: #de4343;
border-color: #c43d3d;
}

.has-warning{
background-color: #eaaf51;
border-color: #d99a36;
}

.listing li:not(:last-child) {
margin-bottom: 0.5rem;
}

.listing li:first-of-type {
width: 83.3333333333%;

input {
border-radius: 4px;
}

.remove {
display: none;
}
}
}

// The contributor listing needs some normalization
#contributors .listing {
max-width:20em;
}
24 changes: 24 additions & 0 deletions app/helpers/edit_field_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,35 @@ def reorder_languages(languages, top_languages)
pull_to_front(languages) { |term| top_languages.include? term }
end

def render_edit_field_partial(field_name, locals)
collection = locals[:f].object.model_name.collection
render_edit_field_partial_with_action(collection, field_name, locals)
end

private

def pull_to_front(array, &block)
temp = array.select(&block)
array.reject!(&block)
temp + array
end

# This finds a partial based on the record_type and field_name
# if no partial exists for the record_type it tries using "records" as a default
def render_edit_field_partial_with_action(record_type, field_name, locals)
partial = find_edit_field_partial(record_type, field_name)
render partial, locals.merge(key: field_name)
end

def find_edit_field_partial(record_type, field_name)
["#{record_type}/edit_fields/_#{field_name}", "records/edit_fields/_#{field_name}",
"#{record_type}/edit_fields/_default", "records/edit_fields/_default"].find do |partial|
logger.debug "Looking for edit field partial #{partial}"
return partial.sub(/\/_/, "/") if partial_exists?(partial)
end
end

def partial_exists?(partial)
lookup_context.find_all(partial).any?
end
end
81 changes: 81 additions & 0 deletions app/inputs/multi_value_input.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# frozen_string_literal: true
class MultiValueInput < SimpleForm::Inputs::CollectionInput
def input(_wrapper_options)
@rendered_first_element = false
input_html_classes.unshift("string")
input_html_options[:name] ||= "#{object_name}[#{attribute_name}][]"

outer_wrapper do
buffer_each(collection) do |value, index|
inner_wrapper do
build_field(value, index)
end
end
end
end

protected

def buffer_each(collection)
collection.each_with_object("".dup).with_index do |(value, buffer), index|
buffer << yield(value, index)
end
end

def outer_wrapper
" <ul class=\"listing\">\n #{yield}\n </ul>\n"
end

def inner_wrapper
<<-HTML
<li class="field-wrapper">
#{yield}
</li>
HTML
end

private

# Although the 'index' parameter is not used in this implementation it is useful in an
# an overridden version of this method, especially when the field is a complex object and
# the override defines nested fields.
def build_field_options(value, _index)
options = input_html_options.dup

options[:value] = value
if @rendered_first_element
options[:id] = nil
options[:required] = nil
else
options[:id] ||= input_dom_id
end
options[:class] ||= []
options[:class] += ["#{input_dom_id} form-control multi-text-field"]
options[:'aria-labelledby'] = label_id
@rendered_first_element = true

options
end

def build_field(value, index)
options = build_field_options(value, index)
if options.delete(:type) == "textarea"
@builder.text_area(attribute_name, options)
else
@builder.text_field(attribute_name, options)
end
end

def label_id
input_dom_id + "_label"
end

def input_dom_id
input_html_options[:id] || "#{object_name}_#{attribute_name}"
end

def collection
@collection ||=
Array(object.send(attribute_name)).reject { |v| v.to_s.strip.blank? } + [""]
end
end
Loading