Giter VIP home page Giter VIP logo

yii2-sortable's Introduction

Krajee Logo
yii2-sortable
Donate

Stable Version Unstable Version License Total Downloads Monthly Downloads Daily Downloads

A Yii 2.0 widget that allows you to create sortable lists and grids and manipulate them using simple drag and drop. It is based on the lightweight html5sortable jQuery plugin, which uses native HTML5 API for drag and drop. It is a leaner alternative for the JUI Sortable plugin and offers very similar functionality. The yii2-sortable widget offers these features:

  • Less than 1KB of javascript used (minified and gzipped).
  • Built using native HTML5 drag and drop API.
  • Supports both list and grid style layouts.
  • Similar API and behaviour to jquery-ui sortable plugin.
  • Works in IE 5.5+, Firefox 3.5+, Chrome 3+, Safari 3+ and, Opera 12+.

Demo

You can see detailed documentation on usage of the extension.

Installation

The preferred way to install this extension is through composer.

NOTE: Check the composer.json for this extension's requirements and dependencies. Read this web tip /wiki on setting the minimum-stability settings for your application's composer.json.

Either run

$ php composer.phar require kartik-v/yii2-sortable "@dev"

or add

"kartik-v/yii2-sortable": "@dev"

to the require section of your composer.json file.

Usage

Sortable

use kartik\sortable\Sortable;
echo Sortable::widget([
    'type' => Sortable::TYPE_LIST,
    'items' => [
        ['content' => 'Item # 1'],
        ['content' => 'Item # 2'],
        ['content' => 'Item # 3'],
    ]   
]); 

License

yii2-sortable is released under the BSD-3-Clause License. See the bundled LICENSE.md for details.

yii2-sortable's People

Contributors

cornernote avatar kartik-v avatar zmedanic avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

yii2-sortable's Issues

Wrong documentation link?

Correct me if I'm wrong but it looks like you provide the link to the documentation for https://github.com/voidberg/html5sortable (here and at http://demos.krajee.com/sortable ) while this widget is based on https://github.com/farhadi/html5sortable (maybe earlier those two were almost identical but now Voidberg's is way ahead).
And I was wondering why 'sortstart' event doesn't work...

Are you planning to replace the js for this widget with newer version? If not maybe switch the documentation link ;)

sortstop event

Hello.

In original description (lukasoppermann/html5sortable) I found 'sortstop' event, but in this plugin it is not implemented (after looking in html.sortable.js). Only 'sortupdate' and 'sortstart' events work.

Have you any plans to implement this?

use "(" instead of "["

Hi,

