2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 15:50:56 +00:00
books/ui/pages/Report/index.vue
sahil28297 231b36a51b Make datatable non-editable in Report and formula field selectable (#85)
* making the datatable fields non editable and making the field selectable that uses formula

* Revised the datatable selectable property

* Update index.vue
2018-09-20 16:23:18 +05:30

77 lines
1.7 KiB
Vue

<template>
<div>
<div class="p-4">
<h4 class="pb-2">{{ reportConfig.title }}</h4>
<report-filters v-if="filtersExists" :filters="reportConfig.filterFields" :filterDefaults="filters" @change="getReportData"></report-filters>
<div class="pt-2" 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 './ReportFilters';
import utils from 'frappejs/client/ui/utils';
export default {
name: 'Report',
props: ['reportName', 'reportConfig', 'filters'],
computed: {
reportColumns() {
return utils.convertFieldsToDatatableColumns(
this.reportConfig.getColumns()
);
},
filtersExists() {
return (this.reportConfig.filterFields || []).length;
}
},
methods: {
async getReportData(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 = data.columns;
}
if (!rows) {
rows = [];
}
if (!columns) {
columns = this.reportColumns;
}
for(let column of columns) {
column.editable = false;
}
if (this.datatable) {
this.datatable.refresh(rows, columns);
} else {
this.datatable = new DataTable(this.$refs.datatable, {
columns: columns,
data: rows
});
}
}
},
components: {
ReportFilters
}
};
</script>
<style>
</style>