{"id":15089261,"url":"https://github.com/simialbi/yii2-nestable","last_synced_at":"2025-04-13T22:56:10.566Z","repository":{"id":57075719,"uuid":"107268665","full_name":"simialbi/yii2-nestable","owner":"simialbi","description":"Yii 2.0 implementation of nested set behavior using jquery.nestable plugin (based on slatiusa/yii2-nestable).","archived":false,"fork":false,"pushed_at":"2025-02-12T14:57:45.000Z","size":85,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-11T21:02:39.790Z","etag":null,"topics":["nestable","nested-set","sortable","widget","yii2","yii2-extension"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/simialbi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-17T12:56:51.000Z","updated_at":"2025-02-12T14:45:20.000Z","dependencies_parsed_at":"2022-08-24T14:55:45.616Z","dependency_job_id":null,"html_url":"https://github.com/simialbi/yii2-nestable","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simialbi%2Fyii2-nestable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simialbi%2Fyii2-nestable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simialbi%2Fyii2-nestable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simialbi%2Fyii2-nestable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simialbi","download_url":"https://codeload.github.com/simialbi/yii2-nestable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794569,"owners_count":21162614,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["nestable","nested-set","sortable","widget","yii2","yii2-extension"],"created_at":"2024-09-25T08:41:54.403Z","updated_at":"2025-04-13T22:56:10.549Z","avatar_url":"https://github.com/simialbi.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# yii2-nestable\n\nYii 2.0 implementation of nested set behavior using jquery.nestable plugin based on\nnestedSortable jQuery plugin implementation.\n* [nestedSortable jQuery plugin](https://github.com/ilikenwf/nestedSortable) \n* [Nested Sets Behavior](https://github.com/creocoder/yii2-nested-sets) for Yii 2\n\n## Installation\n\nThe preferred way to install this extension is through [composer](http://getcomposer.org/download/).\n\nEither run\n\n```\n$ php composer.phar require simialbi/yii2-nestable \"~3.0\"\n```\n\nor add\n\n```\n\"simialbi/yii2-nestable\": \"~3.0\"\n```\n\nto the ```require``` section of your `composer.json` file.\n\n## Usage\n\nMake sure you've attached the NestedSetsBehavior (creocoder/yii2-nested-sets) correctly to your model.\n\nAnd then render the widget in your view. An advanced example could look like this:\n\n```php\n\u003c?php\nuse simialbi\\yii2\\nestable\\widgets\\Nestable;\nuse yii\\helpers\\Url;\nuse yii\\web\\JsExpression;\n\necho Nestable::widget([\n    'items' =\u003e [\n        [\n            'content' =\u003e '\u003cdiv\u003e\u003ca href=\"#test\"\u003eMy Item\u003c/a\u003e\u003cspan class=\"handle\"\u003e\u003c/span\u003e\u003c/div\u003e',\n            'options' =\u003e ['class' =\u003e 'list-group-item'],\n            'listOptions' =\u003e ['class' =\u003e 'list-group'],\n            'items' =\u003e [\n                [\n                    'content' =\u003e '\u003cdiv\u003e\u003ca href=\"#testChild\"\u003eMy Child Item\u003c/a\u003e\u003cspan class=\"handle\"\u003e\u003c/span\u003e\u003c/div\u003e',\n                    'options' =\u003e ['class' =\u003e 'list-group-item']\n                ]\n            ]\n        ], \n        [\n            'content' =\u003e '\u003cdiv\u003e\u003ca href=\"#test2\"\u003eMy Item 2\u003c/a\u003e\u003cspan class=\"handle\"\u003e\u003c/span\u003e\u003c/div\u003e',\n            'options' =\u003e ['class' =\u003e 'list-group-item'],\n            'listOptions' =\u003e ['class' =\u003e 'list-group']\n        ]\n    ],\n    'clientOptions' =\u003e [\n        'expandOnHover' =\u003e 700,\n        'forcePlaceholderSize' =\u003e true,\n        'handle' =\u003e '.handle',\n        'isTree' =\u003e true,\n        'items' =\u003e 'li',\n        'placeholder' =\u003e 'placeholder',\n        'startCollapsed' =\u003e true,\n        'toleranceElement' =\u003e '\u003e div',\n        // this js event will be called on change order of list\n        'relocate' =\u003e new JsExpression('function (evt, ui) {\n            var context = null;\n            var method = \\'root\\';\n            var parent = ui.item.parent(\\'ul\\').parent(\\'.list-group-item\\');\n            \n            if (ui.item.prev(\\'.list-group-item\\').length) {\n                if (parent.length) {\n                    method = \\'after\\';\n                }\n                context = ui.item.prev(\\'.list-group-item\\').data(\\'id\\');\n            } else if (ui.item.next(\\'.list-group-item\\').length) {\n                if (parent.length) {\n                    method = \\'before\\';\n                }\n                context = ui.item.next(\\'.list-group-item\\').data(\\'id\\');\n            } else if (parent.length) {\n                method = \\'prepend\\';\n                context = ui.item.parent(\\'ul\\').parent(\\'.list-group-item\\').data(\\'id\\');\n            }\n            \n            jQuery.ajax({\n                url: \\''.Url::to(['site/my']).'/\\' + method,\n                data: {\n                    id: ui.item.data(\\'id\\'),\n                    context: context\n                }\n            });\n        }')\n    ]\n]);\n?\u003e\n```\n\nYour controller should then look like this:\n```php\n\u003c?php\nnamespace app\\controllers;\n\nuse yii\\web\\Controller;\n\n/**\n * This controller provides move actions\n */\nclass MyController extends Controller {\n    /**\n     * @inheritdoc\n     */\n    public function actions() {\n        return [\n            'root'    =\u003e [\n                'class'      =\u003e 'simialbi\\yii2\\nestable\\actions\\RootAction',\n                'modelClass' =\u003e 'simialbi\\yii2\\nestable\\models\\ActiveRecord'\n            ],\n            'after'   =\u003e [\n                'class'      =\u003e 'simialbi\\yii2\\nestable\\actions\\AfterAction',\n                'modelClass' =\u003e 'simialbi\\yii2\\nestable\\models\\ActiveRecord'\n            ],\n            'before'  =\u003e [\n                'class'      =\u003e 'simialbi\\yii2\\nestable\\actions\\BeforeAction',\n                'modelClass' =\u003e 'simialbi\\yii2\\nestable\\models\\ActiveRecord'\n            ],\n            'prepend' =\u003e [\n                'class'      =\u003e 'simialbi\\yii2\\nestable\\actions\\PrependAction',\n                'modelClass' =\u003e 'simialbi\\yii2\\nestable\\models\\ActiveRecord'\n            ],\n            'append'  =\u003e [\n                'class'      =\u003e 'simialbi\\yii2\\nestable\\actions\\AppendAction',\n                'modelClass' =\u003e 'simialbi\\yii2\\nestable\\models\\ActiveRecord'\n            ]\n        ];\n    }\n}\n```\n\n## License\n\n**yii2-nestable** is released under MIT license. See bundled [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimialbi%2Fyii2-nestable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimialbi%2Fyii2-nestable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimialbi%2Fyii2-nestable/lists"}