Skip to content

Commit 8c43bd5

Browse files
committed
Bug #14770
Whatever a rich content of a contribution is added or updated, check the content cache for text to decide if a notification about contribution modification has to be triggered (in the case such notif is supported).
1 parent f2a2a68 commit 8c43bd5

File tree

1 file changed

+34
-33
lines changed

1 file changed

+34
-33
lines changed

core-war/src/main/webapp/wysiwyg/jsp/htmlEditor.jsp

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@
286286

287287
<script type="text/javascript">
288288
289-
var $deferred;
289+
let $deferred;
290290
291291
<c:if test="${not empty param.notySuccess}">
292292
$(document).ready(function(){
@@ -300,7 +300,7 @@
300300
browseInfo="<%=browseInformation%>" objectId="<%=objectId%>" objectType="<%=objectType%>"
301301
activateWysiwygBackupManager="true" />
302302
303-
if ($.trim($(".wysiwyg-fileStorage").text()).length == 0) {
303+
if ($.trim($(".wysiwyg-fileStorage").text()).length === 0) {
304304
$(".wysiwyg-fileStorage").css("display", "none");
305305
}
306306
};
@@ -330,9 +330,9 @@
330330
}
331331
332332
function choixLien() {
333-
var index = document.recupHtml.liens.selectedIndex;
334-
var str = document.recupHtml.liens.options[index].value;
335-
if (index != 0 && str != null) {
333+
const index = document.recupHtml.liens.selectedIndex;
334+
const str = document.recupHtml.liens.options[index].value;
335+
if (index !== 0 && str != null) {
336336
CKEDITOR.instances.editor1.insertHtml('<a href="' + str + '">' +
337337
str.substring(str.lastIndexOf("/") + 1) + "</a>");
338338
}
@@ -413,42 +413,43 @@
413413
414414
jQuery(document).ready(function() {
415415
jQuery(document.recupHtml).submit(function() {
416+
const wysiwygContent =
417+
sp.editor.wysiwyg.lastBackupManager.instance.existsUnvalidatedContent() ?
418+
sp.editor.wysiwyg.lastBackupManager.instance.getUnvalidatedContent() : '';
419+
const modifContextEnabled = ${isModificationContextEnabled};
420+
const subscriptionHandled = ${isHandledSubscriptionConfirmation};
416421
const contributionId = {
417422
componentInstanceId : '<%=componentId%>',
418423
localId : '<%=objectId%>',
419424
type : '<%=objectType%>'
420425
};
421426
jQuery.contributionModificationContext.validateOnUpdate({
422427
contributionId : contributionId,
423-
status : ${silfn:isDefined(wysiwygTextValue) and isModificationContextEnabled
424-
? 'undefined'
425-
: '$.contributionModificationContext.statuses.CREATION'},
428+
status : wysiwygContent.length > 0 && modifContextEnabled ?
429+
undefined : '$.contributionModificationContext.statuses.CREATION',
426430
callback : function() {
427-
<c:choose>
428-
<c:when test="${silfn:isDefined(wysiwygTextValue) and isHandledSubscriptionConfirmation}">
429-
jQuery.subscription.confirmNotificationSendingOnUpdate({
430-
contribution : {
431-
contributionId : contributionId,
432-
indexable : <%=indexIt%>,
433-
locationId : '${handledSubscriptionLocationId}'
434-
},
435-
comment : {
436-
saveNote : ${silfn:booleanValue(commentActivated)}
437-
},
438-
subscription : {
439-
componentInstanceId : '<%=componentId%>',
440-
type : '${handledSubscriptionType}',
441-
resourceId : '${handledSubscriptionResourceId}'
442-
},
443-
callback : function() {
444-
commit.call(this, false);
445-
}
446-
});
447-
</c:when>
448-
<c:otherwise>
449-
commit.call(this, ${silfn:isNotDefined(wysiwygTextValue) ? 'true' : 'false'});
450-
</c:otherwise>
451-
</c:choose>
431+
if (wysiwygContent.length > 0 && subscriptionHandled) {
432+
jQuery.subscription.confirmNotificationSendingOnUpdate({
433+
contribution: {
434+
contributionId: contributionId,
435+
indexable: <%=indexIt%>,
436+
locationId: '${handledSubscriptionLocationId}'
437+
},
438+
comment: {
439+
saveNote: ${silfn:booleanValue(commentActivated)}
440+
},
441+
subscription: {
442+
componentInstanceId: '<%=componentId%>',
443+
type: '${handledSubscriptionType}',
444+
resourceId: '${handledSubscriptionResourceId}'
445+
},
446+
callback: function () {
447+
commit.call(this, false);
448+
}
449+
});
450+
} else {
451+
commit.call(this, wysiwygContent.length === 0);
452+
}
452453
}});
453454
return false;
454455
});

0 commit comments

Comments
 (0)