invaders-xx/filament-kanban-board 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

invaders-xx/filament-kanban-board

Composer 安装命令:

composer require invaders-xx/filament-kanban-board

包简介

Add a Kanban page to filament

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Define a Kanban page within your Filament's application. It can be a page or a resource's page. image

Installation

You can install the package via composer:

composer require invaders-xx/filament-kanban-board

You can publish the config file with:

php artisan vendor:publish --tag="filament-kanban-board-config"

This is the contents of the published config file:

return [
];

Optionally, you can publish the views using

php artisan vendor:publish --tag="filament-kanban-board-views"

You can also specify your own view for record content to change the behaviour:

public string $recordContentView = 'filament-kanban-board::record-content';

in your class to add more content to your kanban's boxes.

You can define your own styles for each element of the Kanban:

protected function styles(): array
{
    return [
        'wrapper' => 'w-full h-full flex space-x-4 overflow-x-auto',
        'kanbanWrapper' => 'h-full flex-1',
        'kanban' => 'bg-primary-200 rounded px-2 flex flex-col h-full',
        'kanbanHeader' => 'p-2 text-sm text-gray-900',
        'kanbanFooter' => '',
        'kanbanRecords' => 'space-y-2 p-2 flex-1 overflow-y-auto',
        'record' => 'shadow bg-white dark:bg-gray-800 p-2 rounded border',
        'recordContent' => 'w-full',
    ];
}

Usage

In order to use this component, you must create a new Filament Page that extends from FilamentKanbanBoard

class KanbanOrders extends FilamentKanbanBoard
{
    protected function statuses() : Collection
    {
        return collect([
            [
                'id' => 'registered',
                'title' => 'Registered',
            ],
            [
                'id' => 'awaiting_confirmation',
                'title' => 'Awaiting Confirmation',
            ],
            [
                'id' => 'confirmed',
                'title' => 'Confirmed',
            ],
            [
                'id' => 'delivered',
                'title' => 'Delivered',
            ],
        ]);
    }
}

For each status we define, we must return an array with at least 2 keys: id and title.

Now, for records() we may define a list of Sales Orders that come from an Eloquent model in your project.

protected function records() : Collection
{
    return SalesOrder::all()
        ->map(function (SalesOrder $item) {
            return [
                'id' => $item->id,
                'title' => $item->customer->name,
                'status' => $item->status,
            ];
        });
}

As you might see in the above snippet, we must return a collection of array items where each item must have at least 3 keys: id, title and status. The last one is of most importance since it is going to be used to match to which status the record belongs to. For this matter, the component matches status and records with the following comparison.

$status['id'] == $record['status'];

if you need to use this page within a Filament's resource, add the route function definition to the class:

public static function route(string $path): array
{
    return [
        'class' => static::class,
        'route' => $path,
    ];
}

Sorting and Dragging

By default, sorting and dragging between statuses is disabled. To enable it, set in your class:

public bool $sortable = true;
public bool $sortableBetweenStatuses = true;

Behavior and Interactions

When sorting and dragging is enabled, your component can be notified when any of these events occur. The callbacks triggered by these two events are onStatusSorted and onStatusChanged

On onStatusSorted you are notified about which record has changed position within it's status. You are also given a $orderedIds array which holds the ids of the records after being sorted. You must override the following method to get notified on this change.

public function onStatusSorted($recordId, $statusId, $orderedIds)
{
    //   
}

On onStatusChanged gets triggered when a record is moved to another status. In this scenario, you get notified about the record that was changed, the new status, the ordered ids from the previous status and the ordered ids of the new status the record in entering. To be notified about this event, you must override the following method:

public function onStatusChanged($recordId, $statusId, $fromOrderedIds, $toOrderedIds)
{
    //
}

onStatusSorted and onStatusChanged are never triggered simultaneously. You'll get notified of one or the other when an interaction occurs.

You can also get notified when a record in the status board is clicked via the onRecordClick event

public function onRecordClick($recordId)
{
    //
}

To enable onRecordClick set it in the class:

public bool $recordClickEnabled = true;

Editing records in Modal window

You can enable Modal window to edit records:

Make sure to have $recordClickEnabled set to true and $modalRecordClickEnabled set to true:

public bool $recordClickEnabled = true;
public bool $modalRecordClickEnabled = true;

You can set modal title, width, save / cancel button labels:

protected string $editModalRecordTitle = 'Edit modal record title';
protected string $editModalRecordWidth = '2xl';
public string $editModalSaveButtonLabel = "Save";
public string $editModalCancelButtonLabel = "Cancel";

You can set Form components by overriding function getEditModalRecordSchema():

protected static function getEditModalRecordSchema(): array
    {
        return [
            TextInput::make('title'),
            TextInput::make('status'),
        ];
    }

To call Modal with Form override onRecordClick() function and add the following:

public function onRecordClick($recordId, $data): void
    {
        $this->editModalRecord->fill($data);
        $this->dispatchBrowserEvent('open-modal', ['id' => 'kanban--edit-modal-record']);
    }

To manipulate with data from the Modal Form override editRecord() function:

public function editRecord(array $data): void
    {

    }

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

invaders-xx/filament-kanban-board 适用场景与选型建议

invaders-xx/filament-kanban-board 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 17.18k 次下载、GitHub Stars 达 76, 最近一次更新时间为 2022 年 06 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「laravel」 「filament」 「invaders-xx」 「filament-kanban-board」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 invaders-xx/filament-kanban-board 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 invaders-xx/filament-kanban-board 我们能提供哪些服务?
定制开发 / 二次开发

基于 invaders-xx/filament-kanban-board 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 17.18k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 76
  • 点击次数: 18
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 76
  • Watchers: 1
  • Forks: 15
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-08