Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 67 additions & 6 deletions dist/doboard-widget-bundle.js

Large diffs are not rendered by default.

10 changes: 6 additions & 4 deletions dist/doboard-widget-bundle.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/doboard-widget-bundle.min.js.map

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion js/src/loaders/SpotFixTemplatesLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ class SpotFixTemplatesLoader {
<div class="doboard_task_widget-comment_text_container">
<div class="doboard_task_widget-comment_body">{{commentBody}}</div>
<div class="doboard_task_widget-comment_attachments">{{commentAttachments}}</div>
<div class="doboard_task_widget-comment_time">{{commentTime}}</div>
<div id="{{commentId}}" class="doboard_task_widget-comment_time">
<a href="{{commentLink}}">{{commentTime}}</a>
</div>
</div>
</div>
`;
Expand Down
30 changes: 30 additions & 0 deletions js/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,32 @@ window.addEventListener('dblclick', (event) => {
}
});

let lastProcessedHash = null;
function checkUrl() {
const currentUrl = window.location.href;
const regex = /#spotfix_comment_(\d+)_(\d+)/;
const match = currentUrl.match(regex);

if (match) {
const currentHash = match[0];

if (currentHash === lastProcessedHash) {
return;
}

lastProcessedHash = currentHash;

const num1 = Number(match[1]);
const num2 = Number(match[2]);
new CleanTalkWidgetDoboard({}, 'concrete_issue', null, {taskId: num1, commentId: num2});
} else {
lastProcessedHash = null;
}
}

window.addEventListener('hashchange', checkUrl);
window.addEventListener('popstate', checkUrl);

function spotFixInit() {
spotfixIndexedDB.init();
wsSpotfix.connect();
Expand All @@ -44,6 +70,9 @@ function spotFixInit() {
})
.catch(err => console.error('project_get error:', err));
}

checkUrl();

}

function loadBotDetector() {
Expand Down Expand Up @@ -229,6 +258,7 @@ function getTaskFullDetails(tasksDetails, taskId) {
commentAuthorName: getAuthorName(author),
commentBody: comment.commentBody,
commentDate: date,
commentId: comment.commentId,
commentTime: time,
commentUserId: comment.userId || 'Unknown User',
commentAttachments: commentAttachments,
Expand Down
37 changes: 33 additions & 4 deletions js/src/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class CleanTalkWidgetDoboard {
/**
* Constructor
*/
constructor(selectedData, type, timerToOpenWrap) {
constructor(selectedData, type, timerToOpenWrap, taskData) {
this.selectedData = selectedData || '';
this.timerToOpenWrap = timerToOpenWrap;
this.selectedText = selectedData?.selectedText || '';
Expand Down Expand Up @@ -50,6 +50,14 @@ class CleanTalkWidgetDoboard {
iconLockDark: SpotFixSVGLoader.getAsDataURI('iconLockDark'),
iconPublicDark: SpotFixSVGLoader.getAsDataURI('iconPublicDark'),
};

if (taskData && +taskData?.taskId){
this.currentActiveTaskId = +taskData.taskId;
}
if (taskData && +taskData?.commentId){
this.currentActiveCommentId = +taskData.commentId;
}

this.fileUploader = new FileUploader(this.escapeHtml);
this.init(type);
}
Expand Down Expand Up @@ -1013,7 +1021,9 @@ class CleanTalkWidgetDoboard {
});

activeTasks = sortedTasks.filter(task => task.taskStatus !== 'DONE');
finishedTasks = sortedTasks.filter(task => task.taskStatus === 'DONE');
finishedTasks = sortedTasks
.filter(task => task.taskStatus === 'DONE')
.sort((a, b) => new Date(b.taskLastUpdate) - new Date(a.taskLastUpdate));

const container = document.querySelector(".doboard_task_widget-all_issues-container");
if (container) {
Expand Down Expand Up @@ -1441,11 +1451,23 @@ class CleanTalkWidgetDoboard {
}
}

let commentLink = '';
try {
const taskMeta = JSON.parse(currentTaskData.taskMeta) || {};
const safePageUrl = getSafeUrl(taskMeta.pageURL || '');
const baseCommentUrl = safePageUrl ? safePageUrl.split('#')[0] : '';
commentLink = baseCommentUrl
? `${baseCommentUrl}#spotfix_comment_${currentTaskData?.taskId}_${comment?.commentId}`
: '';
} catch (e){}

const commentData = {
commentAuthorName: comment.commentAuthorName,
commentBody: comment.commentBody,
commentDate: comment.commentDate,
commentTime: comment.commentTime,
commentId: `spotfix_comment_${comment?.commentId}`,
commentLink: commentLink || '',
commentAttachments: attachmentsHTML,
Comment thread
veronika-tseleva-cleantalk marked this conversation as resolved.
issueTitle: templateVariables.issueTitle,
avatarCSSClass: avatarData.avatarCSSClass,
Expand Down Expand Up @@ -1522,8 +1544,15 @@ class CleanTalkWidgetDoboard {
const container = document.querySelector('.doboard_task_widget-concrete_issues-container');
if (container) {
setTimeout(() => {
const scrollPosition = container.scrollHeight;
container.scrollTo({top: scrollPosition, behavior: 'smooth'});
if (+taskDetails.taskId === +mainThis.currentActiveTaskId && mainThis.currentActiveCommentId){
const targetComment = document.getElementById(`spotfix_comment_${mainThis.currentActiveCommentId}`);
if (targetComment) {
targetComment.scrollIntoView({ behavior: 'smooth', block: 'center' });
}
} else {
const scrollPosition = container.scrollHeight;
container.scrollTo({top: scrollPosition, behavior: 'smooth'});
}
}, 50);
}
}
Expand Down
10 changes: 10 additions & 0 deletions styles/doboard-widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -1991,3 +1991,13 @@ input:checked + .slider:before {
.left_mobile .doboard_task_widget-wrap {
right: -50px;
}

.doboard_task_widget-comment_time a {
text-decoration: none;
color: inherit;
}
Comment thread
veronika-tseleva-cleantalk marked this conversation as resolved.

.doboard_task_widget-comment_time a:hover {
text-decoration: none;
color: black;
}