Skip to content

Commit

Permalink
Add documentation page for EnumColumnType (#99)
Browse files Browse the repository at this point in the history
  • Loading branch information
Kreyu authored Jun 28, 2024
1 parent b90f5a2 commit 29440fd
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/.vitepress/config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default defineConfig({
{ text: 'DateTime', link: '/reference/types/column/date-time' },
{ text: 'DatePeriod', link: '/reference/types/column/date-period' },
{ text: 'Collection', link: '/reference/types/column/collection' },
{ text: 'Enum', link: '/reference/types/column/enum' },
{ text: 'Template', link: '/reference/types/column/template' },
{ text: 'Actions', link: '/reference/types/column/actions' },
{ text: 'Checkbox', link: '/reference/types/column/checkbox' },
Expand Down
21 changes: 21 additions & 0 deletions docs/src/reference/types/column/enum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<script setup>
import ColumnTypeOptions from "./options/column.md";
</script>

# EnumColumnType

The [`EnumColumnType`](https://github.com/Kreyu/data-table-bundle/blob/main/src/Column/Type/EnumColumnType.php) represents a column with [PHP enumeration](https://www.php.net/manual/language.enumerations.php) as value.

## Overridden options

### `formatter`

- **type**: `null` or `callable`
- **default**: callable that translates the enum if possible

Formats the enum value. If Symfony Translator component is available, and the enum implements [`TranslatableInterface`](https://github.com/symfony/translation-contracts/blob/main/TranslatableInterface.php),
the enum will be translated. Otherwise, the enum name will be displayed.

## Inherited options

<ColumnTypeOptions excludedOptions="['formatter']"/>
8 changes: 8 additions & 0 deletions docs/src/reference/types/column/options/column.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ const props = defineProps({
property_path: 'null',
},
},
excludedOptions: {
type: Array,
default: ['test'],
},
})
</script>

Expand Down Expand Up @@ -100,6 +104,8 @@ Allows you to add a custom block prefix and override the block name used to rend
Useful for example if you have multiple instances of the same column type, and you need to personalize
the rendering of some of them, without the need to create a new column type.

<span v-if="!excludedOptions.includes('formatter')">

### `formatter`

- **type**: `null` or `callable`
Expand All @@ -115,6 +121,8 @@ $builder
;
```

</span>

### `export`

- **type**: `bool` or `array`
Expand Down

0 comments on commit 29440fd

Please sign in to comment.