-
Notifications
You must be signed in to change notification settings - Fork 19
Feature/enhancements #57
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
Merged
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
96f15d5
feat: add new feature flags for field enhancements
ManukMinasyan 05f61d7
feat: add auto-generate code from name feature
ManukMinasyan e1bc535
feat: add sections disabled mode with hidden default section
ManukMinasyan c7659cf
feat: add multi-value and unique per entity type settings
ManukMinasyan b752271
feat: refactor email field to use tags input for multi-value support
ManukMinasyan de7aed0
fix: add dark mode support and remove empty state borders
ManukMinasyan b14d37e
feat: add translations for new field settings and empty states
ManukMinasyan 37e71bb
refactor: extract field creation logic to shared trait
ManukMinasyan b1032b5
chore: remove unused getTypeSettings method and import
ManukMinasyan 148372d
feat: add searchable capability to email field type
ManukMinasyan b7d1f79
chore: remove unused fieldmanager variable and import
ManukMinasyan 7aba8d1
refactor: extract shared field management methods to trait
ManukMinasyan cd9e48c
feat: add command to migrate email field values to array format
ManukMinasyan 297c174
refactor: simplify field form layout and hide entity type
ManukMinasyan 56ae025
fix: show all fields when sections disabled regardless of section
ManukMinasyan 499d73e
fix: improve field card density and icon styling
ManukMinasyan 0f9c671
fix: set default max_values when enabling allow_multiple toggle
ManukMinasyan ec790b9
refactor: rename SYSTEM_SECTIONS_DISABLED to UI_FLAT_FIELD_LAYOUT
ManukMinasyan 10697a8
fix: respect flat layout feature flag in form and infolist builders
ManukMinasyan 67297c0
feat: limit unique constraint option to applicable field types
ManukMinasyan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
44 changes: 44 additions & 0 deletions
44
resources/views/livewire/manage-fields-without-sections.blade.php
This file contains hidden or 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,44 @@ | ||
| <div class="flex flex-col gap-y-6"> | ||
| @if(count($this->fields)) | ||
| <div | ||
| x-sortable | ||
| x-sortable-group="fields" | ||
| class="fi-sc fi-sc-has-gap fi-sc-dense fi-grid lg:fi-grid-cols" | ||
| style="--cols-lg: repeat(12, minmax(0, 12fr)); --cols-default: repeat(2, minmax(0, 1fr));" | ||
| @end.stop="$wire.updateFieldsOrder($event.to.sortable.toArray())" | ||
| > | ||
| @foreach ($this->fields as $field) | ||
| @livewire('manage-custom-field', ['field' => $field], key($field->id . $field->width->value . str()->random(16))) | ||
| @endforeach | ||
| </div> | ||
|
|
||
| <div class="flex justify-center"> | ||
| {{ $this->createFieldAction() }} | ||
| </div> | ||
| @else | ||
| <div class="px-6 py-16"> | ||
| <div class="mx-auto grid max-w-md justify-items-center text-center"> | ||
| <div class="fi-ta-empty-state-icon-ctn mb-6 rounded-full bg-primary-50 p-4 dark:bg-primary-950/50"> | ||
| <x-filament::icon | ||
| icon="{{ __('custom-fields::custom-fields.empty_states.fields_no_sections.icon') }}" | ||
| class="fi-ta-empty-state-icon h-8 w-8 text-primary-500 dark:text-primary-400" | ||
| /> | ||
| </div> | ||
|
|
||
| <h3 class="fi-ta-empty-state-heading text-lg font-semibold leading-7 text-gray-950 dark:text-white mb-2"> | ||
| {{ __('custom-fields::custom-fields.empty_states.fields_no_sections.heading') }} | ||
| </h3> | ||
|
|
||
| <p class="fi-ta-empty-state-description text-sm text-gray-600 dark:text-gray-400 mb-6 leading-relaxed"> | ||
| {{ __('custom-fields::custom-fields.empty_states.fields_no_sections.description') }} | ||
| </p> | ||
|
|
||
| <div class="fi-ta-empty-state-action"> | ||
| {{ $this->createFieldAction() }} | ||
| </div> | ||
| </div> | ||
| </div> | ||
| @endif | ||
|
|
||
| <x-filament-actions::modals/> | ||
| </div> |
121 changes: 121 additions & 0 deletions
121
src/Console/Commands/MigrateEmailFieldValuesCommand.php
This file contains hidden or 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,121 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Relaticle\CustomFields\Console\Commands; | ||
|
|
||
| use Illuminate\Console\Command; | ||
| use Illuminate\Support\Facades\DB; | ||
| use Throwable; | ||
|
|
||
| /** | ||
| * Migrates email field values from string_value to json_value format. | ||
| * | ||
| * This command is needed after the EmailFieldType was changed from STRING | ||
| * data type to MULTI_CHOICE, which stores values in json_value as an array. | ||
| */ | ||
| class MigrateEmailFieldValuesCommand extends Command | ||
| { | ||
| protected $signature = 'custom-fields:migrate-email-values | ||
| {--dry-run : Show what would be migrated without making changes} | ||
| {--force : Run without confirmation in production}'; | ||
|
|
||
| protected $description = 'Migrate email field values from string_value to json_value array format'; | ||
|
|
||
| public function handle(): int | ||
| { | ||
| $isDryRun = $this->option('dry-run'); | ||
|
|
||
| if (app()->isProduction() && ! $isDryRun && ! $this->option('force') && ! $this->confirm('You are running in production. Are you sure you want to continue?')) { | ||
| $this->info('Migration cancelled.'); | ||
|
|
||
| return self::SUCCESS; | ||
| } | ||
|
|
||
| $fieldTable = config('custom-fields.database.table_names.custom_fields'); | ||
| $valueTable = config('custom-fields.database.table_names.custom_field_values'); | ||
|
|
||
| // Find all email type custom fields | ||
| $emailFields = DB::table($fieldTable) | ||
| ->where('type', 'email') | ||
| ->pluck('id'); | ||
|
|
||
| if ($emailFields->isEmpty()) { | ||
| $this->info('No email fields found. Nothing to migrate.'); | ||
|
|
||
| return self::SUCCESS; | ||
| } | ||
|
|
||
| $this->info(sprintf('Found %d email field(s).', $emailFields->count())); | ||
|
|
||
| // Find values that need migration (have string_value but no json_value) | ||
| $valuesToMigrate = DB::table($valueTable) | ||
| ->whereIn('custom_field_id', $emailFields) | ||
| ->whereNotNull('string_value') | ||
| ->where('string_value', '!=', '') | ||
| ->where(function ($query): void { | ||
| $query->whereNull('json_value') | ||
| ->orWhere('json_value', '=', '[]') | ||
| ->orWhere('json_value', '=', 'null'); | ||
| }) | ||
| ->get(); | ||
|
|
||
| if ($valuesToMigrate->isEmpty()) { | ||
| $this->info('No email values need migration. All values are already in the correct format.'); | ||
|
|
||
| return self::SUCCESS; | ||
| } | ||
|
|
||
| $this->info(sprintf('Found %d email value(s) to migrate.', $valuesToMigrate->count())); | ||
|
|
||
| if ($isDryRun) { | ||
| $this->warn('Dry run mode - no changes will be made.'); | ||
| $this->newLine(); | ||
|
|
||
| $this->table( | ||
| ['ID', 'Entity Type', 'Entity ID', 'Current Value', 'New Format'], | ||
| $valuesToMigrate->map(fn ($value): array => [ | ||
| $value->id, | ||
| $value->entity_type, | ||
| $value->entity_id, | ||
| $value->string_value, | ||
| json_encode([$value->string_value]), | ||
| ])->toArray() | ||
| ); | ||
|
|
||
| return self::SUCCESS; | ||
| } | ||
|
|
||
| $bar = $this->output->createProgressBar($valuesToMigrate->count()); | ||
| $bar->start(); | ||
|
|
||
| $migrated = 0; | ||
| $errors = 0; | ||
|
|
||
| foreach ($valuesToMigrate as $value) { | ||
| try { | ||
| DB::table($valueTable) | ||
| ->where('id', $value->id) | ||
| ->update([ | ||
| 'json_value' => json_encode([$value->string_value]), | ||
| 'string_value' => null, | ||
| ]); | ||
|
|
||
| $migrated++; | ||
| } catch (Throwable $e) { | ||
| $this->newLine(); | ||
| $this->error(sprintf('Failed to migrate value ID %d: %s', $value->id, $e->getMessage())); | ||
| $errors++; | ||
| } | ||
|
|
||
| $bar->advance(); | ||
| } | ||
|
|
||
| $bar->finish(); | ||
| $this->newLine(2); | ||
|
|
||
| $this->info(sprintf('Migration complete. Migrated: %d, Errors: %d', $migrated, $errors)); | ||
|
|
||
| return $errors > 0 ? self::FAILURE : self::SUCCESS; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.