2
0
mirror of https://github.com/frappe/books.git synced 2024-11-09 23:30:56 +00:00

incr: add shortcuts for linked entries

- fix quickedit shortcut
- most settings to tab
- fix coa auto select in SetupWizard
- remove sections and tabs if empty
This commit is contained in:
18alantom 2023-04-14 10:43:18 +05:30
parent 1cc5607132
commit 202ddf829b
11 changed files with 75 additions and 39 deletions

View File

@ -142,7 +142,13 @@ export class SetupWizard extends Doc {
}
const countryInfo = getCountryInfo();
return countryInfo[country]?.currency;
const code = countryInfo[country]?.code;
if (!code) {
return;
}
const coaList = getCOAList();
const coa = coaList.find(({ countryCode }) => countryCode === code);
return coa?.name ?? coaList[0].name;
},
dependsOn: ['country'],
},

View File

@ -113,14 +113,15 @@
}
],
"default": "Party",
"section": "Settings"
"hidden": true
},
{
"fieldname": "currency",
"label": "Customer Currency",
"fieldtype": "Link",
"target": "Currency",
"section": "Settings"
"readOnly": true,
"tab": "Settings"
},
{
"fieldname": "exchangeRate",
@ -128,7 +129,7 @@
"fieldtype": "Float",
"default": 1,
"readOnly": true,
"section": "Settings"
"tab": "Settings"
},
{
"fieldname": "discountAfterTax",
@ -136,7 +137,7 @@
"fieldtype": "Check",
"default": false,
"readOnly": false,
"section": "Settings"
"tab": "Settings"
},
{
"fieldname": "outstandingAmount",

View File

@ -28,7 +28,7 @@
<!-- Data Rows -->
<div
class="overflow-auto"
class="overflow-auto custom-scroll"
:style="{ 'max-height': maxHeight }"
v-if="value"
>

View File

@ -1,23 +0,0 @@
<template>
<div class="p-3 d-flex align-items-center">
<indicator :color="indicatorColor" class="me-2 ms-1" />
{{ message }}
</div>
</template>
<script>
import { indicators } from '../colors';
export default {
name: 'MessageDialog',
data() {
return {
indicatorColor: indicators.ORANGE,
};
},
props: {
message: {
type: String,
},
},
};
</script>

View File

@ -106,6 +106,10 @@ export default defineComponent({
shortcut: [ShortcutKey.pmod, 'P'],
description: t`Open Print View if Print is available.`,
},
{
shortcut: [ShortcutKey.pmod, 'L'],
description: t`Toggle Linked Entries widget, not available in Quick Edit view.`,
},
],
},
{

View File

@ -245,6 +245,13 @@ export default defineComponent({
this.printButton?.$el.click();
});
this.shortcuts?.pmod.set(this.context, ['KeyL'], () => {
if (!this.canShowLinks && !this.showLinks) {
return;
}
this.showLinks = !this.showLinks;
});
},
deactivated(): void {
docsPathRef.value = '';
@ -298,7 +305,7 @@ export default defineComponent({
return !this.doc.isCancelled && !this.doc.dirty && this.isPrintable;
},
canShowLinks(): boolean {
if (!this.hasDoc || this.hasQeDoc || this.showLinks) {
if (!this.hasDoc || this.hasQeDoc) {
return false;
}

View File

@ -162,15 +162,20 @@
<script lang="ts">
import { Doc } from 'fyo/model/doc';
import { isPesa } from 'fyo/utils';
import { MovementType } from 'models/inventory/types';
import { ModelNameEnum } from 'models/types';
import Button from 'src/components/Button.vue';
import { getBgColorClass, getBgTextColorClass } from 'src/utils/colors';
import { getBgTextColorClass } from 'src/utils/colors';
import { getLinkedEntries } from 'src/utils/doc';
import { shortcutsKey } from 'src/utils/injectionKeys';
import { getFormRoute, routeTo } from 'src/utils/ui';
import { defineComponent, PropType } from 'vue';
import { PropType, defineComponent, inject } from 'vue';
const COMPONENT_NAME = 'LinkedEntries';
export default defineComponent({
setup() {
return { shortcuts: inject(shortcutsKey) };
},
emits: ['close'],
props: { doc: { type: Object as PropType<Doc>, required: true } },
data() {
@ -183,6 +188,10 @@ export default defineComponent({
},
async mounted() {
await this.setLinkedEntries();
this.shortcuts?.set(COMPONENT_NAME, ['Escape'], () => this.$emit('close'));
},
unmounted() {
this.shortcuts?.delete(COMPONENT_NAME);
},
computed: {
sequence(): string[] {

View File

@ -178,9 +178,7 @@ export default {
};
},
activated() {
this.shortcuts.set(this.context, ['Escape'], () => {
this.routeToPrevious();
});
this.setShortcuts();
},
async mounted() {
if (this.defaults) {
@ -193,6 +191,8 @@ export default {
if (fyo.store.isDevelopment) {
window.qef = this;
}
this.setShortcuts();
},
computed: {
isChild() {
@ -244,6 +244,15 @@ export default {
},
},
methods: {
setShortcuts() {
if (this.shortcuts.has(this.context, ['Escape'])) {
return;
}
this.shortcuts.set(this.context, ['Escape'], () => {
this.routeToPrevious();
});
},
async fetchFieldsAndDoc() {
if (!this.schema) {
return;

View File

@ -320,6 +320,9 @@ export default defineComponent({
},
deactivated(): void {
docsPathRef.value = '';
if (this.editMode) {
this.disableEditMode();
}
},
methods: {
setShortcuts() {

View File

@ -327,7 +327,7 @@ export function getFieldsGroupedByTabAndSection(
): UIGroupedFields {
const grouped: UIGroupedFields = new Map();
for (const field of schema?.fields ?? []) {
const tab = field.tab ?? 'Default';
const tab = field.tab ?? 'Main';
const section = field.section ?? 'Default';
if (!grouped.has(tab)) {
grouped.set(tab, new Map());
@ -349,6 +349,26 @@ export function getFieldsGroupedByTabAndSection(
tabbed.get(section)!.push(field);
}
// Delete empty tabs and sections
for (const tkey of grouped.keys()) {
const section = grouped.get(tkey);
if (!section) {
grouped.delete(tkey);
continue;
}
for (const skey of section.keys()) {
const fields = section.get(skey);
if (!fields || !fields.length) {
section.delete(skey);
}
}
if (!section?.size) {
grouped.delete(tkey);
}
}
return grouped;
}

View File

@ -5,7 +5,7 @@ import {
onMounted,
onUnmounted,
reactive,
ref
ref,
} from 'vue';
import { getIsMac } from './misc';
import { Shortcuts } from './shortcuts';
@ -16,7 +16,7 @@ import {
commonDocSync,
commongDocDelete,
showCannotCancelOrDeleteToast,
showCannotSaveOrSubmitToast
showCannotSaveOrSubmitToast,
} from './ui';
export function useKeys() {