2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

Function for doctype list

This commit is contained in:
thefalconx33 2019-08-01 18:32:19 +05:30
parent 79b99055e0
commit a531450033
2 changed files with 25 additions and 1 deletions

View File

@ -46,6 +46,30 @@ module.exports = {
Object.assign(this.models, toAdd);
},
getDoctypeList(filters) {
let doctypeList = [];
if (filters && Object.keys(filters).length) {
for (let model in this.models) {
let doctypeName = model;
let doctype = this.models[doctypeName];
let matchedFields = 0;
for (let key in filters) {
let field = key;
let value = filters[field];
if (Boolean(doctype[field]) === Boolean(value)) {
matchedFields++;
}
}
if (matchedFields === Object.keys(filters).length)
doctypeList.push(doctypeName);
}
}
return doctypeList;
},
registerView(view, name, module) {
if (!this.views[view]) this.views[view] = {};
this.views[view][name] = module;

View File

@ -1,5 +1,5 @@
<template>
<div class="page-header px-4 py-3 d-flex align-items-center border-bottom bg-white">
<div class="page-header pr-4 ml-0 pl-0 py-2 d-flex align-items-center border-bottom bg-white">
<div class="text-right ml-2" v-for="link of links" :key="link.label">
<f-button secondary @click="link.handler">{{ link.label }}</f-button>
</div>