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

dynamic forms that load flexible metadata #6844

Closed
wants to merge 43 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
5ec7d1b
:construction: WIP: Port over AFlex UI to upload profile
Jun 4, 2024
2b95bb1
Add admin set selection to worktype modal
Jun 6, 2024
449de96
Relocated the Metadata Profiles link
Jun 12, 2024
2e351d6
Merge branch 'flexible_metadata' into metadata-profiles-ui
Jun 12, 2024
c5be4bc
Make metadata profiles index work
Jun 12, 2024
7cd2eff
Make export work
Jun 13, 2024
121787d
Make it possible to create more schemas
Jun 13, 2024
2b087c6
Favoring fetch over [] to follow existing pattern
Jun 13, 2024
0450385
Add hint text to modal
Jun 13, 2024
3737db8
Update translations
Jun 13, 2024
e8c6664
Merge branch 'flexible_metadata' into metadata-profiles-ui
Jun 13, 2024
9a61fd8
Merge branch 'flexible_metadata' into metadata-profiles-ui
Jun 13, 2024
bdaa9ee
Remove locked_at and locked_by_id
Jun 14, 2024
d8e9189
Merge branch 'flexible_metadata' into metadata-profiles-ui
Jun 19, 2024
c8d0e85
Merge branch 'flexible_metadata' into metadata-profiles-ui
Jun 20, 2024
a40f18d
Move db query into the controller
Jun 20, 2024
d743501
Rename admin set dropdown options
Jun 20, 2024
c495c34
Add guard for @admin_sets_for_select
Jun 20, 2024
25d722f
Merge branch 'flexible_metadata' into flexible_double_combo
Jun 24, 2024
fd6cea9
Merge branch 'metadata-profiles-ui' into flexible_double_combo
Jun 24, 2024
8b95caf
Merge branch 'select-admin-set-prior-to-worktype' into flexible_doubl…
Jun 24, 2024
62fefce
Rubocop fixes
Jun 24, 2024
bb652c5
Merge branch 'metadata-profiles-ui' into flexible_double_combo
Jun 24, 2024
deac768
dynamic forms that load flexible metadata
orangewolf Jun 24, 2024
18125d7
Merge branch 'flexible_forms' into flexible_double_combo
orangewolf Jun 24, 2024
5d870fb
Merge branch 'flexible_double_combo' of https://github.com/samvera/hy…
orangewolf Jun 24, 2024
3af2f31
Merge branch 'flexible_metadata' into flexible_forms
orangewolf Jun 25, 2024
3e06bd1
remove some false starts and debug code
orangewolf Jun 25, 2024
a5ba06b
Merge branch 'flexible_metadata' into flexible_forms
orangewolf Jun 25, 2024
0a761ef
Merge branch 'flexible_metadata' into flexible_double_combo
orangewolf Jun 25, 2024
3158922
Merge branch 'flexible_forms' into flexible_double_combo
orangewolf Jun 25, 2024
55fd95a
WIP getting attribute_rows to be dynamic
Jun 25, 2024
3a601f5
🧹 Enables dynamic display for attribute rows
Jun 25, 2024
40d33bf
🚧 WIP - handle dynamic translations
Jun 25, 2024
536f87c
Expand support for i18n labels
Jun 25, 2024
d6e0ea9
Merge branch 'flexible_metadata' into flexible_forms
kirkkwang Jun 25, 2024
b1de02b
Rubocop fixes
Jun 25, 2024
d7a2d1d
Merge branch 'flexible_double_combo' into flexible_forms
Jun 26, 2024
f860fd4
Fix return logic
Jun 26, 2024
631732c
Add flexible conditional
Jun 26, 2024
55b1d0a
Merge pull request #6851 from samvera/flexible_forms
kirkkwang Jun 26, 2024
e060c84
Add flexible conditional
Jun 26, 2024
1fc5d05
Merge branch 'flexible_double_combo' into flexible_forms
kirkkwang Jun 26, 2024
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
Prev Previous commit
Next Next commit
Make metadata profiles index work
Kirk Wang committed Jun 13, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit c5be4bce4fd24ae7ab159cb41c15cb48f1f542ba
2 changes: 2 additions & 0 deletions .dassie/db/schema.rb
Original file line number Diff line number Diff line change
@@ -176,6 +176,8 @@
t.text "profile"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.datetime "locked_at"
t.integer "locked_by_id"
end

create_table "job_io_wrappers", force: :cascade do |t|
23 changes: 21 additions & 2 deletions app/controllers/hyrax/metadata_profiles_controller.rb
Original file line number Diff line number Diff line change
@@ -10,14 +10,33 @@ class MetadataProfilesController < ApplicationController
# GET /allinson_flex_profiles
def index
add_breadcrumbs
@metadata_profiles = Hyrax::FlexibleSchema.page(params[:profile_entries_page])
end

