Skip to content

Commit

Permalink
Adding tabbed navigation to the project page (#1122)
Browse files Browse the repository at this point in the history
* Adding tabs to project page

* adding the project tabs to the content page
enabling user to navigate between the content and details tab of the projects page

* eslint

* Adding tabs to project page

* adding the project tabs to the content page
enabling user to navigate between the content and details tab of the projects page

* eslint

* updating content page spec

* removing deprecated navigation buttons

* removing the onclick css for the create script and approval settings tabs

* eslint

* removing duplicate case statement
  • Loading branch information
JaymeeH authored Dec 12, 2024
1 parent 346daf6 commit 9bec5c9
Show file tree
Hide file tree
Showing 8 changed files with 238 additions and 42 deletions.
19 changes: 19 additions & 0 deletions app/assets/stylesheets/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@


#show {

#project-nav{
@include tab-nav;
margin-top: 3em;
margin-left: 1em;
margin-bottom: 1em;

border-bottom: solid;
border-color: #D0D0D0;
}

.pending-project {
margin-left: 5em;
padding-bottom: 2em;
Expand Down Expand Up @@ -143,6 +154,14 @@
}

#content {
#project-nav{
@include tab-nav;
margin-bottom: 1em;

border-bottom: solid;
border-color: #D0D0D0;
}

#file-list {
width: 90%;
border: 1px solid gray;
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# frozen_string_literal: true
class ProjectsController < ApplicationController

before_action :set_breadcrumbs

def new
Expand Down Expand Up @@ -115,6 +115,9 @@ def show
@project_purpose = @project_metadata[:project_purpose]


@project_session = "details"


respond_to do |format|
format.html do
@project = ProjectShowPresenter.new(project)
Expand Down Expand Up @@ -188,6 +191,7 @@ def contents
@files.sort_by!(&:path)
@project = ProjectShowPresenter.new(project)

@project_session = "content"
end

def project_job_service
Expand Down
3 changes: 3 additions & 0 deletions app/javascript/entrypoints/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { showCreateScript } from './atermScripts';
import { dashStyle, dashTab } from './dashboardTabs';
import { setupTable } from './pulDataTables';
import { showMoreLess } from './showMoreLess';
import { projectStyle, projectTab } from './projectTabs';

window.bootstrap = bootstrap;
window.displayMediafluxVersion = displayMediafluxVersion;
Expand All @@ -29,6 +30,8 @@ window.dashStyle = dashStyle;
window.dashTab = dashTab;
window.setupTable = setupTable;
window.showMoreLess = showMoreLess;
window.projectStyle = projectStyle;
window.projectTab = projectTab;

function initDataUsers() {
function counterIncrement(counterId) {
Expand Down
177 changes: 177 additions & 0 deletions app/javascript/entrypoints/projectTabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
export function projectStyle(railsSession) {
const content = document.getElementById('project-content');
const details = document.getElementById('project-details');
const script = document.getElementById('project-script');
const approval = document.getElementById('project-approval');
const session = railsSession;
const project = document.getElementById('show') || document.getElementById('content');

// Check the session to see which tab should start as active be active
if (project) {
switch (session) {
case 'details':
details.style.borderBottom = 'solid';
details.style.borderColor = '#E77500';
details.classList.add('active');
break;
case 'script':
script.style.borderBottom = 'solid';
script.style.borderColor = '#E77500';
script.classList.add('active');
break;
case 'approval':
approval.style.borderBottom = 'solid';
approval.style.borderColor = '#E77500';
approval.classList.add('active');
break;
default:
content.style.borderBottom = 'solid';
content.style.borderColor = '#E77500';
content.classList.add('active');
break;
}
}

$('#project-content').on('mouseenter', (el) => {
const element = el;
element.preventDefault();
if (!content.classList.contains('active')) {
content.style.borderBottom = 'solid';
content.style.borderColor = '#121212';
}
});

$('#project-content').on('mouseleave', (el) => {
const element = el;
element.preventDefault();
if (!content.classList.contains('active')) {
content.style.border = 'none';
}
});

$('#project-content').on('click', (el) => {
const element = el;
element.preventDefault();
content.style.borderBottom = 'solid';
content.style.borderColor = '#E77500';
content.classList.add('active');
});

$('#project-details').on('mouseenter', (el) => {
const element = el;
element.preventDefault();
if (!details.classList.contains('active')) {
details.style.borderBottom = 'solid';
details.style.borderColor = '#121212';
}
});

$('#project-details').on('mouseleave', (el) => {
const element = el;
element.preventDefault();
if (!details.classList.contains('active')) {
details.style.border = 'none';
}
});

$('#project-details').on('click', (el) => {
const element = el;
element.preventDefault();
details.style.borderBottom = 'solid';
details.style.borderColor = '#E77500';
details.classList.add('active');
});

$('#project-script').on('mouseenter', (el) => {
const element = el;
element.preventDefault();
if (!script.classList.contains('active')) {
script.style.borderBottom = 'solid';
script.style.borderColor = '#121212';
}
});

$('#project-script').on('mouseleave', (el) => {
const element = el;
element.preventDefault();
if (!script.classList.contains('active')) {
script.style.border = 'none';
}
});

// $('#project-script').on('click', (el) => {
// const element = el;
// element.preventDefault();
// script.style.borderBottom = 'solid';
// script.style.borderColor = '#E77500';
// script.classList.add('active');
// });

$('#project-approval').on('mouseenter', (el) => {
const element = el;
element.preventDefault();

if (!approval.classList.contains('active')) {
approval.style.borderBottom = 'solid';
approval.style.borderColor = '#121212';
}
});

$('#project-approval').on('mouseleave', (el) => {
const element = el;
element.preventDefault();

if (!approval.classList.contains('active')) {
approval.style.border = 'none';
}
});

// $('#project-approval').on('click', (el) => {
// const element = el;
// element.preventDefault();
// approval.style.borderBottom = 'solid';
// approval.style.borderColor = '#E77500';
// approval.classList.add('active');
// });
}

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

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

$('#project-details').on('click', (inv) => {
const element = inv;
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
},
});
});

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

