guavacz / filament-drafts Goto Github PK
View Code? Open in Web Editor NEWA filament plugin that adds the ability to manage drafts and revisions of your models.
License: MIT License
A filament plugin that adds the ability to manage drafts and revisions of your models.
License: MIT License
I can created posts, publish/unpublish them etc. but the other revisions would not show up. Sometimes it also triggers an error if click on draft action on a published model.
Flare error page: https://flareapp.io/share/J7orBnxP#F59
Here is a screen-recording of the issue
Pages---MortgageCS Admin.webm
Lets add support for filament v3.
I will send the PR, just need to know if there is anyone already working on v3 support? @LukasFreyCZ
For some reason the table actions for draft/revisions table would not work. I have tried to add them separately and also tried to allow user to pass those actions but nothing works.
The work around for me was to use Tabs on ListRecord pages to filter records. This allowed the usage of existing actions. Other benefit of using tabs is:
list-draftable-records
view file and the livewire components it loadsThe code we need:
use Illuminate\Database\Eloquent\Builder;
use Filament\Resources\Pages\ListRecords\Tab;
public function getTabs(): array
{
return [
'all' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->withoutDrafts()),
'drafts' => Tab::make()
->modifyQueryUsing(fn (Builder $query) => $query->onlyDrafts()->where('is_current', true)),
];
}
@LukasFreyCZ I am planning to send this Pull request. I need to hear your thoughts.
Thanks :)
So field published_at does not update after I published draft record, if I am publishing within creation it updates but in case when record exist and it draft it doesn't
Hi,
i found a couple of issues if used in tandem with filament-nested-resources.
protected function handleRecordCreation(array $data): Model
{
$record = new ($this->getRelation()->getRelated())([
...$data,
'is_published' => !$this->shouldSaveAsDraft,
]);
if ($owner = $this->getOwnerRecord()) {
$record = $this->associateRecordWithParent($record, $owner);
}
if (
($tenant = Filament::getTenant())
) {
return $this->associateRecordWithTenant($record, $tenant);
}
$record->withoutRevision()->save();
return $record;
}
CreateRelatedRecord
as well as CreateRecord
, i think even if you don't want to change the behaviour here it should throw an exception if its neither an instance of EditRecord nor CreateRecord.protected function draft(): void
{
$livewire = $this->getLivewire();
$livewire->shouldSaveAsDraft = true;
if ($livewire instanceof EditRecord) {
$livewire->save();
return;
}
$livewire->create(); // don't know the side effects of just using create if it's not an instance of EditRecord but will see
}
I'll update this issue as i find more.
When i try to edit a Model. I trigger an error.
Description:
After adding the traits to all the resource pages I am getting the following error.
Note: It's happening because of Filament Translatable plugin.
Trait method Guava\FilamentDrafts\Admin\Resources\Pages\Create\Draftable::handleRecordCreation has not been applied as App\Filament\Resources\DeveloperResource\Pages\CreateDeveloper::handleRecordCreation, because of collision with Filament\Resources\Pages\CreateRecord\Concerns\Translatable::handleRecordCreation
Environment:
Possible Solution:
To resolve the collision, consider renaming one of the conflicting methods..
how to add a button to delete revisions?
belongsToMany, hasMany, MorphMany not been loaded on my edit form
Great package, works like a charm.
A humble/request: Is it possible to provide a way to extend or modify the table query for drafts table?
I added into laravel/framework 9 / filament/filamen 2 app guava/filament-drafts 1.2
but after I added
HasDrafts
to one of my models, I got error in app init seeder :
2023_03_21_145712_create_page_contents_table .................... 952ms FAIL
TypeError
Oddvalue\LaravelDrafts\LaravelDrafts::getCurrentUser(): Return value must be of type Illuminate\Contracts\Auth\Authenticatable, null returned
at vendor/oddvalue/laravel-drafts/src/LaravelDrafts.php:15
11▕ protected bool $withDrafts = false;
12▕
13▕ public function getCurrentUser(): Authenticatable
14▕ {
➜ 15▕ return Auth::guard(config('drafts.auth.guard'))->user();
16▕ }
17▕
18▕ public function previewMode(bool $previewMode = true): void
19▕ {
+10 vendor frames
11 database/seeders/pageContentsWithInitData.php:52
App\Models\PageContent::save()
I supposed it was raised as seeders has no current logged user.
Any hint how this issue could be salved? Say, to turn off HasDrafts functionality temporary?
Telling the true I do not need HasDrafts functionality when data are inserted from seeder on app init...
Hello. Great package, enjoying it so far, but on some of my multi lingual assets when using both Translatable and Draftable traits on the same EditRecord class - there is a collision error.
Code -
<?php
namespace App\Filament\Resources\PillarResource\Pages;
use App\Filament\Resources\PillarResource;
use Filament\Actions;
use Filament\Resources\Pages\EditRecord;
use Guava\FilamentDrafts\Admin\Resources\Pages\Edit\Draftable;
class EditPillar extends EditRecord
{
use EditRecord\Concerns\Translatable;
use Draftable;
protected static string $resource = PillarResource::class;
protected function getHeaderActions(): array
{
return [
Actions\DeleteAction::make(),
Actions\LocaleSwitcher::make(),
];
}
}
Results in Trait method Guava\FilamentDrafts\Admin\Resources\Pages\Edit\Draftable::handleRecordUpdate has not been applied as App\Filament\Resources\PillarResource\Pages\EditPillar::handleRecordUpdate, because of collision with Filament\Resources\Pages\EditRecord\Concerns\Translatable::handleRecordUpdate
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.