Skip to content
This repository has been archived by the owner on Mar 18, 2021. It is now read-only.

Commit

Permalink
Change Dashboard Design
Browse files Browse the repository at this point in the history
- Add Dashboard icons
- Add Publishable view and controller
- Implemented draft for dashboard breadcrumb
- Remove collections from my facets
- Add add files action link for collections list
- Fix specs to match new dashboard design
- Make dashboard tab groupping centralized in a new helper
- Add spec for publishables controller
- Add spec for new views
- Fix spec for admin users add file
  • Loading branch information
tonmoy18 authored and rotated8 committed Nov 30, 2015
1 parent a516d63 commit 7595acc
Show file tree
Hide file tree
Showing 33 changed files with 495 additions and 40 deletions.
Binary file added app/assets/images/describe.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/organize.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/publish.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/upload.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 30 additions & 9 deletions app/assets/stylesheets/dashboard.scss
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
@import 'global';

div.heading-tile .glyphicon {
background: $hokie-orange;
div.dashboard-breadcrumb {
margin-bottom: 20px;
margin-top: 20px;
border-bottom: solid $hokie-orange;
}

div.heading-tile {
color: white;
display: block;
width: 2em;
height: 2em;
border-radius: 5px 5px 0 0;
line-height: 1.75em;
margin: 0 auto;
border-radius: 50%;
border: 2px solid $hokie-orange;
padding-top: 10px;
overflow: hidden;
transition-property: background-color, color;
transition-duration: .35s;
transition-timing-function: ease-out;
}

div.heading-tile:hover .glyphicon {
div.heading-tile.active {
background-color: orange;
color: white;
transition-property: background-color, color;
transition-duration: .35s;
transition-timing-function: ease-out;
}

div.heading-tile:hover {
background-color: $hokie-orange;
border-color: $hokie-orange;
color: white;
transition-property: background-color, color;
transition-duration: .35s;
transition-timing-function: ease-out;
}

div.heading-tile a:hover {
text-decoration: none;
}


.dashboard {
.panel-default > .panel-heading {
background-color: $hokie-grey;
Expand All @@ -42,4 +57,10 @@ div.heading-tile:hover .glyphicon {
padding: 0 .25em;
}

}
}

.heading-tile {
img {
height: 64px;
}
}
6 changes: 6 additions & 0 deletions app/assets/stylesheets/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
text-align: left;
}

.table-actionable {
.text-left {
text-align: left;
}
}

#login-form {
margin-top: 5%;
margin-bottom: 5%;
Expand Down
14 changes: 13 additions & 1 deletion app/controllers/collections_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
class CollectionsController < ApplicationController
include Hydra::Catalog

include Sufia::CollectionsControllerBehavior
skip_load_and_authorize_resource :only => [:datacite_search, :crossref_search, :import_metadata, :ldap_search]
skip_load_and_authorize_resource :only => [:datacite_search, :crossref_search, :import_metadata, :ldap_search, :add_files]

def presenter_class
MyCollectionPresenter
Expand Down Expand Up @@ -115,4 +117,14 @@ def ldap_search
render :layout => false
end

def add_files
if current_user.admin?
search_params_logic = [:show_only_generic_files, :add_access_controls_to_solr_params]
else
search_params_logic = [:show_only_generic_files, :show_only_resources_deposited_by_current_user]
end
(_, @files) = search_results({ q: '' }, search_params_logic)
@collection = Collection.find(params[:id])
authorize! :edit, @collection
end
end
17 changes: 17 additions & 0 deletions app/controllers/publishables_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
class PublishablesController < ApplicationController
include Hydra::Catalog
include Hydra::BatchEditBehavior
include Hydra::Collections::SelectsCollections

def index
@publishables = []
# there is almost certainly a better way to do this!!!
Collection.where(depositor: current_user.user_key).each do |collection|
unless collection.member_ids.empty?
unless collection.identifier.any? {|uri| uri.start_with? "doi:"}
@publishables << collection
end
end
end
end
end
17 changes: 17 additions & 0 deletions app/helpers/dashboard_breadcrumb_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module DashboardBreadcrumbHelper
@@dashboard_groups = {
"generic_files" => :upload,
"batch" => :describe,
"my/files" => :describe,
"my/highlights" => :describe,
"my/shares" => :describe,
"batch_edits" => :describe,
"my/collections" => :organize,
"collections" => :organize,
"publishables" => :publish
}

def current_dashboard_tab?(sym)
@@dashboard_groups[params[:controller]] == sym
end
end
28 changes: 28 additions & 0 deletions app/views/batch/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<%= javascript_tag do %>
<%= render partial: "edit", formats: [:js] %>
<% end %>
<%= render partial: "dashboard/_index_partials/heading_actions" %>

<h1>Apply Metadata</h1>
<p>
The information you provide for Title will be applied to the corresponding file only; however all other
information you provide will be applied <em>to the entire batch of files</em> you have just
deposited into <%= t('sufia.product_name') %>. You may edit individual files from
<%= link_to "<i class='glyphicon glyphicon-dashboard'></i> #{t('sufia.bread_crumb.file_list')}".html_safe, sufia.dashboard_files_path %>
once this step is finished. <span class="required"><abbr title="required">*</abbr></span> indicates required fields.
</p>
<%= simple_form_for [sufia, @batch, @form], html: { multipart: true }, builder: Sufia::FormBuilder do |f| %>
<%= render 'metadata', f: f %>
<%= render 'generic_files/permission_form', f: f, batch: @batch %>

<div id="permissions_submit">
<%= button_tag type: 'submit', class: 'btn btn-primary btn-lg',
onclick: "confirmation_needed = false;", id: "upload_submit", name: "update_permission" do %>
<i class="glyphicon glyphicon-floppy-disk"></i> Save
<% end %>
</div>

<% end %>
59 changes: 59 additions & 0 deletions app/views/batch_edits/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<%= render_breadcrumbs builder: Sufia::BootstrapBreadcrumbsBuilder %>
<%= render partial: 'dashboard/_index_partials/heading_actions.html.erb' %>
<h2 class="non lower">Batch Edit Descriptions &nbsp;&nbsp;&nbsp;<small>Click on labels below to edit file descriptions.</small> </h2>
<div class="scrollx scrolly fileHeight"> <!-- original values -->
<h3> <b>Changes will be applied to: (<%= @names.size %> files) </b></h3>
<%= @names.join(", ").html_safe %>
</div> <!-- /original values -->

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

<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="well tab-pane active" id="descriptions_display">
<% @terms.each do |term| %>
<div class="row">
<%= simple_form_for @generic_file, url: batch_edits_path, method: :put, remote: true,
builder: Sufia::FormBuilder, html: { id: "form_#{term.to_s}", class: "ajax-form"} 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 %>
<%= render_edit_field_partial(term, f: f) %>
<div>
<%= f.submit "Save changes", class: 'btn btn-primary field-save updates-batches' , id: "#{term.to_s}_save" %>
<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><!-- /well -->

<div id="permissions_display" class="tab-pane">
<%= form_for @generic_file, url: batch_edits_path, method: :put, remote: true, html: { id: "form_permissions", class: "ajax-form"} do |f| %>
<%= hidden_field_tag('update_type', 'update') %>
<%= hidden_field_tag('key', 'permissions') %>
<%= render "generic_files/permission_form", f: f %>
<div class="row">
<%= f.submit "Save changes", class: 'btn btn-primary updates-batches', id: 'permissions_save' %>
<div id="status_permissions" class="status fleft"></div>
</div>
<% end %>
</div>
</div> <!-- .tab-content -->

<!-- Ajax call to clear the batch before page uload. -->
<%= button_to "Clear Batch", { controller: :batch_edits, action: :clear }, form_class: 'hidden', remote: true, id: 'clear_batch' %>

</div><!-- descriptions_display -->
5 changes: 2 additions & 3 deletions app/views/collections/_show_actions.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
<%= link_to collections.edit_collection_path, class: "btn btn-default", title: "Edit this Dataset" do %>
<span class="glyphicon glyphicon-edit"></span> Edit
<% end %>
<%= link_to sufia.dashboard_files_path, class: "btn btn-default", title: "Add files to this Dataset" do %>
<span class="glyphicon glyphicon-open-file"></span> Files
<%= link_to collections_add_files_path(@collection), class: "btn btn-default", title: "Edit this Dataset" do %>
<span class="glyphicon glyphicon-file">Files</span>
<% end %>
</div>
<%= request_doi_link(@collection) %>
<% end %>
</div>
32 changes: 32 additions & 0 deletions app/views/collections/add_files.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<%= render partial: 'dashboard/_index_partials/heading_actions.html.erb' %>
<h1>Files in <%= @collection.title %></h1>
<% if @files.empty? %>
<span>Please upload some files first</span>
<% else %>
<%= form_for @collection, url: collections.collection_path(@collection) do |f| %>
<%= hidden_field_tag "collection[members][]" %>
<div class="table-responsive">
<table class="table table-actionable table-striped table-hover">
<thead>
<tr>
<th class="text-left">Filename</th>
<th>Date Uploaded</th>
<th>In Collection</th>
</tr>
</thead>
<tbody>
<% @files.each do |file| %>
<tr>
<td><%= render_thumbnail_tag file, { class: "hidden-xs file_listing_thumbnail pull-left media-left" }, { suppress_link: true } %>
<%= file.title_or_label %></td>
<td class="text-center"><%= file.date_uploaded %></td>
<td class="text-center"><%= check_box_tag 'batch_document_ids[]', file.id, @collection.member_ids.include?(file.id) %></td>
</tr>
<% end %>
</tbody>
</table>
<hr />
</div>
<%= f.button('Add Files to Collection', class: 'btn btn-primary') %>
<% end %>
<% end %>
3 changes: 3 additions & 0 deletions app/views/collections/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<% @page_title = "Edit Dataset #{display_title(@collection)} - #{application_name}" %>
<%= render_breadcrumbs builder: Sufia::BootstrapBreadcrumbsBuilder %>
<%= render partial: 'dashboard/_index_partials/heading_actions.html.erb' %>

<h1>Edit Dataset: <%= display_title(@collection) %></h1>

<% unless has_collection_search_parameters? %>
Expand Down
4 changes: 4 additions & 0 deletions app/views/collections/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
<div id="content-header" class="row">
<%= render partial: "dashboard/_index_partials/heading_actions" %>
</div>

<h1>Create New Dataset</h1>

<%= radio_button_tag :doi_status, "assigned", checked = false %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/collections/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<% @page_title = "#{@collection.title} - #{application_name}" %>
<%= render_breadcrumbs builder: Sufia::BootstrapBreadcrumbsBuilder %>

<%= render partial: 'dashboard/_index_partials/heading_actions.html.erb' %>
<div itemscope itemtype="http://schema.org/CollectionPage" class="row">
<div class="col-sm-2">
<%= render partial: 'collections/media_display', locals: { generic_file: @collection } %>
Expand Down
31 changes: 31 additions & 0 deletions app/views/dashboard/_index_partials/_heading_actions.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<% current_tab ||= nil %>
<div class="col-xs-12 heading-row dashboard-breadcrumb">
<% if can?(:create, GenericFile) %>
<div class="col-xs-6 col-sm-3 heading-tile <%="active" if current_dashboard_tab?(:upload) %>">
<%= link_to sufia.new_generic_file_path do %>
<%= image_tag('upload.png') %><br>
<%= t("sufia.dashboard.upload") %>
<% end %>
</div>
<% end %>
<div class="col-xs-6 col-sm-3 heading-tile <%="active" if current_dashboard_tab?(:describe) %>">
<%= link_to sufia.dashboard_files_path do %>
<%= image_tag('describe.png') %><br>
<%= t("sufia.dashboard.view_files") %>
<% end %>
</div>
<% if can?(:create, Collection) %>
<div class="col-xs-6 col-sm-3 heading-tile <%="active" if current_dashboard_tab?(:organize) %>">
<%= link_to sufia.dashboard_collections_path, id: "hydra-collection-add" do %>
<%= image_tag('organize.png') %><br>
<%= t("sufia.dashboard.create_collection") %>
<% end %>
</div>
<% end %>
<div class="col-xs-6 col-sm-3 heading-tile <%="active" if current_dashboard_tab?(:publish) %>">
<%= link_to dashboard_publishables_path, id: "hydra-collection-view" do %>
<%= image_tag('publish.png') %><br>
<%= t("sufia.dashboard.publish") %>
<% end %>
</div>
</div>
16 changes: 16 additions & 0 deletions app/views/dashboard/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<%= content_for :heading do %>
<%= render partial: "dashboard/_index_partials/heading_greetings" %>
<% end %>
<%= content_for :sidebar do %>
<%= render partial: "dashboard/_index_partials/stats" %>
<%= render partial: "dashboard/_index_partials/user_info" %>
<% end %>
<%= render partial: "dashboard/_index_partials/contents" %>

31 changes: 31 additions & 0 deletions app/views/generic_files/edit.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<%= javascript_tag do %>
<%= render partial: "edit", formats: [:js] %>
<% end %>
<%= render_breadcrumbs builder: Sufia::BootstrapBreadcrumbsBuilder %>
<%= render partial: 'dashboard/_index_partials/heading_actions.html.erb' %>
<h1 class="lower">Edit <%= @generic_file %></h1>

<div class="row">
<div class="col-xs-12 col-sm-4">
<%= render partial: 'media_display' %>
</div>
<div class="col-xs-12 col-sm-8">
<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_versioning_link">
<a href="#versioning_display" data-toggle="tab"><i class="glyphicon glyphicon-sitemap"></i> Versions</a>
</li>
<li id="edit_permissions_link"><a href="#permissions_display" data-toggle="tab">
<i class="glyphicon glyphicon-key"></i> Permissions</a>
</li>
</ul>
<div class="tab-content">
<%= render "descriptions", form: @form %>
<%= render "permission", generic_file: @generic_file %>
<%= render "versioning", generic_file: @generic_file %>
</div>
</div> <!-- /.col-sm-8 -->
</div><!-- /.row -->
Loading

0 comments on commit 7595acc

Please sign in to comment.