<?php
namespace JetApplicationModule\Admin\ManageAccess\Visitors\Users;

use Jet\UI;

use Jet\Tr;
use Jet\MVC_View;

/**
 * @var MVC_View $this
 * @var Listing $listing
 */
$listing = $this->getRaw( 'listing' );
$grid = $listing->getGrid();
$filter_form = $listing->getFilterForm();

$filter_form->renderer()->setDefaultLabelWidth([]);
$filter_form->renderer()->setDefaultFieldWidth([]);

$router = $this->getController()->getControllerRouter();

$grid->getColumn( '_edit_' )->addCustomCssStyle( 'width:200px;' );
$grid->getColumn( 'id' )->addCustomCssStyle( 'width:120px;' );

$grid->footer()->setPrepend( $this->render('list/bulk_operations') );
?>

<?= $filter_form->start() ?>
<div class="row toolbar" style="display: flex;gap: 20px;align-items: center;">
	<?php if( ($add_uri = $router->action( 'add' )->URI()) ): ?>
		<?= UI::button_create( Tr::_( 'Create a new User' ) )->setUrl( $add_uri ) ?>
	<?php endif; ?>
	<?=$listing->filter(Listing_Filter_Search::KEY)->renderForm()?>
	<?=$listing->filter(Listing_Filter_Role::KEY)->renderForm()?>
	<?=$listing->filter(Listing_Filter_IsBlocked::KEY)->renderForm()?>
</div>
<?= $filter_form->end() ?>

<div class="row">
	<div class="col-md-12">
		<?= $grid->render(); ?>
	</div>
</div>
