Skip to content

Commit

Permalink
[4.x] Fixes (#7806)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Mar 31, 2023
1 parent 6b3093c commit 6ac62b4
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 43 deletions.
4 changes: 4 additions & 0 deletions resources/css/components/fieldtypes/replicator.css
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@
.replicator-fieldtype {
@apply py-6 px-0 bg-gray-200 border-t border-b;

&:first-child {
@apply border-t-0;
}

> .field-inner {
@apply ml-6;
}
Expand Down
7 changes: 5 additions & 2 deletions resources/js/components/Slugify.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,11 @@ export default {
if (to !== this.slug) this.shouldSlugify = false;
},
slug(slug) {
this.$emit('slugified', slug);
slug: {
immediate: true,
handler(slug) {
this.$emit('slugified', slug);
}
}
},
Expand Down
4 changes: 0 additions & 4 deletions resources/js/components/blueprints/Fields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,14 @@ export default {
fieldtypeSelected(field) {
this.isSelectingNewFieldtype = false;
const handle = field.type;
const pending = {
_id: uniqid(),
type: 'inline',
fieldtype: field.type,
icon: field.icon,
handle,
config: {
...field,
isNew: true,
handle
}
};
Expand Down
2 changes: 1 addition & 1 deletion resources/js/components/blueprints/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export default {
makeSectionsSortable() {
if (sortableSections) sortableSections.destroy();
sortableSections = new Sortable(document.querySelectorAll('.blueprint-sections'), {
sortableSections = new Sortable(this.$el.querySelectorAll('.blueprint-sections'), {
draggable: '.blueprint-section',
handle: '.blueprint-section-drag-handle',
mirror: { constrainDimensions: true, appendTo: 'body' },
Expand Down
6 changes: 4 additions & 2 deletions resources/js/components/entries/Listing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,15 @@ export default {
getStatusTooltip(entry) {
if (entry.status === 'published') {
return __('messages.status_published_with_date', {date: entry.date})
return entry.collection.dated
? __('messages.status_published_with_date', {date: entry.date})
: null; // The label is sufficient.
} else if (entry.status === 'scheduled') {
return __('messages.status_scheduled_with_date', {date: entry.date})
} else if (entry.status === 'expired') {
return __('messages.status_expired_with_date', {date: entry.date})
} else if (entry.status === 'draft') {
return __('Draft');
return null; // The label is sufficient.
}
},
Expand Down
3 changes: 2 additions & 1 deletion resources/js/components/fields/FieldtypeSelector.vue
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,9 @@ export default {
// and id keys. This will be 'field_n' etc, where n would be the total root
// level, grid, or set fields depending on the event listener location.
let field = {
display: `${fieldtype.title} ${__('Field')}`,
type: fieldtype.handle,
display: `${fieldtype.title} ${__('Field')}`,
handle: null, // The handle will be generated from the display by the "slug" fieldtype.
icon: fieldtype.icon,
instructions: null,
localizable: false,
Expand Down
20 changes: 1 addition & 19 deletions resources/js/components/fields/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@

<publish-sections
:sections="blueprint.tabs[0].sections"

@updated="(handle, value) => {
updateField(handle, value, setFieldValue);
if (handle === 'handle') isHandleModified = true
}"
@updated="(handle, value) => updateField(handle, value, setFieldValue)"
@meta-updated="setFieldMeta"
/>

Expand Down Expand Up @@ -138,7 +134,6 @@ export default {
error: null,
errors: {},
editedFields: clone(this.overrides),
isHandleModified: true,
activeTab: 'settings',
storeName: 'base',
fieldtype: null,
Expand Down Expand Up @@ -192,19 +187,6 @@ export default {
},
created() {
// For new fields, we'll slugify the display name into the field name.
// If they edit the handle, we'll stop.
if (this.config.isNew && !this.config.isMeta) {
this.isHandleModified = false;
this.$watch('values.display', function(display) {
if (! this.isHandleModified) {
const handle = this.$slugify(display, '_');
this.updateField('handle', handle);
}
});
}
this.load();
},
Expand Down
29 changes: 17 additions & 12 deletions resources/js/components/fieldsets/EditForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@
</div>
</header>

<div class="publish-form card p-0 mb-10">

<div class="form-group">
<label class="block">{{ __('Title') }}</label>
<small class="help-block">{{ __('messages.fieldsets_title_instructions') }}</small>
<div v-if="errors.title">
<small class="help-block text-red-500" v-for="(error, i) in errors.title" :key="i" v-text="error" />
<div class="publish-form card p-0 @container mb-8">
<div class="publish-fields">
<div class="form-group w-full">
<div class="field-inner">
<label class="block">{{ __('Title') }}</label>
<small class="help-block -mt-2">{{ __('messages.fieldsets_title_instructions') }}</small>
<div v-if="errors.title">
<small class="help-block text-red-500" v-for="(error, i) in errors.title" :key="i" v-text="error" />
</div>
</div>
<div>
<input type="text" name="title" class="input-text" v-model="fieldset.title" autofocus="autofocus">
</div>
</div>
<input type="text" name="title" class="input-text" v-model="fieldset.title" autofocus="autofocus">
</div>

</div>
Expand All @@ -27,7 +32,7 @@
<h2 v-text="__('Fields')" />
</div>

<div class="card" :class="{ 'pt-2': !fields.length }">
<div class="card @container" :class="{ 'pt-2': !fields.length }">
<fields
:fields="fieldset.fields"
:editing-field="editingField"
Expand Down Expand Up @@ -120,10 +125,10 @@ export default {
},
makeSortable() {
new Sortable(this.$el.querySelector('.blueprint-tab-draggable-zone'), {
draggable: '.blueprint-tab-field',
new Sortable(this.$el.querySelector('.blueprint-section-draggable-zone'), {
draggable: '.blueprint-section-field',
handle: '.blueprint-drag-handle',
mirror: { constrainDimensions: true },
mirror: { constrainDimensions: true, appendTo: 'body' },
plugins: [Plugins.SwapAnimation]
}).on('sortable:stop', e => {
this.fieldset.fields.splice(e.newIndex, 0, this.fieldset.fields.splice(e.oldIndex, 1)[0]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<template>

<div class="replicator-set-picker">
<set-picker :sets="groups" :placement="last ? 'bottom-start' : 'auto'" @added="addSet">
<set-picker :sets="groups" :placement="last ? 'bottom-start' : 'bottom'" @added="addSet">
<template #trigger>
<div class="text-center">
<button :class="{ 'btn-round flex items-center justify-center': last }" @click="addSetButtonClicked">
Expand Down
1 change: 1 addition & 0 deletions src/Http/Controllers/CP/Fields/FieldsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ protected function blueprint($blueprint)
'from' => 'display',
'separator' => '_',
'validate' => 'required|not_in:'.implode(',', $reserved),
'show_regenerate' => true,
],
'instructions' => [
'display' => __('Instructions'),
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Resources/CP/Entries/ListedEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function toArray($request)

'permalink' => $entry->absoluteUrl(),
'edit_url' => $entry->editUrl(),
'collection' => $entry->collection()->toArray(),
'collection' => array_merge($entry->collection()->toArray(), ['dated' => $entry->collection()->dated()]),
'viewable' => User::current()->can('view', $entry),
'editable' => User::current()->can('edit', $entry),
'actions' => Action::for($entry, ['collection' => $collection->handle()]),
Expand Down

0 comments on commit 6ac62b4

Please sign in to comment.