mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
Form rendering based on Layout
- ListAndForm is now cached between list and form routes
This commit is contained in:
parent
90f8c754a9
commit
d518ca3e6d
@ -65,7 +65,11 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// section 2
|
// section 2
|
||||||
{ fields: [ "description" ] },
|
{
|
||||||
|
columns: [
|
||||||
|
{ fields: [ "description" ] }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
|
||||||
// section 3
|
// section 3
|
||||||
{
|
{
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div id="app">
|
<div id="app">
|
||||||
<frappe-desk>
|
<frappe-desk>
|
||||||
<router-view :key="$route.path" />
|
<router-view />
|
||||||
</frappe-desk>
|
</frappe-desk>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -10,9 +10,10 @@
|
|||||||
v-if="shouldRenderForm"
|
v-if="shouldRenderForm"
|
||||||
:doc="doc"
|
:doc="doc"
|
||||||
:fields="meta.fields"
|
:fields="meta.fields"
|
||||||
|
:layout="meta.layout"
|
||||||
@field-change="updateDoc"
|
@field-change="updateDoc"
|
||||||
/>
|
/>
|
||||||
<not-found v-else />
|
<not-found v-if="notFound" />
|
||||||
</div>
|
</div>
|
||||||
</keep-alive>
|
</keep-alive>
|
||||||
</template>
|
</template>
|
||||||
@ -40,7 +41,7 @@ export default {
|
|||||||
return frappe.getMeta(this.doctype);
|
return frappe.getMeta(this.doctype);
|
||||||
},
|
},
|
||||||
shouldRenderForm() {
|
shouldRenderForm() {
|
||||||
return this.name && this.doc && !this.notFound;
|
return this.name && this.doc;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
@ -58,14 +59,13 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
let oldName = this.doc.name;
|
|
||||||
if (this.doc._notInserted) {
|
if (this.doc._notInserted) {
|
||||||
await this.doc.insert();
|
await this.doc.insert();
|
||||||
} else {
|
} else {
|
||||||
await this.doc.update();
|
await this.doc.update();
|
||||||
}
|
}
|
||||||
// frappe.ui.showAlert({ message: frappe._('Saved'), color: 'green' });
|
|
||||||
if (oldName !== this.doc.name) {
|
if (this.doc.name !== this.$route.params.name) {
|
||||||
this.$router.push(`/edit/${this.doctype}/${this.doc.name}`);
|
this.$router.push(`/edit/${this.doctype}/${this.doc.name}`);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="frappe-list-form row no-gutters">
|
<div class="frappe-list-form row no-gutters">
|
||||||
<div class="col-4 border-right">
|
<div class="col-4 border-right">
|
||||||
<frappe-list :doctype="doctype" />
|
<frappe-list :doctype="doctype" :key="doctype" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<frappe-form v-if="name" :doctype="doctype" :name="name" />
|
<frappe-form v-if="name" :key="doctype + name" :doctype="doctype" :name="name" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@ -13,20 +13,22 @@ import List from './List';
|
|||||||
import Form from './Form';
|
import Form from './Form';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
doctype: this.$route.params.doctype,
|
|
||||||
name: this.$route.params.name
|
|
||||||
}
|
|
||||||
},
|
|
||||||
components: {
|
components: {
|
||||||
FrappeList: List,
|
FrappeList: List,
|
||||||
FrappeForm: Form
|
FrappeForm: Form
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
doctype() {
|
||||||
|
return this.$route.params.doctype;
|
||||||
|
},
|
||||||
|
name() {
|
||||||
|
return this.$route.params.name;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
.frappe-list-form {
|
.frappe-list-form {
|
||||||
min-height: calc(100vh - 57px);
|
min-height: calc(100vh - 4rem);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user