Skip to content

Commit

Permalink
Merge branch 'feature/blueprints'
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonvarga committed Jul 21, 2020
2 parents b0df9fc + d22dedc commit 258211a
Show file tree
Hide file tree
Showing 132 changed files with 2,909 additions and 1,027 deletions.
7 changes: 0 additions & 7 deletions resources/blueprints/asset.yaml

This file was deleted.

8 changes: 0 additions & 8 deletions resources/blueprints/default.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions resources/blueprints/entry_link.yaml

This file was deleted.

25 changes: 0 additions & 25 deletions resources/blueprints/user.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions resources/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ Statamic.app({
CollectionScaffolder: require('./components/collections/Scaffolder.vue').default,
CollectionEditForm: require('./components/collections/EditForm.vue').default,
CollectionView: require('./components/collections/View.vue').default,
CollectionBlueprintListing: require('./components/collections/BlueprintListing.vue').default,
SessionExpiry: require('./components/SessionExpiry.vue').default,
NavigationListing: require('./components/navigation/Listing.vue').default,
NavigationCreateForm: require('./components/navigation/CreateForm.vue').default,
Expand All @@ -138,6 +139,7 @@ Statamic.app({
Stacks: require('./components/stacks/Stacks.vue').default,
TaxonomyCreateForm: require('./components/taxonomies/CreateForm.vue').default,
TaxonomyEditForm: require('./components/taxonomies/EditForm.vue').default,
TaxonomyBlueprintListing: require('./components/taxonomies/BlueprintListing.vue').default,
AssetContainerCreateForm: require('./components/asset-containers/CreateForm.vue').default,
AssetContainerEditForm: require('./components/asset-containers/EditForm.vue').default,
Updater: require('./components/updater/Updater.vue').default,
Expand Down
1 change: 1 addition & 0 deletions resources/js/bootstrap/fieldtypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Vue.component('global_set_sites-fieldtype', require('../components/globals/Sites
Vue.component('grid-fieldtype', require('../components/fieldtypes/grid/Grid.vue').default);
Vue.component('grid-fieldtype-index', require('../components/fieldtypes/grid/GridIndex.vue').default);
Vue.component('hidden-fieldtype', require('../components/fieldtypes/HiddenFieldtype.vue').default);
Vue.component('html-fieldtype', require('../components/fieldtypes/HtmlFieldtype.vue').default);
Vue.component('integer-fieldtype', require('../components/fieldtypes/IntegerFieldtype.vue').default);
Vue.component('link-fieldtype', require('../components/fieldtypes/LinkFieldtype.vue').default);
Vue.component('list-fieldtype', require('../components/fieldtypes/ListFieldtype.vue').default);
Expand Down
4 changes: 4 additions & 0 deletions resources/js/components/assets/AssetManager.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
v-text="__('Edit Container')"
:redirect="container.edit_url">
</dropdown-item>
<dropdown-item
v-text="__('Edit Blueprint')"
:redirect="container.blueprint_url">
</dropdown-item>
<dropdown-item
v-if="container.can_delete"
v-text="__('Delete Container')"
Expand Down
14 changes: 1 addition & 13 deletions resources/js/components/assets/Editor/Editor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -259,20 +259,8 @@ export default {
this.meta = data.meta;
this.runActionUrl = data.runActionUrl;
this.actions = data.actions;
this.getFieldset();
});
},
/**
* Load the fieldset
*/
getFieldset() {
const url = cp_url(`fields/publish-blueprints/${this.asset.blueprint}`);
this.$axios.get(url).then(response => {
this.fieldset = response.data;
// Flatten fields from all sections into one array.
this.fieldset = data.blueprint;
this.fields = _.chain(this.fieldset.sections)
.map(section => section.fields)
.flatten(true)
Expand Down
27 changes: 19 additions & 8 deletions resources/js/components/blueprints/Builder.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
<div class="blueprint-builder">

<header class="mb-3">
<breadcrumb :url="breadcrumbUrl" :title="__('Blueprints')" />

<div class="flex items-center justify-between">
<h1>{{ initialTitle }}</h1>
<h1 v-text="__('Edit Blueprint')" />
<button type="submit" class="btn-primary" @click.prevent="save" v-text="__('Save')" />
</div>
</header>

<div class="publish-form card p-0">
<div class="publish-form card p-0" v-if="showTitle">
<div class="form-group">
<label class="block">{{ __('Title') }}</label>
<small class="help-block">{{ __('messages.blueprints_title_instructions') }}</small>
Expand All @@ -22,12 +20,13 @@
</div>
</div>

<div class="content mt-5 mb-2">
<div class="content mt-5 mb-2" v-if="useSections">
<h2>{{ __('Tab Sections') }}</h2>
<p class="max-w-lg">{{ __('messages.tab_sections_instructions') }}</p>
</div>

<sections
:single-section="!useSections"
:initial-sections="blueprint.sections"
@updated="sectionsUpdated"
/>
Expand All @@ -45,13 +44,17 @@ export default {
Sections,
},
props: ['action', 'initialBlueprint', 'breadcrumbUrl'],
props: {
action: String,
initialBlueprint: Object,
showTitle: Boolean,
useSections: { type: Boolean, default: true }
},
data() {
return {
blueprint: clone(this.initialBlueprint),
blueprint: this.initializeBlueprint(),
sections: [],
initialTitle: this.initialBlueprint.title,
errors: {}
}
},
Expand Down Expand Up @@ -80,6 +83,14 @@ export default {
methods: {
initializeBlueprint() {
let blueprint = clone(this.initialBlueprint);
if (! this.showTitle) delete blueprint.title;
return blueprint;
},
sectionsUpdated(sections) {
this.sections = sections;
},
Expand Down
17 changes: 14 additions & 3 deletions resources/js/components/blueprints/Listing.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
<template>
<data-list :visible-columns="columns" :columns="columns" :rows="rows">
<data-list :visible-columns="columns" :columns="columns" :rows="rows" :sort="false">
<div class="card p-0" slot-scope="{ filteredRows: rows }">
<data-list-table>
<data-list-table
:reorderable="reorderable"
@reordered="$emit('reordered', $event)"
>
<template slot="cell-title" slot-scope="{ row: blueprint }">
<a :href="blueprint.edit_url">{{ blueprint.title }}</a>
</template>
Expand Down Expand Up @@ -36,7 +39,7 @@ export default {
mixins: [Listing],
props: ['initialRows'],
props: ['initialRows', 'reorderable'],
data() {
return {
Expand All @@ -47,6 +50,14 @@ export default {
{ label: __('Fields'), field: 'fields' },
]
}
},
watch: {
initialRows(rows) {
this.rows = rows;
}
}
}
Expand Down
15 changes: 12 additions & 3 deletions resources/js/components/blueprints/Section.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<template>

<div class="blueprint-section w-full md:w-1/2 2xl:w-1/3" :class="{ 'w-full': isEditing }">
<div class="blueprint-section"
:class="{
'w-full md:w-1/2 2xl:w-1/3': !isEditing && !isSingle,
'w-full': isEditing || isSingle
}"
>
<div class="blueprint-section-card card p-0 h-full flex flex-col">

<div class="bg-grey-20 border-b text-sm flex rounded-t;">
<div class="bg-grey-20 border-b text-sm flex rounded-t;" v-if="!isSingle">
<div class="blueprint-drag-handle blueprint-section-drag-handle w-4 border-r"></div>
<div class="p-1.5 py-1 flex-1">
<span class="font-medium mr-1">
Expand All @@ -25,7 +30,7 @@
class="p-2"
:fields="section.fields"
:editing-field="editingField"
:is-section-expanded="isEditing"
:is-section-expanded="isEditing || isSingle"
:suggestable-condition-fields="suggestableConditionFields"
@field-created="fieldCreated"
@field-updated="fieldUpdated"
Expand Down Expand Up @@ -60,6 +65,10 @@ export default {
section: {
type: Object,
required: true
},
isSingle: {
type: Boolean,
default: false
}
},
Expand Down
10 changes: 8 additions & 2 deletions resources/js/components/blueprints/Sections.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
v-for="(section, i) in sections"
:key="section._id"
:section="section"
:is-single="singleSection"
@updated="updateSection(i, $event)"
@deleted="deleteSection(i)"
/>

<div class="blueprint-add-section-container w-full md:w-1/2 2xl:w-1/3">
<div class="blueprint-add-section-container w-full md:w-1/2 2xl:w-1/3" v-if="!singleSection">
<button class="blueprint-add-section-button outline-none" @click="addSection">
<div class="text-center flex items-center leading-none">
<div class="text-2xl mr-1">+</div>
Expand Down Expand Up @@ -55,6 +56,10 @@ export default {
newSectionText: {
type: String,
default: () => __('New Section')
},
singleSection: {
type: Boolean,
default: false
}
},
Expand All @@ -80,7 +85,8 @@ export default {
methods: {
makeSortable() {
this.makeSectionsSortable();
if (! this.singleSection) this.makeSectionsSortable();
this.makeFieldsSortable();
},
Expand Down
39 changes: 39 additions & 0 deletions resources/js/components/collections/BlueprintListing.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script>
import BlueprintListing from '../blueprints/Listing.vue';
export default {
components: {
BlueprintListing
},
props: {
initialRows: Array,
reorderUrl: String
},
data() {
return {
rows: this.initialRows,
hasBeenReordered: false
}
},
methods: {
reordered(rows) {
this.rows = rows;
this.hasBeenReordered = true;
},
saveOrder() {
let order = this.rows.map(blueprint => blueprint.handle);
this.$axios
.post(this.reorderUrl, { order })
.then(response => this.$toast.success(__('Blueprints successfully reordered')))
.catch(error => this.$toast.error(__('Something went wrong')))
}
}
}
</script>
1 change: 1 addition & 0 deletions resources/js/components/collections/Listing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<template slot="actions" slot-scope="{ row: collection, index }">
<dropdown-list>
<dropdown-item :text="__('Edit Collection')" :redirect="collection.edit_url" />
<dropdown-item :text="__('Edit Blueprints')" :redirect="collection.blueprints_url" />
<dropdown-item :text="__('Scaffold Resources')" :redirect="collection.scaffold_url" />
<dropdown-item
v-if="collection.deleteable"
Expand Down
9 changes: 9 additions & 0 deletions resources/js/components/fieldtypes/HtmlFieldtype.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<template>
<div v-html="config.html" />
</template>

<script>
export default {
mixins: [Fieldtype]
};
</script>
1 change: 1 addition & 0 deletions resources/js/components/forms/Listing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<template slot="actions" slot-scope="{ row: form, index }">
<dropdown-list>
<dropdown-item :text="__('Edit')" :redirect="form.edit_url" />
<dropdown-item :text="__('Edit Blueprint')" :redirect="form.blueprint_url" />
<dropdown-item
v-if="form.deleteable"
:text="__('Delete')"
Expand Down
39 changes: 39 additions & 0 deletions resources/js/components/taxonomies/BlueprintListing.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<script>
import BlueprintListing from '../blueprints/Listing.vue';
export default {
components: {
BlueprintListing
},
props: {
initialRows: Array,
reorderUrl: String
},
data() {
return {
rows: this.initialRows,
hasBeenReordered: false
}
},
methods: {
reordered(rows) {
this.rows = rows;
this.hasBeenReordered = true;
},
saveOrder() {
let order = this.rows.map(blueprint => blueprint.handle);
this.$axios
.post(this.reorderUrl, { order })
.then(response => this.$toast.success(__('Blueprints successfully reordered')))
.catch(error => this.$toast.error(__('Something went wrong')))
}
}
}
</script>
Loading

0 comments on commit 258211a

Please sign in to comment.