this code (copy/paste source is your doku) produces a PHP Parse error (syntax error, unexpected '
[').

echo Sortable::widget([
    'connected'=>true,
    'items'=>[
        ['content'=>'From Item 1'],
        ['content'=>'From Item 2'],
        ['content'=>'From Item 3'],
        ['content'=>'From Item 4'],
    ]
]);

this works for me:

echo Sortable::widget(array(
    'connected'=>true,
    'items'=>array(
        'content'=>'From Item 1',
        'content'=>'From Item 2',
        'content'=>'From Item 3',
        'content'=>'From Item 4',
    )
));

Suggestion: Use RubaXa/Sortable

Hi @kartik-v. The RubaXa/Sortable library seems to be more widely used than html5sortable (compare GitHub's watches and stars) and provides more features like better support for touch devices and more features like auto-scroll. Using it instead of html5sortable could provide a better sortable extension and enhance the dependent ones. I wonder if it is feasible to use it in your yii2-sortable extension (without breaking compatibility of course). I am willing to participate in that if you decide to do it.

Connected functionality lost when rendering the Sortable lists with AJAX?

Hello,

I'm not sure I'm doing something wrong or this is in fact a bug, but when I use AJAX to render the lists on my page I can't seem to drag the items from one list to the other. I can still drag the items within the same list however, so I'm not quite sure what's going on here?

Here is my view:

<div class="box-body">
    <div class="row">
        <div class="col-md-12">
            <div class="row">
                <div class="col-md-6">
                    <div class="box box-solid box-primary">
                        <div class="box-header">
                            <h3 class="box-title">Available</h3>
                        </div>
                        <div class="box-body">
                            <?php
                            echo Sortable::widget([
                                'connected' => 'assign',
                                'items' => $availableArray
                            ]);
                            ?>
                        </div>
                    </div>

                </div>
                <div class="col-md-6">
                    <div class="box box-solid box-success">
                        <div class="box-header">
                            <h3 class="box-title">Assigned</h3>
                        </div>
                        <div class="box-body">
                            <?php
                            echo Sortable::widget([
                                'connected' => 'assign',
                                'items' => $assignedArray
                            ]);
                            ?>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>

and my Controller that I'm accessing via AJAX:

        Yii::$app->response->statusCode = 200;
        Yii::$app->response->data = $this->renderAjax('/assignment/assign', [
            'model' => $model,
            'available' => $availableArray,
            'assigned' => $assignedArray]);
        Yii::$app->response->send();

error "Unable to resolve the request html.sortable.min.js.map"

plz can add in the asset the maps ?

https://github.com/voidberg/html5sortable/tree/master/dist

exception 'yii\base\InvalidRouteException' with message 'Unable to resolve the request "assets/a29ec48/js/html.sortable.min.js.map".' in /home/tucinenc/public_html/app/vendor/yiisoft/yii2/base/Module.php:460
Stack trace:
#0 /home/tucinenc/public_html/app/vendor/yiisoft/yii2/web/Application.php(84): yii\base\Module->runAction('assets/a29ec48/...', Array)
#1 /home/tucinenc/public_html/app/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#2 /home/tucinenc/public_html/app/frontend/web/index.php(18): yii\base\Application->run()
#3 {main}

Next exception 'yii\web\NotFoundHttpException' with message 'Página no encontrada.' in /home/tucinenc/public_html/app/vendor/yiisoft/yii2/web/Application.php:96
Stack trace:
#0 /home/tucinenc/public_html/app/vendor/yiisoft/yii2/base/Application.php(375): yii\web\Application->handleRequest(Object(yii\web\Request))
#1 /home/tucinenc/public_html/app/frontend/web/index.php(18): yii\base\Application->run()
#2 {main}

Allow multiple connected sortables on single page

Enhance the connected property to be a string or boolean and thus allow multiple groups of connected sortables on the page. With this enhancement, the connected property will follow these rules:

  • if set to false or null/empty, this widget will not be connected to any other sortable widget.
  • if set to true, this widget will be connected to all other sortable widgets on the page with connected property set to true.
  • if set to a string, this widget will be connected with other sortable widgets matching the same connected string value.

Events sortupdate don't work. And maxItems not limited elments

Hi

$itemsMain = [
        1 => ['content' => '<i class="glyphicon glyphicon-cog"></i> Item # 1'],
        2 => ['content' => '<i class="glyphicon glyphicon-cog"></i> Item # 2'],
        3 => ['content' => '<i class="glyphicon glyphicon-cog"></i> Item # 3'],
        4 => ['content' => '<i class="glyphicon glyphicon-cog"></i> Item # 4'],
];

echo Sortable::widget([
                'id' => "main_kind",
                'connected'=>true,
                'type'=>'grid',
                'items'=> $itemsMain,
                'pluginOptions' => [
                    'maxItems' => 2
                ],
                'options' => [
                    'class' => 'preview-photo',
                ],
                'pluginEvents' => [
                    'sortupdate' => 'function(e) { console.log(e.detail); }',
                ]
            ]);

I have 3 sortable widgets on one page.
maxItems not limited and i can drop more 2 items from other widget.
console.log(e.detail); undefined, but in documentation they will be return object with information

https://github.com/lukasoppermann/html5sortable#sortupdate

Javascript console warning - using depreciated configuration

html5sortable.js:794 HTML5Sortable: You are using the deprecated configuration "connectWith". This will be removed in an upcoming version, make sure to migrate to the new options when updating.

This is using the latest yii2-sortable update with dynagrid.

Conflict with jQuery UI

The javascript in this widget conflicts with jQuery UI's sortable widget. Is there any chance of changing it's name? I would recommend somethink like kvSortable or yiiSortable.

Method $this->isBs4() do not exist in Sortable.php

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of yii2-sortable.
  • This is not an usage question. I confirm having gone through and read the documentation and demos.
  • This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional).

Steps to reproduce the issue

  1. composer update
  2. Updating kartik-v/yii2-sortable dev-master (5d418b8 => 89593b9)
  3. Calling unknown method: kartik\sortable\Sortable::isBs4()

Expected behavior and actual behavior

When I follow those steps, I see...
Calling unknown method: kartik\sortable\Sortable::isBs4()
I was expecting...
loading the page normally

Environment

Browsers

  • Google Chrome
  • Mozilla Firefox
  • Internet Explorer
  • Safari

Operating System

  • Windows
  • Mac OS X
  • Linux
  • Mobile

Libraries

  • jQuery version:
  • yii2-sortable version: dev-master

Isolating the problem

  • This bug happens on the docs and demos page
  • The bug happens consistently across all tested browsers
  • This bug happens when using yii2-sortable without other plugins.

html5sortable.js: Object does not support 'assign'

Prerequisites

  • I have searched for similar issues in both open and closed tickets and cannot find a duplicate.
  • The issue still exists against the latest master branch of yii2-sortable.
  • This is not an usage question. I confirm having gone through and read the documentation and demos.
  • This is not a general programming / coding question. (Those should be directed to the webtips Q & A forum).
  • I have attempted to find the simplest possible steps to reproduce the issue.
  • I have included a failing test as a pull request (Optional).

Expected behavior and actual behavior

On IE, I get this error:

html5sortable.js (756,9): This object does not support the property or method "assign" (translated from german).

Code snip:

    function sortable(sortableElements, options) {
        // get method string to see if a method is called
        var method = String(options);
        // merge user options with defaultss
        options = Object.assign({

This leads to not functioning sortable in DynGrid config-page.

Any ideas whats wrong here?

On Yii 2.0.15.1 with jQuery 2.2.4

Environment

Browsers

  • Google Chrome
  • Mozilla Firefox
  • Internet Explorer 11
  • Safari

Operating System

  • Windows
  • Mac OS X
  • Linux
  • Mobile

Libraries

  • jQuery version:
  • yii2-sortable version: 1.2.2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.