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

Expand/Collapse All Deliverables #186

Merged
merged 4 commits into from
Dec 3, 2024
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
7 changes: 7 additions & 0 deletions blocks/gmo-program-details/gmo-program-details.css
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,9 @@ body {
position: sticky;
position: -webkit-sticky;
top: 0;
& > .showhide-deliverables {
margin-left: 10px;
}
}
}

Expand Down Expand Up @@ -1053,6 +1056,10 @@ body {
width: 200px;
}

.header.column1 {
margin-left: 16px;
}

.column3 {
width: 140px;
}
Expand Down
30 changes: 30 additions & 0 deletions blocks/gmo-program-details/gmo-program-details.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ export default async function decorate(block) {


// deliverables tab
const expandCollapseTooltip = 'Expand/Collapse All Deliverable Tasks';
const deliverablesTab = div(
{ id: 'tab2', class: 'deliverables tab inactive'},
div(
Expand All @@ -158,6 +159,8 @@ export default async function decorate(block) {
{ class: 'table-wrapper'},
div(
{ class: 'table-header' },
img({ class: 'expand-deliverables showhide-deliverables', src: "/icons/AddCircle_18_N.svg", title: expandCollapseTooltip }),
img({ class: 'collapse-deliverables showhide-deliverables inactive', src: "/icons/RemoveCircle_18_N.svg", title: expandCollapseTooltip }),
div({ class: 'header table-column column1' }, 'Deliverable Task Name'),
div({ class: 'header table-column column2' }, 'Deliverable Type'),
div({ class: 'header table-column column3' }, 'Platforms'),
Expand Down Expand Up @@ -473,13 +476,40 @@ async function addProgramStats(block) {
switchTab(event.target);
});

// enable expand/collapse all deliverables
block.querySelectorAll('.expand-deliverables, .collapse-deliverables').forEach((button) => {
button.addEventListener('click', (event) => {
const clickedBtn = event.currentTarget;
document.querySelector('.showhide-deliverables.inactive').classList.toggle('inactive');
clickedBtn.classList.toggle('inactive');

const expand = clickedBtn.classList.contains('expand-deliverables');
document.querySelectorAll('.row.collapsible').forEach((group) => toggleGroup(group, expand));
});
})

// decorate any new icons
decorateIcons(block);

// remove loading spinner
hideLoadingOverlay(bodyWrapper);
}

function toggleGroup(group, expand) {
if (expand) {
group.querySelector('.icon-next').classList.add('inactive');
group.querySelector('.icon-collapse').classList.remove('inactive');
} else {
group.querySelector('.icon-next').classList.remove('inactive');
group.querySelector('.icon-collapse').classList.add('inactive');
}
Array.from(group.children).forEach((child) => {
if (child.classList.contains('row')) {
child.classList.toggle('inactive', !expand);
}
});
};

function enableBackBtn(block, blockConfig) {
block.querySelector('.back-button').addEventListener('click', () => {
const host = location.origin + getBaseConfigPath();
Expand Down
11 changes: 11 additions & 0 deletions icons/AddCircle_18_N.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions icons/RemoveCircle_18_N.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion scripts/shared-program.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,4 +157,4 @@ export function domEl(tag, ...items) {
export function div(...items) { return domEl('div', ...items); }
export function span(...items) { return domEl('span', ...items); }
export function img(...items) { return domEl('img', ...items); }
export function a(...items) { return domEl('a', ...items); }
export function a(...items) { return domEl('a', ...items); }
Loading