Skip to content

Commit

Permalink
Add dashboard layout to batch edit and file set edit views
Browse files Browse the repository at this point in the history
  • Loading branch information
smithjp committed Mar 27, 2018
1 parent 59044b5 commit 9e54d86
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 64 deletions.
2 changes: 2 additions & 0 deletions app/controllers/hyrax/batch_edits_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class BatchEditsController < ApplicationController
# provides the help_text view method
helper PermissionsHelper

with_themed_layout 'dashboard'

def edit
work = form_class.model_class.new
work.depositor = current_user.user_key
Expand Down
12 changes: 12 additions & 0 deletions app/controllers/hyrax/file_sets_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ class FileSetsController < ApplicationController
private :curation_concern=
helper_method :file_set

layout :decide_layout

# GET /concern/file_sets/:id
def edit
initialize_edit_form
Expand Down Expand Up @@ -168,5 +170,15 @@ def additional_response_formats(_); end
def _prefixes
@_prefixes ||= super + ['hyrax/base']
end

def decide_layout
layout = case action_name
when 'show'
'1_column'
else
'dashboard'
end
File.join(theme, layout)
end
end
end
91 changes: 47 additions & 44 deletions app/views/hyrax/batch_edits/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,32 @@
<%= @form.names.join(", ").html_safe %>
</div> <!-- /original values -->

<div >
<div>
<h3> Descriptions:</h3>

<div class="panel panel-default tabs">
<ul class="nav nav-tabs">
<li id="edit_descriptions_link" class="active"><a href="#descriptions_display" data-toggle="tab"><i class="glyphicon glyphicon-tags"></i> Descriptions</a></li>
<li id="edit_permissions_link"><a href="#permissions_display" data-toggle="tab"><i class="glyphicon glyphicon-lock"></i> Permissions</a></li>
</ul>
<div class="tab-content">
<div class="tab-pane active" id="descriptions_display">
<% @form.terms.each do |term| %>
<div class="row">
<%= simple_form_for @form,
url: hyrax.batch_edits_path,
method: :put,
remote: true,
builder: Hyrax::FormBuilder,
html: { id: "form_#{term.to_s}",
class: "ajax-form" },
data: { model: @form.model_name.param_key } do |f| %>
<div class="col-xs-12 col-sm-4">
<a class="accordion-toggle grey glyphicon-chevron-right-helper collapsed" data-toggle="collapse" href="#collapse_<%= term %>" id="expand_link_<%=term.to_s%>">
<%= f.input_label term %> <span class="chevron"></span>
</a>
</div>
<div id="collapse_<%= term %>" class="collapse scrolly col-xs-12 col-sm-7">
<div class="panel-body">
<div class="tab-content">
<div class="tab-pane active" id="descriptions_display">
<% @form.terms.each do |term| %>
<div class="row">
<%= simple_form_for @form,
url: hyrax.batch_edits_path,
method: :put,
remote: true,
builder: Hyrax::FormBuilder,
html: { id: "form_#{term.to_s}",
class: "ajax-form" },
data: { model: @form.model_name.param_key } do |f| %>
<div class="col-xs-12 col-sm-4">
<a class="accordion-toggle grey glyphicon-chevron-right-helper collapsed" data-toggle="collapse" href="#collapse_<%= term %>" id="expand_link_<%=term.to_s%>">
<%= f.input_label term %> <span class="chevron"></span>
</a>
</div>
<div id="collapse_<%= term %>" class="collapse scrolly col-xs-12 col-sm-7">
<%= hidden_field_tag('update_type', 'update') %>
<%= hidden_field_tag('key', term.to_s) %>
<%# TODO we don't need to show required %>
Expand All @@ -42,34 +43,36 @@
<a class="btn btn-default" data-toggle="collapse" data-parent="#row_<%= term.to_s %>" href="#collapse_<%= term.to_s %>">Cancel </a>
<div class="status fleft"></div>
</div>
</div>
<% end %>
</div>
<% end %>
</div><!-- #descriptions_display -->
</div>
<% end %>
</div>
<% end %>
</div><!-- #descriptions_display -->

<div id="permissions_display" class="tab-pane">
<%= simple_form_for @form.model,
url: hyrax.batch_edits_path,
method: :put,
remote: true,
html: { id: "form_permissions", class: "ajax-form"},
data: { 'param-key' => @form.model_name.param_key } do |f| %>
<%= hidden_field_tag('update_type', 'update') %>
<%= hidden_field_tag('key', 'permissions') %>
<%= render "hyrax/base/form_permission", f: f %>
<%= render "hyrax/base/form_share", f: f %>
<div id="permissions_display" class="tab-pane">
<%= simple_form_for @form.model,
url: hyrax.batch_edits_path,
method: :put,
remote: true,
html: { id: "form_permissions", class: "ajax-form"},
data: { 'param-key' => @form.model_name.param_key } do |f| %>
<%= hidden_field_tag('update_type', 'update') %>
<%= hidden_field_tag('key', 'permissions') %>
<%= render "hyrax/base/form_permission", f: f %>
<%= render "hyrax/base/form_share", f: f %>

