diff --git a/public/js/src/module/controller-webform-oc.js b/public/js/src/module/controller-webform-oc.js index 0aca15d3..109147f6 100644 --- a/public/js/src/module/controller-webform-oc.js +++ b/public/js/src/module/controller-webform-oc.js @@ -153,7 +153,13 @@ function init(formEl, data, loadErrors = []) { ); // For Participant empty-form view in order to show Close button on all pages - if (settings.participant && settings.type !== 'edit') { + // add settings.reasonForChange condition to prevent Close button show on all pages + // for non Participant empty-form that does not have calculate items + if ( + settings.participant && + settings.reasonForChange && + settings.type !== 'edit' + ) { form.view.html.classList.add('empty-untouched'); } diff --git a/test/client/dn-widget.spec.js b/test/client/dn-widget.spec.js index 5b41de50..7c01d05c 100644 --- a/test/client/dn-widget.spec.js +++ b/test/client/dn-widget.spec.js @@ -345,11 +345,11 @@ describe('DN object', () => { ['{"queries":[], "logs":[{"type": "comment"}]}', ''], // first has system user [ - '{"queries":[], "logs":[{"type": "comment", "status": "updated", "user": "root", "date_time":2}]}', + '{"queries":[], "logs":[{"type": "comment", "status": "updated", "user": "system", "date_time":2}]}', '', ], [ - '{"queries":[{"type": "comment", "status": "updated", "user": "root", "date_time":2}], "logs":[]}', + '{"queries":[{"type": "comment", "status": "updated", "user": "system", "date_time":2}], "logs":[]}', '', ], // first has empty user @@ -372,20 +372,20 @@ describe('DN object', () => { ], // first root ignored, next is taken [ - '{"queries":[], "logs":[{"type": "audit", "user": "root", "date_time":2},{"type": "comment", "user": "jen", "date_time":1}]}', + '{"queries":[], "logs":[{"type": "audit", "user": "system", "date_time":2},{"type": "comment", "user": "jen", "date_time":1}]}', 'jen', ], [ - '{"queries":[{"type": "audit", "user": "root", "date_time":2},{"type": "comment", "user": "jen", "date_time":1}], "logs":[]}', + '{"queries":[{"type": "audit", "user": "system", "date_time":2},{"type": "comment", "user": "jen", "date_time":1}], "logs":[]}', 'jen', ], // same, but switched order (same date_time) to test ordering [ - '{"queries":[], "logs":[{"type": "comment", "user": "jen", "date_time":1}, {"type": "audit", "user": "root", "date_time":2}]}', + '{"queries":[], "logs":[{"type": "comment", "user": "jen", "date_time":1}, {"type": "audit", "user": "system", "date_time":2}]}', 'jen', ], [ - '{"queries":[{"type": "comment", "user": "jen", "date_time":1}, {"type": "audit", "user": "root", "date_time":2}], "logs":[]}', + '{"queries":[{"type": "comment", "user": "jen", "date_time":1}, {"type": "audit", "user": "system", "date_time":2}], "logs":[]}', 'jen', ], ].forEach((test) => { diff --git a/widget/discrepancy-note/dn-widget.js b/widget/discrepancy-note/dn-widget.js index fd9d2d31..56a24ba3 100644 --- a/widget/discrepancy-note/dn-widget.js +++ b/widget/discrepancy-note/dn-widget.js @@ -12,7 +12,7 @@ import reasons from '../../public/js/src/module/reasons'; let currentUser; let users; let annotationIconDataUri; -const SYSTEM_USER = 'root'; +const SYSTEM_USER = 'system'; const pad2 = (x) => (x < 10 ? `0${x}` : x); @@ -403,7 +403,7 @@ class Comment extends Widget { : t('widget.dn.fileremoved'); } - this._addAudit(comment, '', false); + this._addAudit(this._decodeHtml(comment), '', false); if (settings.reasonForChange && !this.linkedQuestionReadonly) { const reasonQuestion = reasons.addField(this.linkedQuestion); @@ -1599,6 +1599,20 @@ class Comment extends Widget { ); } + _decodeHtml(str) { + return str.replace( + /(&)|(<)|(>)|(')|(")/g, + (tag) => + ({ + '&': '&', + '<': '<', + '>': '>', + ''': "'", + '"': '"', + }[tag]) + ); + } + _getHistoryRow(item, options = {}) { const types = { comment: ' ',