Skip to content

Commit

Permalink
Extra values for nav field conditions, including depth
Browse files Browse the repository at this point in the history
  • Loading branch information
duncanmcclean committed Nov 11, 2024
1 parent f13a997 commit c026f11
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions resources/js/components/structures/PageEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
:name="publishContainer"
:blueprint="adjustedBlueprint"
:values="values"
:extra-values="extraValues"
:meta="meta"
:errors="errors"
:localized-fields="localizedFields"
Expand Down Expand Up @@ -94,6 +95,7 @@ export default {
meta: null,
originValues: null,
originMeta: null,
extraValues: null,
localizedFields: null,
syncableFields: null,
loading: true,
Expand Down Expand Up @@ -275,6 +277,7 @@ export default {
this.originValues = info.originValues;
this.meta = info.meta;
this.originMeta = info.originMeta;
this.extraValues = info.extraValues;
this.localizedFields = info.localizedFields;
this.syncableFields = info.syncableFields;
},
Expand All @@ -285,6 +288,7 @@ export default {
originValues: this.originValues,
meta: this.meta,
originMeta: this.originMeta,
extraValues: this.extraValues,
localizedFields: this.localizedFields,
syncableFields: this.syncableFields,
entry: this.entry,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function edit(Request $request, $nav, $page)

$page = $nav->in($request->site)->find($page);

[$values, $meta] = $this->extractValuesAndMeta($page, $blueprint);
[$values, $meta, $extraValues] = $this->extractValuesAndMeta($page, $blueprint);

if ($entry = $page->entry()) {
[$originValues, $originMeta] = $this->extractValuesAndMeta($entry, $blueprint);
Expand All @@ -63,6 +63,7 @@ public function edit(Request $request, $nav, $page)
'meta' => $meta,
'originValues' => $originValues ?? null,
'originMeta' => $originMeta ?? null,
'extraValues' => $extraValues,
'localizedFields' => $this->getLocalizedFields($page),
'syncableFields' => $this->getSyncableFields($nav, $entry),
];
Expand Down Expand Up @@ -113,7 +114,11 @@ private function extractValuesAndMeta($page, $blueprint)

$values = $fields->values();

return [$values->all(), $fields->meta()];
$extraValues = [
'depth' => $page instanceof Page ? $page->depth() : null,
];

return [$values->all(), $fields->meta(), $extraValues];
}

private function getPageValues($page)
Expand Down

0 comments on commit c026f11

Please sign in to comment.