Skip to content

Commit

Permalink
Merge pull request #353 from WordPress/manage-attendees-page-block
Browse files Browse the repository at this point in the history
Manage attendees page block
  • Loading branch information
trymebytes authored Oct 2, 2024
2 parents 10c4f60 + f374fdb commit 08ffb77
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 5 deletions.
2 changes: 2 additions & 0 deletions includes/routes/attendee/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ public function handle( string $event_slug ): void {
$attendees = $this->attendee_repository->get_attendees( $event->id() );
}

$this->use_theme();
$this->tmpl(
'event-attendees',
array(
'event' => $event,
'attendees' => $attendees,
'is_active_filter' => $is_active_filter,
'event_id' => $event->id(),
),
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
$view_type = $attributes['view_type'] ?? 'list';
$user_id = get_current_user_id();
$attendees = Translation_Events::get_attendee_repository()->get_attendees( $event_id );
if ( empty( $attendees ) ) {
return '';
}
$attendees_not_contributing = array_filter(
$attendees,
function ( Attendee $attendee ) {
Expand All @@ -23,6 +26,7 @@ function ( Attendee $attendee ) {
);
ob_start();
if ( 'table' === $view_type ) {
$event = Translation_Events::get_event_repository()->get_event( $event_id );
include_once 'render-table.php';
} else {
include_once 'render-list.php';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?php
use Wporg\TranslationEvents\Urls;

?>
<!-- wp:table -->
<figure class="wp-block-table">
<table class="event-stats">
<thead>
<tr>
<th><?php esc_html_e( 'Attendee', 'wporg-translate-events-2024' ); ?></th>
<th><?php esc_html_e( 'Name', 'wporg-translate-events-2024' ); ?></th>
<th><?php esc_html_e( 'Remote', 'wporg-translate-events-2024' ); ?></th>
<th><?php esc_html_e( 'Host', 'wporg-translate-events-2024' ); ?></th>
<th><?php esc_html_e( 'Action', 'wporg-translate-events-2024' ); ?></th>
</tr>
Expand All @@ -23,12 +28,37 @@
?>
/-->
</td>
<td>Host</td>
<td>Make host</td>
<td>
<?php if ( $attendee->is_remote() ) : ?>
<span><?php esc_html_e( 'Yes', 'wporg-translate-events-2024' ); ?></span>
<?php endif; ?>
</td>
<td>
<?php if ( $attendee->is_host() ) : ?>
<span><?php esc_html_e( 'Yes', 'wporg-translate-events-2024' ); ?></span>
<?php endif; ?>
</td>
<td>
<form class="add-remove-user-as-host" method="post" action="<?php echo esc_url( Urls::event_toggle_host( $event->id(), $attendee->user_id() ) ); ?>">
<div class="wp-block-buttons wporg-theme-actions is-layout-flex wp-block-buttons-is-layout-flex">
<?php if ( $attendee->is_host() ) : ?>
<input type="submit" class="wp-block-button__link remove-as-host" value="<?php echo esc_attr__( 'Remove as host', 'wporg-translate-events-2024' ); ?>"/>
<?php else : ?>
<input type="submit" class="wp-block-button__link convert-to-host" value="<?php echo esc_attr__( 'Make co-host', 'wporg-translate-events-2024' ); ?>"/>
<?php endif; ?>
<?php if ( $event->is_hybrid() ) : ?>
<div class="wp-block-button is-style-outline"><a href="<?php echo esc_url( Urls::event_toggle_attendance_mode( $event->id(), $attendee->user_id() ) ); ?>" class="wp-block-button__link wp-element-button set-attendance-mode" id="wporg-theme-button-preview"><?php $attendee->is_remote() ? esc_html_e( 'Set as on-site', 'wporg-translate-events-2024' ) : esc_html_e( 'Set as remote', 'wporg-translate-events-2024' ); ?></a></div>
<?php endif; ?>
<?php if ( ! $attendee->is_host() ) : ?>
<div class="wp-block-button is-style-outline"><a href="<?php echo esc_url( Urls::event_remove_attendee( $event->id(), $attendee->user_id() ) ); ?>" class="wp-block-button__link wp-element-button remove-attendee" id="wporg-theme-button-preview"><?php esc_html_e( 'Remove', 'wporg-translate-events-2024' ); ?></a></div>
<?php endif; ?>
</div>
</form>
</td>
</tr>
<?php endforeach; ?>

</tbody>
</table>
</figure>
<!-- /wp:table -->
<!-- /wp:table -->
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-event-attendees',
array(
'render_callback' => function ( array $attributes ) {
add_filter(
'wporg_block_site_breadcrumbs',
function ( $breadcrumbs ): array {
return array_merge(
$breadcrumbs,
array(
array(
'title' => __( 'Manage Attendees', 'wporg-translate-events-2024' ),
'url' => null,
),
)
);
}
);

render_page(
__DIR__ . '/render.php',
__( 'Manage Attendees', 'wporg-translate-events-2024' ),
$attributes
);
},
)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php
namespace Wporg\TranslationEvents\Theme_2024;

use Wporg\TranslationEvents\Translation_Events;

$event_id = $attributes['event_id'] ?? array();
$event = Translation_Events::get_event_repository()->get_event( $event_id );
if ( ! $event ) {
return '';
}

?>
<!-- wp:wporg-translate-events-2024/attendee-list
<?php
echo wp_json_encode(
array(
'id' => $event->id(),
'view_type' => 'table',
)
);
?>

/-->
1 change: 1 addition & 0 deletions themes/wporg-translate-events-2024/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ function register_blocks(): void {
include_once __DIR__ . '/blocks/event-description/index.php';
include_once __DIR__ . '/blocks/event-attend-button/index.php';
include_once __DIR__ . '/blocks/event-host-list/index.php';
include_once __DIR__ . '/blocks/pages/events/event-attendees/index.php';
}

function register_patterns(): void {
Expand Down
9 changes: 9 additions & 0 deletions themes/wporg-translate-events-2024/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ a.blue-bolded-link {
table.event-stats thead {
background-color: #D9D9D9;
border-bottom: none;
}
a.remove-attendee {
color: var(--wp--preset--color--vivid-red) !important;
}
a.remove-attendee:hover{
background-color: var(--wp--preset--color--vivid-red) !important;
color: var(--wp--preset--color--white) !important;
border-color: var(--wp--preset--color--vivid-red) !important;

}
@media (min-width: 960px) {

Expand Down

0 comments on commit 08ffb77

Please sign in to comment.