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

ASSETS-88888 : Add 'Select All' button on Collections Details and Share Link Page #40

Merged
merged 8 commits into from
Mar 7, 2024
27 changes: 25 additions & 2 deletions blocks/adp-collection-header/adp-collection-header.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,47 @@
z-index: 1;
}


.adp-collection-header-left .adp-collection-title {
margin-bottom: 12px;
margin-bottom: 12px; /* Keeps space between title and items */
}

.adp-collection-subinfo {
display: flex;
/* justify-content: space-between; /* Aligns items to the left and select all to the right */
align-items: center; /* Centers items vertically */
}

.adp-collection-stats {
border: #E6E6E6 1px solid;
border-radius: 6px;
font: 11px/14px var(--body-font-family);
padding: 6px 10px;
width: fit-content;
flex-shrink: 0;
margin-right: 20px; /* Adjust the 20px to whatever fixed space you want between the items and the checkbox */
}

.adp-collection-select-all {
display: flex;
align-items: center; /* This will vertically align the checkbox and label */
}

.adp-collection-select-all input[type="checkbox"] {
margin-right: 5px; /* Adds some space between the checkbox and the label */
}


.adp-collection-header-left .back-button .icon {
height: 10px;
width: 18px;
vertical-align: text-bottom;
}

.adp-collection-header-collection-info {
display: flex;
flex-direction: column; /* Stack the title and sub-info vertically */
}

