Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
c2d4f27
Test for AugmentedPage
jasonvarga Jun 19, 2021
b9c48a2
Sort keys
jasonvarga Jun 19, 2021
45faf8e
Merge branch '3.1' into feature/nav-blueprints
jasonvarga Jul 1, 2021
478fa06
Merge branch 'master' into feature/nav-blueprints
jasonvarga Jul 1, 2021
2746959
commas
jasonvarga Jul 1, 2021
005507c
Pages can set their own array of data, and it'll fall back to the entry
jasonvarga Jul 1, 2021
afe37c2
augmented pages merge the entry fields
jasonvarga Jul 1, 2021
6aef092
style
jasonvarga Jul 1, 2021
cad4e1f
style
jasonvarga Jul 1, 2021
298f298
Navs can have blueprints and they can be edited in the cp
jasonvarga Jul 1, 2021
3d574de
pages can check if they have a custom title
jasonvarga Jul 2, 2021
42e3a92
The page's own data can be set and retrieved on its own
jasonvarga Jul 2, 2021
9120343
Page will only have a blueprint if its in a nav, not a collection.
jasonvarga Jul 5, 2021
b8acfaa
data gets passed through pages
jasonvarga Jul 5, 2021
2972d45
Hook up blueprint ui in edit pane
jasonvarga Jul 5, 2021
73a0de5
Add edit blueprint to twirldown
jasonvarga Jul 5, 2021
746d315
Add blueprint field to edit nav form
jasonvarga Jul 5, 2021
154bd47
Add edit entry link to page editor
jasonvarga Jul 5, 2021
54dccc9
Add link to edit entry in the page twirldown
jasonvarga Jul 5, 2021
83286c8
Nav pages are validated server side using blueprints
jasonvarga Jul 5, 2021
ece2c61
Use cmd+enter or cmd+s to save instead of just enter ...
jasonvarga Jul 5, 2021
e7ffeb1
Use entry title as entry_title instead of the custom title so its not…
jasonvarga Jul 5, 2021
5f4a334
init
jasonvarga Jul 5, 2021
effc74f
Dirty state warning when closing the stack
jasonvarga Jul 5, 2021
4e5f1b9
Only add fields if they're not already in the blueprint
jasonvarga Jul 5, 2021
4e3b475
Merge title/url validation rules with any that may already exist on t…
jasonvarga Jul 5, 2021
802ae99
Remove the url field for entries
jasonvarga Jul 5, 2021
fb8ca61
only splice if there's a url field
jasonvarga Jul 8, 2021
c609ad1
Nav page editor uses syncing feature to show entry value overriding -…
jasonvarga Jul 8, 2021
697098b
unused
jasonvarga Jul 8, 2021
e99f23f
Use separate tree controllers for navs and collections
jasonvarga Jul 8, 2021
f268726
Move namespace
jasonvarga Jul 8, 2021
dd046ff
The collection tree updating was already happening in its own control…
jasonvarga Jul 8, 2021
335849a
Add updating nav tree test, and tidy
jasonvarga Jul 8, 2021
22a1de8
Nav branches can have ids generated
jasonvarga Jul 12, 2021
39ecf9b
Ensure the ids are there on the edit page
jasonvarga Jul 12, 2021
a568fc6
Updating a nav tree is now done by accepting a really basic tree of i…
jasonvarga Jul 12, 2021
572ea4c
whitespace
jasonvarga Jul 12, 2021
dd525b9
Remove old unused exclusion code
jasonvarga Jul 12, 2021
f1e85ab
$page->hasCustomUrl()
jasonvarga Jul 13, 2021
361ecb3
unnecessary
jasonvarga Jul 13, 2021
90ee578
Remove unnecessary 'root needs to be an entry' constraint.
jasonvarga Jul 13, 2021
2e134c6
$page->id() is now the id of the branch, not the entry
jasonvarga Jul 13, 2021
b7b8119
wire up root/parent page correctly now that it doesnt have to just be…
jasonvarga Jul 13, 2021
7ea0a12
$page->in() will get the proper branch (with the right id) rather tha…
jasonvarga Jul 13, 2021
a9eea7c
Should be pages
jasonvarga Jul 13, 2021
f995b74
On-demand values/preprocessing when editing a page ...
jasonvarga Jul 13, 2021
10b5d04
Apply fixes from StyleCI (#3990)
jasonvarga Jul 13, 2021
453ded8
Newly added branches will have their temporary JS ids replaced on the…
jasonvarga Jul 13, 2021
d3d1f61
Handle creating entries and nav items ...
jasonvarga Jul 16, 2021
f7ed8e4
Merge branch 'master' into feature/nav-blueprints
jasonvarga Jul 16, 2021
a2161d6
Apply fixes from StyleCI (#4017)
jasonvarga Jul 16, 2021
44203a6
fix branches with carets being really tall
jasonvarga Jul 17, 2021
8d12a49
i totally neglected existing items in d3d1f61e
jasonvarga Jul 20, 2021
8599e96
Fix type - it should be url, not page. Whoopsied in f995b745.
jasonvarga Jul 20, 2021
8a05c78
Make the title field nullable on pages
jasonvarga Jul 20, 2021
99e5a4c
fix handling of new standard nav items
jasonvarga Jul 20, 2021
4e23bcd
the id of the page gets returned, not the entry
jasonvarga Jul 20, 2021
d7dec17
add entry_id to pages
jasonvarga Jul 20, 2021
88f1db5
graphql
jasonvarga Aug 6, 2021
10167df
Explicitly register the interfaces up front ...
jasonvarga Aug 8, 2021
004aca6
Collection and Nav GraphQL splits ...
jasonvarga Aug 8, 2021
d9400fd
Apply fixes from StyleCI
jasonvarga Aug 8, 2021
b7bb9dd
Deprecate page in collection trees in favor of entry
jasonvarga Aug 8, 2021
5936829
Pass the nav handle
jasonvarga Aug 8, 2021
fbe82e7
remove todo. not the end of the world.
jasonvarga Aug 8, 2021
8074310
Merge branch 'master' into feature/nav-blueprints
jasonvarga Aug 10, 2021
8649179
Update header text
jasonvarga Aug 10, 2021
52819e3
Update button and option text
jasonvarga Aug 10, 2021
a6599fa
Tiny fiddle with origin syncing icon and label text color to increase…
jackmcdade Aug 10, 2021
fa1735c
Merge branch 'master' into feature/nav-blueprints
jasonvarga Aug 10, 2021
da5a167
Merge branch 'master' into feature/nav-blueprints
jasonvarga Aug 10, 2021
635dba6
Fix difference in sync/desync icon positions
jackmcdade Aug 10, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 112 additions & 25 deletions resources/js/components/navigation/View.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<h1 class="flex-1" v-text="title" />

<dropdown-list class="mr-1">
<dropdown-item :text="__('Configure Navigation')" :redirect="editUrl" />
<slot name="twirldown" />
</dropdown-list>

<a @click="$refs.tree.cancel" class="text-2xs text-blue mr-2 underline" v-if="isDirty" v-text="__('Discard changes')" />
Expand All @@ -29,11 +29,11 @@
:class="{ 'flex items-center pr-2': hasCollections }"
@click="addLink"
>
{{ __('Add Link') }}
{{ __('Add Nav Item') }}
<svg-icon name="chevron-down-xs" class="w-2 ml-2" v-if="hasCollections" />
</button>
</template>
<dropdown-item :text="__('Link to URL')" @click="linkPage()" />
<dropdown-item :text="__('Add Nav Item')" @click="linkPage()" />
<dropdown-item :text="__('Link to Entry')" @click="linkEntries()" />
</dropdown-list>

Expand All @@ -51,13 +51,14 @@
:has-collection="false"
:pages-url="pagesUrl"
:submit-url="submitUrl"
:submit-parameters="{ data: submissionData }"
:max-depth="maxDepth"
:expects-root="expectsRoot"
:site="site"
:preferences-prefix="preferencesPrefix"
@edit-page="editPage"
@changed="changed = true; targetParent = null;"
@saved="changed = false"
@saved="treeSaved"
@canceled="changed = false"
>
<template #empty>
Expand Down Expand Up @@ -102,6 +103,10 @@
</template>

<template #branch-options="{ branch, removeBranch, orphanChildren, vm, depth }">
<dropdown-item
v-if="isEntryBranch(branch)"
:text="__('Edit Entry')"
:redirect="branch.edit_url" />
<dropdown-item
v-if="depth < maxDepth"
:text="__('Add child link to URL')"
Expand All @@ -127,14 +132,27 @@

<page-editor
v-if="editingPage"
:initial-title="editingPage.page.title"
:initial-url="editingPage.page.url"
:site="site"
:id="editingPage.page.id"
:entry="editingPage.page.entry"
:editEntryUrl="editingPage.page.entry ? editingPage.page.edit_url : null"
:publish-info="publishInfo[editingPage.page.id]"
:blueprint="blueprint"
:handle="handle"
@publish-info-updated="updatePublishInfo"
@localized-fields-updated="updateLocalizedFields"
@closed="closePageEditor"
@submitted="updatePage"
/>

<page-editor
v-if="creatingPage"
creating
:site="site"
:blueprint="blueprint"
:handle="handle"
@publish-info-updated="updatePendingCreatedPagePublishInfo"
@localized-fields-updated="updatePendingCreatedPageLocalizedFields"
@closed="closePageCreator"
@submitted="pageCreated"
/>
Expand All @@ -156,6 +174,7 @@ import PageEditor from '../structures/PageEditor.vue';
import PageSelector from '../structures/PageSelector.vue';
import RemovePageConfirmation from './RemovePageConfirmation.vue';
import SiteSelector from '../SiteSelector.vue';
import uniqid from 'uniqid';

export default {

Expand All @@ -178,7 +197,8 @@ export default {
maxDepth: { type: Number, default: Infinity, },
expectsRoot: { type: Boolean, required: true },
site: { type: String, required: true },
sites: { type: Array, required: true }
sites: { type: Array, required: true },
blueprint: { type: Object, required: true }
},

data() {
Expand All @@ -192,6 +212,7 @@ export default {
pageBeingDeleted: null,
pageDeletionConfirmCallback: null,
preferencesPrefix: `navs.${this.handle}`,
publishInfo: {},
}
},

Expand All @@ -215,6 +236,12 @@ export default {

hasCollections() {
return this.collections.length > 0;
},

submissionData() {
return _.mapObject(this.publishInfo, value => {
return _.pick(value, ['entry', 'values', 'localizedFields', 'new']);
});
}

},
Expand Down Expand Up @@ -248,11 +275,26 @@ export default {
},

entriesSelected(pages) {
pages = pages.map(page => ({
...page,
id: uniqid(),
entry: page.id,
entry_title: page.title,
title: null
}));

pages.forEach(page => {
this.publishInfo = {...this.publishInfo, [page.id]: {
entry: page.entry,
new: true,
}};
});

this.$refs.tree.addPages(pages, this.targetParent);
},

isEntryBranch(branch) {
return !!branch.id;
return !!branch.entry;
},

isLinkBranch(branch) {
Expand All @@ -263,19 +305,16 @@ export default {
return !this.isEntryBranch(branch) && !this.isLinkBranch(branch);
},

editPage(page, vm, store, $event) {
if (page.id) {
const url = page.edit_url;
$event.metaKey ? window.open(url) : window.location = url;
} else {
this.editingPage = { page, vm, store };
}
editPage(page, vm, store) {
this.editingPage = { page, vm, store };
},

updatePage(page) {
this.editingPage.page.url = page.url;
this.editingPage.page.title = page.title;
updatePage(values) {
this.editingPage.page.url = values.url;
this.editingPage.page.title = values.title;
this.editingPage.page.values = values;
this.$refs.tree.pageUpdated(this.editingPage.store);
this.publishInfo[this.editingPage.page.id].values = values;

this.editingPage = false;
},
Expand All @@ -285,20 +324,31 @@ export default {
},

openPageCreator() {
this.creatingPage = true;
this.creatingPage = { info: null };
},

closePageCreator() {
this.creatingPage = false;
},

pageCreated(page) {
this.closePageCreator();
this.$refs.tree.addPages([{
title: page.title,
url: page.url,
pageCreated(values) {
const page = {
id: uniqid(),
title: values.title,
url: values.url,
children: []
}], this.targetParent);
};

this.$set(this.publishInfo, page.id, {
...this.creatingPage.info,
values,
entry: null,
new: true,
});

this.$refs.tree.addPages([page], this.targetParent);

this.closePageCreator();
},

deleteTreeBranch(branch, removeFromUi, orphanChildren) {
Expand All @@ -314,6 +364,43 @@ export default {

siteSelected(site) {
window.location = site.url;
},

updatePublishInfo(info) {
this.publishInfo = { ...this.publishInfo, [this.editingPage.page.id]: info };
},

updatePendingCreatedPagePublishInfo(info) {
this.creatingPage.info = info;
},

updateLocalizedFields(fields) {
this.publishInfo[this.editingPage.page.id].localizedFields = fields;
},

updatePendingCreatedPageLocalizedFields(fields) {
this.creatingPage.info.localizedFields = fields;
},

treeSaved(response) {
this.changed = false;

this.replaceGeneratedIds(response.data.generatedIds);
},

replaceGeneratedIds(ids) {
for (let [oldId, newId] of Object.entries(ids)) {
// Replace the ID in the publishInfo so if the tree is saved again, its
// data will be submitted using the real ID, and now the temp JS one.
this.$set(this.publishInfo, newId, { ...this.publishInfo[oldId], new: false });
this.$delete(this.publishInfo, oldId);

// Replace the ID in the branch within the tree.
// Same as above, but in the tree itself.
let branch = this.$refs.tree.getNodeByBranchId(oldId);
branch.id = newId;
this.$refs.tree.pageUpdated(branch._vm.store);
}
}

}
Expand Down
11 changes: 8 additions & 3 deletions resources/js/components/publish/Field.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@
<div slot-scope="{ meta, value, loading: loadingMeta }" :class="classes">
<div class="field-inner">
<label class="publish-field-label" :class="{'font-bold': config.bold}" :for="fieldId">
<span :class="{'font-mono bg-grey-20 py-px px-sm text-xs': showHandle, 'cursor-pointer': canToggleLabel }" v-text="labelText" />
<span :class="{
'font-mono bg-grey-20 py-px px-sm text-xs': showHandle,
'cursor-pointer': canToggleLabel,
'text-grey-60': syncable && isSynced
}"
v-text="labelText" />
<i class="required ml-sm" v-if="config.required">*</i>
<avatar v-if="isLocked" :user="lockingUser" class="w-4 rounded-full -mt-px ml-1 mr-1" v-tooltip="lockingUser.name" />
<span v-if="isReadOnly && !isSection" class="text-grey-50 font-normal text-2xs mx-sm">
Expand All @@ -22,7 +27,7 @@
class="outline-none"
@click="$emit('desynced')"
>
<svg-icon name="hyperlink" class="h-4 ml-sm w-4 text-grey-60"
<svg-icon name="hyperlink" class="h-4 w-4 ml-.5 mt-sm text-grey-60"
v-tooltip.top="__('messages.field_synced_with_origin')" />
</button>

Expand All @@ -32,7 +37,7 @@
class="outline-none"
@click="$emit('synced')"
>
<svg-icon name="hyperlink-broken" class="h-4 ml-sm w-4 text-grey-60"
<svg-icon name="hyperlink-broken" class="h-4 w-4 ml-.5 mt-sm text-grey-60"
v-tooltip.top="__('messages.field_desynced_from_origin')" />
</button>
</label>
Expand Down
15 changes: 14 additions & 1 deletion resources/js/components/publish/Fields.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
:meta="meta[field.handle]"
:errors="errors[field.handle]"
:read-only="readOnly"
:syncable="syncable"
:syncable="isSyncableField(field)"
:can-toggle-label="canToggleLabels"
:name-prefix="namePrefix"
@input="$emit('updated', field.handle, $event)"
Expand Down Expand Up @@ -45,6 +45,7 @@ export default {
},
readOnly: Boolean,
syncable: Boolean,
syncableFields: Array,
canToggleLabels: Boolean,
namePrefix: String,
},
Expand All @@ -67,6 +68,18 @@ export default {
return this.state.errors;
}

},

methods: {

isSyncableField(field) {
if (! this.syncable) return false;

if (! this.syncableFields) return true;

return this.syncableFields.includes(field.handle);
}

}

}
Expand Down
8 changes: 6 additions & 2 deletions resources/js/components/structures/Branch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<a
@click="$emit('edit', $event)"
:class="{ 'text-sm font-medium': isTopLevel }"
v-text="page.title || page.url" />
v-text="title" />

<button
v-if="hasChildren"
class="p-1 text-grey-60 hover:text-grey-70 transition duration-100 outline-none"
class="p-1 text-grey-60 hover:text-grey-70 transition duration-100 outline-none flex"
:class="{ '-rotate-90': !isOpen }"
@click="$emit('toggle-open')"
>
Expand Down Expand Up @@ -94,6 +94,10 @@ export default {

isText() {
return this.page.title && !this.page.url;
},

title() {
return this.page.title || this.page.entry_title || this.page.url;
}

},
Expand Down
Loading