2
0
mirror of https://github.com/frappe/books.git synced 2024-09-20 11:29:00 +00:00

chore: Delete old/unused components

This commit is contained in:
Faris Ansari 2019-12-21 21:25:08 +05:30
parent 2d2f5eb57e
commit f8fbb5ca02
9 changed files with 0 additions and 643 deletions

View File

@ -1,20 +0,0 @@
<template>
<div class="card" @click="$emit('click')">
<div class="card-body">
<h5 class="card-title">{{ title }}</h5>
<p class="card-text">
{{ description }}
</p>
</div>
</div>
</template>
<script>
export default {
props: ['title', 'description']
}
</script>
<style scoped>
.card {
cursor: pointer;
}
</style>

View File

@ -1,50 +0,0 @@
<template>
<form-layout
:fields="[docfield]"
:doc="doc"
/>
</template>
<script>
import frappe from 'frappejs';
// import SQLite from 'frappejs/backends/sqlite';
import FormLayout from 'frappejs/ui/components/Form/FormLayout';
import Observable from 'frappejs/utils/observable';
export default {
name: 'DatabaseSelector',
components: {
FormLayout
},
data() {
return {
docfield: {
fieldtype: 'File',
label: 'Select File',
fieldname: 'file',
filetypes: ['.db']
},
value: null,
invalid: false
}
},
created() {
this.doc = new Observable();
},
methods: {
handleChange(fileList) {
const value = fileList[0].name;
this.value = value;
},
async changeDatabase() {
if (frappe.db) {
frappe.db.close();
}
const dbPath = this.value;
frappe.db = new SQLite({ dbPath });
await frappe.db.connect();
await frappe.db.migrate();
}
}
}
</script>

View File

@ -1,47 +0,0 @@
<template>
<div class="frappe-form">
<form-actions v-if="shouldRenderForm" :doc="doc" @send="send"/>
<div class="p-3">
<form-layout
v-if="shouldRenderForm"
:doc="doc"
:fields="meta.fields"
:layout="meta.layout"
:invalid="invalid"
/>
</div>
<not-found v-if="notFound"/>
</div>
</template>
<script>
import frappe from 'frappejs';
import Form from 'frappejs/ui/components/Form/Form';
import FormActions from './EmailSendActions';
export default {
name: 'Form',
extends: Form,
components: {
FormActions
},
methods: {
async send() {
this.doc = await frappe.getDoc(this.doctype, this.name);
var response = await frappe.call({
method: 'send-mail',
args: this.doc.getValidDict()
});
if (response) {
let emailFields = frappe.getMeta('Email').fields;
// this.doc['name'] = this.name;
this.save();
} else {
// Raise Error
console.log('Email Not Found');
}
}
}
};
</script>
<style>
</style>

View File

@ -1,25 +0,0 @@
<template>
<div
class="frappe-form-actions d-flex justify-content-between align-items-center p-3 border-bottom"
>
<h5 class="m-0">Compose Email</h5>
<h5 class="m-0"></h5>
<f-button primary v-if="isDirty" @click="$emit('send')">Send</f-button>
</div>
</template>
<script>
import frappe from 'frappejs';
export default {
props: ['doc'],
data() {
return {
isDirty: false
};
},
created() {
this.doc.on('change', () => {
this.isDirty = this.doc._dirty;
});
}
};
</script>

View File

