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

Added selected connection count #1020

Merged
merged 32 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
b65c4f9
Added selected connection count
roshniahuja Feb 21, 2023
c5edbc7
fixed eslint errors
roshniahuja Feb 21, 2023
8319894
fixed eslint errors
roshniahuja Feb 21, 2023
4cf52a4
fixed eslint errors
roshniahuja Feb 22, 2023
9a28de4
Tried to fix eslint errors
roshniahuja Feb 22, 2023
13d07da
Tried to fix eslint errors
roshniahuja Feb 22, 2023
d1169db
Fixed Eslint errors
roshniahuja Feb 22, 2023
6d01813
Fixed Eslint errors
roshniahuja Feb 22, 2023
2627446
Fixed Eslint errors
roshniahuja Feb 22, 2023
9d15f42
Fixed Eslint errors
roshniahuja Feb 22, 2023
eaa8af0
revert back the changes
roshniahuja Feb 22, 2023
22a5031
CS: Fix prettier issues.
peterwilsoncc Feb 23, 2023
c72d009
Merge branch 'develop' into feature/connection-count
peterwilsoncc Feb 23, 2023
3f6b39e
Added translatable string
roshniahuja Feb 28, 2023
5a49438
Changed variable name for translatable string
roshniahuja Feb 28, 2023
2a807bc
Resolved Eslint errors
roshniahuja Mar 1, 2023
94514d0
Resolved Eslint errors
roshniahuja Mar 1, 2023
6eb5fd6
Resolved Eslint errors
roshniahuja Mar 1, 2023
9628526
Revert back the changes for Eslint errors
roshniahuja Mar 1, 2023
7e895e3
Resolved Eslint errors
roshniahuja Mar 1, 2023
1f3af81
Resolved Eslint errors
roshniahuja Mar 1, 2023
ee43fb9
Resolved Eslint errors
roshniahuja Mar 1, 2023
a508e76
Resolved Eslint errors
roshniahuja Mar 1, 2023
7dcb4a0
Resolved Eslint errors
roshniahuja Mar 1, 2023
393b8b3
CS: Fix prettier issues.
roshniahuja Mar 1, 2023
f160de5
CS: Fix prettier issues.
roshniahuja Mar 1, 2023
dd3d8e8
CS: Fix prettier issues.
roshniahuja Mar 1, 2023
97a6e76
CS: Fix prettier issues.
roshniahuja Mar 1, 2023
484e883
CS: Fix prettier issues.Removed extra space
roshniahuja Mar 1, 2023
fa3e6b2
CS: Fix prettier issues
roshniahuja Mar 2, 2023
9814341
Merge branch 'develop' into feature/connection-count
roshniahuja Mar 2, 2023
e9ae049
changed comment for translator
roshniahuja Mar 6, 2023
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
69 changes: 66 additions & 3 deletions assets/js/push.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ import '../css/push.scss';
import jQuery from 'jquery';
import _ from 'underscore';
import Mustache from 'mustache';
import { sprintf, _n } from '@wordpress/i18n';

const { document, dt } = window;

let selectedText = '';
let selectedConnections = {},
searchString = '';
const processTemplate = _.memoize( ( id ) => {
Expand Down Expand Up @@ -580,7 +581,19 @@ jQuery( window ).on( 'load', () => {
deleteNode.parentNode.removeChild( deleteNode );

delete selectedConnections[ type + id ];

selectedText = sprintf(
/* translators: %d: Number of selected connections. */
_n(
'Selected connection (%d)',
'Selected connections (%d)',
Object.keys( selectedConnections ).length,
'distributor'
),
Object.keys( selectedConnections ).length
);
document.querySelector(
'.selected-connections-text'
).textContent = selectedText;
if (
selectAllConnections.classList.contains( 'unavailable' )
) {
Expand All @@ -602,6 +615,19 @@ jQuery( window ).on( 'load', () => {
selectedConnections[ type + id ] = dtConnections[ type + id ];

const element = event.currentTarget.cloneNode( true );
selectedText = sprintf(
/* translators: %d: Number of selected connections. */
_n(
'Selected connection (%d)',
'Selected connections (%d)',
Object.keys( selectedConnections ).length,
'distributor'
),
Object.keys( selectedConnections ).length
);
document.querySelector(
'.selected-connections-text'
).textContent = selectedText;

const removeLink = document.createElement( 'span' );
removeLink.classList.add( 'remove-connection' );
Expand Down Expand Up @@ -660,6 +686,19 @@ jQuery( window ).on( 'load', () => {

element.appendChild( removeLink );
element.classList = 'added-connection';
selectedText = sprintf(
/* translators: %d: Number of selected connections. */
_n(
'Selected connection (%d)',
'Selected connections (%d)',
Object.keys( selectedConnections ).length,
'distributor'
),
Object.keys( selectedConnections ).length
);
document.querySelector(
'.selected-connections-text'
).textContent = selectedText;

connectionsSelectedList.appendChild( element );

Expand Down Expand Up @@ -691,6 +730,19 @@ jQuery( window ).on( 'load', () => {
);

delete selectedConnections[ type + id ];
selectedText = sprintf(
/* translators: %d: Number of selected connections. */
_n(
'Selected connection (%d)',
'Selected connections (%d)',
Object.keys( selectedConnections ).length,
'distributor'
),
Object.keys( selectedConnections ).length
);
document.querySelector(
'.selected-connections-text'
).textContent = selectedText;

connectionsSelectedList.removeChild(
connectionsSelectedList.firstChild
Expand Down Expand Up @@ -721,7 +773,18 @@ jQuery( window ).on( 'load', () => {
const id = event.currentTarget.getAttribute( 'data-connection-id' );

delete selectedConnections[ type + id ];

selectedText = sprintf(
/* translators: %d: Number of selected connections. */
_n(
'Selected connection (%d)',
'Selected connections (%d)',
Object.keys( selectedConnections ).length,
'distributor'
),
Object.keys( selectedConnections ).length
);
document.querySelector( '.selected-connections-text' ).textContent =
selectedText;
if ( selectAllConnections.classList.contains( 'unavailable' ) ) {
classList( 'all' );
}
Expand Down
2 changes: 1 addition & 1 deletion templates/show-connections.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class="add-connection<# if ( ! _.isEmpty( connections[ key ]['syndicated'] ) ) {
</div>
<div class="connections-selected empty">
<header class="with-selected">
<?php esc_html_e( 'Selected connections', 'distributor' ); ?>
<span class="selected-connections-text"></span>
<button class="button button-link selectno-connections unavailable"><?php esc_html_e( 'Clear', 'distributor' ); ?></button>
</header>
<header class="no-selected">
Expand Down