create page with specified content type + parent

This commit is contained in:
2020-08-12 14:16:28 +02:00
parent c6a3bee139
commit ec732c1c10
7 changed files with 26 additions and 53 deletions
+1 -1
View File
@@ -141,7 +141,7 @@
.catch(exception =>
{
this.loadingState = 'error';
this.loadingError = error;
this.loadingError = exception;
});
});
},
+12 -45
View File
@@ -1,5 +1,5 @@
<template>
<ui-form v-if="!loading" ref="form" class="page-create" v-slot="form" @submit="onSubmit" @load="onLoad">
<div v-if="!loading" class="page-create">
<h2 class="ui-headline">Create page</h2>
<div class="page-create-parent" v-if="config.parent">
Parent: <strong>{{config.parent.name}}</strong>
@@ -17,7 +17,7 @@
<div class="app-confirm-buttons">
<ui-button type="light" :label="config.closeLabel" :disabled="loading" @click="config.close"></ui-button>
</div>
</ui-form>
</div>
</template>
@@ -46,63 +46,30 @@
created()
{
console.info(this.config.parent);
this.model.parentId = this.config.parent ? this.config.parent.id : null;
},
methods: {
onLoad(form)
mounted()
{
PagesApi.getAllowedPageTypes(this.model.parentId).then(response =>
{
form.load(PagesApi.getAllowedPageTypes(this.model.parentId)).then(response =>
{
this.pageTypes = response;
this.loading = false;
});
},
this.pageTypes = response;
this.loading = false;
});
},
methods: {
onSelect(item)
{
this.config.close();
this.$router.push({
name: 'page-create',
params: { type: item.alias }
params: { type: item.alias, parent: this.model.parentId }
});
},
onSubmit(form)
{
//form.handle(TranslationsApi.save(this.item)).then(response =>
//{
// console.info(response);
//});
},
onDelete()
{
//Overlay.confirmDelete().then((opts) =>
//{
// opts.state('loading');
// TranslationsApi.delete(this.model.id).then(response =>
// {
// if (response.success)
// {
// opts.state('success');
// opts.hide();
// this.config.close();
// }
// else
// {
// opts.errors(response.errors);
// }
// });
//});
}
}
}
</script>
+2 -2
View File
@@ -23,7 +23,7 @@
export default {
props: ['id', 'type'],
props: ['id', 'type', 'parent'],
components: { UiEditor },
@@ -88,7 +88,7 @@
onLoad(form)
{
form.load(PagesApi.getById(this.$route.params.id)).then(response =>
form.load(!this.id ? PagesApi.getEmpty(this.type, this.parent) : PagesApi.getById(this.id)).then(response =>
{
this.renderer = 'page.' + response.entity.pageTypeAlias;
this.model = response.entity;
+1 -1
View File
@@ -14,7 +14,7 @@ if (section)
});
routes.push({
path: 'create/:type',
path: 'create/:type/:parent?',
props: true,
name: 'page-create',
component: () => import('zero/pages/' + alias + '/page')
+2 -2
View File
@@ -23,9 +23,9 @@ export default {
},
// get new media model
getEmpty()
getEmpty(type, parent)
{
return Axios.get(base + 'getEmpty').then(res => Promise.resolve(res.data));
return Axios.get(base + 'getEmpty', { params: { type, parent } }).then(res => Promise.resolve(res.data));
},
// get all media items
+7 -1
View File
@@ -5,7 +5,7 @@ using zero.Core.Entities;
namespace zero.Web.Controllers
{
public class PagesController<T> : BackofficeController where T : IPage
public class PagesController<T> : BackofficeController where T : IPage, new()
{
IPagesApi<T> Api;
@@ -23,6 +23,12 @@ namespace zero.Web.Controllers
public async Task<IActionResult> GetById([FromQuery] string id) => Edit(await Api.GetById(id));
public IActionResult GetEmpty(string type, string parent = null) => Edit(new T()
{
PageTypeAlias = type,
ParentId = parent
});
public async Task<IActionResult> Save([FromBody] T model) => Json(await Api.Save(model));
+1 -1
View File
@@ -16,7 +16,7 @@
</environment>
<title>zero</title>
</head>
<body class="theme-light">
<body class="theme-dark">
<div id="app"></div>
<script>
window.zero = window.zero || {};