2017 © Pedro Peláez
 

yii2-extension yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

image

simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  • Tuesday, June 19, 2018
  • by simialbi
  • Repository
  • 0 Watchers
  • 0 Stars
  • 40 Installations
  • JavaScript
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 13 Versions
  • 11 % Grown

The README.md

yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin based on nestedSortable jQuery plugin implementation. * nestedSortable jQuery plugin * Nested Sets Behavior for Yii 2, (*1)

Installation

The preferred way to install this extension is through composer., (*2)

Either run, (*3)

$ php composer.phar require simialbi/yii2-nestable "~3.0"

or add, (*4)

"simialbi/yii2-nestable": "~3.0"

to the require section of your composer.json file., (*5)

Usage

Make sure you've attached the NestedSetsBehavior (creocoder/yii2-nested-sets) correctly to your model., (*6)

And then render the widget in your view. An advanced example could look like this:, (*7)

 [
        [
            'content' => '',
            'options' => ['class' => 'list-group-item'],
            'listOptions' => ['class' => 'list-group'],
            'items' => [
                [
                    'content' => '',
                    'options' => ['class' => 'list-group-item']
                ]
            ]
        ], 
        [
            'content' => '',
            'options' => ['class' => 'list-group-item'],
            'listOptions' => ['class' => 'list-group']
        ]
    ],
    'clientOptions' => [
        'expandOnHover' => 700,
        'forcePlaceholderSize' => true,
        'handle' => '.handle',
        'isTree' => true,
        'items' => 'li',
        'placeholder' => 'placeholder',
        'startCollapsed' => true,
        'toleranceElement' => '> div',
        // this js event will be called on change order of list
        'relocate' => new JsExpression('function (evt, ui) {
            var context = null;
            var method = \'root\';
            var parent = ui.item.parent(\'ul\').parent(\'.list-group-item\');
            
            if (ui.item.prev(\'.list-group-item\').length) {
                if (parent.length) {
                    method = \'after\';
                }
                context = ui.item.prev(\'.list-group-item\').data(\'id\');
            } else if (ui.item.next(\'.list-group-item\').length) {
                if (parent.length) {
                    method = \'before\';
                }
                context = ui.item.next(\'.list-group-item\').data(\'id\');
            } else if (parent.length) {
                method = \'prepend\';
                context = ui.item.parent(\'ul\').parent(\'.list-group-item\').data(\'id\');
            }
            
            jQuery.ajax({
                url: \''.Url::to(['site/my']).'/\' + method,
                data: {
                    id: ui.item.data(\'id\'),
                    context: context
                }
            });
        }')
    ]
]);
?>

Your controller should then look like this:, (*8)

<?php
namespace app\controllers;

use yii\web\Controller;

/**
 * This controller provides move actions
 */
class MyController extends Controller {
    /**
     * @inheritdoc
     */
    public function actions() {
        return [
            'root'    => [
                'class'      => 'simialbi\yii2\nestable\actions\RootAction',
                'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
            ],
            'after'   => [
                'class'      => 'simialbi\yii2\nestable\actions\AfterAction',
                'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
            ],
            'before'  => [
                'class'      => 'simialbi\yii2\nestable\actions\BeforeAction',
                'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
            ],
            'prepend' => [
                'class'      => 'simialbi\yii2\nestable\actions\PrependAction',
                'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
            ],
            'append'  => [
                'class'      => 'simialbi\yii2\nestable\actions\AppendAction',
                'modelClass' => 'simialbi\yii2\nestable\models\ActiveRecord'
            ]
        ];
    }
}

License

yii2-nestable is released under MIT license. See bundled LICENSE for details., (*9)

The Versions

19/06 2018

dev-master

9999999-dev https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

19/06 2018

2.1.1

2.1.1.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

19/06 2018

2.1

2.1.0.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

22/02 2018

2.0

2.0.0.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

19/01 2018

1.0.8

1.0.8.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

20/12 2017

1.0.7

1.0.7.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

15/12 2017

1.0.6

1.0.6.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

15/12 2017

1.0.5

1.0.5.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

15/12 2017

1.0.4

1.0.4.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

15/12 2017

1.0.3

1.0.3.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

15/12 2017

1.0.2

1.0.2.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

15/12 2017

1.0.1

1.0.1.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable

09/11 2017

1.0

1.0.0.0 https://github.com/simialbi/yii2-nestable

Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).

  Sources   Download

MIT

The Requires

 

by Arno Slatius
by Simon Karlen

extension yii2 jquery nested set widget behavior sortable nestable