voskobovich/yii2-tree-manager

Tree Manager using jquery.nestable plugin for Yii 2

Installs: 30 424

Dependents: 1

Suggesters: 0

Security: 0

Stars: 25

Watchers: 10

Forks: 20

Open Issues: 1

Type:yii2-widget

v1.0.6 2018-02-09 14:54 UTC

This package is not auto-updated.

Last update: 2024-11-09 20:22:51 UTC


README

Виджет для управления деревом.

Внимание!

Виджет рассчитан на работу с поведениями Павла Зимакова:

Yii2 Adjacency List Behavior
Yii2 Nested Sets Behavior
Yii2 Nested Intervals Behavior
Yii2 Materialized Path Behavior

Отличная статья на Хабре.

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist voskobovich/yii2-tree-manager "~1.0"

or add

"voskobovich/yii2-tree-manager": "~1.0"

to the require section of your composer.json file.

Usage

  1. Подключите к вашей модели любое из указанных выше поведений

  2. Подключите в контроллер дополнительные actions

public function actions()
{
    $modelClass = 'namespace\ModelName';

    return [
        'moveNode' => [
            'class' => 'voskobovich\tree\manager\actions\MoveNodeAction',
            'modelClass' => $modelClass,
        ],
        'deleteNode' => [
            'class' => 'voskobovich\tree\manager\actions\DeleteNodeAction',
            'modelClass' => $modelClass,
        ],
        'updateNode' => [
            'class' => 'voskobovich\tree\manager\actions\UpdateNodeAction',
            'modelClass' => $modelClass,
        ],
        'createNode' => [
            'class' => 'voskobovich\tree\manager\actions\CreateNodeAction',
            'modelClass' => $modelClass,
        ],
    ];
}
  1. Выведите виджет в удобном месте
use \voskobovich\tree\manager\widgets\nestable\Nestable;

<?= Nestable::widget([
    'modelClass' => 'models\ModelName',
]) ?>

Пример того, как выглядит виджет:

Screenshot