heimrichhannot/contao-progress-bar-widget-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

heimrichhannot/contao-progress-bar-widget-bundle

最新稳定版本:0.1.3

Composer 安装命令:

composer require heimrichhannot/contao-progress-bar-widget-bundle

包简介

This bundle offers a dynamic progress bar widget for the Contao CMS.

README 文档

README

This bundle offers a dynamic progress bar widget for the Contao CMS.

Features

  • adds a progress bar widget (currently for the backend only) for a given database record
  • ajax support (self-auto-updating)
  • also display the progress in numbers

Impressions

The progress bar widget included in an example data container array

The progress bar widget included in an example data container array

Installation

  1. Install via composer: composer require heimrichhannot/contao-progress-bar-widget-bundle.

Usage

  1. Create the field in the desired data container array (DCA) as usual:
    'importProgress'                 => [
        'inputType' => 'huhProgressBar',
        'eval' => [
            // an introduction text for the widget (mandatory)
            'description' => $GLOBALS['TL_LANG']['tl_entity_import_config']['reference']['importProgressDescription'],
            // only show the progress bar but not the numbers below (optional, default false)
            'hideNumbers' => false,
            // hide skipped items from the numbers section (optional, default false)
            'hideSkippedItems' => false
        ]
    ],
  2. The progress is passed via an event listener for the event LoadProgressEvent. Register an event listener (or subscriber) as usual in symfony:
    use HeimrichHannot\ProgressBarWidgetBundle\Event\LoadProgressEvent;
    use HeimrichHannot\ProgressBarWidgetBundle\Widget\ProgressBar;
    use Terminal42\ServiceAnnotationBundle\Annotation\ServiceTag;
    
    /**
     * @ServiceTag("kernel.event_listener", event="huh.progress_bar_widget.event.load_progress")
     */
    class LoadProgressListener
    {
        public function __invoke(LoadProgressEvent $event) {
            if (null === ($record = MyModel::findByPk($event->getId()))) {
                return;
            }
    
            // map the record's state field to the progress bar's expectations
            // of course you can decide yourself in which cases you'd like to pass which state
            switch ($record->state) {
                case 'success':
                    $state = ProgressBar::STATE_SUCCESS;
                    $class = 'tl_confirm';
                    break;
                case 'error':
                    $state = ProgressBar::STATE_FAILED;
                    $class = 'tl_error';
                    break;
                default:
                    $state = ProgressBar::STATE_IN_PROGRESS;
                    $class = '';
            }
    
            $data = [
                'state' => $state,
                'currentProgress' => $record->importProgressCurrent, // field name depends on your dca
                'totalCount' => $record->importProgressTotal, // field name depends on your dca
                'skippedCount' => $record->importProgressSkipped, // field name depends on your dca
            ];
    
            // add messages if some are available
            if ($record->importProgressResult) {
                $data['messages'] = [[
                    'class' => $class,
                    'text' => str_replace("\n", '<br>', $record->importProgressResult),
                ]];
            }
        }
    }

Events

Event Description
LoadProgressEvent Used for passing in the current progress. See above for further explanation

统计信息

  • 总下载量: 1.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 5
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2021-09-14