2
0
mirror of https://github.com/frappe/books.git synced 2025-01-12 19:06:38 +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"> <div class="frappe-desk row no-gutters">
<frappe-sidebar :sidebarConfig="sidebarConfig"></frappe-sidebar> <frappe-sidebar :sidebarConfig="sidebarConfig"></frappe-sidebar>
<frappe-main> <frappe-main>
<frappe-navbar :showSearch="showSearch"></frappe-navbar> <frappe-navbar></frappe-navbar>
<slot></slot> <slot></slot>
</frappe-main> </frappe-main>
</div> </div>
@ -19,11 +19,6 @@ export default {
FrappeMain: Main, FrappeMain: Main,
FrappeNavbar: Navbar FrappeNavbar: Navbar
}, },
computed: {
showSearch() {
return /list|edit/.test(this.$route.path)
}
}
}; };
</script> </script>
<style> <style>

View File

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

View File

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