Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding AdjacencyListWidget #32

Merged
merged 47 commits into from
Aug 26, 2024
Merged

Adding AdjacencyListWidget #32

merged 47 commits into from
Aug 26, 2024

Conversation

cheesegrits
Copy link
Collaborator

Adding a widget, plus a few bug fixes.

cheesegrits and others added 30 commits December 20, 2023 22:06
Bumps [ramsey/composer-install](https://github.com/ramsey/composer-install) from 2 to 3.
- [Release notes](https://github.com/ramsey/composer-install/releases)
- [Commits](ramsey/composer-install@v2...v3)

---
updated-dependencies:
- dependency-name: ramsey/composer-install
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 1.6.0 to 2.1.0.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](dependabot/fetch-metadata@v1.6.0...v2.1.0)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
…ey/composer-install-3

chore(deps): bump ramsey/composer-install from 2 to 3
…ndabot/fetch-metadata-2.1.0

chore(deps): bump dependabot/fetch-metadata from 1.6.0 to 2.1.0
# Conflicts:
#	README.md
# Conflicts:
#	README.md
#	resources/dist/filament-adjacency-list.css
#	resources/dist/filament-adjacency-list.js
#	resources/js/index.js
#	resources/views/builder.blade.php
#	resources/views/components/item.blade.php
Bumps [dependabot/fetch-metadata](https://github.com/dependabot/fetch-metadata) from 2.1.0 to 2.2.0.
- [Release notes](https://github.com/dependabot/fetch-metadata/releases)
- [Commits](dependabot/fetch-metadata@v2.1.0...v2.2.0)

---
updated-dependencies:
- dependency-name: dependabot/fetch-metadata
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
…ndabot/fetch-metadata-2.2.0

chore(deps): bump dependabot/fetch-metadata from 2.1.0 to 2.2.0
@saade
Copy link
Owner

saade commented Aug 23, 2024

Hey! Thanks for the PR and sorry for the delay on reviewing it.

I've made some changes so the code became more cleaner and customizable, please, lmk wyt.

1. A new customization aproach.

Instead of defining each method again and hard coding the component on the form, users can now use the adjacencyList method to customize the widget. The usage follows the same way that Filament uses to configure its form, table and infolist.

class MyWidget extends AdjacencyListWidget {

    protected function adjacencyList(AdjacencyList $adjacencyList): AdjacencyList {
        return $adjacencyList
            ->label('Foo')
            ->editable()
            ->labelKey('nombre')
            ->childrenKey('hijos');
    }

}

2. Item actions and url

Instead of using the isClickable aproach, users can now customize which action is triggered when clicking on an item, or instead define a url to be opened. This follows the same aproach as Filament's table ->recordAction and ->recordUrl methods.

class MyWidget extends AdjacencyListWidget {

    protected function adjacencyList(AdjacencyList $adjacencyList): AdjacencyList {
        return $adjacencyList
            ->itemAction('edit') // or view, delete, moveUp, indent etc ...
            ->itemUrl(
               fn (array $item) => YourResource::getUrl('view', ['record' => $item['id']]) // for example
           )
    }

}

3. Miscellaneous

  • In an effort to align with Filament's theming methodology you will need to use a custom theme to use this plugin. This is the right way of doing it and it solves the problem we're facing earlier.

  • Fixed item gap when not using rules

Let me know what you think!

@saade saade merged commit 2384f5d into saade:3.2 Aug 26, 2024
1 check passed
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants