Skip to content

Commit

Permalink
[5.x] Render HTML for dictionary fields in listings (#11088)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga authored Nov 7, 2024
1 parent 90e8488 commit 97bdb43
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 2 additions & 0 deletions resources/js/bootstrap/fieldtypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import TitleFormats from '../components/collections/TitleFormats.vue';
import ColorFieldtype from '../components/fieldtypes/ColorFieldtype.vue';
import DateFieldtype from '../components/fieldtypes/DateFieldtype.vue';
import DictionaryFieldtype from "../components/fieldtypes/DictionaryFieldtype.vue";
import DictionaryIndexFieldtype from "../components/fieldtypes/DictionaryIndexFieldtype.vue";
import DictionaryFields from "../components/fieldtypes/DictionaryFields.vue";
import FieldDisplayFieldtype from '../components/fieldtypes/FieldDisplayFieldtype.vue';
import FieldsFieldtype from '../components/fieldtypes/grid/FieldsFieldtype.vue';
Expand Down Expand Up @@ -89,6 +90,7 @@ Vue.component('collection_title_formats-fieldtype', TitleFormats);
Vue.component('color-fieldtype', ColorFieldtype);
Vue.component('date-fieldtype', DateFieldtype);
Vue.component('dictionary-fieldtype', DictionaryFieldtype);
Vue.component('dictionary-fieldtype-index', DictionaryIndexFieldtype);
Vue.component('dictionary_fields-fieldtype', DictionaryFields);
Vue.component('field_display-fieldtype', FieldDisplayFieldtype);
Vue.component('fields-fieldtype', FieldsFieldtype);
Expand Down
19 changes: 19 additions & 0 deletions resources/js/components/fieldtypes/DictionaryIndexFieldtype.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<template>
<div class="text-ellipsis" v-html="formatted" />
</template>

<script>
export default {
mixins: [IndexFieldtype],
computed: {
formatted() {
if (!this.value) {
return null;
}
return this.value.join(', ');
},
},
};
</script>
1 change: 0 additions & 1 deletion src/Fieldtypes/Dictionary.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ class Dictionary extends Fieldtype
{
protected $categories = ['controls', 'relationship'];
protected $selectableInForms = true;
protected $indexComponent = 'tags';

protected function configFieldItems(): array
{
Expand Down

0 comments on commit 97bdb43

Please sign in to comment.