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
19 changes: 19 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,

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

View workflow job for this annotation

GitHub Actions / build

A space is required after ','
TyroneAEM marked this conversation as resolved.
Show resolved Hide resolved
} 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,16 @@
const backButton = collectionInfoHeader.querySelector('.back-button a');
backButton.href = createLinkHref(backButton.href);

document.getElementById('select-all-checkbox').addEventListener('click', function(event) {

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

View workflow job for this annotation

GitHub Actions / build

Unexpected function expression

Check warning on line 40 in blocks/adp-collection-header/adp-collection-header.js

View workflow job for this annotation

GitHub Actions / build

Unexpected unnamed function

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

View workflow job for this annotation

GitHub Actions / build

Missing space before function parentheses
// Get the checked state of the select all checkbox

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
var isChecked = event.target.checked;

Check failure on line 42 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 42 in blocks/adp-collection-header/adp-collection-header.js

View workflow job for this annotation

GitHub Actions / build

Unexpected var, use let or const instead

// Get all the checkboxes within the cards

Check failure on line 44 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
var checkboxes = document.querySelectorAll('.checkbox-container input[type="checkbox"], .filetype-video .checkbox-container input[type="checkbox"]');

Check warning on line 45 in blocks/adp-collection-header/adp-collection-header.js

View workflow job for this annotation

GitHub Actions / build

This line has a length of 155. Maximum allowed is 140

Check failure on line 45 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 45 in blocks/adp-collection-header/adp-collection-header.js

View workflow job for this annotation

GitHub Actions / build

Unexpected var, use let or const instead
TyroneAEM marked this conversation as resolved.
Show resolved Hide resolved
// isChecked then selectAllAssets() else deselectAllAssets
isChecked ? selectAllAssets() : deselectAllAssets();
});
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 @@ -39,3 +39,12 @@ export function hasNextCard() {
export function hasPreviousCard() {
return infiniteResultsContainer.hasPreviousCard();
}


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

export function deselectAllAssets() {
infiniteResultsContainer.deselectAllItems();
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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);
});
Expand All @@ -21,3 +22,13 @@ 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;
}
41 changes: 41 additions & 0 deletions blocks/adp-share-header/adp-share-header.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
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>
</div>
`;
TyroneAEM marked this conversation as resolved.
Show resolved Hide resolved

document.getElementById('select-all-checkbox').addEventListener('click', function(event) {

Check warning on line 24 in blocks/adp-share-header/adp-share-header.js

View workflow job for this annotation

GitHub Actions / build

Unexpected unnamed function
// Get the checked state of the select all checkbox
var isChecked = event.target.checked;

// Get all the checkboxes within the cards
var checkboxes = document.querySelectorAll('.checkbox-container input[type="checkbox"], .filetype-video .checkbox-container input[type="checkbox"]');

Check warning on line 29 in blocks/adp-share-header/adp-share-header.js

View workflow job for this annotation

GitHub Actions / build

This line has a length of 155. Maximum allowed is 140
// isChecked then selectAllAssets() else deselectAllAssets
isChecked ? 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