From b3533698c0d8bba4bbc24d7125898f5267a04b75 Mon Sep 17 00:00:00 2001 From: 18alantom <2.alan.tom@gmail.com> Date: Fri, 22 Apr 2022 17:31:04 +0530 Subject: [PATCH] incr: update AutoComplete --- fyo/core/docHandler.ts | 17 ++++-------- fyo/model/types.ts | 8 +++--- src/components/Controls/AutoComplete.vue | 24 ++++------------ src/utils/doc.ts | 35 +++++++++++++++++++++++- 4 files changed, 50 insertions(+), 34 deletions(-) diff --git a/fyo/core/docHandler.ts b/fyo/core/docHandler.ts index a0478558..17a6fae9 100644 --- a/fyo/core/docHandler.ts +++ b/fyo/core/docHandler.ts @@ -133,15 +133,6 @@ export class DocHandler { return doc; } - getModel(schemaName: string): typeof Doc { - const Model = this.models[schemaName]; - if (Model === undefined) { - return Doc; - } - - return Model; - } - async getSingle(schemaName: string) { return await this.getDoc(schemaName, schemaName); } @@ -169,13 +160,17 @@ export class DocHandler { schema?: Schema, Model?: typeof Doc ): Doc { - Model ??= this.getModel(schemaName); + if (!this.models[schemaName] && Model) { + this.models[schemaName] = Model; + } + + Model ??= this.models[schemaName]; schema ??= this.fyo.schemaMap[schemaName]; if (schema === undefined) { throw new Error(`Schema not found for ${schemaName}`); } - const doc = new Model(schema, data, this.fyo); + const doc = new Model!(schema, data, this.fyo); doc.setDefaults(); return doc; } diff --git a/fyo/model/types.ts b/fyo/model/types.ts index ca5e4e9f..8150f7af 100644 --- a/fyo/model/types.ts +++ b/fyo/model/types.ts @@ -31,9 +31,9 @@ export type FormulaMap = Record; export type DefaultMap = Record; export type ValidationMap = Record; export type RequiredMap = Record; -export type CurrenciesMap = Record; -export type HiddenMap = Record