2
0
mirror of https://github.com/frappe/books.git synced 2025-01-23 07:08:36 +00:00

incr: open quick edit on edit click

This commit is contained in:
18alantom 2022-07-11 14:15:37 +05:30
parent 2f33f24db9
commit a8e8649112
9 changed files with 85 additions and 12 deletions

View File

@ -53,7 +53,8 @@
"label": "Items",
"fieldtype": "Table",
"target": "PurchaseInvoiceItem",
"required": true
"required": true,
"edit": true
},
{
"fieldname": "netTotal",

View File

@ -85,5 +85,15 @@
}
],
"tableFields": ["item", "tax", "quantity", "rate", "amount"],
"keywordFields": ["item", "tax"]
"keywordFields": ["item", "tax"],
"quickEditFields": [
"item",
"description",
"hsnCode",
"tax",
"quantity",
"rate",
"itemDiscountAmount",
"itemDiscountPercent"
]
}

View File

@ -52,7 +52,8 @@
"label": "Items",
"fieldtype": "Table",
"target": "SalesInvoiceItem",
"required": true
"required": true,
"edit": true
},
{
"fieldname": "netTotal",

View File

@ -86,5 +86,15 @@
}
],
"tableFields": ["item", "tax", "quantity", "rate", "amount"],
"keywordFields": ["item", "tax"]
"keywordFields": ["item", "tax"],
"quickEditFields": [
"item",
"description",
"hsnCode",
"tax",
"quantity",
"rate",
"itemDiscountAmount",
"itemDiscountPercent"
]
}

View File

@ -50,6 +50,7 @@ export interface TargetField extends BaseField {
fieldtype: FieldTypeEnum.Table | FieldTypeEnum.Link;
target: string; // Name of the table or group of tables to fetch values
create?: boolean; // Whether to show Create in the dropdown
edit?: boolean; // Whether the Table has quick editable columns
}
export interface DynamicLinkField extends BaseField {

View File

@ -6,7 +6,6 @@
flex
justify-center
items-center
h-8
text-sm
"
:class="_class"
@ -35,15 +34,20 @@ export default {
type: Boolean,
default: true,
},
background: {
type: Boolean,
default: true,
},
},
computed: {
_class() {
return {
'opacity-50 cursor-not-allowed pointer-events-none': this.disabled,
'text-white': this.type === 'primary',
'bg-blue-500': this.type === 'primary',
'bg-blue-500': this.type === 'primary' && this.background,
'text-gray-700': this.type !== 'primary',
'bg-gray-200': this.type !== 'primary',
'bg-gray-200': this.type !== 'primary' && this.background,
'h-8': this.background,
'px-3': this.padding && this.icon,
'px-6': this.padding && !this.icon,
};

View File

@ -38,6 +38,7 @@
v-bind="{ row, tableFields, size, ratio, isNumeric }"
:read-only="isReadOnly"
@remove="removeRow(row)"
:can-edit-row="canEditRow"
/>
</div>
@ -169,8 +170,17 @@ export default {
}
return 2;
},
canEditRow() {
return !this.doc?.isSubmitted && this.df.edit;
},
ratio() {
return [0.3].concat(this.tableFields.map(() => 1));
const ratio = [0.3].concat(this.tableFields.map(() => 1));
if (this.canEditRow) {
return ratio.concat(0.3);
}
return ratio;
},
tableFields() {
const fields = fyo.schemaMap[this.df.target].tableFields ?? [];

View File

@ -19,6 +19,7 @@
<feather-icon
name="x"
class="w-4 h-4 -ml-1 cursor-pointer"
:button="true"
@click="$emit('remove')"
/>
</span>
@ -39,6 +40,18 @@
@change="(value) => onChange(df, value)"
@new-doc="(doc) => row.set(df.fieldname, doc.name)"
/>
<Button
:icon="true"
:padding="false"
:background="false"
@click="openRowQuickEdit"
>
<feather-icon
name="edit"
class="w-4 h-4 text-gray-600"
v-if="canEditRow"
/>
</Button>
<!-- Error Display -->
<div
@ -53,6 +66,8 @@
import { Doc } from 'fyo/model/doc';
import Row from 'src/components/Row.vue';
import { getErrorMessage } from 'src/utils';
import { openQuickEdit } from 'src/utils/ui';
import Button from '../Button.vue';
import FormControl from './FormControl.vue';
export default {
@ -64,11 +79,16 @@ export default {
ratio: Array,
isNumeric: Function,
readOnly: Boolean,
canEditRow: {
type: Boolean,
default: false,
},
},
emits: ['remove'],
components: {
Row,
FormControl,
Button,
},
data: () => ({ hovering: false, errors: {} }),
beforeCreate() {
@ -95,6 +115,16 @@ export default {
getErrorString() {
return Object.values(this.errors).filter(Boolean).join(' ');
},
openRowQuickEdit() {
if (!this.row) {
return;
}
openQuickEdit({
schemaName: this.row.schemaName,
name: this.row.name,
});
},
},
};
</script>

View File

@ -4,7 +4,10 @@
:class="white ? 'bg-white' : 'bg-gray-25'"
>
<!-- Quick edit Tool bar -->
<div class="flex items-center justify-between px-4 border-b h-row-largest">
<div
class="flex items-center justify-between px-4 h-row-largest"
:class="{ 'border-b': !isChild }"
>
<!-- Close Button and Status Text -->
<div class="flex items-center">
<Button :icon="true" @click="routeToPrevious">
@ -17,8 +20,8 @@
<!-- Actions, Badge and Status Change Buttons -->
<div class="flex items-stretch gap-2">
<StatusBadge :status="status" />
<DropdownWithActions :actions="actions" />
<StatusBadge :status="status" v-if="!isChild" />
<DropdownWithActions :actions="actions" v-if="!isChild" />
<Button
:icon="true"
@click="sync"
@ -49,7 +52,7 @@
<div
class="px-4 flex-center flex flex-col items-center gap-1.5"
style="height: calc(var(--h-row-mid) * 2 + 1px)"
v-if="doc"
v-if="doc && !isChild"
>
<FormControl
v-if="imageField"
@ -145,6 +148,9 @@ export default {
await this.fetchFieldsAndDoc();
},
computed: {
isChild() {
return !!this?.doc?.schema?.isChild;
},
schema() {
return fyo.schemaMap[this.schemaName] ?? null;
},