<?php

namespace App\Manager\Toolbar\Definition;

use App\Manager\Toolbar\Element\ToolbarButton;
use App\Manager\Toolbar\Element\ToolbarDivider;
use App\Manager\Toolbar\Element\ToolbarDropdown;

class MangaListToolbar extends Toolbar
{
    public function __construct(array $contextData = [])
    {
        $this->addToLeftGroup(new ToolbarButton('arrows-rotate', 'Refresh', 'toolbar#refreshMetadata'))
            ->addToLeftGroup(new ToolbarButton('search', 'Search', 'toolbar#searchLastChapter'))

            ->addToRightGroup(new ToolbarButton('th-large', 'Options', 'toolbar#options'))
            ->addToRightGroup(new ToolbarDivider())
            ->addToRightGroup(new ToolbarDropdown('eye', 'View', 'changeView', [
                ['text' => 'Poster View', 'action' => 'changeView', 'data' => ['view' => 'poster']],
                ['text' => 'Table View', 'action' => 'changeView', 'data' => ['view' => 'table']],
                ['text' => 'Resume View', 'action' => 'changeView', 'data' => ['view' => 'resume']]
            ]))
            ->addToRightGroup(new ToolbarDropdown('sort', 'Sort', 'sort', [
                ['text' => 'Par titre', 'action' => 'sort', 'data' => ['sort' => 'title']],
                ['text' => 'Par année de publication', 'action' => 'sort', 'data' => ['sort' => 'publicationYear']],
                ['text' => 'Par date d\'ajout', 'action' => 'sort', 'data' => ['sort' => 'createdAt']]
            ]))
            ->addToRightGroup(new ToolbarDropdown('filter', 'Filter', 'filter', [
                ['text' => 'Tous les mangas', 'action' => 'filter', 'data' => ['filter' => 'all']],
                ['text' => 'Mangas en cours', 'action' => 'filter', 'data' => ['filter' => 'ongoing']],
                ['text' => 'Mangas terminés', 'action' => 'filter', 'data' => ['filter' => 'completed']]
            ]))
        ;
    }
}
