vgtechs/yii2-kanban

yii2 的看板模块

安装: 2

依赖: 0

建议者: 0

安全: 0

星标: 0

关注者: 0

分支: 11

类型:yii2-extension

1.10.1 2021-08-26 13:34 UTC

README

Latest Stable Version Total Downloads License

资源

安装

安装此扩展的首选方式是通过 composer

运行以下命令之一:

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

或者添加以下内容到你的 composer.jsonrequire 部分:

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

使用方法

为了使用此模块,你需要

  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 将会自动定义。

事件

创建身份

创建一个实现 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 提示会被 jui 提示覆盖

示例用法

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

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

许可证

yii2-kanban 根据 MIT 许可证发布。有关详细信息,请参阅附带的 LICENSE