Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

restricting project tabs to pending projects and eligible system administrators #1149

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions app/javascript/entrypoints/projectTabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,16 @@ export function projectStyle(railsSession) {
}
});

// $('#project-approval').on('click', (el) => {
// const element = el;
// element.preventDefault();
// approval.style.borderBottom = 'solid';
// approval.style.borderColor = '#E77500';
// approval.classList.add('active');
// });
$('#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(contentUrl, detailsUrl) {
export function projectTab(contentUrl, detailsUrl, approveUrl) {
$('#project-content').on('click', (element) => {
element.preventDefault();
$.ajax({
Expand All @@ -157,4 +157,15 @@ export function projectTab(contentUrl, detailsUrl) {
},
});
});

$('#project-approval').on('click', (element) => {
element.preventDefault();
$.ajax({
type: 'GET',
url: approveUrl,
success() {
window.location.href = approveUrl; // update the browser's URL
},
});
});
}
10 changes: 7 additions & 3 deletions app/views/projects/details.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@
<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>
<% if current_user.eligible_sysadmin? %>
<% if @project.pending? %>
<button id="project-script" class="tab-nav"> View Create Script </button>
<button id="project-approval" class="tab-nav"> Approval Setting </button>
<% end %>
<% end %>
</div>

<div class="details">
Expand Down Expand Up @@ -113,5 +117,5 @@
// 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 %>");
projectTab("<%= project_path %>", "<%= project_details_path %>", "<%= project_approve_path %>");
</script>
10 changes: 7 additions & 3 deletions app/views/projects/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,12 @@
<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>
<% if current_user.eligible_sysadmin? %>
<% if @project.pending? %>
<button id="project-script" class="tab-nav"> View Create Script </button>
<button id="project-approval" class="tab-nav"> Approval Setting </button>
<% end %>
<% end %>
</div>
<div class="row align-items-center contents-summary">
<div class="col-sm-2 file-inventory">File Inventory:</div>
Expand Down Expand Up @@ -51,6 +55,6 @@
</div>
<script type="module">
projectStyle('<%= @project_session %>');
projectTab("<%= project_path %>", "<%= project_details_path %>");
projectTab("<%= project_path %>", "<%= project_details_path %>", "<%= project_approve_path %>");
setupTable('#project-contents');
</script>