2
0
mirror of https://github.com/frappe/books.git synced 2025-02-04 04:58:30 +00:00
books/src/pages/ListView/ListCell.vue

31 lines
755 B
Vue
Raw Normal View History

<template>
2019-12-04 00:16:48 +05:30
<div class="py-4 flex items-center truncate" :class="cellClass">
<span class="truncate" v-if="!customRenderer">{{ columnValue }}</span>
<component v-else :is="customRenderer" />
</div>
</template>
<script>
import frappe from 'frappejs';
export default {
name: 'ListCell',
props: ['doc', 'column'],
computed: {
columnValue() {
let { column, doc } = this;
2019-12-03 13:50:45 +05:30
let value = doc[column.fieldname];
return frappe.format(value, column, doc);
},
customRenderer() {
if (!this.column.render) return;
return this.column.render(this.doc);
2019-12-03 13:50:45 +05:30
},
cellClass() {
return ['Int', 'Float', 'Currency'].includes(this.column.fieldtype)
? 'justify-end'
: '';
}
}
};
</script>