Skip to content
This repository has been archived by the owner on Jun 12, 2024. It is now read-only.

Commit

Permalink
Merge branch 'master' into 6.2.2.oc
Browse files Browse the repository at this point in the history
  • Loading branch information
kkrumlian committed Jan 18, 2024
2 parents 8ee5dbb + 4a33800 commit abf9e5b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
8 changes: 7 additions & 1 deletion public/js/src/module/controller-webform-oc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}

Expand Down
12 changes: 6 additions & 6 deletions test/client/dn-widget.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) => {
Expand Down
18 changes: 16 additions & 2 deletions widget/discrepancy-note/dn-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1599,6 +1599,20 @@ class Comment extends Widget {
);
}

_decodeHtml(str) {
return str.replace(
/(&amp;)|(&lt;)|(&gt;)|(&#39;)|(&quot;)/g,
(tag) =>
({
'&amp;': '&',
'&lt;': '<',
'&gt;': '>',
'&#39;': "'",
'&quot;': '"',
}[tag])
);
}

_getHistoryRow(item, options = {}) {
const types = {
comment: '<span class="icon fa-comment-o"> </span>',
Expand Down

0 comments on commit abf9e5b

Please sign in to comment.