mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
fix: Table control
- TableRow to make DynamicLink work - Read only table
This commit is contained in:
parent
6b3bedf909
commit
97ad435ecb
@ -1,44 +1,52 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
|
<div class="text-gray-600 text-sm mb-1" v-if="showLabel">
|
||||||
|
{{ df.label }}
|
||||||
|
</div>
|
||||||
<Row :ratio="ratio" class="border-b px-2 text-gray-600">
|
<Row :ratio="ratio" class="border-b px-2 text-gray-600">
|
||||||
<div class="flex items-center pl-2">No</div>
|
<div class="flex items-center pl-2">No</div>
|
||||||
<div
|
<div
|
||||||
:class="{'px-2 py-3': size === 'small', 'px-3 py-4': size !== 'small', 'text-right': isNumeric(df) }"
|
:class="{
|
||||||
|
'px-2 py-3': size === 'small',
|
||||||
|
'px-3 py-4': size !== 'small',
|
||||||
|
'text-right': isNumeric(df)
|
||||||
|
}"
|
||||||
v-for="df in tableFields"
|
v-for="df in tableFields"
|
||||||
:key="df.fieldname"
|
:key="df.fieldname"
|
||||||
>{{ df.label }}</div>
|
>
|
||||||
|
{{ df.label }}
|
||||||
|
</div>
|
||||||
</Row>
|
</Row>
|
||||||
<Row v-for="row in value" :key="row.name" :ratio="ratio" class="border-b px-2">
|
<TableRow v-for="row in value" :key="row.name" v-bind="{ row, tableFields, size, ratio, isNumeric }" />
|
||||||
<div class="flex items-center pl-2 text-gray-600">{{ row.idx + 1 }}</div>
|
<Row
|
||||||
<FormControl
|
:ratio="ratio"
|
||||||
:size="size"
|
class="text-gray-500 cursor-pointer border-transparent px-2"
|
||||||
class="py-2"
|
v-if="!isReadOnly"
|
||||||
:input-class="{'text-right': isNumeric(df)}"
|
>
|
||||||
:key="df.fieldname"
|
<div class="flex items-center pl-1">
|
||||||
v-for="df in tableFields"
|
<feather-icon
|
||||||
:df="df"
|
name="plus"
|
||||||
:value="row[df.fieldname]"
|
class="w-4 h-4 text-gray-500"
|
||||||
@change="value => row.set(df.fieldname, value)"
|
/>
|
||||||
@new-doc="doc => row.set(df.fieldname, doc.name)"
|
|
||||||
/>
|
|
||||||
</Row>
|
|
||||||
<Row :ratio="ratio" class="text-gray-500 cursor-pointer border-transparent px-2">
|
|
||||||
<div class="flex items-center pl-2">
|
|
||||||
<AddIcon class="w-3 h-3 text-gray-500 stroke-current" />
|
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
:class="{'px-2 py-3': size === 'small', 'px-3 py-4': size !== 'small'}"
|
:class="{
|
||||||
|
'px-2 py-3': size === 'small',
|
||||||
|
'px-3 py-4': size !== 'small'
|
||||||
|
}"
|
||||||
@click="addRow"
|
@click="addRow"
|
||||||
>{{ _('Add Row') }}</div>
|
>
|
||||||
|
{{ _('Add Row') }}
|
||||||
|
</div>
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import Row from '@/components/Row';
|
import Row from '@/components/Row';
|
||||||
import AddIcon from '@/components/Icons/Add';
|
import Icon from '@/components/Icon';
|
||||||
import Base from './Base';
|
import Base from './Base';
|
||||||
import FormControl from './FormControl';
|
import TableRow from './TableRow';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Table',
|
name: 'Table',
|
||||||
@ -50,10 +58,8 @@ export default {
|
|||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
Row,
|
Row,
|
||||||
AddIcon
|
Icon,
|
||||||
},
|
TableRow
|
||||||
beforeCreate() {
|
|
||||||
this.$options.components.FormControl = FormControl;
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
focus() {},
|
focus() {},
|
||||||
|
41
src/components/Controls/TableRow.vue
Normal file
41
src/components/Controls/TableRow.vue
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
<template>
|
||||||
|
<Row
|
||||||
|
:ratio="ratio"
|
||||||
|
class="border-b px-2"
|
||||||
|
>
|
||||||
|
<div class="flex items-center pl-2 text-gray-600">{{ row.idx + 1 }}</div>
|
||||||
|
<FormControl
|
||||||
|
:size="size"
|
||||||
|
class="py-2"
|
||||||
|
:input-class="{ 'text-right': isNumeric(df) }"
|
||||||
|
:key="df.fieldname"
|
||||||
|
v-for="df in tableFields"
|
||||||
|
:df="df"
|
||||||
|
:value="row[df.fieldname]"
|
||||||
|
@change="value => row.set(df.fieldname, value)"
|
||||||
|
@new-doc="doc => row.set(df.fieldname, doc.name)"
|
||||||
|
/>
|
||||||
|
</Row>
|
||||||
|
</template>
|
||||||
|
<script>
|
||||||
|
import FormControl from './FormControl';
|
||||||
|
import Row from '@/components/Row';
|
||||||
|
|
||||||
|
export default {
|
||||||
|
name: 'TableRow',
|
||||||
|
props: ['row', 'tableFields', 'size', 'ratio', 'isNumeric'],
|
||||||
|
components: {
|
||||||
|
Row
|
||||||
|
},
|
||||||
|
beforeCreate() {
|
||||||
|
this.$options.components.FormControl = FormControl;
|
||||||
|
},
|
||||||
|
provide() {
|
||||||
|
return {
|
||||||
|
doctype: this.row.doctype,
|
||||||
|
name: this.row.name,
|
||||||
|
doc: this.row
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
Loading…
Reference in New Issue
Block a user