mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-01 05:02:50 +08:00
Update protocol status bar upon changing of protocol description
This commit is contained in:
parent
c844158f6e
commit
c26489acdc
2 changed files with 28 additions and 21 deletions
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -385,27 +385,33 @@ 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");
|
||||
// The following actions need a refresh of status bar:
|
||||
// - Edit protocol description
|
||||
// - Create new step
|
||||
// - Edit existing step
|
||||
// - Move steps up/down
|
||||
// - Delete step
|
||||
// - New Office file
|
||||
// - Edit image
|
||||
// - Office Online edit file (???)
|
||||
|
||||
// Fetch new updated at label
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: "GET",
|
||||
dataType: "json",
|
||||
success: function (data2) {
|
||||
$("[data-role='protocol-status-bar']").html(data2.html);
|
||||
initLinkUpdate();
|
||||
}
|
||||
});
|
||||
}
|
||||
// TODO - this function will probably become reduntant
|
||||
}
|
||||
|
||||
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 (data) {
|
||||
$("[data-role='protocol-status-bar']").html(data.html);
|
||||
initLinkUpdate();
|
||||
}
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
function initImport() {
|
||||
|
|
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);
|
||||
|
|
Loading…
Reference in a new issue