Files
mixtape/zero.Backoffice.UI/old_app/components/modules/edit-module.vue
T

124 lines
2.4 KiB
Vue
Raw Normal View History

<template>
2020-08-20 01:35:08 +02:00
<ui-form ref="form" v-slot="form" @submit="onSubmit" @load="onLoad">
<ui-overlay-editor class="ui-module-overlay">
2020-08-20 01:35:08 +02:00
<template v-slot:header>
<ui-header-bar :title="config.module.name" :back-button="false" :close-button="true" />
</template>
<template v-slot:footer>
<ui-button type="light onbg" label="@ui.close" @click="config.hide"></ui-button>
2020-09-17 11:26:23 +02:00
<ui-button v-if="!disabled" type="primary" :submit="true" label="Confirm" :state="form.state" :disabled="loading"></ui-button>
2020-08-20 01:35:08 +02:00
</template>
<ui-loading v-if="loading" :is-big="true" />
<div v-if="!loading" class="ui-module-overlay-editor">
2020-10-20 16:00:55 +02:00
<ui-editor :config="editor" v-model="model" :meta="meta" :is-page="false" infos="none" :disabled="disabled" />
2020-08-20 01:35:08 +02:00
</div>
</ui-overlay-editor>
</ui-form>
</template>
<script>
2020-11-20 15:17:41 +01:00
import ModulesApi from 'zero/api/modules.js';
2020-11-01 22:20:29 +01:00
import UiEditor from 'zero/editor/editor.vue';
export default {
props: {
config: Object
},
components: { UiEditor },
data: () => ({
2020-08-20 14:35:08 +02:00
isAdd: true,
2020-08-20 01:35:08 +02:00
disabled: false,
id: null,
loading: true,
state: 'default',
2020-08-20 01:35:08 +02:00
meta: {},
2020-10-20 16:00:55 +02:00
editor: null,
2020-08-20 01:35:08 +02:00
model: {}
}),
2020-10-20 16:00:55 +02:00
created()
{
this.editor = this.config.editor;
},
methods: {
2020-08-20 01:35:08 +02:00
onLoad(form)
{
2020-08-20 14:35:08 +02:00
if (this.config.model)
{
this.isAdd = false;
this.model = JSON.parse(JSON.stringify(this.config.model));
}
form.load(ModulesApi.getEmpty(this.config.module.alias)).then(response =>
2020-08-20 01:35:08 +02:00
{
2020-09-17 11:26:23 +02:00
this.disabled = !response.meta.canEdit || this.config.disabled;
2020-08-20 01:35:08 +02:00
this.meta = response.meta;
2020-08-20 14:35:08 +02:00
if (this.isAdd)
{
this.model = response.entity;
}
2020-08-20 01:35:08 +02:00
this.loading = false;
});
},
onSubmit(form)
{
this.config.confirm(this.model);
}
}
}
</script>
<style lang="scss">
.ui-module-overlay
{
> content
{
2020-08-20 01:35:08 +02:00
position: relative;
padding-top: 0 !important;
}
.ui-box
{
margin: 0;
}
.ui-tabs-list
{
padding: 0;
padding-bottom: 32px;
}
.ui-property.ui-modules
{
margin: 0;
padding: 0;
}
.editor-outer.-infos-aside:not(.is-page)
{
display: block;
}
2020-08-20 01:35:08 +02:00
.ui-loading
{
position: absolute;
left: 50%;
top: 50%;
margin: -14px 0 0 -14px;
}
}
</style>