diff --git a/app/assets/javascripts/dashboard/quick_start.js b/app/assets/javascripts/dashboard/quick_start.js index 809c3d72c..25d1b3c82 100644 --- a/app/assets/javascripts/dashboard/quick_start.js +++ b/app/assets/javascripts/dashboard/quick_start.js @@ -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(); } } }; diff --git a/app/assets/javascripts/protocols/index.js b/app/assets/javascripts/protocols/index.js index 944bfd691..b9acb7b5d 100644 --- a/app/assets/javascripts/protocols/index.js +++ b/app/assets/javascripts/protocols/index.js @@ -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 diff --git a/app/assets/javascripts/reports/reports_datatable.js.erb b/app/assets/javascripts/reports/reports_datatable.js.erb index 467685de5..92901cdb6 100644 --- a/app/assets/javascripts/reports/reports_datatable.js.erb +++ b/app/assets/javascripts/reports/reports_datatable.js.erb @@ -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(); diff --git a/app/views/dashboards/_quick_start.html.erb b/app/views/dashboards/_quick_start.html.erb index 6d0299a69..6e321adb1 100644 --- a/app/views/dashboards/_quick_start.html.erb +++ b/app/views/dashboards/_quick_start.html.erb @@ -15,10 +15,10 @@ <%= t("dashboard.quick_start.description") %>