.adp-collection-header .adp-collection-title {
font: var(--collection-heading-font);
width: 100%;
Expand Down
13 changes: 13 additions & 0 deletions blocks/adp-collection-header/adp-collection-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
import { decorateIcons } from '../../scripts/lib-franklin.js';
import { createLinkHref, navigateTo } from '../../scripts/scripts.js';

import {
selectAllAssets, deselectAllAssets,
} from '../adp-infinite-results-collection/adp-infinite-results-collection.js';


Check failure on line 10 in blocks/adp-collection-header/adp-collection-header.js

View workflow job for this annotation

GitHub Actions / build

More than 1 blank line not allowed
function createCollectionInfoHeader(collectionInfoHeader, collection) {
// include back to collections listing similar to hide filters button
collectionInfoHeader.innerHTML = `
Expand All @@ -14,6 +19,10 @@
<div class="adp-collection-title"></div>
<div class="adp-collection-subinfo">
<div class="adp-collection-stats"></div>
<div class="adp-collection-select-all">
<input type="checkbox" id="select-all-checkbox"/>
<label for="select-all-checkbox">Select All</label>
</div>
</div>
</div>
</div>
Expand All @@ -28,6 +37,10 @@
const backButton = collectionInfoHeader.querySelector('.back-button a');
backButton.href = createLinkHref(backButton.href);

document.getElementById('select-all-checkbox').addEventListener('click', (event) => {
event.target.checked ? selectAllAssets() : deselectAllAssets();

Check failure on line 41 in blocks/adp-collection-header/adp-collection-header.js

View workflow job for this annotation

GitHub Actions / build

Expected indentation of 4 spaces but found 6

Check failure on line 41 in blocks/adp-collection-header/adp-collection-header.js

View workflow job for this annotation

GitHub Actions / build

Expected an assignment or function call and instead saw an expression
});
TyroneAEM marked this conversation as resolved.
Show resolved Hide resolved

collectionInfoHeader.querySelector('.action-collection-delete').addEventListener('click', async (e) => {
e.preventDefault();
const collectionId = getCollectionIdFromURL();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
},
removeItemFromMultiSelectionHandler: () => {
infiniteResultsContainer.removeItemFromMultiSelection(assetId);
//Uncheck select all checkbox

Check failure on line 91 in blocks/adp-infinite-results-collection/CollectionDatasource.js

View workflow job for this annotation

GitHub Actions / build

Expected exception block, space or tab after '//' in comment
document.getElementById('select-all-checkbox').checked = false;
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
infiniteResultsContainer.deselectItem(e.detail.assetId);
});
addEventListener(EventNames.CLOSE_BANNER, () => {
//Uncheck select all checkbox

Check failure on line 19 in blocks/adp-infinite-results-collection/adp-infinite-results-collection.js

View workflow job for this annotation

GitHub Actions / build

Expected exception block, space or tab after '//' in comment
document.getElementById('select-all-checkbox').checked = false;
infiniteResultsContainer.clearAllSelections();
});
}
Expand All @@ -39,3 +41,12 @@
export function hasPreviousCard() {
return infiniteResultsContainer.hasPreviousCard();
}


Check failure on line 45 in blocks/adp-infinite-results-collection/adp-infinite-results-collection.js

View workflow job for this annotation

GitHub Actions / build

More than 1 blank line not allowed
export function selectAllAssets() {
infiniteResultsContainer.selectAllItems();
}

export function deselectAllAssets() {
infiniteResultsContainer.deselectAllItems();
}
2 changes: 2 additions & 0 deletions blocks/adp-infinite-results-linkshare/LinkShareDatasource.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
},
removeItemFromMultiSelectionHandler: () => {
infiniteResultsContainer.removeItemFromMultiSelection(assetId);
//Uncheck select all checkbox

Check failure on line 56 in blocks/adp-infinite-results-linkshare/LinkShareDatasource.js

View workflow job for this annotation

GitHub Actions / build

Expected exception block, space or tab after '//' in comment
document.getElementById('select-all-checkbox').checked = false;
},
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@ export default async function decorate(block) {
const instantSearchDatasource = new LinkShareDatasource();
infiniteResultsContainer = new InfiniteResultsContainer(block, instantSearchDatasource);
infiniteResultsContainer.render();

addEventListener(EventNames.ASSET_QUICK_PREVIEW_CLOSE, (e) => {
infiniteResultsContainer.deselectItem(e.detail.assetId);
});
addEventListener(EventNames.CLOSE_BANNER, () => {
//Uncheck select all checkbox
document.getElementById('select-all-checkbox').checked = false;
infiniteResultsContainer.clearAllSelections();
});
}
Expand All @@ -21,3 +24,11 @@ export function openLinkShare(id) {
// change the url
window.history.pushState({}, '', url);
}

export function selectAllAssets() {
infiniteResultsContainer.selectAllItems();
}

export function deselectAllAssets() {
infiniteResultsContainer.deselectAllItems();
}
55 changes: 55 additions & 0 deletions blocks/adp-share-header/adp-share-header.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

.adp-share-header {
display: flex;
height: 62px;
}

.adp-share-header-left {
display: flex;
gap: 15px;
align-items: center;
width: 100%;
font-size: var(--header-font-size);
padding: 0;
top: 0.01rem;
padding-top: 0.88rem;
padding-bottom: 0.88rem;
z-index: 1;
}

.adp-share-subinfo {
display: flex;
/* justify-content: space-between; /* Aligns items to the left and select all to the right */
align-items: center; /* Centers items vertically */
}

.adp-share-select-all {
display: flex;
align-items: center; /* This will vertically align the checkbox and label */
}

.adp-share-select-all input[type="checkbox"] {
margin-right: 5px; /* Adds some space between the checkbox and the label */
}

.adp-share-header-share-info {
display: flex;
flex-direction: column; /* Stack the title and sub-info vertically */
}

.adp-share-header {
font: var(--collection-heading-font);
width: 100%;
}

.adp-share-header .actions .adp-action {
text-wrap: nowrap;
align-items: center;
}

.adp-share-header .actions {
/* vertically align center */
display: flex;
align-items: center;
justify-content: center;
}
34 changes: 34 additions & 0 deletions blocks/adp-share-header/adp-share-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { decorateIcons } from '../../scripts/lib-franklin.js';
import { createLinkHref, navigateTo } from '../../scripts/scripts.js';

import {
selectAllAssets, deselectAllAssets
} from '../adp-infinite-results-linkshare/adp-infinite-results-linkshare.js';

function createShareInfoHeader(shareInfoHeader) {

shareInfoHeader.innerHTML = `
<div class="adp-share-header-left">
<div class="adp-share-header-share-info">
<div class="adp-share-subinfo">
<div class="adp-share-select-all">
<input type="checkbox" id="select-all-checkbox"/>
<label for="select-all-checkbox">Select All</label>
</div>
</div>
</div>
</div>
`;
TyroneAEM marked this conversation as resolved.
Show resolved Hide resolved

document.getElementById('select-all-checkbox').addEventListener('click', (event) => {
event.target.checked ? selectAllAssets() : deselectAllAssets();
});
TyroneAEM marked this conversation as resolved.
Show resolved Hide resolved

decorateIcons(shareInfoHeader);
return shareInfoHeader;
}

export default async function decorate(block) {
block.innerHTML = '';
createShareInfoHeader(block);
}
Loading