Skip to content

Commit

Permalink
Default to contents for project show page (#1127)
Browse files Browse the repository at this point in the history
* Switched the show page to show the contents and the metadata to be the details page

* Adjusted test to new logic

* Adjust the tests to the new logic

* Adjusted a few more tests

* Adjusted a few more tests to account for the new logic
  • Loading branch information
hectorcorrea authored Dec 13, 2024
1 parent c162d8e commit 20a08f1
Show file tree
Hide file tree
Showing 12 changed files with 215 additions and 230 deletions.
6 changes: 3 additions & 3 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def create
render :new
end

def show
def details
add_breadcrumb(project.title, project_path)
add_breadcrumb("Details")
project
Expand Down Expand Up @@ -175,9 +175,9 @@ def index
def confirmation; end
def revision_confirmation; end

def contents
def show
add_breadcrumb(project.title, project_path)
add_breadcrumb("Contents", project_contents_path)
add_breadcrumb("Contents")
project

@latest_completed_download = current_user.user_requests.where(project_id: @project.id, state: "completed").order(:completion_time).last
Expand Down
35 changes: 9 additions & 26 deletions app/javascript/entrypoints/projectTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,43 +135,26 @@ export function projectStyle(railsSession) {
// });
}

export function projectTab() {
$('#project-content').on('click', (inv) => {
const element = inv;
export function projectTab(contentUrl, detailsUrl) {
$('#project-content').on('click', (element) => {
element.preventDefault();
const contentLocation = `${window.location}/contents`;

$.ajax({
type: 'GET',
url: contentLocation,
success() { // on success..
window.location.href = contentLocation; // update the DIV
url: contentUrl,
success() {
window.location.href = contentUrl; // update the browser's URL
},
});
});

$('#project-details').on('click', (inv) => {
const element = inv;
$('#project-details').on('click', (element) => {
element.preventDefault();
const baseURL = window.location.href;
const content = '/contents';
const detailLocation = baseURL.replace(content, '');
$.ajax({
type: 'GET',
url: detailLocation,
success() { // on success..
window.location.href = detailLocation; // update the DIV
url: detailsUrl,
success() {
window.location.href = detailsUrl; // update the browser's URL
},
});
});

// $('#project-script').on('click', (inv) => {
// const element = inv;
// element.preventDefault();
// });

// $('#project-approval').on('click', (inv) => {
// const element = inv;
// element.preventDefault();
// });
}
56 changes: 0 additions & 56 deletions app/views/projects/contents.html.erb

This file was deleted.

117 changes: 117 additions & 0 deletions app/views/projects/details.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<%= render partial: "project_details_heading" %>

<show id="show">
<% unless @project.in_mediaflux? %>
<div class="pending-project">
Your new project request is in the queue. Please allow 5 business days for our team to review your needs and set everything up. For assistance, please contact [email protected].
</div>
<% end %>

<div id="project-nav">
<button id="project-content" class="tab-nav"> Content Preview </button>
<button id="project-details" class="tab-nav"> Details </button>
<button id="project-script" class="tab-nav"> View Create Script </button>
<button id="project-approval" class="tab-nav"> Approval Setting </button>
</div>

<div class="details">
<h2>Roles
<%# Per ticket #1114 only superusers have edit access %>
<% if @project_eligible_to_edit && current_user.superuser || current_user.sysadmin %>
<%= link_to "Edit", edit_project_path(@project.id), id:"revisible-heading", class: "btn btn-primary btn-sm" %>
<% end %>
</h2>
<dl>
<% if !@data_sponsor.nil? %>
<dt>Data Sponsor</dt>
<dd id="data_sponsor">
<%= @data_sponsor.display_name_safe %>
</dd>
<% end %>
<% if !@data_manager.nil? %>
<dt>Data Manager</dt>
<dd id="data_manager">
<%= @data_manager.display_name_safe %>
</dd>
<% end %>

<dt>Data Users</dt>
<% if @data_users.present? %>
<dd>
<%= @data_user_names %>
</dd>
<% else %>
<dd>
<p>None</p>
</dd>
<% end %>
</dl>
</div>

<div class="details">
<h2>Project Description
<%# Per ticket #1114 only superusers have edit access %>
<% if @project_eligible_to_edit && current_user.superuser %>
<%= link_to "Edit", edit_project_path(@project.id), id:"revisible-heading", class: "btn btn-primary btn-sm" %>
<% end %>
</h2>
<dl>
<dt>Departments</dt>
<% if @departments.empty? %>
<dd><strong class="px-0">None</strong></dd>
<% else %>
<dd>
<% @project.project.metadata_json["departments"].each do |department_code| %>
<% Affiliation.all.each do |hash| %>
<% if hash[:code] == department_code %>
<%= hash[:name] %>
<% end %>
<% end %>
<% end %>
</dd>
<% end %>
<dt>Project Directory</dt>
<dd><%= @project.project_directory %></dd>
<dt>Title</dt>
<dd><%= @project.title %></dd>
<dt>Description:<dt/> <dd><%= @project.description %></dd>
</dl>
</div>

<div class="details">
<%= if @project.pending?
render partial: "pending_details"
else
render partial: "approved_details"
end %>
</div>

<div class="details">
<h2> Provenance </h2>
<p class="provenance-header"> Submission </p>
<ul class>
<% @provenance_events.each do |event| %>
<li class="provenance"> <%= event.event_details %>, <%=event.created_at.to_time.in_time_zone("America/New_York").iso8601%> </li>
<% end %>
</ul>
</div>

<div class="details">
<% if current_user.eligible_sysadmin? %>
<% if @project.pending? %>
<%= link_to "Approve Project", project_approve_path(@project.id), class: "btn btn-primary btn-sm" %>
<%= link_to " View Create Script", "#", class: "bi bi-code btn btn-secondary btn-sm", id: "create-script-btn" %>
<% end %>
<% end %>
</div>

<!-- this div is populated by the AJAX below -->
<div id="create-script-text"></div>
</show>

<script type="module">
// Make the AJAX call to fetch the aterm script
showCreateScript('<%= project_create_script_path(format: "json") %>');
projectStyle('<%= @project_session %>');
projectTab("<%= project_path %>", "<%= project_details_path %>");
</script>
Loading

0 comments on commit 20a08f1

Please sign in to comment.