Skip to content

Commit

Permalink
refining sysadmin dashboard (#632)
Browse files Browse the repository at this point in the history
* refining sysadmin dashboard
only displaying the sysadmin dashboard, and combining the two separate divs into one

* separating javascript into the application js, and the styling into the settings scss
fixing the collapsing mechanism in the show more button
additional styling

* javascript cleanup

* updating sysadmin tests

* allowing superusers to continue to see the project dashboard

* updating superuser specs

* js lint
  • Loading branch information
JaymeeH authored Apr 11, 2024
1 parent 04592d6 commit dde4574
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 30 deletions.
32 changes: 25 additions & 7 deletions app/assets/stylesheets/_settings.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,37 @@
text-decoration-thickness: 3px;
}

h4 {
margin-left: 0.2em;
text-decoration: underline;
text-decoration-thickness: 3px;
}

.project-list {
list-style-type: none;
a {
color: black;
}
}
.sysadmin-list {
list-style-type: none;
margin-left: 1.5em;
a {
color: black;
}
}

.visible-row {
visibility: unset;
}

.invisible-row {
visibility: collapse;
}

#show-more-sysadmin{
margin-top: 0.5em;
}
}

#dashboard-projects {
Expand All @@ -56,13 +81,6 @@
min-width: 30em;
}

#dashboard-approved{
@include dashboard-component;
margin-top: 1em;
min-width: 30em;
}


#show{
.pending-project {
margin-left: 5em;
Expand Down
17 changes: 17 additions & 0 deletions app/javascript/entrypoints/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,22 @@ function showMoreLessContent() {
});
}

function showMoreLessSysAdmin() {
$('#show-more-sysadmin').on('click', (el) => {
const element = el;
if (el.target.textContent === 'Show More') {
$('.bottom-section').removeClass('invisible-row');
element.target.textContent = 'Show Less';
} else {
// Show less
$('.bottom-section').addClass('invisible-row');
element.target.textContent = 'Show More';
// Source: https://stackoverflow.com/a/10681265/446681
}
el.preventDefault();
});
}

function initPage() {
$('#test-jquery').click((event) => {
setTargetHtml(event, 'jQuery works!');
Expand All @@ -171,6 +187,7 @@ function initPage() {
initDataUsers();
initListContentsModal();
showMoreLessContent();
showMoreLessSysAdmin();
}

window.addEventListener('load', () => initPage());
Expand Down
53 changes: 30 additions & 23 deletions app/views/welcome/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<% else %>
<h1>Welcome, <%= current_user.given_name %>!</h1>
<div style="display: inline-flex">
<% if !current_user.eligible_sysadmin? or current_user.superuser? %>
<div id="dashboard-projects">
<h1>My Projects</h1>
<% if @sponsored_projects.size > 0 %>
Expand Down Expand Up @@ -58,33 +59,39 @@
</ul>
<% end %>
</div>
<% end %>
</div>
<div style="display: inline-flex">
<% if current_user.eligible_sysadmin?%>
<div id="dashboard-pending">
<h2>Pending Projects</h2>
<% if !@pending_projects.empty? %>
<ul class="project-list">
<% @pending_projects.each do |project| %>
<li>
<%= link_to(project.title, project_approve_path(project)) %>
</li>
<% end %>
</ul>
<% end %>
</div>
<div id="dashboard-approved">
<h2>Approved Projects</h2>
<% if !@approved_projects.empty? %>
<ul class="project-list">
<% @approved_projects.each do |project| %>
<li>
<%= link_to(project.title, project) %>
</li>
<% end %>
</ul>
<% end %>
<h1>Project Administration</h1>
<h4>Pending Projects</h4>
<% if !@pending_projects.empty? %>
<ul class="project-list">
<% @pending_projects.each do |project| %>
<li>
<%= link_to(project.title, project_approve_path(project)) %>
</li>
<% end %>
</ul>
<% else %>
<p> (none) </p>
<% end %>
<h4>Recently Approved Projects</h4>
<% if !@approved_projects.empty? %>
<table class="sysadmin-list">
<% @approved_projects.each_with_index do |project, index| %>
<% @row_css = index < 5 ? "visible-row top-section" : "invisible-row bottom-section" %>
<tr class ="<%=@row_css%>">
<td><%= link_to(project.title, project) %> </td>
</tr>
<% end %>
</table>
<button id="show-more-sysadmin" type="button" class="btn btn-dark">Show More</button>
<% else %>
<p> (none) </p>
<% end %>
</div>
<%end%>
</div>
<% end %>
<% end %>

0 comments on commit dde4574

Please sign in to comment.