diff --git a/schemas/types.ts b/schemas/types.ts index ea9bd692..48ea636c 100644 --- a/schemas/types.ts +++ b/schemas/types.ts @@ -72,7 +72,6 @@ export type SelectOption = { value: string; label: string }; export interface OptionField extends Omit { fieldtype: OptionFieldType; options: SelectOption[]; - emptyMessage?: string; allowCustom?: boolean; } @@ -85,7 +84,6 @@ export interface TargetField extends Omit { export interface DynamicLinkField extends Omit { fieldtype: DynamicLinkFieldType; - emptyMessage?: string; references: string; // Reference to an option field that links to schema } diff --git a/src/components/Dropdown.vue b/src/components/Dropdown.vue index 0dfc4b9f..2394ff42 100644 --- a/src/components/Dropdown.vue +++ b/src/components/Dropdown.vue @@ -21,13 +21,17 @@ {{ t`Loading...` }}
{{ getEmptyMessage() }}
- - diff --git a/src/components/Popover.vue b/src/components/Popover.vue index f7e3140f..e0f3df2c 100644 --- a/src/components/Popover.vue +++ b/src/components/Popover.vue @@ -27,6 +27,7 @@ export default { emits: ['open', 'close'], props: { showPopup: { + type: [Boolean, null], default: null, }, right: Boolean, diff --git a/src/components/ShortcutsHelper.vue b/src/components/ShortcutsHelper.vue index a1132041..9672677c 100644 --- a/src/components/ShortcutsHelper.vue +++ b/src/components/ShortcutsHelper.vue @@ -83,27 +83,38 @@ export default defineComponent({ ], }, { - label: t`Doc`, - description: t`Applicable when a Doc is open in the Form view or Quick Edit view`, + label: t`Entry`, + description: t`Applicable when a entry is open in the Form view or Quick Edit view`, collapsed: false, shortcuts: [ { shortcut: [ShortcutKey.pmod, 'S'], description: [ - t`Save or Submit a doc.`, - t`A doc is submitted only if it is submittable and is in the saved state.`, + t`Save or Submit an entry.`, + t`An entry is submitted only if it is submittable and is in the saved state.`, ].join(' '), }, { shortcut: [ShortcutKey.pmod, ShortcutKey.delete], description: [ - t`Cancel or Delete a doc.`, - t`A doc is cancelled only if it is in the submitted state.`, - t`A submittable doc is deleted only if it is in the cancelled state.`, + t`Cancel or Delete an entry.`, + t`An entry is cancelled only if it is in the submitted state.`, + t`A submittable entry is deleted only if it is in the cancelled state.`, ].join(' '), }, ], }, + { + label: t`List View`, + description: t`Applicable when the List View of an entry type is open`, + collapsed: false, + shortcuts: [ + { + shortcut: [ShortcutKey.pmod, 'N'], + description: t`Create a new entry of the same type as the List View`, + }, + ], + }, { label: t`Quick Search`, description: t`Applicable when Quick Search is open`, diff --git a/src/pages/ListView/ListView.vue b/src/pages/ListView/ListView.vue index 1e6d24ee..3b26e07a 100644 --- a/src/pages/ListView/ListView.vue +++ b/src/pages/ListView/ListView.vue @@ -55,6 +55,7 @@ import { } from 'src/utils/misc'; import { docsPathRef } from 'src/utils/refs'; import { openQuickEdit, routeTo } from 'src/utils/ui'; +import { Shortcuts } from 'src/utils/vueUtils'; import List from './List.vue'; export default { @@ -79,6 +80,7 @@ export default { listFilters: {}, }; }, + inject: { shortcutManager: { from: 'shortcuts' } }, async activated() { if (typeof this.filters === 'object') { this.$refs.filterDropdown.setFilter(this.filters, true); @@ -90,9 +92,12 @@ export default { if (this.fyo.store.isDevelopment) { window.lv = this; } + + this.shortcuts.pmod.set(['KeyN'], this.makeNewDoc); }, deactivated() { docsPathRef.value = ''; + this.shortcuts.pmod.delete(['KeyN']); }, methods: { updatedData(listFilters) { @@ -113,6 +118,10 @@ export default { }); }, async makeNewDoc() { + if (!this.canCreate) { + return; + } + const filters = getCreateFiltersFromListViewFilters(this.filters ?? {}); const doc = fyo.doc.getNewDoc(this.schemaName, filters); const path = this.getFormPath(doc); @@ -165,6 +174,16 @@ export default { canCreate() { return fyo.schemaMap[this.schemaName].create !== false; }, + shortcuts() { + // @ts-ignore + const shortcutManager = this.shortcutManager; + if (shortcutManager instanceof Shortcuts) { + return shortcutManager; + } + + // no-op (hopefully) + throw Error('Shortcuts Not Found'); + }, }, };