Skip to content

Commit

Permalink
feat(filament): added image editor (#689)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyrch authored Jun 4, 2024
1 parent 9f0a6a3 commit 09f91ca
Show file tree
Hide file tree
Showing 74 changed files with 495 additions and 481 deletions.
2 changes: 2 additions & 0 deletions app/Filament/Actions/Models/Wiki/AttachImageAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function getForm(Form $form): Form
$fields[] = FileUpload::make($facet->name)
->label($facet->localize())
->image()
->imageEditor()
->imageEditorAspectRatios([null, '2:3'])
->storeFiles(false);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public function getForm(Form $form): Form
$fields[] = FileUpload::make($facet->name)
->label($facet->localize())
->image()
->imageEditor()
->imageEditorAspectRatios([null, '2:3'])
->storeFiles(false);
}
}
Expand Down
26 changes: 18 additions & 8 deletions app/Filament/Resources/Admin/Announcement.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public static function getNavigationIcon(): string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getSlug(): string
public static function getRecordSlug(): string
{
return static::getDefaultSlug().'announcements';
return 'announcements';
}

/**
Expand Down Expand Up @@ -144,12 +144,7 @@ public static function table(Table $table): Table
->sortable()
->searchable()
->copyableWithMessage(),
])
->defaultSort(AnnouncementModel::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->actions(static::getActions())
->bulkActions(static::getBulkActions());
]);
}

/**
Expand Down Expand Up @@ -240,6 +235,21 @@ public static function getBulkActions(): array
);
}

/**
* Get the header actions available for the resource.
*
* @return array
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getHeaderActions(): array
{
return array_merge(
parent::getHeaderActions(),
[],
);
}

/**
* Get the pages available for the resource.
*
Expand Down
12 changes: 3 additions & 9 deletions app/Filament/Resources/Admin/Dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public static function getNavigationIcon(): string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getSlug(): string
public static function getRecordSlug(): string
{
return static::getDefaultSlug().'dumps';
return 'dumps';
}

/**
Expand Down Expand Up @@ -150,13 +150,7 @@ public static function table(Table $table): Table
->sortable()
->searchable()
->copyableWithMessage(),
])
->defaultSort(DumpModel::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->actions(static::getActions())
->bulkActions(static::getBulkActions())
->headerActions(static::getHeaderActions());
]);
}

/**
Expand Down
26 changes: 18 additions & 8 deletions app/Filament/Resources/Admin/Feature.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ public static function getNavigationIcon(): string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getSlug(): string
public static function getRecordSlug(): string
{
return static::getDefaultSlug().'features';
return 'features';
}

/**
Expand Down Expand Up @@ -157,12 +157,7 @@ public static function table(Table $table): Table
->label(__('filament.fields.feature.value.name'))
->sortable()
->copyableWithMessage(),
])
->defaultSort(FeatureModel::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->actions(static::getActions())
->bulkActions(static::getBulkActions());
]);
}

/**
Expand Down Expand Up @@ -252,6 +247,21 @@ public static function getBulkActions(): array
);
}

/**
* Get the header actions available for the resource.
*
* @return array
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getHeaderActions(): array
{
return array_merge(
parent::getHeaderActions(),
[],
);
}

/**
* Get the pages available for the resource.
*
Expand Down
26 changes: 18 additions & 8 deletions app/Filament/Resources/Admin/FeaturedTheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ public static function getNavigationIcon(): string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getSlug(): string
public static function getRecordSlug(): string
{
return static::getDefaultSlug().'featured-themes';
return 'featured-themes';
}

/**
Expand Down Expand Up @@ -262,12 +262,7 @@ public static function table(Table $table): Table
->toggleable()
->placeholder('-')
->urlToRelated(UserResource::class, FeaturedThemeModel::RELATION_USER),
])
->defaultSort(FeaturedThemeModel::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->actions(static::getActions())
->bulkActions(static::getBulkActions());
]);
}

/**
Expand Down Expand Up @@ -376,6 +371,21 @@ public static function getBulkActions(): array
);
}

/**
* Get the header actions available for the resource.
*
* @return array
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getHeaderActions(): array
{
return array_merge(
parent::getHeaderActions(),
[],
);
}

/**
* Get the pages available for the resource.
*
Expand Down
26 changes: 18 additions & 8 deletions app/Filament/Resources/Auth/Permission.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ public static function getNavigationIcon(): string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getSlug(): string
public static function getRecordSlug(): string
{
return static::getDefaultSlug().'permissions';
return 'permissions';
}

/**
Expand Down Expand Up @@ -151,12 +151,7 @@ public static function table(Table $table): Table
->sortable()
->searchable()
->copyableWithMessage(),
])
->defaultSort(PermissionModel::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->actions(static::getActions())
->bulkActions(static::getBulkActions());
]);
}

/**
Expand Down Expand Up @@ -257,6 +252,21 @@ public static function getBulkActions(): array
);
}

/**
* Get the header actions available for the resource.
*
* @return array
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getHeaderActions(): array
{
return array_merge(
parent::getHeaderActions(),
[],
);
}

/**
* Get the pages available for the resource.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ public function table(Table $table): Table
->recordTitleAttribute(Role::ATTRIBUTE_NAME)
->inverseRelationship(Role::RELATION_PERMISSIONS)
->columns(RoleResource::table($table)->getColumns())
->defaultSort(Role::TABLE.'.'.Role::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->headerActions(static::getHeaderActions())
->actions(static::getActions())
->bulkActions(static::getBulkActions());
->defaultSort(Role::TABLE.'.'.Role::ATTRIBUTE_ID, 'desc');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,7 @@ public function table(Table $table): Table
->recordTitleAttribute(User::ATTRIBUTE_NAME)
->inverseRelationship(User::RELATION_PERMISSIONS)
->columns(UserResource::table($table)->getColumns())
->defaultSort(User::TABLE.'.'.User::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->headerActions(static::getHeaderActions())
->actions(static::getActions())
->bulkActions(static::getBulkActions());
->defaultSort(User::TABLE.'.'.User::ATTRIBUTE_ID, 'desc');
}

/**
Expand Down
26 changes: 18 additions & 8 deletions app/Filament/Resources/Auth/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ public static function getNavigationIcon(): string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getSlug(): string
public static function getRecordSlug(): string
{
return static::getDefaultSlug().'roles';
return 'roles';
}

/**
Expand Down Expand Up @@ -193,12 +193,7 @@ public static function table(Table $table): Table
->sortable()
->toggleable()
->placeholder('-'),
])
->defaultSort(RoleModel::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->actions(static::getActions())
->bulkActions(static::getBulkActions());
]);
}

/**
Expand Down Expand Up @@ -318,6 +313,21 @@ public static function getBulkActions(): array
);
}

/**
* Get the header actions available for the resource.
*
* @return array
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getHeaderActions(): array
{
return array_merge(
parent::getHeaderActions(),
[],
);
}

/**
* Get the pages available for the resource.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ public function table(Table $table): Table
->recordTitleAttribute(Permission::ATTRIBUTE_NAME)
->inverseRelationship(Permission::RELATION_ROLES)
->columns(PermissionResource::table($table)->getColumns())
->defaultSort(Permission::TABLE.'.'.Permission::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->headerActions(static::getHeaderActions())
->actions(static::getActions())
->bulkActions(static::getBulkActions());
->defaultSort(Permission::TABLE.'.'.Permission::ATTRIBUTE_ID, 'desc');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,7 @@ public function table(Table $table): Table
->recordTitleAttribute(User::ATTRIBUTE_NAME)
->inverseRelationship(User::RELATION_ROLES)
->columns(UserResource::table($table)->getColumns())
->defaultSort(User::TABLE.'.'.User::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->headerActions(static::getHeaderActions())
->actions(static::getActions())
->bulkActions(static::getBulkActions());
->defaultSort(User::TABLE.'.'.User::ATTRIBUTE_ID, 'desc');
}

/**
Expand Down
26 changes: 18 additions & 8 deletions app/Filament/Resources/Auth/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ public static function getNavigationIcon(): string
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getSlug(): string
public static function getRecordSlug(): string
{
return static::getDefaultSlug().'users';
return 'users';
}

/**
Expand Down Expand Up @@ -173,12 +173,7 @@ public static function table(Table $table): Table
->label(__('filament.fields.user.email'))
->icon('heroicon-m-envelope')
->toggleable(),
])
->defaultSort(UserModel::ATTRIBUTE_ID, 'desc')
->filters(static::getFilters())
->filtersFormMaxHeight('400px')
->actions(static::getActions())
->bulkActions(static::getBulkActions());
]);
}

/**
Expand Down Expand Up @@ -297,6 +292,21 @@ public static function getBulkActions(): array
);
}

/**
* Get the header actions available for the resource.
*
* @return array
*
* @noinspection PhpMissingParentCallCommonInspection
*/
public static function getHeaderActions(): array
{
return array_merge(
parent::getHeaderActions(),
[],
);
}

/**
* Get the pages available for the resource.
*
Expand Down
Loading

0 comments on commit 09f91ca

Please sign in to comment.