@ -1,204 +0,0 @@
<template>
<div class="bg-white">
<page-header :breadcrumbs="breadcrumbs" />
<div class="form-container col-9 col-lg-8 col-xl-7 mx-2 mt-4">
<form-actions
v-if="shouldRenderForm"
:doc="doc"
@save="save"
@submit="submit"
@revert="revert"
@print="print"
:links="links"
/>
<hr class="mb-3" />
<form-layout
v-if="shouldRenderForm"
:doc="doc"
:fields="meta.fields"
:layout="meta.layout"
:invalid="isFormInvalid"
/>
</div>
</div>
</template>
<script>
import frappe from 'frappejs';
import FormActions from 'frappejs/ui/components/Form/FormActions';
import FormLayout from 'frappejs/ui/components/Form/FormLayout';
import PageHeader from '@/components/PageHeader';
export default {
name: 'FormView',
props: ['doctype', 'name'],
components: {
PageHeader,
FormActions,
FormLayout
},
watch: {
name(newValue, oldValue) {
if (newValue !== oldValue) {
this.loadDoc();
}
}
},
data() {
return {
doc: null,
links: [],
isFormInvalid: false,
notFound: false
};
},
computed: {
breadcrumbs() {
if (this.doc)
return [
{
title: this.getFormTitle(),
route: '#/list/' + this.getListTitle()
}
];
},
shouldRenderForm() {
return this.name && this.doc;
},
meta() {
return frappe.getMeta(this.doctype);
}
},
created() {
if (!this.defaults) {
this.defaults = {};
}
this.meta.fields.map(field => {
if (field.defaultValue)
this.defaults[field.fieldname] = field.defaultValue;
});
this.loadDoc();
},
methods: {
async loadDoc() {
if (!this.name) return;
try {
// need to de-reference to let vue know that doc is changed
this.doc = null;
this.doc = await frappe.getDoc(this.doctype, this.name);
if (
this.doc._notInserted &&
this.meta.fields.map(df => df.fieldname).includes('name')
) {
// For a user editable name field,
// it should be unset since it is autogenerated
this.doc.set('name', '');
}
if (this.doc._notInserted && this.defaults) {
for (let fieldname in this.defaults) {
const value = this.defaults[fieldname];
await this.doc.set(fieldname, value);
}
}
this.setLinks();
this.doc.on('change', this.setLinks);
} catch (e) {
console.log(e);
this.notFound = true;
this.$router.push({
path: `/`
});
}
},
getFormTitle() {
try {
// For different list/form based on same doctype
// Since they will have different title
return (
this.meta.getFormTitle(this.doc) || this.meta.label || this.doctype
);
} catch (e) {
return this.meta.label || this.doctype;
}
},
getListTitle() {
try {
// For different list/form based on same doctype
// Since they will have different route to their list
return this.meta.getListTitle(this.doc);
} catch (e) {
return this.doctype;
}
},
async save() {
this.setValidity();
if (this.isFormInvalid) return;
try {
if (this.doc.isNew()) {
await this.doc.insert();
} else {
await this.doc.update();
}
this.$emit('save', this.doc);
} catch (e) {
console.error(e);
throw e;
}
},
async submit() {
await this.doc.set('submitted', 1);
try {
await this.save();
} catch (e) {
await this.doc.set('submitted', 0);
await this.doc.set('_dirty', false);
}
},
async revert() {
this.doc.set('submitted', 0);
try {
await this.save();
} catch (e) {
await this.doc.set('submitted', 1);
await this.doc.set('_dirty', false);
}
},
print() {
this.$router.push(`/print/${this.doctype}/${this.name}`);
},
setLinks() {
if (this.meta.links) {
let links = [];
for (let link of this.meta.links) {
if (link.condition(this)) {
link.handler = () => {
link.action(this);
};
links.push(link);
}
}
this.links = links;
}
},
setValidity() {
const form = this.$el.querySelector('form');
let validity = form.checkValidity();
this.isFormInvalid = !validity;
}
}
};
</script>
<style>
.table th,
.table td {
vertical-align: middle;
}
</style>

View File

@ -1,44 +0,0 @@
<template>
<div :key="usedToReRender">
<div
class="mr-2 d-flex"
v-for="filter in Object.keys(currentFilters)"
:key="filter"
style="user-select: none; "
>
<span
class="p-0 pl-2 py-1 badge badge-light border lead d-flex align-items-center font-weight-normal"
>
{{ filter }} = "{{ currentFilters[filter] }}"
<feather-icon class="mb-1 mx-2" name="x" @click.native="removeFilter(filter)" />
</span>
</div>
</div>
</template>
<script>
export default {
name: 'ListFilters',
props: ['filters'],
data() {
return {
currentFilters: this.filters,
usedToReRender: 0
};
},
computed: {
filterValues() {
return this.currentFilters;
}
},
methods: {
removeFilter(filter) {
delete this.currentFilters[filter];
this.usedToReRender += 1;
}
}
};
</script>
<style scoped>
</style>

View File

@ -1,23 +0,0 @@
<template>
<div class="d-flex mt-2">
<div style="flex: 1;">
<list-filters :filters="filters"></list-filters>
</div>
<div class="d-flex flex-column-reverse" style="padding-bottom: 1rem;">
<f-button primary @click="$emit('newClick')">{{ _('New {0}', title) }}</f-button>
</div>
</div>
</template>
<script>
import ListFilters from './ListFilters';
export default {
name: 'ListToolbar',
props: ['title', 'filters'],
components: {
ListFilters
}
};
</script>

View File

