2
0
mirror of https://github.com/frappe/books.git synced 2025-01-12 19:06:38 +00:00

- Dynamic doctype hidden prop

- Table UI Fix: Column expands when active.
This commit is contained in:
thefalconx33 2019-07-19 18:52:32 +05:30
parent fd6eeac8cd
commit 6621a2c7af
2 changed files with 36 additions and 18 deletions

View File

@ -55,7 +55,12 @@ export default {
return this.fields.find(df => df.fieldname === fieldname); return this.fields.find(df => df.fieldname === fieldname);
}, },
shouldRenderField(fieldname) { shouldRenderField(fieldname) {
const hidden = Boolean(this.getDocField(fieldname).hidden); let hidden;
try {
hidden = Boolean(this.getDocField(fieldname).hidden(this.doc));
} catch (e) {
hidden = Boolean(this.getDocField(fieldname).hidden) || false;
}
if (hidden) { if (hidden) {
return false; return false;

View File

@ -4,12 +4,10 @@
<thead> <thead>
<tr> <tr>
<th scope="col" width="60"> <th scope="col" width="60">
<input class="mr-2" type="checkbox" @change="toggleCheckAll"> <input class="mr-2" type="checkbox" @change="toggleCheckAll" />
<span>#</span> <span>#</span>
</th> </th>
<th scope="col" v-for="column in columns" :key="column.fieldname"> <th scope="col" v-for="column in columns" :key="column.fieldname">{{ column.label }}</th>
{{ column.label }}
</th>
</tr> </tr>
</thead> </thead>
<tbody v-if="rows.length"> <tbody v-if="rows.length">
@ -20,10 +18,12 @@
type="checkbox" type="checkbox"
:checked="checkedRows.includes(i)" :checked="checkedRows.includes(i)"
@change="e => onCheck(e, i)" @change="e => onCheck(e, i)"
> />
<span>{{ i + 1 }}</span> <span>{{ i + 1 }}</span>
</th> </th>
<td v-for="column in columns" :key="column.fieldname" <td
v-for="column in columns"
:key="column.fieldname"
tabindex="1" tabindex="1"
:ref="column.fieldname + i" :ref="column.fieldname + i"
@click="activateFocus(i, column.fieldname)" @click="activateFocus(i, column.fieldname)"
@ -37,7 +37,10 @@
@keydown.down="focusBelowCell(i, column.fieldname)" @keydown.down="focusBelowCell(i, column.fieldname)"
@keydown.esc="escOnCell(i, column.fieldname)" @keydown.esc="escOnCell(i, column.fieldname)"
> >
<div class="table-cell" :class="{'active': isFocused(i, column.fieldname)}"> <div
class="table-cell"
:class="{'active': isFocused(i, column.fieldname),'p-1': isEditing(i, column.fieldname)}"
>
<frappe-control <frappe-control
v-if="isEditing(i, column.fieldname)" v-if="isEditing(i, column.fieldname)"
:docfield="getDocfield(column.fieldname)" :docfield="getDocfield(column.fieldname)"
@ -47,9 +50,11 @@
:autofocus="true" :autofocus="true"
@change="onCellChange(i, column.fieldname, $event)" @change="onCellChange(i, column.fieldname, $event)"
/> />
<div class="text-truncate" v-else> <div
{{ row[column.fieldname] || '&nbsp;' }} class="text-truncate"
</div> :data-fieldtype="column.fieldtype"
v-else
>{{ row[column.fieldname] || '&nbsp;' }}</div>
</div> </div>
</td> </td>
</tr> </tr>
@ -57,9 +62,7 @@
<tbody v-else> <tbody v-else>
<tr> <tr>
<td :colspan="columns.length + 1" class="text-center"> <td :colspan="columns.length + 1" class="text-center">
<div class="table-cell"> <div class="table-cell">No Data</div>
No Data
</div>
</td> </td>
</tr> </tr>
</tbody> </tbody>
@ -104,7 +107,10 @@ export default {
}, },
focusPreviousCell() { focusPreviousCell() {
let { index, fieldname } = this.currentlyFocused; let { index, fieldname } = this.currentlyFocused;
if (this.isFocused(index, fieldname) && !this.isEditing(index, fieldname)) { if (
this.isFocused(index, fieldname) &&
!this.isEditing(index, fieldname)
) {
let pos = this._getColumnIndex(fieldname); let pos = this._getColumnIndex(fieldname);
pos -= 1; pos -= 1;
if (pos < 0) { if (pos < 0) {
@ -120,8 +126,10 @@ export default {
}, },
focusNextCell() { focusNextCell() {
let { index, fieldname } = this.currentlyFocused; let { index, fieldname } = this.currentlyFocused;
if (this.isFocused(index, fieldname) && !this.isEditing(index, fieldname)) { if (
this.isFocused(index, fieldname) &&
!this.isEditing(index, fieldname)
) {
let pos = this._getColumnIndex(fieldname); let pos = this._getColumnIndex(fieldname);
pos += 1; pos += 1;
if (pos > this.columns.length - 1) { if (pos > this.columns.length - 1) {
@ -292,7 +300,7 @@ export default {
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
td { td {
padding: 0; padding: 0rem;
outline: none; outline: none;
} }
@ -322,4 +330,9 @@ td {
[data-fieldtype='Link'] .input-group-append { [data-fieldtype='Link'] .input-group-append {
display: none; display: none;
} }
[data-fieldtype='Currency'],
[data-fieldtype='Float'] {
text-align: right !important;
}
</style> </style>