-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AIDAPP-372]: Introduce sub categories that can be created and applie…
…d to knowledge base articles (#351) * [AIDAPP-372]: Introduce sub categories that can be created and applied to knowledge base articles * added testcase * added testcases for create a subcategory * chore: fix enforcement of copyright on all files * Fix permissions in some tests Signed-off-by: Kevin Ullyott <[email protected]> * Enhance tests for creating subcategories by adding necessary permissions and assertions Signed-off-by: Kevin Ullyott <[email protected]> * Remove display of parent category on the view page Signed-off-by: Kevin Ullyott <[email protected]> * Fix modal to use an info list Signed-off-by: Kevin Ullyott <[email protected]> --------- Signed-off-by: Kevin Ullyott <[email protected]> Co-authored-by: payal-canyon <[email protected]> Co-authored-by: Kevin Ullyott <[email protected]>
- Loading branch information
1 parent
1041cfb
commit 5b32e86
Showing
10 changed files
with
447 additions
and
4 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
...atabase/migrations/2024_12_10_084809_add_parent_id_to_knowledge_base_categories_table.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
/* | ||
<COPYRIGHT> | ||
Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. | ||
Aiding App™ is licensed under the Elastic License 2.0. For more details, | ||
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.> | ||
Notice: | ||
- You may not provide the software to third parties as a hosted or managed | ||
service, where the service provides users with access to any substantial set of | ||
the features or functionality of the software. | ||
- You may not move, change, disable, or circumvent the license key functionality | ||
in the software, and you may not remove or obscure any functionality in the | ||
software that is protected by the license key. | ||
- You may not alter, remove, or obscure any licensing, copyright, or other notices | ||
of the licensor in the software. Any use of the licensor’s trademarks is subject | ||
to applicable law. | ||
- Canyon GBS LLC respects the intellectual property rights of others and expects the | ||
same in return. Canyon GBS™ and Aiding App™ are registered trademarks of | ||
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks | ||
vigorously. | ||
- The software solution, including services, infrastructure, and code, is offered as a | ||
Software as a Service (SaaS) by Canyon GBS LLC. | ||
- Use of this software implies agreement to the license terms and conditions as stated | ||
in the Elastic License 2.0. | ||
For more information or inquiries please visit our website at | ||
<https://www.canyongbs.com> or contact us via email at legal@canyongbs.com. | ||
</COPYRIGHT> | ||
*/ | ||
|
||
use Illuminate\Support\Facades\Schema; | ||
use Illuminate\Database\Schema\Blueprint; | ||
use Illuminate\Database\Migrations\Migration; | ||
|
||
return new class () extends Migration { | ||
public function up(): void | ||
{ | ||
Schema::table('knowledge_base_categories', function (Blueprint $table) { | ||
$table->foreignUuid('parent_id')->nullable()->constrained('knowledge_base_categories'); | ||
}); | ||
} | ||
|
||
public function down(): void | ||
{ | ||
Schema::table('knowledge_base_categories', function (Blueprint $table) { | ||
$table->dropConstrainedForeignId('parent_id'); | ||
}); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
154 changes: 154 additions & 0 deletions
154
...Resources/KnowledgeBaseCategoryResource/RelationManagers/SubCategoriesRelationManager.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
<?php | ||
|
||
/* | ||
<COPYRIGHT> | ||
Copyright © 2016-2024, Canyon GBS LLC. All rights reserved. | ||
Aiding App™ is licensed under the Elastic License 2.0. For more details, | ||
see <https://github.com/canyongbs/aidingapp/blob/main/LICENSE.> | ||
Notice: | ||
- You may not provide the software to third parties as a hosted or managed | ||
service, where the service provides users with access to any substantial set of | ||
the features or functionality of the software. | ||
- You may not move, change, disable, or circumvent the license key functionality | ||
in the software, and you may not remove or obscure any functionality in the | ||
software that is protected by the license key. | ||
- You may not alter, remove, or obscure any licensing, copyright, or other notices | ||
of the licensor in the software. Any use of the licensor’s trademarks is subject | ||
to applicable law. | ||
- Canyon GBS LLC respects the intellectual property rights of others and expects the | ||
same in return. Canyon GBS™ and Aiding App™ are registered trademarks of | ||
Canyon GBS LLC, and we are committed to enforcing and protecting our trademarks | ||
vigorously. | ||
- The software solution, including services, infrastructure, and code, is offered as a | ||
Software as a Service (SaaS) by Canyon GBS LLC. | ||
- Use of this software implies agreement to the license terms and conditions as stated | ||
in the Elastic License 2.0. | ||
For more information or inquiries please visit our website at | ||
<https://www.canyongbs.com> or contact us via email at legal@canyongbs.com. | ||
</COPYRIGHT> | ||
*/ | ||
|
||
namespace AidingApp\KnowledgeBase\Filament\Resources\KnowledgeBaseCategoryResource\RelationManagers; | ||
|
||
use Filament\Forms\Form; | ||
use Filament\Tables\Table; | ||
use Filament\Infolists\Infolist; | ||
use Filament\Forms\Components\Textarea; | ||
use Filament\Tables\Actions\EditAction; | ||
use Filament\Tables\Actions\ViewAction; | ||
use Filament\Tables\Columns\IconColumn; | ||
use Filament\Forms\Components\TextInput; | ||
use Filament\Tables\Actions\ActionGroup; | ||
use Filament\Tables\Actions\CreateAction; | ||
use Filament\Tables\Actions\DeleteAction; | ||
use Illuminate\Database\Eloquent\Builder; | ||
use Filament\Infolists\Components\Section; | ||
use Filament\Infolists\Components\TextEntry; | ||
use Filament\Tables\Actions\AssociateAction; | ||
use Filament\Tables\Actions\BulkActionGroup; | ||
use App\Filament\Forms\Components\IconSelect; | ||
use Filament\Tables\Actions\DeleteBulkAction; | ||
use Filament\Tables\Actions\DissociateAction; | ||
use Filament\Tables\Actions\DissociateBulkAction; | ||
use App\Filament\Tables\Columns\OpenSearch\TextColumn; | ||
use Filament\Resources\RelationManagers\RelationManager; | ||
use AidingApp\KnowledgeBase\Models\KnowledgeBaseCategory; | ||
|
||
class SubCategoriesRelationManager extends RelationManager | ||
{ | ||
protected static string $relationship = 'subCategories'; | ||
|
||
protected static ?string $inverseRelationship = 'parentCategory'; | ||
|
||
public function infolist(Infolist $infolist): Infolist | ||
{ | ||
return $infolist | ||
->schema([ | ||
Section::make() | ||
->schema([ | ||
TextEntry::make('name') | ||
->label('Name'), | ||
TextEntry::make('icon') | ||
->state(fn (KnowledgeBaseCategory $record): string => (string) str($record->icon)->after('heroicon-o-')->headline()) | ||
->icon(fn (KnowledgeBaseCategory $record): string => $record->icon) | ||
->hidden(fn (KnowledgeBaseCategory $record): bool => blank($record->icon)), | ||
TextEntry::make('description') | ||
->label('Description') | ||
->columnSpanFull(), | ||
TextEntry::make('slug') | ||
->hidden(fn (KnowledgeBaseCategory $record): bool => blank($record->slug)), | ||
]) | ||
->columns(), | ||
]); | ||
} | ||
|
||
public function form(Form $form): Form | ||
{ | ||
return $form | ||
->schema([ | ||
TextInput::make('name') | ||
->label('Name') | ||
->required() | ||
->string(), | ||
IconSelect::make('icon'), | ||
TextInput::make('slug') | ||
->regex('/^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/') | ||
->unique(ignoreRecord: true) | ||
->maxLength(255) | ||
->required() | ||
->dehydrateStateUsing(fn (string $state): string => strtolower($state)), | ||
Textarea::make('description') | ||
->label('Description') | ||
->nullable() | ||
->string() | ||
->columnSpanFull(), | ||
]); | ||
} | ||
|
||
public function table(Table $table): Table | ||
{ | ||
return $table | ||
->recordTitleAttribute('name') | ||
->heading('Subcategories') | ||
->columns([ | ||
TextColumn::make('name'), | ||
TextColumn::make('slug'), | ||
IconColumn::make('icon') | ||
->icon(fn (string $state): string => $state) | ||
->tooltip(fn (?string $state): ?string => filled($state) ? (string) str($state)->after('heroicon-o-')->headline() : null), | ||
]) | ||
->headerActions([ | ||
CreateAction::make() | ||
->label('New Subcategory') | ||
->modalHeading('Create knowledge base subcategory'), | ||
AssociateAction::make() | ||
->modalHeading('Associate knowledge base subcategory') | ||
->preloadRecordSelect() | ||
->recordSelectOptionsQuery( | ||
fn (Builder $query) => $query->where('id', '!=', $this->getOwnerRecord()->getKey()) | ||
->doesntHave('parentCategory') | ||
->doesntHave('subCategories') | ||
), | ||
]) | ||
->actions([ | ||
ActionGroup::make([ | ||
ViewAction::make(), | ||
EditAction::make(), | ||
DissociateAction::make(), | ||
DeleteAction::make(), | ||
]), | ||
]) | ||
->bulkActions([ | ||
BulkActionGroup::make([ | ||
DissociateBulkAction::make(), | ||
DeleteBulkAction::make(), | ||
]), | ||
]); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.