goldenscarab/modulus-service-template

An helper to create html list easily

v0.1.6 2022-02-25 13:02 UTC

This package is auto-updated.

Last update: 2024-04-21 23:27:49 UTC


README

A helper to generate HTML back-office lists in Bootstrap very easily

Required

  • Composer
  • PHP >= 7.2
  • Laravel >= 5.8

Installation

Require this package with composer.

composer require goldenscarab/modulus-service-template

Laravel 5.8 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.

Usage

// Exemple sur une liste d'utilisateurs
{!! Template::list4([
        'table_id'     => null,
        'table_class'  => 'table-sortable',
        'route_prefix' => $route_prefix,
        'can_prefix'   => $can_prefix,
        'menu'         => [
            'button' => [
                'label'      => ['template' => [
                    'format' => '<i class="fa fa-list mr-2"></i>Éléments<span class="badge badge-dark ml-2">%s</span>',
                    'args'   => ['callback' => [
                        'function' => 'count',
                        'args'     => ':menuItems'
                    ]]
                ]],
                'permission' => 'menu-read',
                'href'       => ['url'    => [
                    'route' => $route_prefix . '.item.list',
                    'args'   => [':id']
                ]],
            ],
            'dropdown' => [ 'items' => [
                [
                    'label'      => '<i class="fa fa-eye mr-2"></i>Voir la page',
                    'permission' => 'page-read',
                    'href'       => [
                        'url' => [
                            'template' => [
                                'format' => '%s%s',
                                'args'   => [url('/'), ':uri']
                            ]
                        ]
                    ],
                    'class' => ['condition' => [
                        'value'      => ':status',
                        'operator'   => '==',
                        'comparator' => 1,
                        'true'       => '',
                        'false'      => 'disabled'
                    ]]
                ],
                [
                    'label'                 => [
                        'template' => [
                            'format' => '<i class="fa fa-clipboard mr-2"></i>[ page|%s ]',
                            'args'   => ':slug',
                        ]
                    ],
                    'permission'            => 'page-read',
                    'href'                  => '#',
                    'title'                 => 'Copier le Tag',
                    'class'                 => 'clipboard-copy',
                    'data-clipboard-action' => 'copy',
                    'data-clipboard-text'   => [
                        'template' => [
                            'format' => '[ page|%s ]',
                            'args'   => ':slug',
                        ]   
                    ],
                ],
                '[READ]',
                '[UPDATE]',
                '[DUPLICATE]',
                '[SEPARATOR]',
                '[DELETE]'
            ]]
        ],
        'source' => $items,
        'columns' => array([
	            'label'    => '#',
	            'value'    => ':id',
	            'sortable' => 'id'
	        ],[
	            'label'    => 'Dossier',
	            'value'    => ':folder_html',
	            'sortable' => 'ged_folders.title'
	        ],[
	            'label'    => 'Nom',
	            'value'    => ':name',
	            'sortable' => 'name',
	        ],[
	            'label'    => 'Version',
	            'value'    => ['template' => [
                    'format' => 'v%s',
                    'args'   => ':version'
                ]],
	            'sortable' => 'version',
	            'class'    => 'text-center'
	        ],[
				'label'    => 'Position',
				'class'    => 'text-center',
                'value'     => ['callback' => [
                    'function' => 'pos_sort', 
                    'args'     => [':id', ':position']
                ]],
				'sortable' => 'position'
			],[
	            'label'    => 'Statut',
	            'value'    => ':validation_html',
	            'class'    => 'text-center'
	        ],[
	            'label'    => 'Visibilité',
	            'class'    => 'text-center',
	            'value'    => ['callback' => [
                    'function' => 'published_html', 
                    'args'     => ':status'
                ]],
	            'sortable' => 'status',
	        ],[
	            'label'    => 'Date',
	            'value'    => ':updated_at->diffForHumans()',
	            'sortable' => 'updated_at'
	        ]
	    )
    ]) !!}

Click here for more examples

Security

If you discover any security related issues, please email contact@goldenscarab.fr instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.