def import
uploaded_io = params[:file]
if uploaded_io.blank?
redirect_to profiles_path, alert: 'Please select a file to upload'
redirect_to metadata_profiles_path, alert: 'Please select a file to upload'
return
end

begin
@flexible_schema = Hyrax::FlexibleSchema.first_or_create do |f|
f.profile = YAML.safe_load_file(uploaded_io.path)
end

redirect_to metadata_profiles_path, notice: 'AllinsonFlexProfile was successfully created.'
rescue => e
redirect_to metadata_profiles_path, alert: @flexible_schema.errors.messages.to_s
return
end
end

def export
@allinson_flex_profile = AllinsonFlex::Profile.find(params[:profile_id])
filename = "metadata-profile-v.#{@allinson_flex_profile.profile_version}.yml"
File.open(filename, "w") { |file| file.write(@allinson_flex_profile.profile.to_hash.to_yaml(indentation: 8)) }
send_file filename, type: "application/yaml", x_sendfile: true
end

private
@@ -28,4 +47,4 @@ def add_breadcrumbs
add_breadcrumb t(:'hyrax.dashboard.metadata_profiles'), hyrax.metadata_profiles_path
end
end
end
end
20 changes: 20 additions & 0 deletions app/models/hyrax/flexible_schema.rb
Original file line number Diff line number Diff line change
@@ -2,6 +2,10 @@
class Hyrax::FlexibleSchema < ApplicationRecord
serialize :profile, coder: YAML

def self.current_version
self.order("created_at asc").last.profile
end

def title
"#{profile['profile']['responsibility_statement']} - version #{id}"
end
@@ -10,6 +14,22 @@ def attributes_for(class_name)
class_names[class_name]
end

def schema_version
profile['m3_version']
end

def metadata_profile_type
profile['profile']['type']
end

def version
id
end

def profile_created_at
created_at.strftime("%b %d, %Y")
end

private

def class_names
20 changes: 3 additions & 17 deletions app/views/hyrax/metadata_profiles/index.html.erb
Original file line number Diff line number Diff line change
@@ -21,6 +21,7 @@
<th scope="col">Profile Version</th>
<th scope="col">Profile Type</th>
<th scope="col">Created At</th>
<th scope="col">Actions</th>
</tr>
</thead>
<tbody>
@@ -29,25 +30,10 @@

<!-- TODO: fix show pgs -->
<td><%= hyrax_metadata_profile.schema_version %></td>
<td><%= link_to hyrax_metadata_profile.metadata_profile_version.to_f, hyrax.metadata_profile_path(hyrax_metadata_profile) %></td>
<td><%= hyrax_metadata_profile.id.to_f %></td>
<td><%= hyrax_metadata_profile.metadata_profile_type %></td>
<td><%= hyrax_metadata_profile.created_at.strftime("%b %d, %Y") %></td>
<% if hyrax_metadata_profile == AllinsonFlex::Profile.current_version %>
<% if hyrax_metadata_profile.locked_at && hyrax_metadata_profile.locked_at < Time.now %>
<th colspan=3 ><%= link_to raw("<span title='click to force unlock' class='glyphicon glyphicon-lock'></span>"), hyrax.unlock_metadata_profile_path(hyrax_metadata_profile), method: :post, data: { confirm: 'Are you sure that no other user is editing the metadata_profile right now?' } %>
<%= hyrax_metadata_profile.lock_statement %>
</th>

<% else %>
<th><%= link_to raw('<span class="glyphicon glyphicon-pencil"></span>'), hyrax.edit_metadata_profile_path(hyrax_metadata_profile), data: { turbolinks: false } %></th>
<th><%= link_to raw('<span class="glyphicon glyphicon-download-alt"></span>'), hyrax.metadata_profile_export_path(hyrax_metadata_profile), tagert: "_blank" %></th>
<th><%= link_to raw('<span class="glyphicon glyphicon-remove"></span>'), hyrax.metadata_profile_path(hyrax_metadata_profile), method: :delete, data: { confirm: 'Are you sure?' } %></th>
<% end %>
<% else %>
<td></td>
<td></td>
<td></td>
<% end %>
<th><%= link_to raw('<span class="fa fa-download"></span>'), hyrax.metadata_profile_export_path(hyrax_metadata_profile), target: "_blank" %></th>
</tr>
<% end %>
</tbody>
3 changes: 1 addition & 2 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -275,9 +275,8 @@

if ENV['HYRAX_FLEXIBLE']
# Metadata profiles routes
resources :metadata_profiles, except: :update do
resources :metadata_profiles, except: [:update, :show, :destroy] do
collection { post :import }
member { post :unlock }
get 'export'
end
end