mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2024-12-28 19:24:10 +08:00
Merge pull request #1785 from biosistemika/lm-ml-sci-3193
Update protocol status bar upon protocol changing [SCI-3193]
This commit is contained in:
commit
be0393e642
5 changed files with 26 additions and 24 deletions
|
@ -15,7 +15,7 @@ function init() {
|
|||
initCopyToRepository();
|
||||
initLinkUpdate();
|
||||
initLoadFromRepository();
|
||||
initRefreshStatusBar();
|
||||
refreshProtocolStatusBar();
|
||||
initImport();
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ function initEditMyModuleDescription() {
|
|||
|
||||
function initEditProtocolDescription() {
|
||||
$('#protocol_description_view').on('click', function(){
|
||||
TinyMCE.init('#protocol_description_textarea');
|
||||
TinyMCE.init('#protocol_description_textarea', refreshProtocolStatusBar);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -384,28 +384,20 @@ function loadFromRepository() {
|
|||
}
|
||||
}
|
||||
|
||||
function initRefreshStatusBar() {
|
||||
$("[data-role='steps-container']")
|
||||
.on(
|
||||
"ajax:success",
|
||||
function(e, data) {
|
||||
if ($(e.target).is("[data-role='edit-step-form'], [data-role='new-step-form']")) {
|
||||
// Get the status bar URL
|
||||
var url = $("[data-role='protocol-status-bar-url']").attr("data-url");
|
||||
function refreshProtocolStatusBar() {
|
||||
// Get the status bar URL
|
||||
var url = $("[data-role='protocol-status-bar-url']").attr("data-url");
|
||||
|
||||
// Fetch new updated at label
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (data2) {
|
||||
$("[data-role='protocol-status-bar']").html(data2.html);
|
||||
initLinkUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
// Fetch new updated at label
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (data) {
|
||||
$("[data-role='protocol-status-bar']").html(data.html);
|
||||
initLinkUpdate();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function initImport() {
|
||||
|
|
|
@ -162,7 +162,7 @@
|
|||
});
|
||||
}
|
||||
|
||||
// Set callback for click on edit button
|
||||
// Set callback for click on move step
|
||||
function applyMoveStepCallBack() {
|
||||
$("[data-action='move-step']").off("ajax:success");
|
||||
$("[data-action='move-step']")
|
||||
|
@ -188,6 +188,8 @@
|
|||
$stepUp.find(".badge").html(stepUpPosition+1);
|
||||
$("html, body").animate({ scrollTop: $step.offset().top - window.innerHeight / 2 });
|
||||
}
|
||||
|
||||
refreshProtocolStatusBar();
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -607,6 +609,7 @@
|
|||
DragNDropSteps.clearFiles();
|
||||
FilePreviewModal.init();
|
||||
$.initTooltips();
|
||||
refreshProtocolStatusBar();
|
||||
},
|
||||
error: function(xhr) {
|
||||
if (xhr.responseJSON['assets.file']) {
|
||||
|
|
|
@ -404,6 +404,7 @@ var FilePreviewModal = (function() {
|
|||
imageEditor = {};
|
||||
$('#tui-image-editor').html('');
|
||||
$('#fileEditModal').modal('hide');
|
||||
refreshProtocolStatusBar();
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -466,6 +467,7 @@ var FilePreviewModal = (function() {
|
|||
modal.find('.file-name').text(name);
|
||||
modal.find('.preview-close').click(function() {
|
||||
modal.modal('hide');
|
||||
refreshProtocolStatusBar();
|
||||
});
|
||||
modal.modal();
|
||||
modal.find('a[disabled=disabled]').click(function(ev) {
|
||||
|
|
3
app/assets/javascripts/sitewide/tiny_mce.js
vendored
3
app/assets/javascripts/sitewide/tiny_mce.js
vendored
|
@ -18,7 +18,7 @@ var TinyMCE = (function() {
|
|||
|
||||
// returns a public API for TinyMCE editor
|
||||
return Object.freeze({
|
||||
init: function(selector, mceConfig = {}) {
|
||||
init: function(selector, onSaveCallback) {
|
||||
var tinyMceContainer;
|
||||
var tinyMceInitSize;
|
||||
if (typeof tinyMCE !== 'undefined') {
|
||||
|
@ -164,6 +164,7 @@ var TinyMCE = (function() {
|
|||
editorForm.find('.tinymce-status-badge').removeClass('hidden');
|
||||
editor.remove();
|
||||
editorForm.find('.tinymce-view').html(data.html).removeClass('hidden');
|
||||
if (onSaveCallback) { onSaveCallback(); }
|
||||
}).on('ajax:error', function(ev, data) {
|
||||
var model = editor.getElement().dataset.objectType;
|
||||
$(this).renderFormErrors(model, data.responseJSON);
|
||||
|
|
|
@ -156,6 +156,8 @@ class AssetsController < ApplicationController
|
|||
tkn = current_user.get_wopi_token
|
||||
@token = tkn.token
|
||||
@ttl = (tkn.ttl * 1000).to_s
|
||||
@asset.step&.protocol&.update(updated_at: Time.now)
|
||||
|
||||
create_wopi_file_activity(current_user, true)
|
||||
|
||||
render layout: false
|
||||
|
@ -185,6 +187,7 @@ class AssetsController < ApplicationController
|
|||
@asset.team.release_space(orig_file_size)
|
||||
# Post process file here
|
||||
@asset.post_process_file(@asset.team)
|
||||
@asset.step&.protocol&.update(updated_at: Time.now)
|
||||
|
||||
render_html = if @asset.step
|
||||
asset_position = @asset.step.asset_position(@asset)
|
||||
|
@ -239,6 +242,7 @@ class AssetsController < ApplicationController
|
|||
render_403 && return unless can_manage_protocol_in_module?(step.protocol) ||
|
||||
can_manage_protocol_in_repository?(step.protocol)
|
||||
step_asset = StepAsset.create!(step: step, asset: asset)
|
||||
step.protocol&.update(updated_at: Time.now)
|
||||
|
||||
edit_url = edit_asset_url(step_asset.asset_id)
|
||||
elsif params[:element_type] == 'Result'
|
||||
|
|
Loading…
Reference in a new issue