diff --git a/app/assets/stylesheets/zizia/_import_table.scss b/app/assets/stylesheets/zizia/_import_table.scss new file mode 100644 index 0000000..3fb0946 --- /dev/null +++ b/app/assets/stylesheets/zizia/_import_table.scss @@ -0,0 +1,6 @@ +.desc::after { + content: ' ▾' +} +.asc::after { + content: ' ▴' +} diff --git a/app/assets/stylesheets/zizia/zizia.scss b/app/assets/stylesheets/zizia/zizia.scss index f426d59..5e5b9eb 100644 --- a/app/assets/stylesheets/zizia/zizia.scss +++ b/app/assets/stylesheets/zizia/zizia.scss @@ -1,6 +1,7 @@ @import 'file_upload'; @import 'field_guide'; @import 'new'; +@import 'import_table'; .btn { white-space:normal !important; diff --git a/app/controllers/zizia/csv_import_details_controller.rb b/app/controllers/zizia/csv_import_details_controller.rb index ebb0b95..716183d 100644 --- a/app/controllers/zizia/csv_import_details_controller.rb +++ b/app/controllers/zizia/csv_import_details_controller.rb @@ -1,21 +1,30 @@ # frozen_string_literal: true module Zizia class CsvImportDetailsController < ApplicationController + helper_method :sort_column, :sort_direction load_and_authorize_resource with_themed_layout 'dashboard' def index - @csv_import_details = Zizia::CsvImportDetail.order(:id).page csv_import_detail_params[:page] + @csv_import_details = Zizia::CsvImportDetail.order(sort_column + ' ' + sort_direction).page csv_import_detail_params[:page] end def show - @csv_import_detail = Zizia::CsvImportDetail.find(csv_import_detail_params["id"]) + @csv_import_detail = Zizia::CsvImportDetail.find(csv_import_detail_params['id']) end private + def sort_column + Zizia::CsvImportDetail.column_names.include?(params[:sort]) ? params[:sort] : 'created_at' + end + + def sort_direction + %w[asc desc].include?(params[:direction]) ? params[:direction] : 'desc' + end + def csv_import_detail_params - params.permit(:id, :page) + params.permit(:id, :page, :sort, :direction) end end end diff --git a/app/helpers/zizia/application_helper.rb b/app/helpers/zizia/application_helper.rb index 0249b06..99d0a2f 100644 --- a/app/helpers/zizia/application_helper.rb +++ b/app/helpers/zizia/application_helper.rb @@ -1,6 +1,26 @@ # frozen_string_literal: true module Zizia module ApplicationHelper + def human_update_actor_stack(update_actor_stack) + case update_actor_stack + when 'HyraxDelete' + 'Overwrite All Files & Metadata' + when 'HyraxMetadataOnly' + 'Update Existing Metadata, create new works' + when 'HyraxOnlyNew' + 'Ignore Existing Works, new works only' + else + 'Unknown' + end + end + + def sortable(column, title = nil) + title ||= column.titleize + css_class = column == sort_column ? "current #{sort_direction}" : nil + direction = column == sort_column && sort_direction == 'asc' ? 'desc' : 'asc' + link_to title, { sort: column, direction: direction }, class: css_class + end + def collections_for_select ActiveFedora::SolrService.query('has_model_ssim:Collection').map do |c| [c['title_tesim'][0], c['id']] diff --git a/app/views/zizia/csv_import_details/index.html.erb b/app/views/zizia/csv_import_details/index.html.erb index fddab5e..a40b917 100644 --- a/app/views/zizia/csv_import_details/index.html.erb +++ b/app/views/zizia/csv_import_details/index.html.erb @@ -1,9 +1,9 @@
ID | +<%= sortable 'id', 'ID' %> | Associated User | -Date | +<%= sortable 'created_at', 'Date' %> | CSV File | Number of Works | Number of Files | @@ -23,7 +23,7 @@ <%= csv_import_detail.created_at.strftime("%B %-d, %Y %H:%M") %>- <%= csv_import_detail.csv_import.manifest %> + <%= File.basename(csv_import_detail.csv_import.manifest.to_s) %> | <%= csv_import_detail.pre_ingest_works.count %> @@ -38,7 +38,7 @@ <%= csv_import_detail.status %> | - <%= csv_import_detail.update_actor_stack %> + <%= human_update_actor_stack(csv_import_detail.update_actor_stack) %> |
---|