Skip to content

Commit b47e257

Browse files
[6.x] Blueprints fieldtype so we can style the Blueprints setting (#11755)
Co-authored-by: Jason Varga <jason@pixelfear.com>
1 parent 7c9d35d commit b47e257

5 files changed

Lines changed: 50 additions & 6 deletions

File tree

resources/js/bootstrap/fieldtypes.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import AssetsFieldtype from '../components/fieldtypes/assets/AssetsFieldtype.vue
1414
import AssetsIndexFieldtype from '../components/fieldtypes/assets/AssetsIndexFieldtype.vue';
1515
import AssetFolderFieldtype from '../components/fieldtypes/AssetFolderFieldtype.vue';
1616
import BardButtonsSettingFieldtype from '../components/fieldtypes/bard/BardButtonsSettingFieldtype.vue';
17+
import BlueprintsFieldtype from '../components/fieldtypes/BlueprintsFieldtype.vue';
1718
import ButtonGroupFieldtype from '../components/fieldtypes/ButtonGroupFieldtype.vue';
1819
import CheckboxesFieldtype from '../components/fieldtypes/CheckboxesFieldtype.vue';
1920
import Routes from '../components/collections/Routes.vue';
@@ -85,6 +86,7 @@ export default function registerFieldtypes(app) {
8586
);
8687
app.component('bard_buttons_setting-fieldtype', BardButtonsSettingFieldtype);
8788
app.component('button_group-fieldtype', ButtonGroupFieldtype);
89+
app.component('blueprints-fieldtype', BlueprintsFieldtype);
8890
app.component('checkboxes-fieldtype', CheckboxesFieldtype);
8991
app.component(
9092
'code-fieldtype',
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<script>
2+
import Fieldtype from './Fieldtype.vue';
3+
import { Button } from '@statamic/ui';
4+
5+
export default {
6+
mixins: [Fieldtype],
7+
8+
components: {
9+
Button,
10+
},
11+
};
12+
</script>
13+
14+
<template>
15+
<div class="mt-4 flex items-center gap-2">
16+
<Button
17+
v-if="config.options.length > 0"
18+
:href="blueprint.edit_url"
19+
variant="filled"
20+
size="sm"
21+
v-for="blueprint in config.options"
22+
:key="blueprint.handle"
23+
>
24+
{{ blueprint.title }}
25+
</Button>
26+
<Button size="sm" :href="config.all_blueprints_url">
27+
{{ __('View All Blueprints') }}
28+
</Button>
29+
</div>
30+
</template>

src/Fieldtypes/Blueprints.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Statamic\Fieldtypes;
4+
5+
use Statamic\Fields\Fieldtype;
6+
7+
class Blueprints extends Fieldtype
8+
{
9+
protected $categories = ['special'];
10+
}

src/Http/Controllers/CP/Collections/CollectionsController.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -456,12 +456,13 @@ protected function editFormBlueprint($collection)
456456
'blueprints' => [
457457
'display' => __('Blueprints'),
458458
'instructions' => __('statamic::messages.collections_blueprint_instructions'),
459-
'type' => 'html',
460-
'html' => ''.
461-
'<div class="text-xs">'.
462-
' <span class="rtl:ml-4 ltr:mr-4">'.$collection->entryBlueprints()->map(fn ($bp) => __($bp->title()))->join(', ').'</span>'.
463-
' <a href="'.cp_route('collections.blueprints.index', $collection).'" class="text-blue">'.__('Edit').'</a>'.
464-
'</div>',
459+
'type' => 'blueprints',
460+
'options' => $collection->entryBlueprints()->map(fn ($bp) => [
461+
'handle' => $bp->handle(),
462+
'title' => __($bp->title()),
463+
'edit_url' => cp_route('collections.blueprints.edit', [$collection->handle(), $bp->handle()]),
464+
])->values()->all(),
465+
'all_blueprints_url' => cp_route('collections.blueprints.index', $collection->handle()),
465466
],
466467
'default_publish_state' => [
467468
'display' => __('Publish by Default'),

src/Providers/ExtensionServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class ExtensionServiceProvider extends ServiceProvider
6666
Fieldtypes\Assets\Assets::class,
6767
Fieldtypes\Bard::class,
6868
Fieldtypes\Bard\Buttons::class,
69+
Fieldtypes\Blueprints::class,
6970
Fieldtypes\ButtonGroup::class,
7071
Fieldtypes\Checkboxes::class,
7172
Fieldtypes\Code::class,

0 commit comments

Comments
 (0)