Skip to content

Commit

Permalink
SAK-40738 CKEditor autosave alerts about saved text for ckeditor othe…
Browse files Browse the repository at this point in the history
…r than the one that originated the autosave (sakaiproject#9857)
  • Loading branch information
hornersa authored Sep 30, 2021
1 parent db2bcf0 commit 0eb1e03
Show file tree
Hide file tree
Showing 54 changed files with 269 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ function resizeFrame(){
</label>
</div>
<div class="col-md-12">
#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set($entityval = "$message.id")
<input type="hidden" id="$contextkey" name="$contextkey" value="annc">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">
#if ($new=="true")
#if ($!tempBody.length() != 0)
<textarea name="body" class="block" id="body" cols="65" rows="30" wrap="virtual">$formattedText.escapeHtmlFormattedTextarea($tempBody)</textarea>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@
#if (($submission.Submitted || !$alertGradeDraft) && $!value_feedback_text && !$!value_feedback_text.isEmpty())
<p class="text-info">$tlang.getString("gradingsub.belisthe")</p>
<div class="textarea-holder">
#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set($entityval = "$submission.id")
<input type="hidden" id="$contextkey" name="$contextkey" value="asn_instructor_grade">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">
<textarea name="$name_feedback_text" id="$name_feedback_text" rows="30" wrap="virtual" cols="80">
$formattedText.escapeHtmlFormattedTextarea($!value_feedback_text)
</textarea>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,12 @@
$tlang.getString("gen.assinf")
</label>
<div class="col-sm-12">
#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set($entityval = "$assignmentId")
<input type="hidden" id="$contextkey" name="$contextkey" value="asn_instructor_edit">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">

<table border="0" style="margin:0"><tr><td>
<textarea name="$name_Description" id="$name_Description" cols="80" rows="30" wrap="virtual">$formattedText.escapeHtmlFormattedTextarea($value_Description)</textarea>
#chef_setupformattedtextarea($name_Description)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,11 @@
#end
<table border="0"><tr><td>
#if(!$view_only)
#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set($entityval = "$submissionReference")
<input type="hidden" id="$contextkey" name="$contextkey" value="asn_student_review">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">
<textarea name="$name_feedback_comment" id="$name_feedback_comment" rows="30" wrap="virtual" cols="80">#if($!value_feedback_comment)$formattedText.escapeHtmlFormattedTextarea($!value_feedback_comment)#end</textarea>
#chef_setupformattedtextarea($name_feedback_comment)
#else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ $(document).ready(function(){
<input type="hidden" name="$name_check_plagiarism_eula_agreement" id="$name_check_plagiarism_eula_agreement" value="true" checked="checked"/>
#end
</p>
#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set($entityval = "$assignment.Id")
<input type="hidden" id="$contextkey" name="$contextkey" value="asn_student_view">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">
<table border="0">
<tr>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,12 @@ $(function() {
$timezone
</p>
<div class="itemSummary">

#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set( $entityval = "$!event.getId()" )
<input type="hidden" id="$contextkey" name="$contextkey" value="calendar_new">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">

<label for="body" class="block">$tlang.getString("new.descr")</label>
#if ($savedData.getDescription().length() !=0)
<textarea name="description" id="description" wrap="virtual" rows="10">$formattedText.escapeHtmlFormattedTextarea($savedData.getDescription())</textarea>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -619,6 +619,12 @@ $(function() {
$timezone
</p>
<div class="longtext">
#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set( $entityval = "$!event.getId()" )
<input type="hidden" id="$contextkey" name="$contextkey" value="calendar_new">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">

<label for="xbody" class="block">
$tlang.getString("new.descr")
</label>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
$tlang.getString("instr.html")
</p>
<form name="addContentForm" id="addContentForm" method="post" action="#toolForm("ResourcesHelperAction")" >
#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set($entityval = $!{pipe-init-id})
<input type="hidden" id="$contextkey" name="$contextkey" value="content_create_html">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">

<input type="hidden" name="pipe-init-id" id="pipe-init-id" value="$!{pipe-init-id}" />
<input type="hidden" name="requestStateId" id="requestStateId" value="$!{requestStateId}" />
#if($!{item.isMissing("contenttext")})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
<div class="sak-banner-error">$tlang.getString("label.alert") $formattedText.escapeHtml($itemAlertMessage)</div>
#end
<form name="addContentForm" id="addContentForm" method="post" action="#toolForm("ResourcesHelperAction")" >
#set($contextkey = "ckeditor-autosave-context")
#set($entitykey = "ckeditor-autosave-entity-id")
#set($entityval = $!{item.id})
<input type="hidden" id="$contextkey" name="$contextkey" value="content_create_html">
<input type="hidden" id="$entitykey" name="$entitykey" value="$entityval">

<input type="hidden" name="pipe-init-id" id="pipe-init-id" value="$!{pipe-init-id}" />
<input type="hidden" name="requestStateId" id="requestStateId" value="$!{requestStateId}" />
#if($!{item.isMissing("contentarea")})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1233,8 +1233,12 @@ public int compare(SimpleStudentPage o1, SimpleStudentPage o2) {
UIOutput.make(tofill, "lessonsSubnavItemId")
.decorate(new UIFreeAttributeDecorator("value", String.valueOf(pageItem.getId())));

String currentPageId = String.valueOf(simplePageBean.getCurrentPage().getPageId());
UIOutput.make(tofill, "lessonsCurrentPageId")
.decorate(new UIFreeAttributeDecorator("value", String.valueOf(simplePageBean.getCurrentPage().getPageId())));
.decorate(new UIFreeAttributeDecorator("value", currentPageId));
UIOutput.make(tofill, "ckeditor-autosave-entity-id")
.decorate(new UIFreeAttributeDecorator("name", "ckeditor-autosave-entity-id"))
.decorate(new UIFreeAttributeDecorator("value", currentPageId));
}

public void printSubpage(List<SimplePageItem> itemList, boolean first, UIBranchContainer sectionWrapper, UIBranchContainer sectionContainer, UIBranchContainer columnContainer, UIBranchContainer tableContainer,
Expand Down
2 changes: 2 additions & 0 deletions lessonbuilder/tool/src/webapp/templates/ShowPage.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@
</head>

<body rsf:id="scr=sakai-body">
<input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="lessonsPageAutoSaveContext" />
<input type='hidden' rsf:id="ckeditor-autosave-entity-id" id="ckeditor-autosave-entity-id"/>
<input type='hidden' rsf:id="lessonsSubnavToolId" id="lessonsSubnavToolId"/>
<input type='hidden' rsf:id="lessonsSubnavTopLevelPageId" id="lessonsSubnavTopLevelPageId"/>
<input type='hidden' rsf:id="lessonsSubnavPageId" id="lessonsSubnavPageId"/>
Expand Down
55 changes: 53 additions & 2 deletions library/src/webapp-filtered/editor/ckeditor.launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*
******************************************************************************/
var sakai = sakai || {};
var autosaveContext = "ckeditor-autosave-context";
var autosaveEntityKey = "ckeditor-autosave-entity-id";
sakai.editor = sakai.editor || {};
sakai.editor.editors = sakai.editor.editors || {};
// Temporarily disable enableResourceSearch till citations plugin is ported (SAK-22862)
Expand Down Expand Up @@ -112,6 +114,53 @@ sakai.editor.editors.ckeditor.launch = function(targetId, config, w, h) {
}
}

// Prune the GET parameters and '?' off the URL
function pruneUrl(url) {
return url.split('?')[0];
}

// Truncate the Tests & Quizzes Settings URL to only include up to the tool_id.
function truncateSamigoSettingsUrl(url) {
var arr = url.split('/');
return "https://" + arr[2] + "/" + arr[3] + "/" + arr[4] + "/" + arr[6] + "/" + arr[7];
}

// The autosave plugin's default use of a URL is not sufficient for many Sakai entities
// whereby the tool URL is not distinct.
function getAutoSaveKey() {
var _saveKeyPrefix = "autosave",
_saveKeyUrl = window.location.href,
_saveKeyDelimiter = "_",
_saveKeyAttribute = "value",
_context = "unknown",
_entityVal = "undefined",
_username = "";

// Lookup two hidden inputs field to make autosave key unique beyond Sakai's presented URL
var contextElement = document.getElementById(autosaveContext);
if (contextElement != null)
_context = contextElement.getAttribute(_saveKeyAttribute);
var entityElement = document.getElementById(autosaveEntityKey);
if (entityElement != null)
_entityVal = entityElement.getAttribute(_saveKeyAttribute);

// Including the username in the autosavekey can help prevent instances on shared devices
// (e.g., in computer labs on campus) where one user's autosaved contents could otherwise be inadvertently accessible
// to another user.
if (typeof portal != 'undefined' && typeof portal.user != 'undefined' && typeof portal.user.eid != 'undefined' &&
typeof portal.user.eid == 'string') {
_username = portal.user.eid;
}

if (_context == "overview")
_saveKeyUrl = pruneUrl(_saveKeyUrl);
else if ((_context == "samigo_authorSettings") || (_context == "samigo_publishedSettings"))
_saveKeyUrl = truncateSamigoSettingsUrl(_saveKeyUrl);

return _saveKeyPrefix + _saveKeyDelimiter + _saveKeyUrl + _saveKeyDelimiter + targetId +
_saveKeyDelimiter + _context + _saveKeyDelimiter + _entityVal + _saveKeyDelimiter + _username;
}

var folder = "";

var collectionId = "";
Expand Down Expand Up @@ -341,9 +390,11 @@ sakai.editor.editors.ckeditor.launch = function(targetId, config, w, h) {
pasteFromWordRemoveFontStyles : false,
pasteFromWordRemoveStyles : false,
autosave : {
saveDetectionSelectors : "form input[type='button'],form input[type='submit']",
SaveKey: getAutoSaveKey(),
// Include ".ui-dialog-buttons button" which are used in Syllabus
saveDetectionSelectors : "form input[type='button'],form input[type='submit'],.ui-dialog-buttons button",
//Delay for autosave
delay: 120,
delay: 5,
//autosave_messageType can be "no" or "notification"
messageType : "statusbar"
},
Expand Down
2 changes: 2 additions & 0 deletions msgcntr/messageforums-app/src/webapp/jsp/compose.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@
</div>
</div>
</div>
<f:verbatim><input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="messages_compose" /></f:verbatim>
<h:panelGroup rendered="#{PrivateMessagesTool.currentMsgUuid!=null}"><f:verbatim><input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="</f:verbatim><h:outputText value="#{PrivateMessagesTool.currentMsgUuid}"/><f:verbatim>"/></f:verbatim></h:panelGroup>

<h4><h:outputText value="#{msgs.pvt_star}" styleClass="reqStar"/><h:outputText value="#{msgs.pvt_message}" /></h4>
<sakai:inputRichText textareaOnly="#{PrivateMessagesTool.mobileSession}" value="#{PrivateMessagesTool.composeBody}" id="pvt_message_body" rows="#{ForumTool.editorRows}" cols="132">
Expand Down
3 changes: 3 additions & 0 deletions msgcntr/messageforums-app/src/webapp/jsp/dfCompose.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<sakai:view title="#{msgs.cdfm_container_title}" toolCssHref="/messageforums-tool/css/msgcntr.css">
<!--jsp/dfCompose.jsp-->
<h:form id="dfCompose">
<f:verbatim><input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="forums_dfCompose" /></f:verbatim>
<h:panelGroup rendered="#{ForumTool.selectedTopic.topic.id!=null}"><f:verbatim><input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="</f:verbatim><h:outputText value="#{ForumTool.selectedTopic.topic.id}"/><f:verbatim>"/></f:verbatim></h:panelGroup>

<f:verbatim><input type="hidden" id="currentTopicId" name="currentTopicId" value="</f:verbatim><h:outputText value="#{ForumTool.selectedTopic.topic.id}"/><f:verbatim>"/></f:verbatim>
<f:verbatim><input type="hidden" id="currentForumId" name="currentForumId" value="</f:verbatim><h:outputText value="#{ForumTool.selectedForum.forum.id}"/><f:verbatim>"/></f:verbatim>
<script>includeLatestJQuery("msgcntr");</script>
Expand Down
5 changes: 4 additions & 1 deletion msgcntr/messageforums-app/src/webapp/jsp/dfMessageReply.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<f:view>

<sakai:view title="#{msgs.cdfm_reply_tool_bar_message}" toolCssHref="/messageforums-tool/css/msgcntr.css">
<!--jsp/dfMessageReplyThread.jsp-->
<!--jsp/dfMessageReply.jsp-->
<h:form id="dfCompose" styleClass="specialLink">
<f:verbatim><input type="hidden" id="currentMessageId" name="currentMessageId" value="</f:verbatim><h:outputText value="#{ForumTool.selectedMessage.message.id}"/><f:verbatim>"/></f:verbatim>
<f:verbatim><input type="hidden" id="currentTopicId" name="currentTopicId" value="</f:verbatim><h:outputText value="#{ForumTool.selectedTopic.topic.id}"/><f:verbatim>"/></f:verbatim>
Expand Down Expand Up @@ -116,6 +116,9 @@
<h:outputText value="#{msgs.cdfm_message_insert}" />
</a>
</div>
<f:verbatim><input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="forums_dfMessageReploy" /></f:verbatim>
<h:panelGroup rendered="#{ForumTool.selectedMessage.message.id!=null}"><f:verbatim><input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="</f:verbatim><h:outputText value="#{ForumTool.selectedMessage.message.id}"/><f:verbatim>"/></f:verbatim></h:panelGroup>

<sakai:inputRichText textareaOnly="#{PrivateMessagesTool.mobileSession}" value="#{ForumTool.composeBody}" id="df_compose_body" rows="#{ForumTool.editorRows}" cols="132">
</sakai:inputRichText>
<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,9 @@
<a href="javascript:void(0)" onclick="InsertHTML('<b><i><h:outputText value="#{msgs.cdfm_insert_original_text_comment}"/></i></b><br/><b><i><h:outputText value="#{msgs.cdfm_from}" /></i></b> <i><h:outputText value="#{ForumTool.selectedTopic.topic.postAnonymous ? ForumTool.selectedMessage.anonId : ForumTool.selectedMessage.message.authorEscaped}" /><h:outputText value=" #{msgs.cdfm_openb}" /><h:outputText value="#{ForumTool.selectedMessage.message.created}" ><f:convertDateTime pattern="#{msgs.date_format_static}" locale="#{ForumTool.userLocale}" timeZone="#{ForumTool.userTimeZone}"/></h:outputText><h:outputText value="#{msgs.cdfm_closeb}" /></i><br/><b><i><h:outputText value="#{msgs.cdfm_subject}" /></i></b>');">
<h:outputText value="#{msgs.cdfm_message_insert}" /></a>
</div>
<f:verbatim><input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="forums_dfMessageReplyThread" /></f:verbatim>
<h:panelGroup rendered="#{ForumTool.selectedMessage.message.id!=null}"><f:verbatim><input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="</f:verbatim><h:outputText value="#{ForumTool.selectedMessage.message.id}"/><f:verbatim>"/></f:verbatim></h:panelGroup>

<sakai:inputRichText textareaOnly="#{PrivateMessagesTool.mobileSession}" value="#{ForumTool.composeBody}" id="df_compose_body" rows="#{ForumTool.editorRows}" cols="132">
</sakai:inputRichText>
<%-- pre-morpheus would need this: script>
Expand Down
2 changes: 2 additions & 0 deletions msgcntr/messageforums-app/src/webapp/jsp/dfMsgRevise.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
<sakai:view_content>
<!--jsp/dfMsgRevise.jsp-->
<h:form id="dfCompose">
<f:verbatim><input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="forums_dfMsgRevise" /></f:verbatim>
<h:panelGroup rendered="#{ForumTool.selectedMessage.message.id!=null}"><f:verbatim><input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="</f:verbatim><h:outputText value="#{ForumTool.selectedMessage.message.id}"/><f:verbatim>"/></f:verbatim></h:panelGroup>
<f:verbatim><input type="hidden" id="currentMessageId" name="currentMessageId" value="</f:verbatim><h:outputText value="#{ForumTool.selectedMessage.message.id}"/><f:verbatim>"/></f:verbatim>
<f:verbatim><input type="hidden" id="currentTopicId" name="currentTopicId" value="</f:verbatim><h:outputText value="#{ForumTool.selectedTopic.topic.id}"/><f:verbatim>"/></f:verbatim>
<f:verbatim><input type="hidden" id="currentForumId" name="currentForumId" value="</f:verbatim><h:outputText value="#{ForumTool.selectedForum.forum.id}"/><f:verbatim>"/></f:verbatim>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@

<%--RTEditor area - if enabled--%>
<h:panelGroup rendered="#{! ForumTool.disableLongDesc}">
<f:verbatim><input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="forums_dfReviseForumSettingsAttach" /></f:verbatim>
<h:panelGroup rendered="#{ForumTool.selectedForum.forum.id!=null}"><f:verbatim><input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="</f:verbatim><h:outputText value="#{ForumTool.selectedForum.forum.id}"/><f:verbatim>"/></f:verbatim></h:panelGroup>

<h:outputText id="outputLabel2" value="#{msgs.cdfm_fullDescription}" styleClass="labeled"/>
<sakai:inputRichText textareaOnly="#{PrivateMessagesTool.mobileSession}" rows="#{ForumTool.editorRows}" cols="132" id="df_compose_description" value="#{ForumTool.selectedForum.forum.extendedDescription}">
</sakai:inputRichText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,9 @@
</h:panelGrid>
<%--RTEditor area - if enabled--%>
<h:panelGroup rendered="#{! ForumTool.disableLongDesc}">
<f:verbatim><input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="forums_dfReviseTopicSettingsAttach" /></f:verbatim>
<h:panelGroup rendered="#{ForumTool.selectedTopic.topic.id!=null}"><f:verbatim><input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="</f:verbatim><h:outputText value="#{ForumTool.selectedTopic.topic.id}"/><f:verbatim>"/></f:verbatim></h:panelGroup>

<h:outputText id="outputLabel2" value="#{msgs.cdfm_fullDescription}" styleClass="labeled"/>
<sakai:inputRichText textareaOnly="#{PrivateMessagesTool.mobileSession}"
rows="#{ForumTool.editorRows}"
Expand Down
2 changes: 2 additions & 0 deletions msgcntr/messageforums-app/src/webapp/jsp/pvtMsgForward.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
<div class="instruction">
<h:outputText value="#{msgs.cdfm_required}"/> <h:outputText value="#{msgs.pvt_star}" styleClass="reqStarInline"/>
</div>
<f:verbatim><input type="hidden" id="ckeditor-autosave-context" name="ckeditor-autosave-context" value="messages_pvtMsgReply" /></f:verbatim>
<h:panelGroup rendered="#{PrivateMessagesTool.detailMsg.msg.id!=null}"><f:verbatim><input type="hidden" id="ckeditor-autosave-entity-id" name="ckeditor-autosave-entity-id" value="</f:verbatim><h:outputText value="#{PrivateMessagesTool.detailMsg.msg.id}"/><f:verbatim>"/></f:verbatim></h:panelGroup>

<h:outputLink rendered="#{PrivateMessagesTool.renderPrivacyAlert}" value="#{PrivateMessagesTool.privacyAlertUrl}" target="_blank" >
<sakai:instruction_message value="#{PrivateMessagesTool.privacyAlert}"/>
Expand Down
Loading

0 comments on commit 0eb1e03

Please sign in to comment.