diff --git a/fyo/utils/index.ts b/fyo/utils/index.ts index e7bad878..35fef677 100644 --- a/fyo/utils/index.ts +++ b/fyo/utils/index.ts @@ -41,6 +41,26 @@ export function isPesa(value: unknown): value is Money { return value instanceof Money; } +export function isFalsy(value: unknown): boolean { + if (!value) { + return true; + } + + if (isPesa(value) && value.isZero()) { + return true; + } + + if (Array.isArray(value) && value.length === 0) { + return true; + } + + if (typeof value === 'object' && Object.keys(value).length === 0) { + return true; + } + + return false; +} + export function getActions(doc: Doc): Action[] { const Model = doc.fyo.models[doc.schemaName]; if (Model === undefined) { diff --git a/src/components/Controls/AutoComplete.vue b/src/components/Controls/AutoComplete.vue index 6e43ca6c..27601784 100644 --- a/src/components/Controls/AutoComplete.vue +++ b/src/components/Controls/AutoComplete.vue @@ -54,14 +54,22 @@ stroke-linejoin="round" /> + + + + @@ -71,7 +79,9 @@ import { FieldTypeEnum } from 'schemas/types'; import Dropdown from 'src/components/Dropdown.vue'; import { fuzzyMatch } from 'src/utils'; import { getFormRoute, routeTo } from 'src/utils/ui'; +import Popover from '../Popover.vue'; import Base from './Base.vue'; +import QuickView from '../QuickView.vue'; export default { name: 'AutoComplete', @@ -79,9 +89,12 @@ export default { extends: Base, components: { Dropdown, + Popover, + QuickView, }, data() { return { + showQuickView: false, linkValue: '', isLoading: false, suggestions: [], @@ -100,7 +113,23 @@ export default { const value = this.linkValue || this.value; this.setLinkValue(this.getLinkValue(value)); }, + unmounted() { + this.showQuickView = false; + }, + deactivated() { + this.showQuickView = false; + }, computed: { + linkSchemaName() { + let schemaName = this.df?.target; + + if (!schemaName) { + const references = this.df?.references ?? ''; + schemaName = this.doc?.[references]; + } + + return schemaName; + }, options() { if (!this.df) { return []; @@ -139,19 +168,12 @@ export default { }, methods: { async routeToLinkedDoc() { - let schemaName = this.df?.target; const name = this.value; - - if (!schemaName) { - const references = this.df?.references ?? ''; - schemaName = this.doc?.[references]; - } - - if (!schemaName || !name) { + if (!this.linkSchemaName || !name) { return; } - const route = getFormRoute(schemaName, name); + const route = getFormRoute(this.linkSchemaName, name); await routeTo(route); }, setLinkValue(value) { diff --git a/src/components/QuickView.vue b/src/components/QuickView.vue new file mode 100644 index 00000000..966d44ee --- /dev/null +++ b/src/components/QuickView.vue @@ -0,0 +1,70 @@ + +