Skip to content

Commit

Permalink
Clean up interface and add subjects, extents and locations to summary…
Browse files Browse the repository at this point in the history
… - also a lhs nav for now
  • Loading branch information
payten committed Feb 12, 2013
1 parent 6dae6dc commit c1f1376
Show file tree
Hide file tree
Showing 16 changed files with 304 additions and 63 deletions.
9 changes: 9 additions & 0 deletions backend/spec/controller_subject_spec.rb
Expand Up @@ -47,4 +47,13 @@ def create_subject

JSONModel(:subject).find(id).ref_id.should eq("CustomIdentifier123")
end


it "can resolve an id from a subject uri" do
id = create_subject
subject = JSONModel(:subject).find(id)

JSONModel(:subject).id_for(subject['uri']).should eq(id)
end

end
11 changes: 5 additions & 6 deletions frontend/app/assets/stylesheets/archivesspace/form.less
Expand Up @@ -152,14 +152,13 @@ section h3 {
border: 1px solid #e5e5e5;
}
.as-nav-list > li:first-child > a {
-webkit-border-radius: 6px 6px 0 0;
-moz-border-radius: 6px 6px 0 0;
border-radius: 6px 6px 0 0;
.border-radius(6px 6px 0 0);
}
.as-nav-list > li:last-child > a {
-webkit-border-radius: 0 0 6px 6px;
-moz-border-radius: 0 0 6px 6px;
border-radius: 0 0 6px 6px;
.border-radius(0 0 6px 6px);
}
.as-nav-list > li:first-child:last-child > a {
.border-radius(6px)
}
.as-nav-list > .active > a {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/views/locations/show.html.erb
Expand Up @@ -11,7 +11,7 @@

<%= render :partial => "shared/flash_messages" %>
<%= read_only_view(@location) %>
<%= read_only_view(@location.to_hash) %>
</div>
</div>
</div>
72 changes: 72 additions & 0 deletions public/app/assets/stylesheets/archivesspace/common.less
@@ -1,5 +1,6 @@
body {
position: relative;
height: auto;
}

h2 > .label {
Expand Down Expand Up @@ -191,4 +192,75 @@ h2 > .label {
border-color: #EEE;
}
}
}

/* Form sidebar navigation */

.as-nav-list {
width: 228px;
margin: 0;
padding: 0;
background-color: #fff;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
border-radius: 6px;
-webkit-box-shadow: 0 1px 4px rgba(0,0,0,.065);
-moz-box-shadow: 0 1px 4px rgba(0,0,0,.065);
box-shadow: 0 1px 4px rgba(0,0,0,.065);
}
.as-nav-list > li > a {
display: block;
*width: 190px;
margin: 0 0 -1px;
padding: 8px 14px;
border: 1px solid #e5e5e5;
}
.as-nav-list > li:first-child > a {
.border-radius(6px 6px 0 0);
}
.as-nav-list > li:last-child > a {
.border-radius(0 0 6px 6px);
}
.as-nav-list > li:first-child:last-child > a {
.border-radius(6px)
}
.as-nav-list > .active > a {
position: relative;
z-index: 2;
padding: 9px 15px;
border: 0;
text-shadow: 0 1px 0 rgba(0,0,0,.15);
-webkit-box-shadow: inset 1px 0 0 rgba(0,0,0,.1), inset -1px 0 0 rgba(0,0,0,.1);
-moz-box-shadow: inset 1px 0 0 rgba(0,0,0,.1), inset -1px 0 0 rgba(0,0,0,.1);
box-shadow: inset 1px 0 0 rgba(0,0,0,.1), inset -1px 0 0 rgba(0,0,0,.1);
}
.as-nav-list .icon-chevron-right {
float: right;
margin-top: 2px;
margin-right: -6px;
.opacity(25);
}
.as-nav-list > li > a:hover {
background-color: #f5f5f5;
}
.as-nav-list a:hover .icon-chevron-right {
.opacity(50);
}
.as-nav-list .active .icon-chevron-right,
.as-nav-list .active a:hover .icon-chevron-right {
.opacity(100);
}
.as-nav-list {
.btn-group {
width: 100%;
}
.btn-submit-group {
width: 100%;
button:first-child {
width: 80%;
}
#createPlusOne {
width: 20%;
}
}
}
13 changes: 11 additions & 2 deletions public/app/controllers/site_controller.rb
Expand Up @@ -11,7 +11,7 @@ def search
end

def resource
@resource = JSONModel(:resource).find(params[:id], :repo_id => params[:repo_id])
@resource = JSONModel(:resource).find(params[:id], :repo_id => params[:repo_id], "resolve[]" => ["subjects", "container_locations"])
@repository = JSONModel(:repository).find(params[:repo_id])
@tree = JSONModel(:resource_tree).find(nil, :resource_id => @resource.id, :repo_id => params[:repo_id])

Expand All @@ -22,7 +22,7 @@ def resource
end

def archival_object
@archival_object = JSONModel(:archival_object).find(params[:id], :repo_id => params[:repo_id])
@archival_object = JSONModel(:archival_object).find(params[:id], :repo_id => params[:repo_id], "resolve[]" => ["subjects"])
@resource = JSONModel(:resource).find_by_uri(@archival_object['resource']['ref'], :repo_id => params[:repo_id])
@repository = JSONModel(:repository).find(params[:repo_id])
@children = JSONModel::HTTP::get_json("/repositories/#{params[:repo_id]}/archival_objects/#{@archival_object.id}/children")
Expand Down Expand Up @@ -61,6 +61,15 @@ def repository
end


def subject
render "site/todo"
end


def location
render "site/todo"
end

private

def set_search_criteria
Expand Down
18 changes: 17 additions & 1 deletion public/app/helpers/application_helper.rb
Expand Up @@ -52,11 +52,27 @@ def icon_for(type)
end

