From 4835346bbc528e5e4dacd4e9ad9e836b093334bf Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Tue, 15 Oct 2024 17:57:44 +0100 Subject: [PATCH 01/13] Create trashed events page block --- includes/routes/event/list-trashed.php | 2 +- .../pages/events/trashed-events/index.php | 30 +++++++++++++++++++ .../pages/events/trashed-events/render.php | 9 ++++++ .../wporg-translate-events-2024/functions.php | 1 + 4 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 themes/wporg-translate-events-2024/blocks/pages/events/trashed-events/index.php create mode 100644 themes/wporg-translate-events-2024/blocks/pages/events/trashed-events/render.php diff --git a/includes/routes/event/list-trashed.php b/includes/routes/event/list-trashed.php index 2a6d59e1..12cf144a 100644 --- a/includes/routes/event/list-trashed.php +++ b/includes/routes/event/list-trashed.php @@ -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( diff --git a/themes/wporg-translate-events-2024/blocks/pages/events/trashed-events/index.php b/themes/wporg-translate-events-2024/blocks/pages/events/trashed-events/index.php new file mode 100644 index 00000000..fa590276 --- /dev/null +++ b/themes/wporg-translate-events-2024/blocks/pages/events/trashed-events/index.php @@ -0,0 +1,30 @@ + 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 + ); + }, + ) +); diff --git a/themes/wporg-translate-events-2024/blocks/pages/events/trashed-events/render.php b/themes/wporg-translate-events-2024/blocks/pages/events/trashed-events/render.php new file mode 100644 index 00000000..47f57f59 --- /dev/null +++ b/themes/wporg-translate-events-2024/blocks/pages/events/trashed-events/render.php @@ -0,0 +1,9 @@ + $event_ids, + 'show_flag' => false, +); +?> + diff --git a/themes/wporg-translate-events-2024/functions.php b/themes/wporg-translate-events-2024/functions.php index b761156c..85b9ce01 100644 --- a/themes/wporg-translate-events-2024/functions.php +++ b/themes/wporg-translate-events-2024/functions.php @@ -34,6 +34,7 @@ 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'; } function register_patterns(): void { From 62881e6304c0b6efd1474d5760d65a76ef64d599 Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Tue, 15 Oct 2024 17:58:52 +0100 Subject: [PATCH 02/13] Add post status to WP_Query to allow fetching of trash events --- .../blocks/event-template/index.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/themes/wporg-translate-events-2024/blocks/event-template/index.php b/themes/wporg-translate-events-2024/blocks/event-template/index.php index 0d39dc67..662392dc 100644 --- a/themes/wporg-translate-events-2024/blocks/event-template/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-template/index.php @@ -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' ), ) ); From f8c92fd1ffff536298bf30326e9b65b6bf01ff6d Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Tue, 15 Oct 2024 18:41:58 +0100 Subject: [PATCH 03/13] Create delete link block --- .../blocks/event-delete-link/index.php | 34 +++++++++++++++++++ .../blocks/event-list/index.php | 1 + .../wporg-translate-events-2024/functions.php | 1 + 3 files changed, 36 insertions(+) create mode 100644 themes/wporg-translate-events-2024/blocks/event-delete-link/index.php diff --git a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php new file mode 100644 index 00000000..d401156d --- /dev/null +++ b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php @@ -0,0 +1,34 @@ + 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 ''; + } + ?> + + + + + diff --git a/themes/wporg-translate-events-2024/functions.php b/themes/wporg-translate-events-2024/functions.php index 85b9ce01..ec86cb76 100644 --- a/themes/wporg-translate-events-2024/functions.php +++ b/themes/wporg-translate-events-2024/functions.php @@ -35,6 +35,7 @@ function register_blocks(): void { 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 { From 56e989e8ff54b57607cc7b5c47ac881c29b4ba28 Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Tue, 15 Oct 2024 19:07:48 +0100 Subject: [PATCH 04/13] Style buttons --- .../blocks/event-delete-link/index.php | 2 +- .../blocks/event-trash-link/index.php | 4 ++-- themes/wporg-translate-events-2024/style.css | 19 +++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php index d401156d..c5e8adbc 100644 --- a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php @@ -23,7 +23,7 @@ } ?> diff --git a/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php b/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php index 8e422540..9acbb525 100644 --- a/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php @@ -24,8 +24,8 @@ } if ( $event->is_trashed() ) : ?> - diff --git a/themes/wporg-translate-events-2024/style.css b/themes/wporg-translate-events-2024/style.css index fcfd2af3..c682fe6c 100644 --- a/themes/wporg-translate-events-2024/style.css +++ b/themes/wporg-translate-events-2024/style.css @@ -206,6 +206,25 @@ span.user-remote-icon.dashicons-video-alt2 { .event-nav-link:hover { text-decoration: underline; +} + +.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; + } @media (min-width: 960px) { From 9f8f85992c1ebdcd74abd7c9afc3f8b83039a7e0 Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Thu, 14 Nov 2024 18:19:11 +0100 Subject: [PATCH 05/13] Add prompt to trash when clicked on list item --- assets/js/translation-events.js | 10 ++++++++++ .../blocks/event-trash-link/index.php | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/assets/js/translation-events.js b/assets/js/translation-events.js index 5052977d..b79738bb 100644 --- a/assets/js/translation-events.js +++ b/assets/js/translation-events.js @@ -21,6 +21,16 @@ } ); + $( '.trash-event-from-list' ).on( + 'click', + function ( e ) { + e.preventDefault(); + if ( confirm( 'Are you sure you want to delete this event?' ) ) { + window.location = $(this).attr('href'); + } + } + ); + $( '.trash-event' ).on( 'click', function ( e ) { diff --git a/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php b/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php index 9acbb525..7edb132d 100644 --- a/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php @@ -31,7 +31,7 @@ class="small-btn" From 66a521b9b6ac20d0645581a55b2e4e96a611932d Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Fri, 15 Nov 2024 17:33:12 +0100 Subject: [PATCH 06/13] Add missing restore link --- .../blocks/event-trash-link/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php b/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php index 7edb132d..6b561267 100644 --- a/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php @@ -24,7 +24,7 @@ } if ( $event->is_trashed() ) : ?> - From 6f444bf2bebe62ec18d8f788c097d2c050f94255 Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Fri, 15 Nov 2024 18:43:43 +0100 Subject: [PATCH 07/13] Add prompt for permanent deletion --- assets/js/translation-events.js | 9 ++++++--- .../blocks/event-delete-link/index.php | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/assets/js/translation-events.js b/assets/js/translation-events.js index b79738bb..69eff146 100644 --- a/assets/js/translation-events.js +++ b/assets/js/translation-events.js @@ -21,12 +21,15 @@ } ); - $( '.trash-event-from-list' ).on( + $( '.trash-event-from-list, #delete-permanently' ).on( 'click', function ( e ) { e.preventDefault(); - if ( confirm( 'Are you sure you want to delete this event?' ) ) { - window.location = $(this).attr('href'); + 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; } } ); diff --git a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php index c5e8adbc..e4047023 100644 --- a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php @@ -24,6 +24,7 @@ ?> From 3c7ae9b3875ff5455356373f1820dc573fac71f5 Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Fri, 22 Nov 2024 17:40:34 +0100 Subject: [PATCH 08/13] Use icon for delete-permanently --- .../assets/icons/delete-permanently.svg | 3 +++ .../blocks/event-delete-link/index.php | 5 ++-- themes/wporg-translate-events-2024/style.css | 24 ++++++++++++++----- 3 files changed, 24 insertions(+), 8 deletions(-) create mode 100644 themes/wporg-translate-events-2024/assets/icons/delete-permanently.svg diff --git a/themes/wporg-translate-events-2024/assets/icons/delete-permanently.svg b/themes/wporg-translate-events-2024/assets/icons/delete-permanently.svg new file mode 100644 index 00000000..b595a040 --- /dev/null +++ b/themes/wporg-translate-events-2024/assets/icons/delete-permanently.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php index e4047023..6ee4837d 100644 --- a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php @@ -22,11 +22,12 @@ return ''; } ?> + - + Date: Fri, 22 Nov 2024 17:55:12 +0100 Subject: [PATCH 09/13] Add restore icon --- .../assets/icons/restore.svg | 2 ++ themes/wporg-translate-events-2024/style.css | 25 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 themes/wporg-translate-events-2024/assets/icons/restore.svg diff --git a/themes/wporg-translate-events-2024/assets/icons/restore.svg b/themes/wporg-translate-events-2024/assets/icons/restore.svg new file mode 100644 index 00000000..020a2d80 --- /dev/null +++ b/themes/wporg-translate-events-2024/assets/icons/restore.svg @@ -0,0 +1,2 @@ + + \ No newline at end of file diff --git a/themes/wporg-translate-events-2024/style.css b/themes/wporg-translate-events-2024/style.css index 6687da29..29f5957b 100644 --- a/themes/wporg-translate-events-2024/style.css +++ b/themes/wporg-translate-events-2024/style.css @@ -227,16 +227,29 @@ span.user-remote-icon.dashicons-video-alt2 { } -.delete-permanently-icon { - -webkit-mask: url(assets/icons/delete-permanently.svg) no-repeat center; - mask: url(assets/icons/delete-permanently.svg) no-repeat center; - -webkit-mask-size: contain; - mask-size: contain; - background-color: var(--wp--preset--color--vivid-red); /* Set your desired color here */ +.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); } @media (min-width: 960px) { From 208f3a051ce4f2df8dc801981f54177b01879fc7 Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Fri, 22 Nov 2024 17:56:24 +0100 Subject: [PATCH 10/13] Update class names --- .../blocks/event-delete-link/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php index 6ee4837d..c86f0e85 100644 --- a/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-delete-link/index.php @@ -27,7 +27,7 @@ class="is-destructive" id="delete-permanently" title=""> - + Date: Fri, 22 Nov 2024 18:15:33 +0100 Subject: [PATCH 11/13] Use restore icon --- .../blocks/event-trash-link/index.php | 6 +++--- themes/wporg-translate-events-2024/style.css | 5 +++++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php b/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php index 6b561267..38a2d085 100644 --- a/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-trash-link/index.php @@ -25,9 +25,9 @@ if ( $event->is_trashed() ) : ?> - + title="" + class="no-text-decoration"> + Date: Fri, 22 Nov 2024 18:18:05 +0100 Subject: [PATCH 12/13] Restore to original content --- .../assets/icons/delete-permanently.svg | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/themes/wporg-translate-events-2024/assets/icons/delete-permanently.svg b/themes/wporg-translate-events-2024/assets/icons/delete-permanently.svg index b595a040..8266234e 100644 --- a/themes/wporg-translate-events-2024/assets/icons/delete-permanently.svg +++ b/themes/wporg-translate-events-2024/assets/icons/delete-permanently.svg @@ -1,3 +1,13 @@ - - + + + + ic_fluent_delete_forever_28_regular + Created with Sketch. + + + + + + + \ No newline at end of file From 7fae5a6b4f25a5ce8ac86aa1ec038be1df2d858f Mon Sep 17 00:00:00 2001 From: Tosin Oguntuyi Date: Tue, 3 Dec 2024 14:29:05 +0100 Subject: [PATCH 13/13] Move admin links to the far right of the row --- .../blocks/event-list/index.php | 14 +++++++++++--- themes/wporg-translate-events-2024/style.css | 8 ++++++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/themes/wporg-translate-events-2024/blocks/event-list/index.php b/themes/wporg-translate-events-2024/blocks/event-list/index.php index 28f8e54c..d4bb9f6a 100644 --- a/themes/wporg-translate-events-2024/blocks/event-list/index.php +++ b/themes/wporg-translate-events-2024/blocks/event-list/index.php @@ -33,12 +33,20 @@ - - - + + +