Skip to content

Commit eef7df7

Browse files
committed
delete form blueprints
1 parent c8830a9 commit eef7df7

17 files changed

Lines changed: 138 additions & 238 deletions

File tree

resources/js/components/blueprints/Builder.vue

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ export default {
5656
initialBlueprint: Object,
5757
showTitle: Boolean,
5858
useTabs: { type: Boolean, default: true },
59-
isFormBlueprint: { type: Boolean, default: false },
6059
},
6160
6261
data() {
@@ -84,15 +83,9 @@ export default {
8483
this.$events.$on('root-form-save', () => {
8584
this.$nextTick(() => this.save());
8685
});
87-
88-
if (this.isFormBlueprint) {
89-
Statamic.$config.set('isFormBlueprint', true);
90-
}
9186
},
9287
9388
beforeUnmount() {
94-
Statamic.$config.set('isFormBlueprint', false);
95-
9689
this.$events.$off('root-form-save');
9790
9891
this.saveKeyBinding.destroy();

resources/js/components/fields/FieldtypeSelector.vue

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -225,11 +225,7 @@ export default {
225225
created() {
226226
if (this.fieldtypesLoaded) return;
227227
228-
let url = cp_url('fields/fieldtypes?selectable=true');
229-
230-
if (this.$config.get('isFormBlueprint')) url += '&forms=true';
231-
232-
this.$axios.get(url)
228+
this.$axios.get(cp_url('fields/fieldtypes?selectable=true'))
233229
.then((response) => (loadedFieldtypes.value = response.data))
234230
.catch((e) => {
235231
this.$toast.error(e.response?.data?.message || __('Something went wrong'));

resources/js/pages/blueprints/Edit.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ defineProps({
1010
canDefineLocalizable: { type: Boolean, default: undefined },
1111
resetRoute: String,
1212
isResettable: Boolean,
13-
isFormBlueprint: Boolean,
1413
});
1514
</script>
1615

@@ -24,7 +23,6 @@ defineProps({
2423
:initial-blueprint="blueprint"
2524
:use-tabs="useTabs"
2625
:can-define-localizable="canDefineLocalizable"
27-
:is-form-blueprint="isFormBlueprint"
2826
>
2927
<template v-if="isResettable" #actions>
3028
<ui-dropdown>

resources/js/pages/blueprints/Index.vue

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { Link } from '@inertiajs/vue3';
44
import Head from '@/pages/layout/Head.vue';
55
import { Header, Dropdown, DropdownMenu, DropdownLabel, DropdownItem, Button, Subheading, Panel, DocsCallout, Icon, StatusIndicator } from '@ui';
66
7-
defineProps(['collections', 'taxonomies', 'navs', 'assetContainers', 'globals', 'forms', 'userBlueprint', 'groupBlueprint', 'additional']);
7+
defineProps(['collections', 'taxonomies', 'navs', 'assetContainers', 'globals', 'userBlueprint', 'groupBlueprint', 'additional']);
88
99
const resetters = ref({});
1010
</script>
@@ -179,29 +179,6 @@ const resetters = ref({});
179179
</Panel>
180180
</template>
181181

182-
<template v-if="forms.length">
183-
<Subheading size="lg" class="mb-2" :text="__('Forms')" />
184-
<Panel>
185-
<table class="data-table">
186-
<thead>
187-
<tr>
188-
<th class="text-start!">{{ __('Blueprint') }}</th>
189-
</tr>
190-
</thead>
191-
<tbody>
192-
<tr v-for="form in forms" :key="form.handle">
193-
<td>
194-
<div class="flex items-center gap-2">
195-
<Icon name="forms" class="text-gray-500 me-1" />
196-
<Link :href="form.edit_url" v-text="__(form.title)" />
197-
</div>
198-
</td>
199-
</tr>
200-
</tbody>
201-
</table>
202-
</Panel>
203-
</template>
204-
205182
<Subheading size="lg" class="mb-2" :text="__('Users')" />
206183
<Panel>
207184
<table class="data-table">

resources/js/pages/forms/Index.vue

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,6 @@ const reloadPage = () => router.reload();
7474
</template>
7575
<template #prepended-row-actions="{ row: form }">
7676
<DropdownItem v-if="form.can_edit" :text="__('Configure')" :href="form.edit_url" icon="cog" />
77-
<DropdownItem
78-
v-if="form.can_edit_blueprint"
79-
icon="blueprint-edit"
80-
:text="__('Edit Blueprint')"
81-
:href="form.blueprint_url"
82-
/>
8377
</template>
8478
</Listing>
8579

resources/js/pages/forms/Show.vue

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,6 @@ function exportSubmissions() {
123123
<Dropdown v-if="form.canEdit || form.canDelete" placement="left-start" class="me-2">
124124
<DropdownMenu>
125125
<DropdownItem v-if="form.canEdit" :text="__('Configure Form')" icon="cog" :href="form.editUrl" />
126-
<DropdownItem
127-
v-if="form.canConfigureFields"
128-
:text="__('Edit Blueprint')"
129-
icon="blueprint-edit"
130-
:href="form.blueprintUrl"
131-
/>
132126
<DropdownItem
133127
v-if="form.canDelete"
134128
:text="__('Delete Form')"
@@ -146,13 +140,6 @@ function exportSubmissions() {
146140
:url="form.editUrl"
147141
/>
148142
149-
<CommandPaletteItem
150-
category="Actions"
151-
:text="__('Edit Blueprint')"
152-
icon="blueprint-edit"
153-
:url="form.blueprintUrl"
154-
/>
155-
156143
<CommandPaletteItem
157144
category="Actions"
158145
:text="__('Delete Form')"

routes/cp.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,8 +304,8 @@
304304
Route::get('asset-containers/{asset_container}/edit', [AssetContainerBlueprintController::class, 'edit'])->name('asset-containers.edit');
305305
Route::patch('asset-containers/{asset_container}', [AssetContainerBlueprintController::class, 'update'])->name('asset-containers.update');
306306

307-
Route::get('forms/{form}/edit', [FormBlueprintController::class, 'edit'])->name('forms.edit');
308-
Route::patch('forms/{form}', [FormBlueprintController::class, 'update'])->name('forms.update');
307+
Route::get('forms/{form}/edit', FormBlueprintController::class)->name('forms.edit');
308+
Route::patch('forms/{form}', FormBlueprintController::class)->name('forms.update');
309309

310310
Route::get('globals/{global_set}/edit', [GlobalsBlueprintController::class, 'edit'])->name('globals.edit');
311311
Route::patch('globals/{global_set}', [GlobalsBlueprintController::class, 'update'])->name('globals.update');

src/CommandPalette/Palette.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,6 @@ protected function buildFields(): self
114114
->map(fn ($set) => $set->blueprintCommandPaletteLink())
115115
->each(fn (Link $link) => $this->addCommand($link));
116116

117-
Facades\Form::all()
118-
->map(fn ($form) => $form->blueprintCommandPaletteLink())
119-
->each(fn (Link $link) => $this->addCommand($link));
120-
121117
$this->addCommand(Facades\User::blueprintCommandPaletteLink());
122118
$this->addCommand(Facades\UserGroup::blueprintCommandPaletteLink());
123119

src/Forms/Form.php

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,23 @@ public function formFields($fields = null)
9090

9191
return new FormFields($fields ?? []);
9292
})
93+
->setter(function ($fields) {
94+
if (isset($fields['tabs'])) {
95+
$fields = [
96+
'sections' => collect($fields['tabs'])->flatMap(fn ($tab) => $tab['sections'])->all(),
97+
];
98+
}
99+
100+
if (isset($fields['fields'])) {
101+
$fields = [
102+
'sections' => [
103+
['fields' => $fields['fields']],
104+
],
105+
];
106+
}
107+
108+
return $fields;
109+
})
93110
->args(func_get_args());
94111
}
95112

@@ -148,14 +165,6 @@ public function blueprint()
148165
return $blueprint;
149166
}
150167

151-
public function blueprintCommandPaletteLink()
152-
{
153-
return $this->blueprint()?->commandPaletteLink(
154-
type: 'Forms',
155-
url: $this->editBlueprintUrl(),
156-
);
157-
}
158-
159168
/**
160169
* Get or set the honeypot field.
161170
*
@@ -283,6 +292,10 @@ public function save()
283292

284293
File::put($this->path(), YAML::dump($data));
285294

295+
if ($blueprint = Facades\Blueprint::find("forms.{$this->handle()}")) {
296+
$blueprint->delete();
297+
}
298+
286299
foreach ($afterSaveCallbacks as $callback) {
287300
$callback($this);
288301
}
@@ -460,9 +473,10 @@ public function deleteUrl()
460473
return cp_route('forms.destroy', $this->handle());
461474
}
462475

476+
/** @deprecated */
463477
public function editBlueprintUrl()
464478
{
465-
return cp_route('blueprints.forms.edit', $this->handle());
479+
return cp_route('forms.fields.index', $this->handle());
466480
}
467481

468482
public function hasFiles()

src/Http/Controllers/CP/Fields/BlueprintController.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public function index()
3232
'navs' => $this->navs(),
3333
'assetContainers' => $this->assets(),
3434
'globals' => $this->globals(),
35-
'forms' => $this->forms(),
3635
'userBlueprint' => [
3736
'edit_url' => cp_route('blueprints.users.edit'),
3837
],
@@ -99,15 +98,4 @@ public function globals()
9998
'edit_url' => cp_route('blueprints.globals.edit', $set->handle()),
10099
])->values()->all();
101100
}
102-
103-
public function forms(): array
104-
{
105-
return User::current()->can('configure form fields')
106-
? Form::all()->map(fn ($form) => [
107-
'title' => $form->title(),
108-
'handle' => $form->handle(),
109-
'edit_url' => cp_route('blueprints.forms.edit', $form->handle()),
110-
])->values()->all()
111-
: [];
112-
}
113101
}

0 commit comments

Comments
 (0)