Merge pull request #2478 from aignatov-bio/ai-sci-4449-fix-new-protocol-report-dashboard

Fix protocol and report create modals after dashboard redirect [SCI-4449]
This commit is contained in:
aignatov-bio 2020-03-24 16:38:08 +01:00 committed by GitHub
commit d62ec81472
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 6 deletions

View file

@ -7,6 +7,18 @@ var DasboardQuickStartWidget = (function() {
var createTaskButton = '#create-task-modal .create-task-button';
var newProjectsVisibility = '#create-task-modal .new-projects-visibility';
function initNewReportLink() {
$('.quick-start-widget .new-report').click(() => {
sessionStorage.setItem('scinote-dashboard-new-report', Math.floor(Date.now() / 1000));
});
}
function initNewProtocolLink() {
$('.quick-start-widget .new-protocol').click(() => {
sessionStorage.setItem('scinote-dashboard-new-protocol', Math.floor(Date.now() / 1000));
});
}
function initNewTaskModal() {
$('.quick-start-widget .new-task').click(() => {
$('#create-task-modal').modal('show');
@ -108,6 +120,8 @@ var DasboardQuickStartWidget = (function() {
init: () => {
if ($('.quick-start-widget').length) {
initNewTaskModal();
initNewProtocolLink();
initNewReportLink();
}
}
};

View file

@ -300,6 +300,7 @@ function initCreateNewModal() {
var link = $("[data-action='create-new']");
var modal = $("#create-new-modal");
var submitBtn = modal.find(".modal-footer [data-action='submit']");
var newProtocol = parseInt(sessionStorage.getItem('scinote-dashboard-new-protocol'), 10);
link.on("click", function() {
$.ajax({
@ -329,7 +330,10 @@ function initCreateNewModal() {
});
});
if ($('#protocols-index').data('new-protocol')) link.click();
if (Math.floor(Date.now() / 1000) - newProtocol < 15) {
link.click();
sessionStorage.removeItem('scinote-dashboard-new-protocol');
}
submitBtn.on("click", function() {
// Submit the form inside modal

View file

@ -181,13 +181,17 @@
}
function initNewReportModal() {
var newReport = parseInt(sessionStorage.getItem('scinote-dashboard-new-report'), 10);
$('#new-report-btn').on('click', function() {
$('#new-report-modal').modal('show');
initSelectPicker();
initRedirectToNewReportPage();
});
if ($('#content-reports-index').data('new-report')) $('#new-report-btn').click();
if (Math.floor(Date.now() / 1000) - newReport < 15) {
$('#new-report-btn').click();
sessionStorage.removeItem('scinote-dashboard-new-report');
}
}
initDatatable();

View file

@ -15,10 +15,10 @@
<%= t("dashboard.quick_start.description") %>
</div>
<div class="new-task btn btn-secondary btn-block"><i class="fas fa-plus"></i><%= t("dashboard.quick_start.new_task") %></div>
<%= link_to protocols_path(new_protocol: true), {class: "new-protocol btn btn-secondary btn-block"} do %>
<%= link_to protocols_path, {class: "new-protocol btn btn-secondary btn-block"} do %>
<i class="fas fa-edit"></i><%= t("dashboard.quick_start.new_protocol") %>
<% end %>
<%= link_to reports_path(new_report: true), {class: "new-report btn btn-secondary btn-block"} do %>
<%= link_to reports_path, {class: "new-report btn btn-secondary btn-block"} do %>
<i class="fas fa-clipboard-check"></i><%= t("dashboard.quick_start.new_report") %>
<% end %>
<% end %>

View file

@ -5,7 +5,7 @@
<% provide(:head_title, t("protocols.index.head_title")) %>
<% if current_team %>
<div class="content-pane" id="protocols-index" <%= "data-new-protocol=true" if params[:new_protocol] %>>
<div class="content-pane" id="protocols-index">
<ul class="nav nav-tabs nav-settings">
<li role="presentation" class="<%= "active" if @type == :public %>">
<%= link_to t("protocols.index.navigation.public"), protocols_path(team: @current_team, type: :public) %>

View file

@ -6,7 +6,7 @@
<%= stylesheet_link_tag 'datatables' %>
<div class="content-pane">
<div id="content-reports-index" <%= "data-new-report=true" if params[:new_report] %>>
<div id="content-reports-index">
<div class="row">
<div class="col-md-12">
<% if can_manage_reports?(current_team) %>