Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[frontend] add logic to open/close tasks on print #447

Closed
wants to merge 1 commit into from
Closed

Conversation

Fbasham
Copy link
Member

@Fbasham Fbasham commented Jun 21, 2023

Note [22 June 2023]

I'm putting this in draft since the requirements have changed based on requests from the design team. This issue with the approach taken in this PR is that it will expand ALL groups/tasks, when the desired behaviour is to be able to toggle all groups/tasks open via a button, and then subsequently collapse groups/tasks the user doesn't want printed. In other words, this PR only allows for all accordions open in the print, and the user perhaps wants or needs finer control over the printed document.


This PR aims to solve the issue of opening all tasks on print. When printing is finished, all tasks that weren't previously opened should be closed, but the ones that were open should remain open. This also applies to the 3 timeline summaries.

Inspiration found here

Also removed an unused style in the global css.

@Fbasham Fbasham requested a review from a team June 21, 2023 12:42
@CurtisUnderwood
Copy link
Contributor

image

Can only get one page in print on Chrome when all collapsed, seems to work in Firefox

@CurtisUnderwood
Copy link
Contributor

image
Restart Quiz button is sticking around

@Fbasham Fbasham marked this pull request as draft June 21, 2023 15:11
@Fbasham Fbasham force-pushed the print branch 2 times, most recently from 6e3ed9a to f13518d Compare June 21, 2023 18:39
@Fbasham Fbasham marked this pull request as ready for review June 21, 2023 18:39
Comment on lines +105 to +109
let details = [...document.querySelectorAll<HTMLDetailsElement>('details:not([open])')]
for (let e of details) {
e.setAttribute('open', '')
e.dataset.wasclosed = ''
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use const and open the details element by using open property setter with true.

Suggested change
let details = [...document.querySelectorAll<HTMLDetailsElement>('details:not([open])')]
for (let e of details) {
e.setAttribute('open', '')
e.dataset.wasclosed = ''
}
const details = document.querySelectorAll<HTMLDetailsElement>('details:not([open])')
details.forEach((el) => {
el.open = true
el.dataset.wasclosed = ''
})

Comment on lines +113 to +117
let details = [...document.querySelectorAll<HTMLDetailsElement>('details[data-wasclosed]')]
for (let e of details) {
e.removeAttribute('open')
delete e.dataset.wasclosed
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use const and close the details element by using open property setter with false.

Suggested change
let details = [...document.querySelectorAll<HTMLDetailsElement>('details[data-wasclosed]')]
for (let e of details) {
e.removeAttribute('open')
delete e.dataset.wasclosed
}
const details = document.querySelectorAll<HTMLDetailsElement>('details[data-wasclosed]')
details.forEach((el) => {
el.open = false
delete el.dataset.wasclosed
})

@Fbasham Fbasham marked this pull request as draft June 22, 2023 12:01
@Fbasham Fbasham closed this Jun 22, 2023
@Fbasham Fbasham deleted the print branch June 23, 2023 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants