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

fix: Minor component fixes

- Use meta.getKeywordFields instead of keywordFields
- Make the full "Add Row" Row clickable
- Highlight today's date in DatePicker
- Set default filters on activated in Report
This commit is contained in:
Faris Ansari 2019-12-20 12:24:12 +05:30
parent c0c7a9edbb
commit c9d0219320
4 changed files with 17 additions and 13 deletions

View File

@ -18,7 +18,9 @@ export default {
let results = await frappe.db.getAll({ let results = await frappe.db.getAll({
doctype, doctype,
filters, filters,
fields: [...new Set(['name', meta.titleField, ...meta.keywordFields])] fields: [
...new Set(['name', meta.titleField, ...meta.getKeywordFields()])
]
}); });
let createNewOption = this.getCreateNewOption(); let createNewOption = this.getCreateNewOption();
let suggestions = results let suggestions = results
@ -77,8 +79,6 @@ export default {
async openNewDoc() { async openNewDoc() {
let doctype = this.df.target; let doctype = this.df.target;
let doc = await frappe.getNewDoc(doctype); let doc = await frappe.getNewDoc(doctype);
let currentPath = this.$route.path;
let currentQuery = this.$route.query;
let filters = await this.getFilters(); let filters = await this.getFilters();
openQuickEdit({ openQuickEdit({
doctype, doctype,

View File

@ -17,24 +17,25 @@
{{ df.label }} {{ df.label }}
</div> </div>
</Row> </Row>
<TableRow v-for="row in value" :key="row.name" v-bind="{ row, tableFields, size, ratio, isNumeric }" /> <TableRow
v-for="row in value"
:key="row.name"
v-bind="{ row, tableFields, size, ratio, isNumeric }"
/>
<Row <Row
:ratio="ratio" :ratio="ratio"
class="text-gray-500 cursor-pointer border-transparent px-2 w-full" class="text-gray-500 cursor-pointer border-transparent px-2 w-full"
v-if="!isReadOnly" v-if="!isReadOnly"
@click.native="addRow"
> >
<div class="flex items-center pl-1"> <div class="flex items-center pl-1">
<feather-icon <feather-icon name="plus" class="w-4 h-4 text-gray-500" />
name="plus"
class="w-4 h-4 text-gray-500"
/>
</div> </div>
<div <div
:class="{ :class="{
'px-2 py-3': size === 'small', 'px-2 py-3': size === 'small',
'px-3 py-4': size !== 'small' 'px-3 py-4': size !== 'small'
}" }"
@click="addRow"
> >
{{ _('Add Row') }} {{ _('Add Row') }}
</div> </div>
@ -43,8 +44,8 @@
</template> </template>
<script> <script>
import frappe from 'frappejs';
import Row from '@/components/Row'; import Row from '@/components/Row';
import Icon from '@/components/Icon';
import Base from './Base'; import Base from './Base';
import TableRow from './TableRow'; import TableRow from './TableRow';
@ -58,7 +59,6 @@ export default {
}, },
components: { components: {
Row, Row,
Icon,
TableRow TableRow
}, },
methods: { methods: {
@ -70,7 +70,7 @@ export default {
}, },
computed: { computed: {
ratio() { ratio() {
return [0.3].concat(this.tableFields.map(_ => 1)); return [0.3].concat(this.tableFields.map(() => 1));
}, },
tableFields() { tableFields() {
let meta = frappe.getMeta(this.df.childtype); let meta = frappe.getMeta(this.df.childtype);

View File

@ -58,6 +58,7 @@
class="w-6 h-6 mr-1 last:mr-0 flex-center cursor-pointer rounded-md hover:bg-blue-100 hover:text-blue-500" class="w-6 h-6 mr-1 last:mr-0 flex-center cursor-pointer rounded-md hover:bg-blue-100 hover:text-blue-500"
:class="{ :class="{
'text-gray-600': date.getMonth() !== currentMonth - 1, 'text-gray-600': date.getMonth() !== currentMonth - 1,
'text-blue-500': toValue(date) === toValue(today),
'bg-blue-100 font-semibold text-blue-500': 'bg-blue-100 font-semibold text-blue-500':
toValue(date) === value toValue(date) === value
}" }"
@ -95,6 +96,9 @@ export default {
this.selectCurrentMonthYear(); this.selectCurrentMonthYear();
}, },
computed: { computed: {
today() {
return this.getDate();
},
datesAsWeeks() { datesAsWeeks() {
let datesAsWeeks = []; let datesAsWeeks = [];
let dates = this.dates.slice(); let dates = this.dates.slice();

View File

@ -117,7 +117,7 @@ export default {
} }
}; };
}, },
async mounted() { async activated() {
this.reportData.columns = this.report.getColumns(); this.reportData.columns = this.report.getColumns();
await this.setDefaultFilters(); await this.setDefaultFilters();
await this.fetchReportData(); await this.fetchReportData();