Skip to content

Commit

Permalink
[5.x] Add UI for listing field sortable config (#10259)
Browse files Browse the repository at this point in the history
Co-authored-by: Jason Varga <[email protected]>
  • Loading branch information
ryanmitchell and jasonvarga authored Jun 25, 2024
1 parent b9cad86 commit 055f752
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions resources/lang/en/messages.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
'fields_instructions_instructions' => 'Provide additional field instructions like this very text. Markdown formatting is supported.',
'fields_instructions_position_instructions' => 'Show instructions above or below the field.',
'fields_listable_instructions' => 'Control the listing column visibility.',
'fields_sortable_instructions' => 'Control if the field should be sortable in listing views.',
'fields_visibility_instructions' => 'Control field visibility on publish forms.',
'fields_replicator_preview_instructions' => 'Control preview visibility in Replicator/Bard sets.',
'fieldset_import_fieldset_instructions' => 'The fieldset to be imported.',
Expand Down
6 changes: 6 additions & 0 deletions src/Fields/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,12 @@ public static function commonFieldOptions(): Fields
'type' => 'section',
],
],
'sortable' => [
'display' => __('Sortable'),
'instructions' => __('statamic::messages.fields_sortable_instructions'),
'type' => 'toggle',
'default' => true,
],
'visibility' => [
'display' => __('Visibility'),
'instructions' => __('statamic::messages.fields_visibility_instructions'),
Expand Down
4 changes: 4 additions & 0 deletions tests/Fields/BlueprintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo
'instructions' => 'One instructions',
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down Expand Up @@ -469,6 +470,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo
'instructions' => 'Two instructions',
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down Expand Up @@ -557,6 +559,7 @@ public function converts_to_array_suitable_for_rendering_prefixed_conditional_fi
'instructions' => null,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand All @@ -582,6 +585,7 @@ public function converts_to_array_suitable_for_rendering_prefixed_conditional_fi
'instructions' => null,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down
1 change: 1 addition & 0 deletions tests/Fields/FieldTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ public function preProcess($data)
'instructions' => 'Test instructions',
'instructions_position' => 'below',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down
4 changes: 4 additions & 0 deletions tests/Fields/FieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo
'hide_display' => false,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'replicator_preview' => true,
'duplicate' => true,
],
Expand All @@ -453,6 +454,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo
'hide_display' => false,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'replicator_preview' => true,
'duplicate' => true,
],
Expand Down Expand Up @@ -517,6 +519,7 @@ public function converts_to_array_suitable_for_rendering_prefixed_conditional_fi
'hide_display' => false,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'replicator_preview' => true,
'duplicate' => true,
],
Expand All @@ -542,6 +545,7 @@ public function converts_to_array_suitable_for_rendering_prefixed_conditional_fi
'hide_display' => false,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'replicator_preview' => true,
'duplicate' => true,
],
Expand Down
2 changes: 2 additions & 0 deletions tests/Fields/SectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo
'instructions' => 'One instructions',
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand All @@ -147,6 +148,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo
'instructions' => 'Two instructions',
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down
2 changes: 2 additions & 0 deletions tests/Fields/TabTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo
'instructions' => 'One instructions',
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand All @@ -172,6 +173,7 @@ public function converts_to_array_suitable_for_rendering_fields_in_publish_compo
'instructions' => 'Two instructions',
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down
1 change: 1 addition & 0 deletions tests/Fieldtypes/NestedFieldsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public function preProcess($data)
'instructions' => 'Some instructions',
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down
3 changes: 3 additions & 0 deletions tests/Fieldtypes/SetsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ public function it_preprocesses_for_config_with_groups()
'instructions' => null,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down Expand Up @@ -255,6 +256,7 @@ public function it_preprocesses_for_config_with_groups()
'instructions' => null,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down Expand Up @@ -314,6 +316,7 @@ public function it_preprocesses_for_config_without_groups()
'instructions' => null,
'instructions_position' => 'above',
'listable' => 'hidden',
'sortable' => true,
'visibility' => 'visible',
'replicator_preview' => true,
'duplicate' => true,
Expand Down

0 comments on commit 055f752

Please sign in to comment.