@ -1,156 +0,0 @@
<template>
<div class="report-view" style="height: 100%">
<div style="height: 100%">
<div class="pb-4 d-flex">
<page-header :breadcrumbs="breadcrumbs" style="flex-grow: 1;" />
<report-links class="d-flex flex-row-reverse" v-if="linksExists" :links="links"></report-links>
</div>
<div class="pl-1">
<report-filters
class="col-12"
v-if="shouldRenderFields"
:filterFields="reportConfig.filterFields"
:filterDoc="filterDoc"
:filterDefaults="filters"
@change="getReportData"
:key="usedToReRender"
></report-filters>
</div>
<div class="pt-2 px-4" style="height: 100%" ref="datatable" v-once></div>
</div>
<not-found v-if="!reportConfig" />
</div>
</template>
<script>
import DataTable from 'frappe-datatable';
import frappe from 'frappejs';
import ReportFilters from 'frappejs/ui/pages/Report/ReportFilters';
import ReportLinks from 'frappejs/ui/pages/Report/ReportLinks';
import PageHeader from '@/components/PageHeader';
import utils from 'frappejs/client/ui/utils';
export default {
name: 'Report',
props: ['reportName', 'reportConfig', 'filters'],
data() {
return {
currentFilters: this.filters,
usedToReRender: 0,
filterDoc: undefined,
links: []
};
},
computed: {
breadcrumbs() {
return [
{
title: 'Reports',
route: ''
},
{
title: this.reportConfig.title,
route: ''
}
];
},
shouldRenderFields() {
return (this.reportConfig.filterFields || []).length && this.filterDoc;
},
linksExists() {
return (this.reportConfig.linkFields || []).length;
}
},
async created() {
this.setLinks();
this.filterDoc = await frappe.newCustomDoc(this.reportConfig.filterFields);
},
methods: {
async getReportData(filters) {
this.currentFilters = filters;
let data = await frappe.call({
method: this.reportConfig.method,
args: filters
});
let rows, columns;
if (data.rows) {
rows = data.rows;
} else {
rows = data;
}
if (data.columns) {
columns = this.getColumns(data);
}
if (!rows) {
rows = [];
}
if (!columns) {
columns = this.getColumns();
}
for (let column of columns) {
column.editable = false;
}
if (this.datatable) {
if (rows.length) {
this.datatable.refresh(rows, columns);
} else {
// remove all rows form datatable
this.datatable.wrapper.innerHTML = '';
this.datatable = undefined;
}
} else {
if (rows.length) {
this.datatable = new DataTable(this.$refs.datatable, {
columns: columns,
data: rows,
treeView: this.reportConfig.treeView || false,
cellHeight: 35
});
}
}
this.setLinks();
return [rows, columns];
},
setLinks() {
if (this.linksExists) {
let links = [];
for (let link of this.reportConfig.linkFields) {
if (!link.condition || (link.condition && link.condition(this)))
links.push({
label: link.label,
handler: () => {
link.action(this);
}
});
}
this.links = links;
}
},
getColumns(data) {
const columns = this.reportConfig.getColumns(data);
return utils.convertFieldsToDatatableColumns(columns);
}
},
components: {
ReportFilters,
ReportLinks,
PageHeader
}
};
</script>
<style>
.datatable {
font-size: 12px;
}
.dt-scrollable {
height: 77vh;
}
.report-view {
overflow: hidden;
}
</style>

View File

@ -1,74 +0,0 @@
<template>
<div>
<page-header title="Reports" />
<div class="row">
<div class="col-8 mx-auto">
<clickable-card
class="mt-2"
title="General Ledger"
description="List of all ledger entries booked against all accounts"
@click="routeTo('general-ledger', { 'referenceType': 'SalesInvoice' })"
/>
<clickable-card
class="mt-2"
title="Profit and Loss"
description="Profit and Loss statement"
@click="routeTo('profit-and-loss')"
/>
<clickable-card
class="mt-2"
title="Trial Balance"
description="Trial Balance"
@click="routeTo('trial-balance')"
/>
<clickable-card
class="mt-2"
title="Sales Register"
description="Sales transactions for a given period with invoiced amount and tax details"
@click="routeTo('sales-register')"
/>
<clickable-card
class="mt-2"
title="Bank Reconciliation"
description="Bank Reconciliation statement"
@click="routeTo('bank-reconciliation',{'toDate' : (new Date()).toISOString()})"
/>
<clickable-card
v-if="country === 'India'"
class="mt-2"
title="Goods and Service Tax"
description="See your goods and services tax here."
@click="routeTo('gst-taxes',{'toDate' : (new Date()).toISOString()})"
/>
</div>
</div>
</div>
</template>
<script>
import frappe from 'frappejs';
import PageHeader from '../components/PageHeader';
import ClickableCard from '../components/ClickableCard';
export default {
name: 'Report',
data() {
return {
country: ''
};
},
components: {
PageHeader,
ClickableCard
},
async created() {
const doc = await frappe.getDoc('AccountingSettings');
this.country = doc.country;
},
methods: {
routeTo(route, filters) {
const query = new URLSearchParams(filters);
this.$router.push(`/report/${route}?${query}`);
}
}
};
</script>