def label_and_value(label, value)
return if value.nil?
return if value.blank?

label = content_tag(:div, label, :class => "control-label")
value = content_tag(:div, value, :class => "controls label-only")
content_tag(:div, label + value, :class => "control-group")
end

def i18n_enum(jsonmodel_type, property, value)
return if value.blank?

property_defn = JSONModel(jsonmodel_type).schema["properties"][property]

return if property_defn.nil?

if property_defn.has_key? "dynamic_enum"
enum_key = property_defn["dynamic_enum"]
#return "enumerations.#{enum_key}.#{value}"
I18n.t("enumerations.#{enum_key}.#{value}", :default => value)
else
I18n.t("#{jsonmodel_type}.#{property}_#{value}", :default => value)
end
end

end
Empty file.
Empty file.
Empty file.
7 changes: 3 additions & 4 deletions public/app/views/search/results.html.erb
Expand Up @@ -16,24 +16,23 @@
<% @search_data['results'].each do |result| %>
<%
id = JSONModel(result["primary_type"]).id_for(result['uri'])
repo_id = JSONModel(:repository).id_for(JSONModel.repository_for(result['uri']))
repo_id = JSONModel(:repository).id_for(JSONModel.repository_for(result['uri']),{}, true)
%>
<li class="result">
<h3>
<%= icon_for result["primary_type"] %>
<%= link_to result["title"] || result['display_string'], :controller => :site, :action => result["primary_type"], :id => id, :repo_id => repo_id %>
</h3>
<div class="result-summary">
<div class="label label-info pull-right"><%= I18n.t("#{result["primary_type"]}._html.singular") %></div>
<p class="muted">Summary goes here</p>
<%= render :partial => "search/result_summary_#{result["primary_type"]}", :locals => {:obj => result} %>
</div>
</li>
<% end %>
</ul>
<%= render :partial => "search/pagination" %>
<% else %>
<p class="alert alert-info">
<%= I18n.t("search_results.no_results_prefix") %> <em><%= params[:q] %></em>.
<%= I18n.t("search_results.no_results") %></em>.
</p>
<% end %>
</div>
Expand Down
76 changes: 68 additions & 8 deletions public/app/views/site/archival_object.html.erb
Expand Up @@ -11,19 +11,64 @@
<div class="content-pane">
<div class="row-fluid">
<div class="span3">

<div id="">
<ul class="nav nav-list as-nav-list">
<li><a href="#summary"><%= I18n.t("archival_object._html.section.summary") %> <span class="icon-chevron-right"></span></a></li>
<% if @archival_object['extents'].length > 0 %>
<li><a href="#extents"><%= I18n.t("extent._html.plural") %> <span class="icon-chevron-right"></span></a></li>
<% end %>
<% if @archival_object['subjects'].length > 0 %>
<li><a href="#subjects"><%= I18n.t("subject._html.plural") %> <span class="icon-chevron-right"></span></a></li>
<% end %>
<% if @children.length > 0 %>
<li><a href="#components"><%= I18n.t("archival_object._html.section.components") %> <span class="icon-chevron-right"></span></a></li>
<% end %>
</ul>
</div>
</div>
<div class="span9">
<fieldset class="form-horizontal">
<section>
<h3>Summary</h3>
<section id="summary">
<h3><%= I18n.t("archival_object._html.section.summary") %></h3>

<%# label_and_value I18n.t("resource.finding_aid_title"), @resource['finding_aid_title'] %>
<%= label_and_value I18n.t("archival_object.ref_id"), @archival_object['ref_id'] %>
<%= label_and_value I18n.t("archival_object.component_id"), @archival_object['component_id'] %>
<%= label_and_value I18n.t("archival_object.level"), i18n_enum(:archival_object, 'level', @archival_object['level']) %>
<%= label_and_value I18n.t("archival_object.language"), i18n_enum(:archival_object, 'language', @archival_object['language']) %>
</section>

<% if @archival_object['extents'].length > 0 %>
<section id="extents">
<h3><%= I18n.t("extent._html.plural") %></h3>
<ul class="results-list">
<% @archival_object['extents'].each do |extent| %>
<li class="result">
<%= extent['number'] %> <%= i18n_enum(:extent, 'extent_type', extent['extent_type']) %> (<%= i18n_enum(:extent, 'portion', extent['portion']) %>)
</li>
<% end %>
</ul>
</section>
<% end %>
<% if @archival_object['subjects'].length > 0 %>
<section id="subjects">
<h3><%= I18n.t("subject._html.plural") %></h3>
<ul class="results-list">
<% @archival_object['subjects'].each do |subject| %>
<li class="result">
<h4>
<%= icon_for "subject" %>
<%= link_to(subject['_resolved']['title'], {:controller => :site, :action => :subject, :id => JSONModel(:subject).id_for(subject['ref'])}) %>
</h4>
</li>
<% end %>
</ul>
</section>
<% end %>
<% if @children.length > 0 %>
<section>
<h3>Components</h3>
<section id="components">
<h3><%= I18n.t("archival_object._html.section.components") %></h3>

<ul class="results-list">
<% @children.each do |child| %>
Expand All @@ -40,9 +85,24 @@

</fieldset>

<br/>
<br/>

<pre><%= @archival_object.inspect %></pre>
<div class="accordion" id="source">
<div class="accordion-group">
<div class="accordion-heading">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#source" href="#collapseOne">
Debugging
</a>
</div>
<div id="collapseOne" class="accordion-body collapse">
<div class="accordion-inner">
<%= @archival_object.inspect %>
</div>
</div>
</div>
</div>

</div>
</div>
</div>
</div>

0 comments on commit c1f1376

Please sign in to comment.