<% @form.batch_document_ids.each do |batch_id| %>
<%= hidden_field_tag "batch_document_ids[]", batch_id %>
<% end %>
<div class="row">
<%= f.submit "Save changes", class: 'btn btn-primary', id: 'permissions_save' %>
<div id="status_permissions" class="status fleft"></div>
<% @form.batch_document_ids.each do |batch_id| %>
<%= hidden_field_tag "batch_document_ids[]", batch_id %>
<% end %>
<div class="row">
<%= f.submit "Save changes", class: 'btn btn-primary', id: 'permissions_save' %>
<div id="status_permissions" class="status fleft"></div>
</div>
<% end %>
</div>
<% end %>
</div> <!-- .tab-content -->
</div>
</div> <!-- .tab-content -->
</div>

<!-- Ajax call to clear the batch before page uload. -->
<%= button_to "Clear Batch", hyrax.clear_batch_edits_path, form_class: 'hidden', remote: true, id: 'clear_batch' %>
Expand Down
44 changes: 24 additions & 20 deletions app/views/hyrax/file_sets/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,28 @@
<%= media_display curation_concern.to_presenter %>
</div>
<div class="col-xs-12 col-sm-8">
<ul class="nav nav-tabs" role="tablist">
<li id="edit_descriptions_link" class="active">
<a href="#descriptions_display" data-toggle="tab"><i class="fa fa-tags"></i> Descriptions</a>
</li>
<li id="edit_versioning_link">
<a href="#versioning_display" data-toggle="tab"><i class="fa fa-sitemap"></i> Versions</a>
</li>
<li id="edit_permissions_link">
<a href="#permissions_display" data-toggle="tab"><i class="fa fa-key"></i> Permissions</a>
</li>
</ul>
<div class="tab-content">
<div id="descriptions_display" class="tab-pane active">
<h2>Descriptions </h2>
<%= render "form" %>
<div class="panel panel-default tabs">
<ul class="nav nav-tabs" role="tablist">
<li id="edit_descriptions_link" class="active">
<a href="#descriptions_display" data-toggle="tab"><i class="fa fa-tags"></i> Descriptions</a>
</li>
<li id="edit_versioning_link">
<a href="#versioning_display" data-toggle="tab"><i class="fa fa-sitemap"></i> Versions</a>
</li>
<li id="edit_permissions_link">
<a href="#permissions_display" data-toggle="tab"><i class="fa fa-key"></i> Permissions</a>
</li>
</ul>
<div class="panel-body">
<div class="tab-content">
<div id="descriptions_display" class="tab-pane active">
<h2>Descriptions </h2>
<%= render "form" %>
</div>
<%= render "permission", file_set: curation_concern %>
<%= render "versioning", file_set: curation_concern %>
</div>
</div>
<%= render "permission", file_set: curation_concern %>
<%= render "versioning", file_set: curation_concern %>
</div>
</div><!-- /.col-sm-8 -->
</div><!-- /.row -->
</div><!-- /.col-sm-8 -->
</div><!-- /.row -->
</div>
1 change: 1 addition & 0 deletions spec/controllers/hyrax/batch_edits_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
expect(controller).to receive(:add_breadcrumb).with(I18n.t('hyrax.dashboard.my.works'), Hyrax::Engine.routes.url_helpers.my_works_path(locale: 'en'))
get :edit
expect(response).to be_successful
expect(response).to render_template('dashboard')
expect(assigns[:form].model.creator).to match_array ["Fred", "Wilma"]
end
end
Expand Down
5 changes: 5 additions & 0 deletions spec/controllers/hyrax/file_sets_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
expect(assigns[:version_list]).to be_kind_of Hyrax::VersionListPresenter
expect(assigns[:parent]).to eq parent
expect(response).to render_template(:edit)
expect(response).to render_template('dashboard')
end
end

Expand Down Expand Up @@ -150,6 +151,7 @@
post :update, params: { id: file_set, revision: version1 }
expect(response.code).to eq '401'
expect(response).to render_template 'unauthorized'
expect(response).to render_template('dashboard')
end
end
end
Expand Down Expand Up @@ -196,6 +198,7 @@
post :update, params: { id: file_set, file_set: { keyword: [''] } }
expect(response.code).to eq '422'
expect(response).to render_template('edit')
expect(response).to render_template('dashboard')
expect(assigns[:file_set]).to eq file_set
end
end
Expand All @@ -220,6 +223,7 @@
get :edit, params: { id: file_set }
expect(response.code).to eq '401'
expect(response).to render_template('unauthorized')
expect(response).to render_template('dashboard')
end
end
end
Expand Down Expand Up @@ -278,6 +282,7 @@
get :edit, params: { id: public_file_set }
expect(response.code).to eq '401'
expect(response).to render_template(:unauthorized)
expect(response).to render_template('dashboard')
end
end

Expand Down

0 comments on commit 9e54d86

Please sign in to comment.