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

Deleted events page #371

Open
wants to merge 13 commits into
base: trunk
Choose a base branch
from
13 changes: 13 additions & 0 deletions assets/js/translation-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,19 @@
}
);

$( '.trash-event-from-list, #delete-permanently' ).on(
'click',
function ( e ) {
e.preventDefault();
const permanent_delete_clause = 'delete-permanently' == $(this).attr('id') ? 'permanently' : '';
const confirmMessage = `Are you sure you want to ${permanent_delete_clause} delete this event?`;

if ( confirm( confirmMessage ) ) {
window.location = this.href;
}
}
);

$( '.trash-event' ).on(
'click',
function ( e ) {
Expand Down
2 changes: 1 addition & 1 deletion includes/routes/event/list-trashed.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function handle(): void {
// phpcs:enable

$trashed_events_query = $this->event_repository->get_trashed_events( $current_page, 10 );

$this->use_theme();
$this->tmpl(
'trashed-events',
array(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions themes/wporg-translate-events-2024/assets/icons/restore.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;

use Wporg\TranslationEvents\Translation_Events;
use Wporg\TranslationEvents\Urls;

register_block_type(
'wporg-translate-events-2024/event-delete-link',
array(
// phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.Found
'render_callback' => function ( array $attributes, $content, $block ) {
if ( ! isset( $block->context['postId'] ) ) {
return '';
}
$event_id = $block->context['postId'];
$event = Translation_Events::get_event_repository()->get_event( $event_id );
if ( ! $event ) {
return '';
}
ob_start();
if ( ! current_user_can( 'delete_translation_event', $event->id() ) || 'trash' !== $event->status() ) {
return '';
}
?>

<a href="<?php echo esc_url( Urls::event_delete( $event->id() ) ); ?>"
class="is-destructive"
id="delete-permanently"
title="<?php echo esc_attr__( 'Delete permanently', 'gp-translation-events' ); ?>">
<span class="gp-events-icon gp-events-icon-delete-permanently" aria-hidden="true"></span>
</a>
<?php
return ob_get_clean();
},
)
);
13 changes: 11 additions & 2 deletions themes/wporg-translate-events-2024/blocks/event-list/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,20 @@
<?php
endif;
?>
<!-- wp:wporg-translate-events-2024/event-edit-link /-->
<!-- wp:wporg-translate-events-2024/event-trash-link /-->
</div>
<!-- wp:wporg-translate-events-2024/event-attendance-mode /-->
<!-- wp:wporg-translate-events-2024/event-start /-->
<?php
if ( current_user_can( 'edit_translation_event', $event_id ) ) :
?>
<div class="gp-events-admin-links">
<!-- wp:wporg-translate-events-2024/event-edit-link /-->
<!-- wp:wporg-translate-events-2024/event-trash-link /-->
<!-- wp:wporg-translate-events-2024/event-delete-link /-->
</div>
<?php
endif;
?>
<!-- /wp:wporg-translate-events-2024/event-template -->
</li>
<?php
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@

$query = new \WP_Query(
array(
'p' => intval( $attributes['id'] ),
'post_type' => Translation_Events::CPT,
'p' => intval( $attributes['id'] ),
'post_type' => Translation_Events::CPT,
'post_status' => array( 'publish', 'draft', 'trash' ),
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@
if ( $event->is_trashed() ) :
?>
<a href="<?php echo esc_url( Urls::event_trash( $event->id() ) ); ?>"
class="button is-small"
title="<?php echo esc_attr__( 'Restore', 'gp-translation-events' ); ?>">
<?php echo esc_attr__( 'Restore', 'gp-translation-events' ); ?>
title="<?php echo esc_attr__( 'Restore', 'gp-translation-events' ); ?>"
class="no-text-decoration">
<span class="gp-events-icon gp-events-icon-restore" aria-hidden="true"></span>
</a>
<?php else : ?>
<a href="<?php echo esc_url( Urls::event_trash( $event->id() ) ); ?>"
class="event-list-item-button is-destructive"
class="event-list-item-button is-destructive trash-event-from-list"
title="<?php echo esc_attr__( 'Move to trash', 'gp-translation-events' ); ?>">
<span class="dashicons dashicons-trash"></span>
</a>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;

register_block_type(
'wporg-translate-events-2024/page-events-trashed-events',
array(
'render_callback' => function ( array $attributes ) {
add_filter(
'wporg_block_site_breadcrumbs',
function ( $breadcrumbs ): array {
return array_merge(
$breadcrumbs,
array(
array(
'title' => __( 'Deleted Translation Events', 'wporg-translate-events-2024' ),
'url' => null,
),
)
);
}
);

render_page(
__DIR__ . '/render.php',
__( 'Deleted Translation Events', 'wporg-translate-events-2024' ),
$attributes
);
},
)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;
$event_ids = $attributes['trashed_events_query'] ['event_ids'] ?? array();
$data = array(
'event_ids' => $event_ids,
'show_flag' => false,
);
?>
<!-- wp:wporg-translate-events-2024/event-list <?php echo wp_json_encode( $data ); ?> /-->
2 changes: 2 additions & 0 deletions themes/wporg-translate-events-2024/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ function register_blocks(): void {
include_once __DIR__ . '/blocks/event-edit-link/index.php';
include_once __DIR__ . '/blocks/event-trash-link/index.php';
include_once __DIR__ . '/blocks/event-nav-links/index.php';
include_once __DIR__ . '/blocks/pages/events/trashed-events/index.php';
include_once __DIR__ . '/blocks/event-delete-link/index.php';
}

function register_patterns(): void {
Expand Down
67 changes: 60 additions & 7 deletions themes/wporg-translate-events-2024/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -207,13 +207,66 @@ span.user-remote-icon.dashicons-video-alt2 {
.event-nav-link:hover {
text-decoration: underline;
}
@media (min-width: 960px) {

.wporg-marker-list__container .wporg-marker-list-item {
display: grid;
align-items: start;
gap: var(--wp--preset--spacing--20);
grid-template-columns: 45% 1fr 2fr;
.is-destructive{
color: var(--wp--preset--color--vivid-red);

}

.small-btn {
padding: 3px 12px;
font-size: 12px;
min-height: 28px;
margin-left: 3px;
border: thin solid currentColor;
text-decoration: none;
}

.small-btn:hover {
border: 2px solid currentColor;
font-weight: bold;

}

.no-text-decoration {
text-decoration: none;
}

.gp-events-icon {
display: inline-block;
width: 20px;
height: 20px;
vertical-align: middle;
-webkit-mask-size: contain;
mask-size: contain;
-webkit-mask-repeat: no-repeat;
mask-repeat: no-repeat;
-webkit-mask-position: center;
mask-position: center;
}

.gp-events-icon-delete-permanently {
-webkit-mask-image: url(assets/icons/delete-permanently.svg);
mask-image: url(assets/icons/delete-permanently.svg);
background-color: var(--wp--preset--color--vivid-red);
}

.gp-events-icon-restore {
-webkit-mask-image: url(assets/icons/restore.svg);
mask-image: url(assets/icons/restore.svg);
background-color: var(--wp--preset--color--vivid-green-cyan);
}

.gp-events-admin-links {
text-align: right;
}

@media (min-width: 960px) {
.wporg-marker-list__container .wporg-marker-list-item {
display: grid;
align-items: start;
gap: var(--wp--preset--spacing--20);
grid-template-columns: 45% 1fr 1fr 1fr;
}
}

Expand All @@ -225,7 +278,7 @@ span.user-remote-icon.dashicons-video-alt2 {

@media (min-width: 1280px) {
.wporg-marker-list__container .wporg-marker-list-item {
grid-template-columns: 60% 1fr 1fr;
grid-template-columns: 60% repeat(auto-fit, minmax(0, 1fr));
}
}

Expand Down
Loading