mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-10-04 19:05:37 +08:00
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:
commit
d62ec81472
6 changed files with 28 additions and 6 deletions
|
@ -7,6 +7,18 @@ var DasboardQuickStartWidget = (function() {
|
||||||
var createTaskButton = '#create-task-modal .create-task-button';
|
var createTaskButton = '#create-task-modal .create-task-button';
|
||||||
var newProjectsVisibility = '#create-task-modal .new-projects-visibility';
|
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() {
|
function initNewTaskModal() {
|
||||||
$('.quick-start-widget .new-task').click(() => {
|
$('.quick-start-widget .new-task').click(() => {
|
||||||
$('#create-task-modal').modal('show');
|
$('#create-task-modal').modal('show');
|
||||||
|
@ -108,6 +120,8 @@ var DasboardQuickStartWidget = (function() {
|
||||||
init: () => {
|
init: () => {
|
||||||
if ($('.quick-start-widget').length) {
|
if ($('.quick-start-widget').length) {
|
||||||
initNewTaskModal();
|
initNewTaskModal();
|
||||||
|
initNewProtocolLink();
|
||||||
|
initNewReportLink();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -300,6 +300,7 @@ function initCreateNewModal() {
|
||||||
var link = $("[data-action='create-new']");
|
var link = $("[data-action='create-new']");
|
||||||
var modal = $("#create-new-modal");
|
var modal = $("#create-new-modal");
|
||||||
var submitBtn = modal.find(".modal-footer [data-action='submit']");
|
var submitBtn = modal.find(".modal-footer [data-action='submit']");
|
||||||
|
var newProtocol = parseInt(sessionStorage.getItem('scinote-dashboard-new-protocol'), 10);
|
||||||
|
|
||||||
link.on("click", function() {
|
link.on("click", function() {
|
||||||
$.ajax({
|
$.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() {
|
submitBtn.on("click", function() {
|
||||||
// Submit the form inside modal
|
// Submit the form inside modal
|
||||||
|
|
|
@ -181,13 +181,17 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function initNewReportModal() {
|
function initNewReportModal() {
|
||||||
|
var newReport = parseInt(sessionStorage.getItem('scinote-dashboard-new-report'), 10);
|
||||||
$('#new-report-btn').on('click', function() {
|
$('#new-report-btn').on('click', function() {
|
||||||
$('#new-report-modal').modal('show');
|
$('#new-report-modal').modal('show');
|
||||||
initSelectPicker();
|
initSelectPicker();
|
||||||
initRedirectToNewReportPage();
|
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();
|
initDatatable();
|
||||||
|
|
|
@ -15,10 +15,10 @@
|
||||||
<%= t("dashboard.quick_start.description") %>
|
<%= t("dashboard.quick_start.description") %>
|
||||||
</div>
|
</div>
|
||||||
<div class="new-task btn btn-secondary btn-block"><i class="fas fa-plus"></i><%= t("dashboard.quick_start.new_task") %></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") %>
|
<i class="fas fa-edit"></i><%= t("dashboard.quick_start.new_protocol") %>
|
||||||
<% end %>
|
<% 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") %>
|
<i class="fas fa-clipboard-check"></i><%= t("dashboard.quick_start.new_report") %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
<% provide(:head_title, t("protocols.index.head_title")) %>
|
<% provide(:head_title, t("protocols.index.head_title")) %>
|
||||||
|
|
||||||
<% if current_team %>
|
<% 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">
|
<ul class="nav nav-tabs nav-settings">
|
||||||
<li role="presentation" class="<%= "active" if @type == :public %>">
|
<li role="presentation" class="<%= "active" if @type == :public %>">
|
||||||
<%= link_to t("protocols.index.navigation.public"), protocols_path(team: @current_team, type: :public) %>
|
<%= link_to t("protocols.index.navigation.public"), protocols_path(team: @current_team, type: :public) %>
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
<%= stylesheet_link_tag 'datatables' %>
|
<%= stylesheet_link_tag 'datatables' %>
|
||||||
|
|
||||||
<div class="content-pane">
|
<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="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<% if can_manage_reports?(current_team) %>
|
<% if can_manage_reports?(current_team) %>
|
||||||
|
|
Loading…
Add table
Reference in a new issue