simialbi/yii2-kanban

Kanban board module for yii2

Installs: 1 058

Dependents: 1

Suggesters: 0

Security: 0

Stars: 9

Watchers: 7

Forks: 11

Open Issues: 0

Type:yii2-extension

2.3.0 2022-02-09 11:00 UTC

README

Latest Stable Version Total Downloads License build

Resources

Installation

The preferred way to install this extension is through composer.

Either run

$ php composer.phar require --prefer-dist simialbi/yii2-kanban

or add

"simialbi/yii2-kanban": "^2.0.0"

to the require section of your composer.json.

Usage

In order to use this module, you will need to:

  1. Setup Module your application so that the module is available.
  2. Create a user identity class which extends UserInterface

Setup Module

Configure the module in the modules section of your Yii configuration file.

'modules' => [
    'kanban' => [
        'class' => 'simialbi\yii2\kanban\Module',
        //'statuses' => [],
        //'statusColors' => [],
        //'on boardCreated' => function ($event) {},
        //[...]
    ]
]

Parameters

Notice: The Statuses Task::STATUS_NOT_BEGUN, Task::STATUS_DONE and TASK::STATUS_LATE will automatically be defined if you do not define them.

Events

Setup console config and apply migrations

Apply the migrations either with the following command: yii migrate --migration-namespaces='simialbi\yii2\kanban\migrations' or configure your console like this:

[
    'controllerMap' => [
        'migrate' => [
            'class' => 'yii\console\controllers\MigrateController',
            'migrationNamespaces' => [
                'simialbi\yii2\kanban\migrations'
            ]
        ]
    ]
]

and apply the yii migrate command.

Create identity

Create an identity class which implements simialbi\yii2\models\UserInterface e.g.:

<?php
use yii\db\ActiveRecord;
use simialbi\yii2\models\UserInterface;

class User extends ActiveRecord implements UserInterface
{
    /**
     * {@inheritDoc}
     */
    public static function tableName()
    {
        return 'user';
    }

    /**
     * {@inheritDoc}
     */
    public static function findIdentity($id)
    {
        return static::findOne($id);
    }

    /**
     * {@inheritDoc}
     */
    public static function findIdentityByAccessToken($token, $type = null)
    {
        return static::findOne(['access_token' => $token]);
    }

    /**
     * {@inheritDoc}
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * {@inheritDoc}
     */
    public function getAuthKey()
    {
        return $this->auth_key;
    }

    /**
     * {@inheritDoc}
     */
    public function validateAuthKey($authKey)
    {
        return $this->getAuthKey() === $authKey;
    }

    /**
     * {@inheritDoc}
     */
    public function getImage() {
        return $this->image;
    }

    /**
     * {@inheritDoc}
     */
    public function getName() {
        return trim($this->first_name . ' ' . $this->last_name);
    }

    /**
     * {@inheritDoc}
     */
    public function getEmail() {
        return $this->email;
    }

    /**
     * {@inheritDoc}
     */
    public function getMobile() {
        return $this->mobile;
    }

    /**
     * {@inheritDoc}
     */
    public static function findIdentities() {
        return static::find()->all();
    }
}

After creating this class define it as identity class in your application configuration:

'components' => [
    'user' => [
        'identityClass' => 'app\models\User'
    ]
]

Configure jQuery UI (optional)

If you don't use jQuery UI somewhere else in your application, you can minify the load by just load the needed scripts:

'components' => [
    'assetManager' => [
        'bundles' => [
            'yii\jui\JuiAsset' => [
                'css' => [],
                'js' => [
                    'ui/data.js',
                    'ui/scroll-parent.js',
                    'ui/widget.js',
                    'ui/widgets/mouse.js',
                    'ui/widgets/sortable.js',
                ],
                'publishOptions' => [
                    'only' => [
                        'ui/*',
                        'ui/widgets/*'
                    ]
                ]
            ]
        ]
    ]
]

Notice: If you use the full jquery ui package, the bootstrap tooltip used by this module gets overridden by jui tooltip

Example Usage

Now you can access the kanban module by navigating to /kanban.

Notice: Some of the actions can only be done as authenticated (logged in) user like creating boards, buckets etc.

License

yii2-kanban is released under MIT license. See bundled LICENSE for details.