Skip to content

Commit ba99f6b

Browse files
committed
Enhance reset link functionality in magic URL setup
- Updated reset link label to reflect its action of clearing expiration, improving user clarity. - Added logic to reset label text when expiration is cleared, ensuring consistent user feedback. - Refactored badge display logic for better handling of expiration states, enhancing overall user experience.
1 parent 9e2c18b commit ba99f6b

1 file changed

Lines changed: 46 additions & 10 deletions

File tree

dt-reports/magic-url-setup.php

Lines changed: 46 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -430,6 +430,16 @@ function clear_expiration_after_reset(metaKey, id, sysType) {
430430
if (badge) {
431431
badge.remove();
432432
}
433+
434+
// Reset label text when expiration has been cleared
435+
const resetButton = appAccordion.querySelector('.app-link-row .reset');
436+
if (resetButton) {
437+
const resetRow = resetButton.closest('.app-link-row');
438+
const resetLabel = resetRow ? resetRow.querySelector('.app-link-label') : null;
439+
if (resetLabel) {
440+
resetLabel.textContent = '<?php echo esc_js( __( 'Reset link', 'disciple_tools' ) ) ?>';
441+
}
442+
}
433443
}
434444
}
435445
},
@@ -534,19 +544,29 @@ function app_link_set_expiration(evt) {
534544
badge.textContent = badgeText;
535545
} else {
536546
const appLabel = appAccordion.querySelector('.app-label');
537-
if (appLabel) {
538-
const newBadge = document.createElement('span');
539-
newBadge.className = 'app-expiration-badge';
540-
newBadge.style.cssText = 'font-size: 0.85em; color: #666; margin-top: 0.25rem;';
541-
newBadge.textContent = badgeText;
542-
// Insert under the title (after first child)
543-
const insertBefore = appLabel.children[1] || null;
544-
appLabel.insertBefore(newBadge, insertBefore);
545-
}
547+
if (appLabel) {
548+
const newBadge = document.createElement('span');
549+
newBadge.className = 'app-expiration-badge';
550+
newBadge.style.cssText = 'font-size: 0.85em; color: #666; margin-top: 0.25rem;';
551+
newBadge.textContent = badgeText;
552+
// Insert under the title (after first child)
553+
const insertBefore = appLabel.children[1] || null;
554+
appLabel.insertBefore(newBadge, insertBefore);
555+
}
546556
}
547557
} else if (badge) {
548558
badge.remove();
549559
}
560+
561+
// Update reset label to mention clearing expiration
562+
const resetButton = appAccordion.querySelector('.app-link-row .reset');
563+
if (resetButton) {
564+
const resetRow = resetButton.closest('.app-link-row');
565+
const resetLabel = resetRow ? resetRow.querySelector('.app-link-label') : null;
566+
if (resetLabel) {
567+
resetLabel.textContent = '<?php echo esc_js( __( 'Reset link (clears expiration)', 'disciple_tools' ) ) ?>';
568+
}
569+
}
550570
}
551571

552572
// Show success message
@@ -752,7 +772,23 @@ class="dt-action-button small button qr"
752772
onclick="app_link_reset(event)"
753773
class="dt-action-button small button reset"
754774
><img class="dt-icon" alt="undo" src="<?php echo esc_url( get_template_directory_uri() . '/dt-assets/images/undo.svg' ) ?>" /></a>
755-
<span class="app-link-label"><?php esc_html_e( 'Reset link (also clears expiration)', 'disciple_tools' ) ?></span>
775+
<?php if ( class_exists( 'Disciple_Tools_Bulk_Magic_Link_Sender_API' ) ) : ?>
776+
<?php
777+
$has_expiration = ! empty( $expiration_data['ts'] )
778+
|| ( ! empty( $expiration_data['ts_formatted'] ) && $expiration_data['ts_formatted'] !== '---' );
779+
?>
780+
<span class="app-link-label">
781+
<?php
782+
if ( $has_expiration ) {
783+
esc_html_e( 'Reset link (clears expiration)', 'disciple_tools' );
784+
} else {
785+
esc_html_e( 'Reset link', 'disciple_tools' );
786+
}
787+
?>
788+
</span>
789+
<?php else : ?>
790+
<span class="app-link-label"><?php esc_html_e( 'Reset link', 'disciple_tools' ) ?></span>
791+
<?php endif; ?>
756792
</div>
757793
<?php if ( class_exists( 'Disciple_Tools_Bulk_Magic_Link_Sender_API' ) ): ?>
758794
<div class="app-link-row" style="margin-top: 1rem; padding-top: 1rem; border-top: 1px solid #e0e0e0;">

0 commit comments

Comments
 (0)