2
0
mirror of https://github.com/frappe/books.git synced 2025-01-23 15:18:24 +00:00

refactor: remove status messages and actions

- QuickEdit wont be used as a main form
This commit is contained in:
18alantom 2023-04-17 11:01:02 +05:30
parent c754fd35ce
commit 653ea9f800

View File

@ -16,19 +16,12 @@
style="z-index: 1" style="z-index: 1"
> >
<!-- Close Button and Status Text --> <!-- Close Button and Status Text -->
<div class="flex items-center">
<Button :icon="true" @click="routeToPrevious"> <Button :icon="true" @click="routeToPrevious">
<feather-icon name="x" class="w-4 h-4" /> <feather-icon name="x" class="w-4 h-4" />
</Button> </Button>
<span v-if="statusText" class="ms-2 text-base text-gray-600">{{
statusText
}}</span>
</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">
<StatusBadge :status="status" />
<DropdownWithActions :actions="actions" />
<Button <Button
:icon="true" :icon="true"
@click="sync" @click="sync"
@ -99,14 +92,9 @@
import { computed } from '@vue/reactivity'; import { computed } from '@vue/reactivity';
import { t } from 'fyo'; import { t } from 'fyo';
import { DocValue } from 'fyo/core/types'; import { DocValue } from 'fyo/core/types';
import { DocStatus } from 'fyo/model/types';
import { getDocStatus } from 'models/helpers';
import { InvoiceStatus } from 'models/types';
import { Field, Schema } from 'schemas/types'; import { Field, Schema } from 'schemas/types';
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';
import DropdownWithActions from 'src/components/DropdownWithActions.vue';
import StatusBadge from 'src/components/StatusBadge.vue';
import TwoColumnForm from 'src/components/TwoColumnForm.vue'; import TwoColumnForm from 'src/components/TwoColumnForm.vue';
import { fyo } from 'src/initFyo'; import { fyo } from 'src/initFyo';
import { shortcutsKey } from 'src/utils/injectionKeys'; import { shortcutsKey } from 'src/utils/injectionKeys';
@ -115,7 +103,6 @@ import {
commonDocSubmit, commonDocSubmit,
commonDocSync, commonDocSync,
focusOrSelectFormControl, focusOrSelectFormControl,
getActionsForDoc,
} from 'src/utils/ui'; } from 'src/utils/ui';
import { useDocShortcuts } from 'src/utils/vueUtils'; import { useDocShortcuts } from 'src/utils/vueUtils';
import { defineComponent, inject, ref } from 'vue'; import { defineComponent, inject, ref } from 'vue';
@ -131,9 +118,7 @@ export default defineComponent({
components: { components: {
Button, Button,
FormControl, FormControl,
StatusBadge,
TwoColumnForm, TwoColumnForm,
DropdownWithActions,
}, },
emits: ['close'], emits: ['close'],
setup() { setup() {
@ -161,19 +146,15 @@ export default defineComponent({
return { return {
titleField: null, titleField: null,
imageField: null, imageField: null,
statusText: '',
} as { } as {
titleField: null | Field; titleField: null | Field;
imageField: null | Field; imageField: null | Field;
statusText: string;
}; };
}, },
activated() { activated() {
console.log('act');
this.setShortcuts(); this.setShortcuts();
}, },
async mounted() { async mounted() {
console.log('mou');
await this.initialize(); await this.initialize();
if (fyo.store.isDevelopment) { if (fyo.store.isDevelopment) {
@ -200,13 +181,6 @@ export default defineComponent({
schema(): Schema { schema(): Schema {
return fyo.schemaMap[this.schemaName]!; return fyo.schemaMap[this.schemaName]!;
}, },
status(): DocStatus | InvoiceStatus {
if (!this.doc) {
return 'Draft';
}
return getDocStatus(this.doc);
},
fields() { fields() {
if (!this.schema) { if (!this.schema) {
return []; return [];
@ -226,20 +200,9 @@ export default defineComponent({
return fieldnames.map((f) => fyo.getField(this.schemaName, f)); return fieldnames.map((f) => fyo.getField(this.schemaName, f));
}, },
actions() {
if (!this.doc) {
return [];
}
return getActionsForDoc(this.doc);
},
}, },
methods: { methods: {
setShortcuts() { setShortcuts() {
if (this.shortcuts?.has(this.context, ['Escape'])) {
return;
}
this.shortcuts?.set(this.context, ['Escape'], () => { this.shortcuts?.set(this.context, ['Escape'], () => {
this.routeToPrevious(); this.routeToPrevious();
}); });
@ -277,22 +240,14 @@ export default defineComponent({
return; return;
} }
this.statusText = t`Saving`;
await commonDocSync(this.doc); await commonDocSync(this.doc);
setTimeout(() => {
this.statusText = '';
}, 300);
}, },
async submit() { async submit() {
if (!this.doc) { if (!this.doc) {
return; return;
} }
this.statusText = t`Submitting`;
await commonDocSubmit(this.doc); await commonDocSubmit(this.doc);
setTimeout(() => {
this.statusText = '';
}, 300);
}, },
async routeToPrevious() { async routeToPrevious() {
if (this.doc?.dirty && this.doc?.inserted) { if (this.doc?.dirty && this.doc?.inserted) {