Fixed Create Ticket
This commit is contained in:
@@ -363,47 +363,50 @@
|
|||||||
outline: none;
|
outline: none;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@script
|
||||||
<script>
|
<script>
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
const initialiseHelpdeskTicketCreate = function () {
|
||||||
const form = document.querySelector('.helpdesk-ticket-form');
|
const form = document.querySelector('.helpdesk-ticket-form');
|
||||||
const editor = document.querySelector('[data-helpdesk-details-editor]');
|
const editor = document.querySelector('[data-helpdesk-details-editor]');
|
||||||
const bodyField = document.getElementById('body');
|
const bodyField = document.getElementById('body');
|
||||||
|
|
||||||
if (!form || !editor || !bodyField) {
|
if (! form || ! editor || ! bodyField || form.dataset.editorReady === 'true') {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const syncBody = function() {
|
form.dataset.editorReady = 'true';
|
||||||
bodyField.value = editor.innerHTML.trim();
|
|
||||||
bodyField.dispatchEvent(new Event('input', {
|
const syncBody = function () {
|
||||||
bubbles: true
|
const value = editor.innerHTML.trim();
|
||||||
}));
|
|
||||||
bodyField.dispatchEvent(new Event('change', {
|
bodyField.value = value;
|
||||||
bubbles: true
|
bodyField.dispatchEvent(new Event('input', { bubbles: true }));
|
||||||
}));
|
bodyField.dispatchEvent(new Event('change', { bubbles: true }));
|
||||||
|
|
||||||
|
@this.set('body', value, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
document.querySelectorAll('[data-helpdesk-editor-command]').forEach(function(button) {
|
document.querySelectorAll('[data-helpdesk-editor-command]').forEach(function (button) {
|
||||||
button.addEventListener('click', function() {
|
button.addEventListener('click', function () {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
document.execCommand(button.dataset.helpdeskEditorCommand, false, null);
|
document.execCommand(button.dataset.helpdeskEditorCommand, false, null);
|
||||||
syncBody();
|
syncBody();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelectorAll('[data-helpdesk-editor-format]').forEach(function(button) {
|
document.querySelectorAll('[data-helpdesk-editor-format]').forEach(function (button) {
|
||||||
button.addEventListener('click', function() {
|
button.addEventListener('click', function () {
|
||||||
editor.focus();
|
editor.focus();
|
||||||
document.execCommand('formatBlock', false, button.dataset.helpdeskEditorFormat);
|
document.execCommand('formatBlock', false, button.dataset.helpdeskEditorFormat);
|
||||||
syncBody();
|
syncBody();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
document.querySelectorAll('[data-helpdesk-editor-link]').forEach(function(button) {
|
document.querySelectorAll('[data-helpdesk-editor-link]').forEach(function (button) {
|
||||||
button.addEventListener('click', function() {
|
button.addEventListener('click', function () {
|
||||||
const url = window.prompt('Enter link URL');
|
const url = window.prompt('Enter link URL');
|
||||||
|
|
||||||
if (!url) {
|
if (! url) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -413,8 +416,15 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
editor.addEventListener('input', syncBody);
|
||||||
|
editor.addEventListener('keyup', syncBody);
|
||||||
editor.addEventListener('blur', syncBody);
|
editor.addEventListener('blur', syncBody);
|
||||||
form.addEventListener('submit', syncBody, true);
|
form.addEventListener('submit', syncBody, true);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
initialiseHelpdeskTicketCreate();
|
||||||
|
|
||||||
|
document.addEventListener('livewire:navigated', initialiseHelpdeskTicketCreate);
|
||||||
</script>
|
</script>
|
||||||
|
@endscript
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user