Another batch of important updates and fixes
This commit is contained in:
@@ -9,8 +9,8 @@ window.addEventListener('load', () => {
|
||||
|
||||
function initComments() {
|
||||
const ce = {}
|
||||
ce.updatePager = initPagination('pagination', onPageChange)
|
||||
window.commentElements = ce
|
||||
ce.updatePager = initPagination('pagination', onPageChange)
|
||||
ce.commentsCountEl = document.getElementById('comments-count')
|
||||
ce.commentsContainerEl = document.getElementById('comments-container')
|
||||
ce.commentForm = document.getElementById('comment-form')
|
||||
@@ -58,16 +58,20 @@ function initComments() {
|
||||
if (/\/slovarji\/\d+\/vsebina/.test(pageURL)) {
|
||||
ce.terminsList = document.getElementById('term-list')
|
||||
if (ce.terminsList) {
|
||||
ce.terminsList.addEventListener('click', displayComments)
|
||||
ce.terminsList.addEventListener('click', () =>
|
||||
changeEntryCommentSection()
|
||||
)
|
||||
}
|
||||
const ctxBtns = document.getElementsByName('comments-type')
|
||||
if (ctxBtns) {
|
||||
const ctxBtnsArray = Array.from(ctxBtns)
|
||||
ctxBtnsArray.forEach(el => el.addEventListener('click', displayComments))
|
||||
ctxBtnsArray.forEach(el =>
|
||||
el.addEventListener('click', () => changeEntryCommentSection())
|
||||
)
|
||||
}
|
||||
}
|
||||
ce.commentMessageInput && ce.commentReplyInput && clearMessageInput()
|
||||
displayComments()
|
||||
changeEntryCommentSection()
|
||||
}
|
||||
|
||||
function autoGrow({ target: inputToResize }) {
|
||||
@@ -496,24 +500,16 @@ function normalCommentColors(selectedText, btnEyeOffEl) {
|
||||
selectedText.classList.remove('comment-white-text')
|
||||
}
|
||||
|
||||
// function getCtxId({ target }) {
|
||||
// console.log(target)
|
||||
// const termBtn = target.closest('.terms-label')
|
||||
// console.log(termBtn)
|
||||
// if (termBtn) {
|
||||
// console.log(termBtn)
|
||||
// displayComments()
|
||||
// }
|
||||
// }
|
||||
|
||||
const ctxBtns = document.getElementsByName('comments-type')
|
||||
const commentsTab = document.getElementById('content-comments')
|
||||
if (ctxBtns) {
|
||||
const ctxBtnsArray = Array.from(ctxBtns)
|
||||
ctxBtnsArray.forEach(el => el.addEventListener('click', displayComments))
|
||||
ctxBtnsArray.forEach(el =>
|
||||
el.addEventListener('click', () => changeEntryCommentSection())
|
||||
)
|
||||
}
|
||||
if (commentsTab) {
|
||||
commentsTab.addEventListener('click', displayComments)
|
||||
commentsTab.addEventListener('click', () => changeEntryCommentSection())
|
||||
}
|
||||
|
||||
function getCtxTypeId(type) {
|
||||
@@ -572,10 +568,15 @@ function checkButton(type) {
|
||||
return checked
|
||||
}
|
||||
|
||||
async function changeEntryCommentSection() {
|
||||
await onPageChange()
|
||||
}
|
||||
|
||||
async function onPageChange(newPage) {
|
||||
const { updatePager } = window.commentElements
|
||||
try {
|
||||
const { page, numberOfAllPages } = await displayComments(newPage)
|
||||
let { page, numberOfAllPages } = await displayComments(newPage)
|
||||
numberOfAllPages ||= 1
|
||||
updatePager(page, numberOfAllPages)
|
||||
} catch (error) {
|
||||
let message = i18next.t('Prišlo je do napake.')
|
||||
|
||||
@@ -544,6 +544,7 @@ function initDictionaries() {
|
||||
}
|
||||
|
||||
function handleClick({ target }) {
|
||||
// TODO Fix leaks and related server request spam. Many click action create a new object or attach a new event listener on every click.
|
||||
const term = target.closest('.terms-label')
|
||||
const versionEl = target.closest('.date-element')
|
||||
const deleteEntryEl = target.closest('#delete-entry')
|
||||
@@ -652,11 +653,11 @@ function initDictionaries() {
|
||||
} = window.dictionaryElements
|
||||
event?.preventDefault()
|
||||
const dictionaryIdElem = document.getElementById('hidden-dictionary-id')
|
||||
const dictctionaryId = dictionaryIdElem.value
|
||||
const dictionaryId = dictionaryIdElem.value
|
||||
const deleteEntry = document.getElementById('delete-entry')
|
||||
try {
|
||||
const { data } = await axios.get('/api/v1/entries', {
|
||||
params: { id: entryId, dictctionaryId: dictctionaryId }
|
||||
params: { id: entryId, dictionaryId }
|
||||
})
|
||||
insertTermData(entryId, data)
|
||||
const isPublishedEl = data.entry.is_published
|
||||
@@ -947,7 +948,7 @@ function initDictionaries() {
|
||||
const dictionaryId = hiddenEl.value
|
||||
try {
|
||||
const { data } = await axios.get('/api/v1/entries/fetch-terms', {
|
||||
params: { id: dictionaryId }
|
||||
params: { dictionaryId }
|
||||
})
|
||||
renderTerms(data, entryId)
|
||||
} catch (error) {
|
||||
|
||||
@@ -677,11 +677,21 @@ function initPagination(paginationRootElIds, onPageChange, currentPage = 1) {
|
||||
|
||||
function initControls(paginationRootElId) {
|
||||
const rootEl = document.getElementById(paginationRootElId)
|
||||
|
||||
if (!rootEl) {
|
||||
return
|
||||
}
|
||||
|
||||
const btnFirstPage = rootEl.querySelector('.first-page')
|
||||
const btnPreviousPage = rootEl.querySelector('.previous-page')
|
||||
const btnNextPage = rootEl.querySelector('.next-page')
|
||||
const btnLastPage = rootEl.querySelector('.last-page')
|
||||
const formEl = rootEl.querySelector('form')
|
||||
|
||||
if (!formEl) {
|
||||
return
|
||||
}
|
||||
|
||||
const pageInputEl = formEl.querySelector('input')
|
||||
const pagesCountDisplayEl = formEl.querySelector('.pages-total')
|
||||
|
||||
|
||||
@@ -118,7 +118,6 @@
|
||||
"ID Slovarja": "Dictionary ID",
|
||||
"ID: Ni idja": "ID: No ID",
|
||||
"IDEKSIRAJ": "INDEX",
|
||||
"Imate neshranjene spremebe. Ali jih želite shraniti?": "Your changes have not been saved. Do you want to save them?",
|
||||
"Imate neshranjene spremembe. Ali jih želite shraniti?": "Your changes have not been saved. Do you want to save them?",
|
||||
"Ime": "First name",
|
||||
"IME": "FIRST NAME",
|
||||
|
||||
@@ -118,7 +118,6 @@
|
||||
"ID Slovarja": "ID Slovarja",
|
||||
"ID: Ni idja": "ID: Ni idja",
|
||||
"IDEKSIRAJ": "IDEKSIRAJ",
|
||||
"Imate neshranjene spremebe. Ali jih želite shraniti?": "Imate neshranjene spremebe. Ali jih želite shraniti?",
|
||||
"Imate neshranjene spremembe. Ali jih želite shraniti?": "Imate neshranjene spremembe. Ali jih želite shraniti?",
|
||||
"Ime": "Ime",
|
||||
"IME": "IME",
|
||||
|
||||
@@ -158,6 +158,10 @@ form#register-form {
|
||||
input {
|
||||
border: none;
|
||||
}
|
||||
|
||||
&.pt-6 {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user