|
|
@ -69,57 +69,24 @@ const parseAndLoadTemplate = () => { |
|
|
|
const parseTemplate = ({ tables = [], ...rest }: Record<string, any>) => { |
|
|
|
const parseTemplate = ({ tables = [], ...rest }: Record<string, any>) => { |
|
|
|
const parsedTemplate = { |
|
|
|
const parsedTemplate = { |
|
|
|
...rest, |
|
|
|
...rest, |
|
|
|
tables: tables.map( |
|
|
|
tables: tables.map(({ v = [], columns = [], ...rest }: Record<string, any>) => ({ |
|
|
|
({ manyToMany = [], hasMany = [], belongsTo = [], v = [], columns = [], ...rest }: Record<string, any>) => ({ |
|
|
|
...rest, |
|
|
|
...rest, |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
|
...columns.map((c: any, idx: number) => { |
|
|
|
...columns.map((c: any, idx: number) => { |
|
|
|
c.key = idx |
|
|
|
c.key = idx |
|
|
|
return c |
|
|
|
return c |
|
|
|
}), |
|
|
|
}), |
|
|
|
...v.map((v: any) => { |
|
|
|
...manyToMany.map((mm: any) => ({ |
|
|
|
const res: any = { |
|
|
|
column_name: mm.title || `${rest.table_name} <=> ${mm.ref_table_name}`, |
|
|
|
column_name: v.title, |
|
|
|
uidt: LinkToAnotherRecord, |
|
|
|
ref_table_name: { |
|
|
|
type: 'mm', |
|
|
|
...v, |
|
|
|
...mm, |
|
|
|
}, |
|
|
|
})), |
|
|
|
} |
|
|
|
...hasMany.map((hm: any) => ({ |
|
|
|
return res |
|
|
|
column_name: hm.title || `${rest.table_name} => ${hm.table_name}`, |
|
|
|
}), |
|
|
|
uidt: LinkToAnotherRecord, |
|
|
|
], |
|
|
|
type: 'hm', |
|
|
|
})), |
|
|
|
ref_table_name: hm.table_name, |
|
|
|
|
|
|
|
...hm, |
|
|
|
|
|
|
|
})), |
|
|
|
|
|
|
|
...belongsTo.map((bt: any) => ({ |
|
|
|
|
|
|
|
column_name: bt.title || `${rest.table_name} => ${bt.ref_table_name}`, |
|
|
|
|
|
|
|
uidt: UITypes.ForeignKey, |
|
|
|
|
|
|
|
ref_table_name: bt.table_name, |
|
|
|
|
|
|
|
...bt, |
|
|
|
|
|
|
|
})), |
|
|
|
|
|
|
|
...v.map((v: any) => { |
|
|
|
|
|
|
|
const res: any = { |
|
|
|
|
|
|
|
column_name: v.title, |
|
|
|
|
|
|
|
ref_table_name: { |
|
|
|
|
|
|
|
...v, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if (v.lk) { |
|
|
|
|
|
|
|
res.uidt = Lookup |
|
|
|
|
|
|
|
res.ref_table_name.table_name = v.lk.ltn |
|
|
|
|
|
|
|
res.ref_column_name = v.lk.lcn |
|
|
|
|
|
|
|
res.ref_table_name.type = v.lk.type |
|
|
|
|
|
|
|
} else if (v.rl) { |
|
|
|
|
|
|
|
res.uidt = Rollup |
|
|
|
|
|
|
|
res.ref_table_name.table_name = v.rl.rltn |
|
|
|
|
|
|
|
res.ref_column_name = v.rl.rlcn |
|
|
|
|
|
|
|
res.ref_table_name.type = v.rl.type |
|
|
|
|
|
|
|
res.fn = v.rl.fn |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return res |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
}), |
|
|
|
|
|
|
|
), |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
project.value = parsedTemplate |
|
|
|
project.value = parsedTemplate |
|
|
|
} |
|
|
|
} |
|
|
@ -132,27 +99,6 @@ const deleteTable = (tableIdx: number) => { |
|
|
|
// TODO: |
|
|
|
// TODO: |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const isRelation = (col: ColumnType) => { |
|
|
|
|
|
|
|
return col.uidt === 'LinkToAnotherRecord' || col.uidt === 'ForeignKey' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isLookup = (col: ColumnType) => { |
|
|
|
|
|
|
|
return col.uidt === 'Lookup' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isRollup = (col: ColumnType) => { |
|
|
|
|
|
|
|
return col.uidt === 'Rollup' |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isVirtual = (col: ColumnType) => { |
|
|
|
|
|
|
|
// TODO: uiTypes |
|
|
|
|
|
|
|
// return col && uiTypes.some(ut => ut.name === col.uidt && ut.virtual); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isLookupOrRollup = (col: ColumnType) => { |
|
|
|
|
|
|
|
return isLookup(col) || isRollup(col) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const isSelect = (col: ColumnType) => { |
|
|
|
const isSelect = (col: ColumnType) => { |
|
|
|
return col.uidt === 'MultiSelect' || col.uidt === 'SingleSelect' |
|
|
|
return col.uidt === 'MultiSelect' || col.uidt === 'SingleSelect' |
|
|
|
} |
|
|
|
} |
|
|
@ -161,10 +107,6 @@ const onColumnNameUpdate = (oldCol: ColumnType, newVal: string, tn: string) => { |
|
|
|
// TODO |
|
|
|
// TODO |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const onRTypeChange = (oldType: string, newType: string, col: ColumnType, table: string) => { |
|
|
|
|
|
|
|
// TODO |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const deleteTableColumn = (i: number, j: number, col: Record<string, any>, table: Record<string, any>) => { |
|
|
|
const deleteTableColumn = (i: number, j: number, col: Record<string, any>, table: Record<string, any>) => { |
|
|
|
const deleteTable = project.value.tables[i] |
|
|
|
const deleteTable = project.value.tables[i] |
|
|
|
const deleteColumn = deleteTable.columns[j] |
|
|
|
const deleteColumn = deleteTable.columns[j] |
|
|
@ -191,14 +133,6 @@ const addNewColumnRow = (table: Record<string, any>, uidt?: string) => { |
|
|
|
input.select() |
|
|
|
input.select() |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const getIcon = (type: string) => { |
|
|
|
|
|
|
|
// TODO |
|
|
|
|
|
|
|
return { |
|
|
|
|
|
|
|
name: 'CreateTime', |
|
|
|
|
|
|
|
icon: 'mdi-calendar-clock', |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
</script> |
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<template> |
|
|
|
<template> |
|
|
|