mirror of
https://github.com/frappe/books.git
synced 2024-12-23 11:29:03 +00:00
commit
ea71a8da1e
@ -18,7 +18,7 @@ export default {
|
|||||||
FrappeSidebar: Sidebar,
|
FrappeSidebar: Sidebar,
|
||||||
FrappeMain: Main,
|
FrappeMain: Main,
|
||||||
FrappeNavbar: Navbar
|
FrappeNavbar: Navbar
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<style>
|
<style>
|
||||||
|
@ -29,7 +29,7 @@ import ListItem from './ListItem';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'List',
|
name: 'List',
|
||||||
props: ['doctype', 'filters'],
|
props: ['doctype'],
|
||||||
components: {
|
components: {
|
||||||
ListActions,
|
ListActions,
|
||||||
ListItem
|
ListItem
|
||||||
@ -53,6 +53,8 @@ export default {
|
|||||||
frappe.db.on(`change:${this.doctype}`, () => {
|
frappe.db.on(`change:${this.doctype}`, () => {
|
||||||
this.updateList();
|
this.updateList();
|
||||||
});
|
});
|
||||||
|
this.$root.$on('navbarSearch', this.updateList);
|
||||||
|
this.$root.$emit('newList');
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
this.updateList();
|
this.updateList();
|
||||||
@ -62,7 +64,13 @@ export default {
|
|||||||
let doc = await frappe.getNewDoc(this.doctype);
|
let doc = await frappe.getNewDoc(this.doctype);
|
||||||
this.$router.push(`/edit/${this.doctype}/${doc.name}`);
|
this.$router.push(`/edit/${this.doctype}/${doc.name}`);
|
||||||
},
|
},
|
||||||
async updateList() {
|
async updateList(query=null) {
|
||||||
|
let filters = null
|
||||||
|
if (query) {
|
||||||
|
filters = {
|
||||||
|
keywords : ['like', query]
|
||||||
|
}
|
||||||
|
}
|
||||||
const indicatorField = this.hasIndicator ? this.meta.indicators.key : null;
|
const indicatorField = this.hasIndicator ? this.meta.indicators.key : null;
|
||||||
const fields = [
|
const fields = [
|
||||||
'name',
|
'name',
|
||||||
@ -74,7 +82,7 @@ export default {
|
|||||||
const data = await frappe.db.getAll({
|
const data = await frappe.db.getAll({
|
||||||
doctype: this.doctype,
|
doctype: this.doctype,
|
||||||
fields,
|
fields,
|
||||||
filters: this.filters || null
|
filters: filters || null
|
||||||
});
|
});
|
||||||
|
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
@ -1,7 +1,39 @@
|
|||||||
<template>
|
<template>
|
||||||
<nav class="frappe-navbar navbar navbar-light bg-light row no-gutters border-bottom border-top">
|
<nav class="frappe-navbar navbar navbar-light bg-light row no-gutters border-bottom border-top">
|
||||||
<form class="form-inline col-4 pr-3">
|
<form v-if="showSearch" class="form-inline col-4 pr-3">
|
||||||
<input type="search" name="search" class="form-control shadow-none w-100" placeholder="Search...">
|
<input type="text"
|
||||||
</form>
|
v-model="searchValue"
|
||||||
</nav>
|
@input="updateSearch"
|
||||||
|
name="search"
|
||||||
|
class="form-control shadow-none w-100"
|
||||||
|
:placeholder="_('Search...')">
|
||||||
|
</form>
|
||||||
|
<div class="navbar-text">.</div>
|
||||||
|
</nav>
|
||||||
</template>
|
</template>
|
||||||
|
<script>
|
||||||
|
import { debounce } from 'lodash';
|
||||||
|
export default {
|
||||||
|
props: ['showSearch'],
|
||||||
|
data() {
|
||||||
|
return {
|
||||||
|
searchValue: ''
|
||||||
|
};
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
showSearch() {
|
||||||
|
// TODO: Make this configurable
|
||||||
|
return /list|edit/.test(this.$route.path)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$root.$on('newList', () => this.searchValue = '')
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
updateSearch: debounce(function() {
|
||||||
|
this.$root.$emit('navbarSearch', this.searchValue)
|
||||||
|
}, 500)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<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" :filters="filters" :key="doctype" />
|
<frappe-list :doctype="doctype" :key="doctype" />
|
||||||
</div>
|
</div>
|
||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<frappe-form v-if="name" :key="doctype + name" :doctype="doctype" :name="name" @save="onSave" />
|
<frappe-form v-if="name" :key="doctype + name" :doctype="doctype" :name="name" @save="onSave" />
|
||||||
@ -13,7 +13,7 @@ import List from '../components/List/List';
|
|||||||
import Form from '../components/Form/Form';
|
import Form from '../components/Form/Form';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
props: ['doctype', 'name', 'filters'],
|
props: ['doctype', 'name'],
|
||||||
components: {
|
components: {
|
||||||
FrappeList: List,
|
FrappeList: List,
|
||||||
FrappeForm: Form
|
FrappeForm: Form
|
||||||
|
Loading…
Reference in New Issue
Block a user