Skip to content

Commit

Permalink
Move fields into blueprint ...
Browse files Browse the repository at this point in the history
- Because I added the listable field to the blueprint for processing, I hadn't noticed it was also being output in the loop.
- Might as well move the rest. Cleans up the vue.
  • Loading branch information
jasonvarga committed Jan 17, 2020
1 parent 8a26e0a commit 82377fb
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 44 deletions.
47 changes: 4 additions & 43 deletions resources/js/components/fields/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,53 +53,14 @@
>
<div class="publish-fields" v-show="activeTab === 'settings'" slot-scope="{ setFieldValue }">

<form-group
handle="display"
:display="__('Display')"
:instructions="__('messages.fields_display_instructions')"
width="50"
autoselect
:value="values.display"
@input="updateField('display', $event, setFieldValue)"
/>

<form-group
handle="handle"
:display="__('Handle')"
:instructions="__('messages.fields_handle_instructions')"
width="50"
:value="values.handle"
@input="updateField('handle', $event, setFieldValue); isHandleModified = true"
/>

<form-group
fieldtype="text"
handle="instructions"
:display="__('Instructions')"
:instructions="__('messages.fields_instructions_instructions')"
:value="values.instructions"
@input="updateField('instructions', $event, setFieldValue)"
/>

<form-group
fieldtype="select"
handle="listable"
:display="__('Listable')"
:instructions="__('messages.fields_listable_instructions')"
:config="{ options: {
hidden: __('Hidden by default'),
true: __('Yes'),
false: __('No')
}}"
:value="values.listable"
@input="updateField('listable', $event, setFieldValue)"
/>

<publish-fields
v-if="blueprint.sections.length"
class="w-full"
:fields="blueprint.sections[0].fields"
@updated="(handle, value) => updateField(handle, value, setFieldValue)"
@updated="(handle, value) => {
updateField(handle, value, setFieldValue);
if (handle === 'handle') isHandleModified = true
}"
/>

</div>
Expand Down
34 changes: 33 additions & 1 deletion src/Http/Controllers/CP/Fields/FieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,38 @@ public function update(Request $request)

protected function blueprint($blueprint)
{
return $blueprint->ensureField('listable', ['type' => 'select', 'cast_booleans' => true]);
$prepends = collect([
'display' => [
'type' => 'text',
'instructions' => __('statamic::messages.fields_display_instructions'),
'width' => 50,
],
'handle' => [
'type' => 'text',
'instructions' => __('statamic::messages.fields_handle_instructions'),
'width' => 50,
],
'instructions' => [
'type' => 'text',
'instructions' => __('statamic::messages.fields_instructions_instructions'),
],
'listable' => [
'type' => 'select',
'instructions' => __('statamic::messages.fields_listable_instructions'),
'cast_booleans' => true,
'width' => 50,
'options' => [
'hidden' => __('Hidden by default'),
'true' => __('Yes'),
'false' => __('No'),
],
]
]);

foreach ($prepends->reverse() as $handle => $prepend) {
$blueprint->ensureFieldPrepended($handle, $prepend);
}

return $blueprint;
}
}

0 comments on commit 82377fb

Please sign in to comment.