// $('#project-approval').on('click', (inv) => {
// const element = inv;
// element.preventDefault();
// });
}
15 changes: 8 additions & 7 deletions app/views/projects/contents.html.erb
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<%= render partial: "project_details_heading" %>

<content id= "content">

<h2>Contents Summary</h2>
<div class="container">
<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="row align-items-center contents-summary">
<div class="col-sm-2 file-inventory">File Inventory:</div>
<div class="col-sm-2 file-total-label">Total Files: <%= @num_files %></div>
Expand All @@ -15,10 +19,6 @@
</div>

<%= render partial: "contents", locals: { files: @files } %>
<section class="container-fluid px-1 mx-0 my-1 project-contents__navigate">
<a href="<%= project_path(@project) %>" class="btn btn-primary">Review Metadata</a>
<a href="<%= root_path %>" class="btn btn-secondary">Return to Dashboard</a>
</section>
<section class="project-alerts my-4">
<div class="row">
<div class="col">
Expand Down Expand Up @@ -50,6 +50,7 @@
</div>
</div>
<script type="module">
// Setup the DataTables
projectStyle('<%= @project_session %>');
projectTab();
setupTable('#project-contents');
</script>
20 changes: 10 additions & 10 deletions app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@
</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 %>
Expand Down Expand Up @@ -58,7 +65,7 @@
<% Affiliation.all.each do |hash| %>
<% if hash[:code] == department_code %>
<%= hash[:name] %>
<% end %>
<% end %>
<% end %>
<% end %>
</dd>
Expand Down Expand Up @@ -89,21 +96,12 @@
</ul>
</div>

<div class="details">
<% if !current_user.eligible_sysadmin? %>
<%= link_to "Review Contents", project_contents_path(@project.id), class: "btn btn-primary btn-sm" %>
<%= link_to "Return to Dashboard", root_path, class: "btn btn-primary btn-sm" %>
<% end %>
</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 %>
<%= link_to "Review Contents", project_contents_path(@project.id), class: "btn btn-primary btn-sm" %>
<%= link_to "Return to Dashboard", root_path, class: "btn btn-return btn-sm" %>
<% end %>
</div>

Expand All @@ -114,4 +112,6 @@
<script type="module">
// Make the AJAX call to fetch the aterm script
showCreateScript('<%= project_create_script_path(format: "json") %>');
projectStyle('<%= @project_session %>');
projectTab();
</script>
6 changes: 3 additions & 3 deletions app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
</div>
</div>
<div id="dashboard-nav">
<button id="dash-projects" class="tab-nav"> Projects </button>
<button id="dash-activity" class="tab-nav"> Activity </button>
<button id="dash-admin" class="tab-nav"> Administration </button>
<button id="dash-projects" class="tab-nav"> Projects </button>
<button id="dash-activity" class="tab-nav"> Activity </button>
<button id="dash-admin" class="tab-nav"> Administration </button>
</div>
<% if @dash_session == "project"%>
<%= render partial: "projects_listing", locals: { projects: @dashboard_projects.sort_by(&:updated_at).reverse, table_id: "projects-listing" } %>
Expand Down
Loading

0 comments on commit 9bec5c9

Please sign in to comment.