mirror of
https://github.com/frappe/books.git
synced 2024-11-10 07:40:55 +00:00
incr: two way bound quick edit for item rows
This commit is contained in:
parent
a8e8649112
commit
3dfdf22f9f
@ -86,6 +86,7 @@ import TableRow from './TableRow.vue';
|
|||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'Table',
|
name: 'Table',
|
||||||
|
emits: ['editrow'],
|
||||||
extends: Base,
|
extends: Base,
|
||||||
props: {
|
props: {
|
||||||
value: { type: Array, default: () => [] },
|
value: { type: Array, default: () => [] },
|
||||||
|
@ -45,12 +45,9 @@
|
|||||||
:padding="false"
|
:padding="false"
|
||||||
:background="false"
|
:background="false"
|
||||||
@click="openRowQuickEdit"
|
@click="openRowQuickEdit"
|
||||||
|
v-if="canEditRow"
|
||||||
>
|
>
|
||||||
<feather-icon
|
<feather-icon name="edit" class="w-4 h-4 text-gray-600" />
|
||||||
name="edit"
|
|
||||||
class="w-4 h-4 text-gray-600"
|
|
||||||
v-if="canEditRow"
|
|
||||||
/>
|
|
||||||
</Button>
|
</Button>
|
||||||
|
|
||||||
<!-- Error Display -->
|
<!-- Error Display -->
|
||||||
@ -66,7 +63,6 @@
|
|||||||
import { Doc } from 'fyo/model/doc';
|
import { Doc } from 'fyo/model/doc';
|
||||||
import Row from 'src/components/Row.vue';
|
import Row from 'src/components/Row.vue';
|
||||||
import { getErrorMessage } from 'src/utils';
|
import { getErrorMessage } from 'src/utils';
|
||||||
import { openQuickEdit } from 'src/utils/ui';
|
|
||||||
import Button from '../Button.vue';
|
import Button from '../Button.vue';
|
||||||
import FormControl from './FormControl.vue';
|
import FormControl from './FormControl.vue';
|
||||||
|
|
||||||
@ -120,10 +116,7 @@ export default {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
openQuickEdit({
|
this.$parent.$emit('editrow', this.row);
|
||||||
schemaName: this.row.schemaName,
|
|
||||||
name: this.row.name,
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
@ -1,26 +1,31 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col bg-gray-25">
|
<div class="flex bg-gray-25">
|
||||||
<!-- Page Header (Title, Buttons, etc) -->
|
<div class="flex flex-1 flex-col">
|
||||||
<PageHeader :title="title" :border="false">
|
<!-- Page Header (Title, Buttons, etc) -->
|
||||||
<slot name="header" />
|
<PageHeader :title="title" :border="false">
|
||||||
</PageHeader>
|
<slot name="header" />
|
||||||
|
</PageHeader>
|
||||||
|
|
||||||
<!-- Invoice Form -->
|
<!-- Invoice Form -->
|
||||||
<div
|
<div
|
||||||
class="
|
class="
|
||||||
border
|
border
|
||||||
rounded-lg
|
rounded-lg
|
||||||
shadow-lg
|
shadow-lg
|
||||||
flex flex-col
|
flex flex-col
|
||||||
self-center
|
self-center
|
||||||
w-form
|
w-form
|
||||||
h-full
|
h-full
|
||||||
mb-4
|
mb-4
|
||||||
bg-white
|
bg-white
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<slot name="body" />
|
<slot name="body" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Invoice Quick Edit -->
|
||||||
|
<slot name="quickedit" />
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
|
@ -101,6 +101,7 @@
|
|||||||
:showHeader="true"
|
:showHeader="true"
|
||||||
:max-rows-before-overflow="4"
|
:max-rows-before-overflow="4"
|
||||||
@change="(value) => doc.set('items', value)"
|
@change="(value) => doc.set('items', value)"
|
||||||
|
@editrow="(r) => (row = r)"
|
||||||
:read-only="doc?.submitted"
|
:read-only="doc?.submitted"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@ -175,6 +176,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
<template #quickedit v-if="row">
|
||||||
|
<QuickEditForm
|
||||||
|
class="w-80"
|
||||||
|
:name="row.name"
|
||||||
|
:source-doc="row"
|
||||||
|
:schema-name="row.schemaName"
|
||||||
|
:route-back="false"
|
||||||
|
@close="row = null"
|
||||||
|
/>
|
||||||
|
</template>
|
||||||
</FormContainer>
|
</FormContainer>
|
||||||
</template>
|
</template>
|
||||||
<script>
|
<script>
|
||||||
@ -190,13 +202,13 @@ import StatusBadge from 'src/components/StatusBadge.vue';
|
|||||||
import { fyo } from 'src/initFyo';
|
import { fyo } from 'src/initFyo';
|
||||||
import { docsPathMap } from 'src/utils/misc';
|
import { docsPathMap } from 'src/utils/misc';
|
||||||
import {
|
import {
|
||||||
docsPath,
|
docsPath,
|
||||||
getActionsForDocument,
|
getActionsForDocument,
|
||||||
openSettings,
|
routeTo,
|
||||||
routeTo,
|
showMessageDialog
|
||||||
showMessageDialog,
|
|
||||||
} from 'src/utils/ui';
|
} from 'src/utils/ui';
|
||||||
import { handleErrorWithDialog } from '../errorHandling';
|
import { handleErrorWithDialog } from '../errorHandling';
|
||||||
|
import QuickEditForm from './QuickEditForm.vue';
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'InvoiceForm',
|
name: 'InvoiceForm',
|
||||||
@ -208,6 +220,7 @@ export default {
|
|||||||
DropdownWithActions,
|
DropdownWithActions,
|
||||||
Table,
|
Table,
|
||||||
FormContainer,
|
FormContainer,
|
||||||
|
QuickEditForm,
|
||||||
},
|
},
|
||||||
provide() {
|
provide() {
|
||||||
return {
|
return {
|
||||||
@ -220,6 +233,7 @@ export default {
|
|||||||
return {
|
return {
|
||||||
chstatus: false,
|
chstatus: false,
|
||||||
doc: null,
|
doc: null,
|
||||||
|
row: null,
|
||||||
color: null,
|
color: null,
|
||||||
printSettings: null,
|
printSettings: null,
|
||||||
companyName: null,
|
companyName: null,
|
||||||
@ -309,9 +323,6 @@ export default {
|
|||||||
async handleError(e) {
|
async handleError(e) {
|
||||||
await handleErrorWithDialog(e, this.doc);
|
await handleErrorWithDialog(e, this.doc);
|
||||||
},
|
},
|
||||||
openInvoiceSettings() {
|
|
||||||
openSettings('Invoice');
|
|
||||||
},
|
|
||||||
formattedValue(fieldname, doc) {
|
formattedValue(fieldname, doc) {
|
||||||
if (!doc) {
|
if (!doc) {
|
||||||
doc = this.doc;
|
doc = this.doc;
|
||||||
|
@ -19,9 +19,9 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Actions, Badge and Status Change Buttons -->
|
<!-- Actions, Badge and Status Change Buttons -->
|
||||||
<div class="flex items-stretch gap-2">
|
<div class="flex items-stretch gap-2" v-if="!isChild">
|
||||||
<StatusBadge :status="status" v-if="!isChild" />
|
<StatusBadge :status="status" />
|
||||||
<DropdownWithActions :actions="actions" v-if="!isChild" />
|
<DropdownWithActions :actions="actions" />
|
||||||
<Button
|
<Button
|
||||||
:icon="true"
|
:icon="true"
|
||||||
@click="sync"
|
@click="sync"
|
||||||
@ -92,6 +92,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import { computed } from '@vue/reactivity';
|
import { computed } from '@vue/reactivity';
|
||||||
import { t } from 'fyo';
|
import { t } from 'fyo';
|
||||||
|
import { Doc } from 'fyo/model/doc';
|
||||||
import { getDocStatus } from 'models/helpers';
|
import { getDocStatus } from 'models/helpers';
|
||||||
import Button from 'src/components/Button.vue';
|
import Button from 'src/components/Button.vue';
|
||||||
import FormControl from 'src/components/Controls/FormControl.vue';
|
import FormControl from 'src/components/Controls/FormControl.vue';
|
||||||
@ -109,6 +110,8 @@ export default {
|
|||||||
schemaName: String,
|
schemaName: String,
|
||||||
defaults: String,
|
defaults: String,
|
||||||
white: { type: Boolean, default: false },
|
white: { type: Boolean, default: false },
|
||||||
|
sourceDoc: { type: Doc, default: null },
|
||||||
|
routeBack: { type: Boolean, default: true },
|
||||||
hideFields: { type: Array, default: () => [] },
|
hideFields: { type: Array, default: () => [] },
|
||||||
showFields: { type: Array, default: () => [] },
|
showFields: { type: Array, default: () => [] },
|
||||||
},
|
},
|
||||||
@ -119,6 +122,7 @@ export default {
|
|||||||
TwoColumnForm,
|
TwoColumnForm,
|
||||||
DropdownWithActions,
|
DropdownWithActions,
|
||||||
},
|
},
|
||||||
|
emits: ['close'],
|
||||||
provide() {
|
provide() {
|
||||||
return {
|
return {
|
||||||
schemaName: this.schemaName,
|
schemaName: this.schemaName,
|
||||||
@ -233,6 +237,10 @@ export default {
|
|||||||
}, 300);
|
}, 300);
|
||||||
},
|
},
|
||||||
async fetchDoc() {
|
async fetchDoc() {
|
||||||
|
if (this.sourceDoc) {
|
||||||
|
return (this.doc = this.sourceDoc);
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.schemaName) {
|
if (!this.schemaName) {
|
||||||
this.$router.back();
|
this.$router.back();
|
||||||
}
|
}
|
||||||
@ -289,7 +297,12 @@ export default {
|
|||||||
if (this.doc.dirty && !this.doc.notInserted) {
|
if (this.doc.dirty && !this.doc.notInserted) {
|
||||||
this.doc.load();
|
this.doc.load();
|
||||||
}
|
}
|
||||||
this.$router.back();
|
|
||||||
|
if (this.routeBack) {
|
||||||
|
this.$router.back();
|
||||||
|
} else {
|
||||||
|
this.$emit('close');
|
||||||
|
}
|
||||||
},
|
},
|
||||||
setTitleSize() {
|
setTitleSize() {
|
||||||
if (!this.$refs.titleControl) {
|
if (!this.$refs.titleControl) {
|
||||||
|
Loading…
Reference in New Issue
Block a user