Skip to content
Merged
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
91 changes: 47 additions & 44 deletions dist/doboard-widget-bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 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.

12 changes: 10 additions & 2 deletions js/src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ async function spotFixConfirmUserEmail(emailConfirmationToken, params) {
localStorage.setItem('spotfix_email', result.email);
localStorage.setItem('spotfix_session_id', result.sessionId);
localStorage.setItem('spotfix_user_id', result.userId);
localStorage.setItem('spotfix_widget_is_closed', '0');
await spotfixIndexedDB.init();
wsSpotfix.connect();
wsSpotfix.subscribe();

// Get pending task from LS
const pendingTaskRaw = localStorage.getItem('spotfix_pending_task');
Expand Down Expand Up @@ -77,7 +80,6 @@ async function handleCreateTask(sessionId, taskDetails) {
const result = await createTaskDoboard(sessionId, taskDetails);
if (result && result.taskId && taskDetails.taskDescription) {
const sign = `<br><br><br><em>The spot has been posted at the following URL <a href="${window.location.href}"><span class="task-link task-link--done">${window.location.href}</span></a></em>`;
localStorage.setItem('spotfix-description', '');
await addTaskComment({
projectToken: taskDetails.projectToken,
accountId: taskDetails.accountId,
Expand Down Expand Up @@ -212,6 +214,9 @@ function registerUser(taskDetails) {
localStorage.setItem('spotfix_email', response.email);
localStorage.setItem('spotfix_accounts', JSON.stringify(response.accounts));
spotfixIndexedDB.init();
localStorage.setItem('spotfix_widget_is_closed', '0');
wsSpotfix.connect();
wsSpotfix.subscribe();
userUpdate(projectToken, accountId);
} else if (response.operationStatus === 'SUCCESS' && response.operationMessage && response.operationMessage.length > 0) {
if (response.operationMessage == 'Waiting for email confirmation') {
Expand Down Expand Up @@ -249,7 +254,10 @@ function loginUser(taskDetails) {
localStorage.setItem('spotfix_email', userEmail);
localStorage.setItem('spotfix_accounts', JSON.stringify(response.accounts));
checkLogInOutButtonsVisible();
localStorage.setItem('spotfix_widget_is_closed', '0');
spotfixIndexedDB.init();
wsSpotfix.connect();
wsSpotfix.subscribe();
} else if (response.operationStatus === 'SUCCESS' && response.operationMessage && response.operationMessage.length > 0) {
if (typeof showMessageCallback === 'function') {
showMessageCallback(response.operationMessage, 'notice');
Expand Down Expand Up @@ -440,4 +448,4 @@ function addIconPack() {
}
})
}
}
}
2 changes: 1 addition & 1 deletion js/src/loaders/SpotFixTemplatesLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ class SpotFixTemplatesLoader {
<label class="spotfix_placeholder_title" for="doboard_task_widget-title">Report about</label>
</div>

<div class="doboard_task_widget-input-container doboard_task_widget-input-container-textarea">
<div class="doboard_task_widget-input-container doboard_task_widget-input-container-textarea" style="flex-grow: 1; min-height: 120px">
<textarea id="doboard_task_widget-description" class="doboard_task_widget-field" name="description" placeholder=" " required></textarea>
<label for="doboard_task_widget-description" class="doboard_task_widget-field-textarea-label" >Description</label>
</div>
Expand Down
76 changes: 35 additions & 41 deletions js/src/widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -636,31 +636,6 @@ class CleanTalkWidgetDoboard {
document.querySelector('.doboard_task_widget-login').classList.add('hidden');
}

const descEl = document.querySelector(
'.doboard_task_widget-container-maximize #doboard_task_widget-description'
);

if (descEl) {
const parentEl = descEl.closest('.doboard_task_widget-input-container');

if (parentEl) {
let isSmall = false;

const ro = new ResizeObserver(([entry]) => {
const height = entry.contentRect.height;
const next = height < 120;

if (next === isSmall) return;

isSmall = next;

descEl.classList.toggle('is-small', isSmall);
});

ro.observe(parentEl);
}
}

if (
selection.type === 'Range'
) {
Expand All @@ -678,29 +653,33 @@ class CleanTalkWidgetDoboard {
tinymce.remove('#doboard_task_widget-description');
}

const savedDescription = localStorage.getItem('spotfix-description') || '';
const savedDescription = localStorage.getItem('spotfix-description-ls') || '';

SpotFixTinyMCE.init({
selector: '#doboard_task_widget-description',
plugins: 'link lists',
menubar: false,
statusbar: false,
toolbar_location: 'bottom',
height: '100%',
width: '100%',
toolbar: 'screenshotButton emoticons bullist numlist bold italic strikethrough underline blockquote',
height: 120,
icons: 'icon_pack_SpotFix',
file_picker_types: 'file image media',
setup: function (editor) {
editor.on('init', function() {
if (savedDescription) {
editor.setContent(savedDescription);
editor.save();
editor.setContent(savedDescription, { format: 'html' });
}

setTimeout(() => {
editor.save();
});
});
editor.on('change', function () {
editor.save();
const content = editor.getContent();
localStorage.setItem('spotfix-description', content);
localStorage.setItem('spotfix-description-ls', content);
});
// editor.ui.registry.addButton('attachmentButton', {
// icon: 'paperclip',
Expand All @@ -721,6 +700,7 @@ class CleanTalkWidgetDoboard {
});
}
})

break;
case 'wrap':
await this.getTaskCount();
Expand Down Expand Up @@ -996,6 +976,7 @@ class CleanTalkWidgetDoboard {
},
);
}

if (!this.nonRequesting) {
issuesCommentsContainer.innerHTML = daysWrapperHTML;
} else {
Expand Down Expand Up @@ -1043,6 +1024,19 @@ class CleanTalkWidgetDoboard {
editor.on('change', function () {
editor.save();
});
editor.on('init', () => {
// Scroll to the bottom comments
if(!this.nonRequesting) {
const container = document.querySelector('.doboard_task_widget-concrete_issues-container');

if (container) {
setTimeout(() => {
const scrollPosition = container.scrollHeight;
container.scrollTo({ top: scrollPosition, behavior: 'smooth' });
}, 50);
}
}
});
editor.ui.registry.addButton('attachmentButton', {
icon: 'paperclip',
tooltip: 'Add file',
Expand All @@ -1064,20 +1058,20 @@ class CleanTalkWidgetDoboard {
});
}

if(this.nonRequesting) {
const container = document.querySelector('.doboard_task_widget-concrete_issues-container');

if (container) {
setTimeout(() => {
const scrollPosition = container.scrollHeight;
container.scrollTo({ top: scrollPosition, behavior: 'smooth' });
}, 50);
}
}

// Hide spinner preloader
hideContainersSpinner();

// Scroll to the bottom comments
if(!this.nonRequesting) {
setTimeout(() => {
const contentContainer = document.querySelector('.doboard_task_widget-content');
contentContainer.scrollTo({
top: contentContainer.scrollHeight,
behavior: 'smooth',
});
}, 0);
}

const sendButton = document.querySelector('.doboard_task_widget-send_message_button');
if (sendButton) {
this.fileUploader.init();
Expand Down
16 changes: 5 additions & 11 deletions styles/doboard-widget.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,21 +84,15 @@
cursor: pointer;
}

.doboard_task_widget-container-maximize #doboard_task_widget-description {
height: 90%;
position: absolute;
}

.doboard_task_widget-container-maximize #doboard_task_widget-description.is-small {
position: relative;
height: auto;
}

.doboard_task_widget-container-maximize .doboard_task_widget-field {
display: flex;
justify-content: center;
}

.doboard_task_widget-input-container-textarea .tox-tinymce {
position: absolute;
}

.doboard_task_widget-container-maximize {
width: 80vw !important;
max-width: 1120px !important;
Expand Down Expand Up @@ -1415,4 +1409,4 @@ input:checked + .slider:before {
left: 14px;
font-size: 10px;
color: #252A2F;
}
}