2
0
mirror of https://github.com/frappe/books.git synced 2024-11-13 00:46:28 +00:00

Refactor code

This commit is contained in:
Suraj Shetty 2018-07-12 21:57:23 +05:30
parent 8bff2e42fb
commit 5d60955856
3 changed files with 25 additions and 23 deletions

View File

@ -2,7 +2,7 @@
<div class="frappe-desk row no-gutters">
<frappe-sidebar :sidebarConfig="sidebarConfig"></frappe-sidebar>
<frappe-main>
<frappe-navbar :showSearch="showSearch"></frappe-navbar>
<frappe-navbar></frappe-navbar>
<slot></slot>
</frappe-main>
</div>
@ -19,11 +19,6 @@ export default {
FrappeMain: Main,
FrappeNavbar: Navbar
},
computed: {
showSearch() {
return /list|edit/.test(this.$route.path)
}
}
};
</script>
<style>

View File

@ -53,8 +53,8 @@ export default {
frappe.db.on(`change:${this.doctype}`, () => {
this.updateList();
});
this.$root.$on('search', this.updateList)
this.$root.$emit('newList')
this.$root.$on('navbarSearch', this.updateList);
this.$root.$emit('newList');
},
mounted() {
this.updateList();

View File

@ -6,27 +6,34 @@
@input="updateSearch"
name="search"
class="form-control shadow-none w-100"
placeholder="Search...">
:placeholder="_('Search...')">
</form>
<div class="navbar-text">HI</div>
<div class="navbar-text">.</div>
</nav>
</template>
<script>
import { debounce } from 'lodash';
export default {
props: ["showSearch"],
data() {
return {
searchValue: ''
};
},
mounted() {
this.$root.$on('newList', () => this.searchValue = '')
},
methods: {
updateSearch: debounce(function() {
this.$root.$emit("search", this.searchValue);
}, 500)
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>