2
0
mirror of https://github.com/frappe/books.git synced 2024-11-08 14:50:56 +00:00

incr: refactor core.ts to use schema !meta

This commit is contained in:
18alantom 2022-03-24 15:20:40 +05:30
parent 19278e92d6
commit 74d173f682
8 changed files with 748 additions and 799 deletions

View File

@ -1,21 +1,4 @@
import Document from '../frappe/model/document';
import Meta from '../frappe/model/meta';
import { Model } from '../src/types/model';
export function getModels(): Record<string, Model> {
// TODO: complete this function
return {};
}
export function getMeta(doctype: string): Meta {
// TODO: compete this function
return new Meta();
}
export function getNewDoc(data: Record<string, unknown>): Document {
// TODO: compete this function
return new Document();
}
import { Field, FieldTypeEnum, SchemaMap } from '../schemas/types';
export const sqliteTypeMap = {
AutoComplete: 'text',
@ -41,3 +24,12 @@ export const sqliteTypeMap = {
};
export const validTypes = Object.keys(sqliteTypeMap);
export function getFieldsByType(
schemaName: string,
schemaMap: SchemaMap,
type: FieldTypeEnum
): Field[] {
const fields = schemaMap[schemaName].fields ?? [];
return fields.filter((f) => f.fieldtype === type);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
export type RawType = string | number | boolean;
export type RawData = Record<string, RawType>[];
import { Field, RawValue } from '../../schemas/types';
export type QueryFilter = Record<string, string | string[]>;
export interface GetQueryBuilderOptions {
@ -9,3 +9,20 @@ export interface GetQueryBuilderOptions {
orderBy: string;
order: 'desc' | 'asc';
}
export interface GetAllOptions {
schemaName?: string;
fields?: string[];
filters?: Record<string, string>;
start?: number;
limit?: number;
groupBy?: string;
orderBy?: string;
order?: 'asc' | 'desc';
}
export type ColumnDiff = { added: Field[]; removed: string[] };
export type FieldValueMap = Record<
string,
RawValue | undefined | FieldValueMap[]
>;

View File

@ -1,12 +1,10 @@
import NumberSeries from './doctype/NumberSeries/NumberSeries.js';
import PatchRun from './doctype/PatchRun/PatchRun.js';
import PrintFormat from './doctype/PrintFormat/PrintFormat.js';
import SingleValue from './doctype/SingleValue/SingleValue.js';
import SystemSettings from './doctype/SystemSettings/SystemSettings.js';
export default {
NumberSeries,
PrintFormat,
SingleValue,
SystemSettings,
PatchRun,

View File

@ -17,10 +17,16 @@
"required": true
},
{
"fieldname": "party",
"label": "Party",
"fieldtype": "DynamicLink",
"target": ["Customer", "Supplier"]
"fieldname": "customer",
"label": "Customer",
"fieldtype": "Link",
"target": "Customer"
},
{
"fieldname": "supplier",
"label": "Supplier",
"fieldtype": "Link",
"target": "Supplier"
},
{
"fieldname": "debit",

View File

@ -14,11 +14,16 @@
"readOnly": true
},
{
"fieldname": "party",
"label": "Party",
"fieldname": "customer",
"label": "Customer",
"fieldtype": "Link",
"target": ["Customer", "Supplier"],
"required": true
"target": "Customer"
},
{
"fieldname": "supplier",
"label": "Supplier",
"fieldtype": "Link",
"target": "Supplier"
},
{
"fieldname": "date",

View File

@ -14,7 +14,7 @@
"meta": true
},
{
"fieldname": "parentName",
"fieldname": "parentSchemaName",
"fieldtype": "Data",
"required": true,
"meta": true

View File

@ -79,10 +79,10 @@ export interface OptionField extends BaseField {
options: SelectOption[];
}
// @formatter:off
// prettier-ignore
export interface TargetField extends BaseField {
fieldtype: FieldTypeEnum.Table | FieldTypeEnum.Link;
target: string | string[]; // Name of the table or group of tables to fetch values
target: string; // Name of the table or group of tables to fetch values
}
// @formatter:off