Skip to content

Commit b8cd03b

Browse files
jasonvargaclaude
andcommitted
Make publish container reference and site reactive
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 8a2269b commit b8cd03b

5 files changed

Lines changed: 18 additions & 6 deletions

File tree

resources/js/components/entries/PublishForm.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
v-if="fieldset"
7474
ref="container"
7575
:name="publishContainer"
76-
:reference="initialReference"
76+
:reference="reference"
7777
:blueprint="fieldset"
7878
v-model="values"
7979
:extra-values="extraValues"
@@ -370,6 +370,7 @@ export default {
370370
originValues: this.initialOriginValues,
371371
originMeta: this.initialOriginMeta,
372372
site: this.initialSite,
373+
reference: this.initialReference,
373374
selectingOrigin: false,
374375
selectedOrigin: null,
375376
isWorkingCopy: this.initialIsWorkingCopy,
@@ -687,6 +688,7 @@ export default {
687688
this.fieldset = data.blueprint;
688689
this.permalink = data.permalink;
689690
this.site = localization.handle;
691+
this.reference = data.reference;
690692
this.localizing = false;
691693
this.initialPublished = data.values.published;
692694
this.readOnly = data.readOnly;

resources/js/components/globals/PublishForm.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
v-if="fieldset && !fieldset.empty"
7373
ref="container"
7474
:name="publishContainer"
75-
:reference="initialReference"
75+
:reference="reference"
7676
:blueprint="fieldset"
7777
v-model="values"
7878
:meta="meta"
@@ -164,6 +164,7 @@ export default {
164164
originValues: this.initialOriginValues || {},
165165
originMeta: this.initialOriginMeta || {},
166166
site: this.initialSite,
167+
reference: this.initialReference,
167168
readOnly: this.initialReadOnly,
168169
syncFieldConfirmationText: __('messages.sync_entry_field_confirmation_text'),
169170
pendingLocalization: null,
@@ -301,6 +302,7 @@ export default {
301302
this.actions = data.actions;
302303
this.fieldset = data.blueprint;
303304
this.site = localization.handle;
305+
this.reference = data.reference;
304306
this.localizing = false;
305307
this.afterActionSuccessfullyCompleted(data);
306308
this.$nextTick(() => this.$refs.container.clearDirtyState());

resources/js/components/terms/PublishForm.vue

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
v-if="fieldset"
5757
ref="container"
5858
:name="publishContainer"
59-
:reference="initialReference"
59+
:reference="reference"
6060
:blueprint="fieldset"
6161
v-model="values"
6262
:meta="meta"
@@ -215,6 +215,7 @@ export default {
215215
originValues: this.initialOriginValues || {},
216216
originMeta: this.initialOriginMeta || {},
217217
site: this.initialSite,
218+
reference: this.initialReference,
218219
isPreviewing: false,
219220
state: 'new',
220221
published: this.initialPublished,
@@ -440,6 +441,7 @@ export default {
440441
this.actions = data.actions;
441442
this.fieldset = data.blueprint;
442443
this.site = localization.handle;
444+
this.reference = data.reference;
443445
this.localizing = false;
444446
this.$nextTick(() => this.$refs.container.clearDirtyState());
445447
});

resources/js/components/ui/Publish/Components.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,5 @@ const { components } = injectContainerContext();
55
</script>
66

77
<template>
8-
<component v-for="component in components" :key="component.name" :is="component.name" v-bind="component.props" v-on="component.events" />
8+
<component v-for="component in components" :key="component.id" :is="component.name" v-bind="component.props" v-on="component.events" />
99
</template>

resources/js/components/ui/Publish/Container.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,12 @@ function blurField(handle, user = Statamic.user) {
273273
function pushComponent(name, { props }) {
274274
const component = new Component(uniqid(), name, props);
275275
components.value.push(component);
276+
const originalDestroy = component.destroy.bind(component);
277+
component.destroy = () => {
278+
const index = components.value.indexOf(component);
279+
if (index !== -1) components.value.splice(index, 1);
280+
originalDestroy();
281+
};
276282
return component;
277283
}
278284
@@ -336,8 +342,8 @@ provideContainerContext({ ...provided, container: provided });
336342
onMounted(() => {
337343
Statamic.$events.$emit('publish-container-created', {
338344
name: props.name,
339-
reference: props.reference,
340-
site: props.site,
345+
reference: toRef(() => props.reference),
346+
site: toRef(() => props.site),
341347
values,
342348
setFieldValue,
343349
setValues,

0 commit comments

Comments
 (0)