Skip to content

Commit

Permalink
fix(trello): task list support
Browse files Browse the repository at this point in the history
  • Loading branch information
askides committed Sep 27, 2024
1 parent a1fe3fe commit 3f8272f
Showing 1 changed file with 22 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/content/trello.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ togglbutton.render(
className: 'trello',
description: getDescription,
projectName: getProject,
container: cardContainerSelector,
container: '[data-testid="card-back-name"]',
})

// Pass through click on Trello button to the timer link
Expand All @@ -57,16 +57,16 @@ togglbutton.render(

/* Checklist buttons */
togglbutton.render(
'.checklist-item-details:not(.toggl)',
{ observe: true },
'[data-testid="check-item-container"]:not(.toggl)',
{ observe: true, debounceInterval: 1000 },
(elem) => {
const getTitleText = () => {
const title = $('.window-title h2')
return title ? title.textContent.trim() : ''
const description = $('#card-back-name')
return description ? description.textContent.trim() : ''
}

const getTaskText = () => {
const task = $('.checklist-item-details-text', elem)
const task = $('.ak-renderer-wrapper', elem)
return task ? task.textContent.trim() : ''
}

Expand All @@ -79,14 +79,27 @@ togglbutton.render(
buttonType: 'minimal',
projectName: getProject,
description: getDescription,
container: cardContainerSelector,
container: '[data-testid="card-back-name"]',
})
const wrapper = document.createElement('span')
wrapper.classList.add('checklist-item-menu')
wrapper.style.display = 'flex'
wrapper.style.alignItems = 'center'
wrapper.style.marginLeft = '4px'
wrapper.appendChild(link)
elem.querySelector('.checklist-item-controls').appendChild(wrapper)

// Add StopPropagation to prevent the card from closing.
wrapper.addEventListener('click', (e) => {
e.preventDefault()
e.stopPropagation()

// Click on the Toggl button
link.querySelector('button').click()
})

elem
.querySelector('[data-testid="check-item-hover-buttons"]')
.appendChild(wrapper)
},
`.checklist-items-list, ${cardContainerSelector}`,
cardContainerSelector,
)

0 comments on commit 3f8272f

Please sign in to comment.