simialbi/yii2-kanban

yii2 的看板模块

安装次数: 1,064

依赖项: 1

建议者: 0

安全: 0

星标: 10

关注者: 7

分支: 11

开放问题: 0

类型:yii2-extension

2.3.0 2022-02-09 11:00 UTC

README

Latest Stable Version Total Downloads License build

资源

安装

安装此扩展的首选方法是使用 composer

运行以下命令

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

或者在您的 composer.json 文件的 require 部分添加

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

to

使用方法

为了使用此模块,您需要

  1. 配置模块 以使模块可用。
  2. 创建一个扩展 UserInterface 的用户身份

配置模块

在您的 Yii 配置文件的模块部分配置模块。

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

参数

注意:如果未定义,将自动定义状态 Task::STATUS_NOT_BEGUNTask::STATUS_DONETASK::STATUS_LATE

事件

设置控制台配置并应用迁移

使用以下命令应用迁移: yii migrate --migration-namespaces='simialbi\yii2\kanban\migrations' 或配置您的控制台如下

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

然后应用 yii migrate 命令。

创建身份

创建一个实现 simialbi\yii2\models\UserInterface 的身份类,例如。

<?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();
    }
}

创建此类后,在您的应用程序配置中将它定义为身份类

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

配置 jQuery UI(可选)

如果您在您的应用程序的其他地方没有使用 jQuery UI,您可以仅通过加载所需的脚本来减少加载量

'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/*'
                    ]
                ]
            ]
        ]
    ]
]

注意:如果您使用完整的 jQuery UI 包,此模块使用的 bootstrap tooltip 将被 jui tooltip 覆盖

示例用法

现在您可以通过导航到 /kanban 访问看板模块。

注意:某些操作只能由认证(登录)用户执行,例如创建看板、桶等。

许可证

yii2-kanban 在 MIT 许可证下发布。有关详细信息,请参阅捆绑的 LICENSE