|
|
@ -10,7 +10,9 @@ |
|
|
|
v-on="on" |
|
|
|
v-on="on" |
|
|
|
@click="$toast.info('Happy hacking!').goAway(3000)" |
|
|
|
@click="$toast.info('Happy hacking!').goAway(3000)" |
|
|
|
> |
|
|
|
> |
|
|
|
<v-icon small class="mr-1"> mdi-file-excel-outline </v-icon> |
|
|
|
<v-icon small class="mr-1"> |
|
|
|
|
|
|
|
mdi-file-excel-outline |
|
|
|
|
|
|
|
</v-icon> |
|
|
|
Import |
|
|
|
Import |
|
|
|
</v-btn> |
|
|
|
</v-btn> |
|
|
|
</template> |
|
|
|
</template> |
|
|
@ -24,11 +26,15 @@ |
|
|
|
</v-icon> |
|
|
|
</v-icon> |
|
|
|
|
|
|
|
|
|
|
|
<v-btn small outlined class="mr-1" @click="project = { tables: [] }"> |
|
|
|
<v-btn small outlined class="mr-1" @click="project = { tables: [] }"> |
|
|
|
<v-icon small> mdi-close </v-icon> |
|
|
|
<v-icon small> |
|
|
|
|
|
|
|
mdi-close |
|
|
|
|
|
|
|
</v-icon> |
|
|
|
Reset |
|
|
|
Reset |
|
|
|
</v-btn> |
|
|
|
</v-btn> |
|
|
|
<v-btn small outlined class="mr-1" @click="createTableClick"> |
|
|
|
<v-btn small outlined class="mr-1" @click="createTableClick"> |
|
|
|
<v-icon small> mdi-plus </v-icon> |
|
|
|
<v-icon small> |
|
|
|
|
|
|
|
mdi-plus |
|
|
|
|
|
|
|
</v-icon> |
|
|
|
New table |
|
|
|
New table |
|
|
|
</v-btn> |
|
|
|
</v-btn> |
|
|
|
<v-btn |
|
|
|
<v-btn |
|
|
@ -234,22 +240,22 @@ |
|
|
|
<span |
|
|
|
<span |
|
|
|
v-if="isRelation(col)" |
|
|
|
v-if="isRelation(col)" |
|
|
|
class="caption pointer primary--text" |
|
|
|
class="caption pointer primary--text" |
|
|
|
@click="navigateToTable(col.rtn)" |
|
|
|
@click="navigateToTable(col.ref_table_name)" |
|
|
|
> |
|
|
|
> |
|
|
|
{{ col.rtn }} |
|
|
|
{{ col.ref_table_name }} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
<template v-else-if="isLookup(col)"> |
|
|
|
<template v-else-if="isLookup(col)"> |
|
|
|
<span |
|
|
|
<span |
|
|
|
class="caption pointer primary--text" |
|
|
|
class="caption pointer primary--text" |
|
|
|
@click=" |
|
|
|
@click=" |
|
|
|
navigateToTable( |
|
|
|
navigateToTable( |
|
|
|
col.rtn && col.rtn.table_name |
|
|
|
col.ref_table_name && col.ref_table_name.table_name |
|
|
|
) |
|
|
|
) |
|
|
|
" |
|
|
|
" |
|
|
|
> |
|
|
|
> |
|
|
|
{{ col.rtn && col.rtn.table_name }} |
|
|
|
{{ col.ref_table_name && col.ref_table_name.table_name }} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
<span class="caption">({{ col.rcn }})</span> |
|
|
|
<span class="caption">({{ col.ref_column_name }})</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
|
|
|
|
|
|
|
|
<template v-else-if="isRollup(col)"> |
|
|
|
<template v-else-if="isRollup(col)"> |
|
|
@ -257,11 +263,11 @@ |
|
|
|
class="caption pointer primary--text" |
|
|
|
class="caption pointer primary--text" |
|
|
|
@click=" |
|
|
|
@click=" |
|
|
|
navigateToTable( |
|
|
|
navigateToTable( |
|
|
|
col.rtn && col.rtn.table_name |
|
|
|
col.ref_table_name && col.ref_table_name.table_name |
|
|
|
) |
|
|
|
) |
|
|
|
" |
|
|
|
" |
|
|
|
> |
|
|
|
> |
|
|
|
{{ col.rtn && col.rtn.table_name }} |
|
|
|
{{ col.ref_table_name && col.ref_table_name.table_name }} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
<span class="caption">({{ col.fn }})</span> |
|
|
|
<span class="caption">({{ col.fn }})</span> |
|
|
|
</template> |
|
|
|
</template> |
|
|
@ -288,13 +294,13 @@ |
|
|
|
:items=" |
|
|
|
:items=" |
|
|
|
col.uidt === 'ForeignKey' |
|
|
|
col.uidt === 'ForeignKey' |
|
|
|
? [ |
|
|
|
? [ |
|
|
|
...uiTypes, |
|
|
|
...uiTypes, |
|
|
|
{ |
|
|
|
{ |
|
|
|
name: 'ForeignKey', |
|
|
|
name: 'ForeignKey', |
|
|
|
icon: 'mdi-link-variant', |
|
|
|
icon: 'mdi-link-variant', |
|
|
|
virtual: 1, |
|
|
|
virtual: 1, |
|
|
|
}, |
|
|
|
}, |
|
|
|
] |
|
|
|
] |
|
|
|
: uiTypes |
|
|
|
: uiTypes |
|
|
|
" |
|
|
|
" |
|
|
|
item-text="name" |
|
|
|
item-text="name" |
|
|
@ -339,7 +345,7 @@ |
|
|
|
> |
|
|
|
> |
|
|
|
<td class="pa-1 text-left"> |
|
|
|
<td class="pa-1 text-left"> |
|
|
|
<v-autocomplete |
|
|
|
<v-autocomplete |
|
|
|
:value="col.rtn" |
|
|
|
:value="col.ref_table_name" |
|
|
|
placeholder="Related table" |
|
|
|
placeholder="Related table" |
|
|
|
outlined |
|
|
|
outlined |
|
|
|
class="caption" |
|
|
|
class="caption" |
|
|
@ -353,9 +359,9 @@ |
|
|
|
:items=" |
|
|
|
:items=" |
|
|
|
isLookupOrRollup(col) |
|
|
|
isLookupOrRollup(col) |
|
|
|
? getRelatedTables( |
|
|
|
? getRelatedTables( |
|
|
|
table.table_name, |
|
|
|
table.table_name, |
|
|
|
isRollup(col) |
|
|
|
isRollup(col) |
|
|
|
) |
|
|
|
) |
|
|
|
: project.tables |
|
|
|
: project.tables |
|
|
|
" |
|
|
|
" |
|
|
|
:item-text=" |
|
|
|
:item-text=" |
|
|
@ -373,7 +379,7 @@ |
|
|
|
:value-comparator="compareRel" |
|
|
|
:value-comparator="compareRel" |
|
|
|
@input=" |
|
|
|
@input=" |
|
|
|
(v) => |
|
|
|
(v) => |
|
|
|
onRtnChange(col.rtn, v, col, table) |
|
|
|
onRtnChange(col.ref_table_name, v, col, table) |
|
|
|
" |
|
|
|
" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</td> |
|
|
|
</td> |
|
|
@ -413,12 +419,12 @@ |
|
|
|
</td> |
|
|
|
</td> |
|
|
|
<td v-if="isLookupOrRollup(col)" class="pa-1"> |
|
|
|
<td v-if="isLookupOrRollup(col)" class="pa-1"> |
|
|
|
<span v-if="viewMode" class="caption"> |
|
|
|
<span v-if="viewMode" class="caption"> |
|
|
|
{{ col.rcn }} |
|
|
|
{{ col.ref_column_name }} |
|
|
|
</span> |
|
|
|
</span> |
|
|
|
|
|
|
|
|
|
|
|
<v-autocomplete |
|
|
|
<v-autocomplete |
|
|
|
v-else |
|
|
|
v-else |
|
|
|
v-model="col.rcn" |
|
|
|
v-model="col.ref_column_name" |
|
|
|
placeholder="Related table column" |
|
|
|
placeholder="Related table column" |
|
|
|
outlined |
|
|
|
outlined |
|
|
|
dense |
|
|
|
dense |
|
|
@ -433,9 +439,9 @@ |
|
|
|
project.tables.find( |
|
|
|
project.tables.find( |
|
|
|
(t) => |
|
|
|
(t) => |
|
|
|
t.table_name === |
|
|
|
t.table_name === |
|
|
|
((col.rtn && |
|
|
|
((col.ref_table_name && |
|
|
|
col.rtn.table_name) || |
|
|
|
col.ref_table_name.table_name) || |
|
|
|
col.rtn) |
|
|
|
col.ref_table_name) |
|
|
|
) || { columns: [] } |
|
|
|
) || { columns: [] } |
|
|
|
).columns.filter((v) => !isVirtual(v)) |
|
|
|
).columns.filter((v) => !isVirtual(v)) |
|
|
|
" |
|
|
|
" |
|
|
@ -484,8 +490,8 @@ |
|
|
|
v-if="!isRollup(col)" |
|
|
|
v-if="!isRollup(col)" |
|
|
|
:colspan=" |
|
|
|
:colspan=" |
|
|
|
isLookupOrRollup(col) || |
|
|
|
isLookupOrRollup(col) || |
|
|
|
isRelation(col) || |
|
|
|
isRelation(col) || |
|
|
|
isSelect(col) |
|
|
|
isSelect(col) |
|
|
|
? isRollup(col) |
|
|
|
? isRollup(col) |
|
|
|
? 0 |
|
|
|
? 0 |
|
|
|
: 1 |
|
|
|
: 1 |
|
|
@ -501,8 +507,8 @@ |
|
|
|
small |
|
|
|
small |
|
|
|
color="grey" |
|
|
|
color="grey" |
|
|
|
@click.stop=" |
|
|
|
@click.stop=" |
|
|
|
deleteTableColumn(i, j, col, table) |
|
|
|
deleteTableColumn(i, j, col, table) |
|
|
|
" |
|
|
|
" |
|
|
|
v-on="on" |
|
|
|
v-on="on" |
|
|
|
> |
|
|
|
> |
|
|
|
mdi-delete-outline |
|
|
|
mdi-delete-outline |
|
|
@ -848,42 +854,43 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (const column of t.columns || []) { |
|
|
|
for (const column of t.columns || []) { |
|
|
|
|
|
|
|
console.log(column) |
|
|
|
if (this.isRelation(column)) { |
|
|
|
if (this.isRelation(column)) { |
|
|
|
if (column.type === 'hm') { |
|
|
|
if (column.type === 'hm') { |
|
|
|
table.hasMany.push({ |
|
|
|
table.hasMany.push({ |
|
|
|
tn: column.rtn, |
|
|
|
table_name: column.ref_table_name, |
|
|
|
_cn: column.column_name |
|
|
|
title: column.column_name |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else if (column.type === 'mm') { |
|
|
|
} else if (column.type === 'mm') { |
|
|
|
table.manyToMany.push({ |
|
|
|
table.manyToMany.push({ |
|
|
|
rtn: column.rtn, |
|
|
|
ref_table_name: column.ref_table_name, |
|
|
|
_cn: column.column_name |
|
|
|
title: column.column_name |
|
|
|
}) |
|
|
|
}) |
|
|
|
} else if (column.uidt === UITypes.ForeignKey) { |
|
|
|
} else if (column.uidt === UITypes.ForeignKey) { |
|
|
|
table.belongsTo.push({ |
|
|
|
table.belongsTo.push({ |
|
|
|
tn: column.rtn, |
|
|
|
table_name: column.ref_table_name, |
|
|
|
_cn: column.column_name |
|
|
|
title: column.column_name |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (this.isLookup(column)) { |
|
|
|
} else if (this.isLookup(column)) { |
|
|
|
if (column.rtn) { |
|
|
|
if (column.ref_table_name) { |
|
|
|
table.v.push({ |
|
|
|
table.v.push({ |
|
|
|
_cn: column.column_name, |
|
|
|
title: column.column_name, |
|
|
|
lk: { |
|
|
|
lk: { |
|
|
|
ltn: column.rtn.table_name, |
|
|
|
ltn: column.ref_table_name.table_name, |
|
|
|
type: column.rtn.type, |
|
|
|
type: column.ref_table_name.type, |
|
|
|
lcn: column.rcn |
|
|
|
lcn: column.ref_column_name |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (this.isRollup(column)) { |
|
|
|
} else if (this.isRollup(column)) { |
|
|
|
if (column.rtn) { |
|
|
|
if (column.ref_table_name) { |
|
|
|
table.v.push({ |
|
|
|
table.v.push({ |
|
|
|
_cn: column.column_name, |
|
|
|
title: column.column_name, |
|
|
|
rl: { |
|
|
|
rl: { |
|
|
|
rltn: column.rtn.table_name, |
|
|
|
rltn: column.ref_table_name.table_name, |
|
|
|
rlcn: column.rcn, |
|
|
|
rlcn: column.ref_column_name, |
|
|
|
type: column.rtn.type, |
|
|
|
type: column.ref_table_name.type, |
|
|
|
fn: column.fn |
|
|
|
fn: column.fn |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
@ -947,7 +954,7 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
for (const mm of t.manyToMany) { |
|
|
|
for (const mm of t.manyToMany) { |
|
|
|
const rTable = this.project.tables.find( |
|
|
|
const rTable = this.project.tables.find( |
|
|
|
t1 => t1.table_name === mm.rtn |
|
|
|
t1 => t1.table_name === mm.ref_table_name |
|
|
|
) |
|
|
|
) |
|
|
|
tables.push({ |
|
|
|
tables.push({ |
|
|
|
...rTable, |
|
|
|
...rTable, |
|
|
@ -964,7 +971,7 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
for (const mm of t.manyToMany) { |
|
|
|
for (const mm of t.manyToMany) { |
|
|
|
if (mm.rtn === tableName) { |
|
|
|
if (mm.ref_table_name === tableName) { |
|
|
|
tables.push({ |
|
|
|
tables.push({ |
|
|
|
...t, |
|
|
|
...t, |
|
|
|
type: 'mm' |
|
|
|
type: 'mm' |
|
|
@ -998,7 +1005,7 @@ export default { |
|
|
|
continue |
|
|
|
continue |
|
|
|
} |
|
|
|
} |
|
|
|
table.columns = table.columns.filter( |
|
|
|
table.columns = table.columns.filter( |
|
|
|
c => c.rtn !== deleteTable.table_name |
|
|
|
c => c.ref_table_name !== deleteTable.table_name |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
this.project.tables.splice(i, 1) |
|
|
|
this.project.tables.splice(i, 1) |
|
|
@ -1011,31 +1018,31 @@ export default { |
|
|
|
// if relation column, delete the corresponding relation from other table |
|
|
|
// if relation column, delete the corresponding relation from other table |
|
|
|
if (col.uidt === UITypes.LinkToAnotherRecord) { |
|
|
|
if (col.uidt === UITypes.LinkToAnotherRecord) { |
|
|
|
if (col.type === 'hm') { |
|
|
|
if (col.type === 'hm') { |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.rtn) |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.ref_table_name) |
|
|
|
index = |
|
|
|
index = |
|
|
|
rTable && |
|
|
|
rTable && |
|
|
|
rTable.columns.findIndex( |
|
|
|
rTable.columns.findIndex( |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.rtn === table.table_name |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.ref_table_name === table.table_name |
|
|
|
) |
|
|
|
) |
|
|
|
} else if (col.type === 'mm') { |
|
|
|
} else if (col.type === 'mm') { |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.rtn) |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.ref_table_name) |
|
|
|
index = |
|
|
|
index = |
|
|
|
rTable && |
|
|
|
rTable && |
|
|
|
rTable.columns.findIndex( |
|
|
|
rTable.columns.findIndex( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'mm' |
|
|
|
c.type === 'mm' |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (col.uidt === UITypes.ForeignKey) { |
|
|
|
} else if (col.uidt === UITypes.ForeignKey) { |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.rtn) |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.ref_table_name) |
|
|
|
index = |
|
|
|
index = |
|
|
|
rTable && |
|
|
|
rTable && |
|
|
|
rTable.columns.findIndex( |
|
|
|
rTable.columns.findIndex( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'hm' |
|
|
|
c.type === 'hm' |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -1050,8 +1057,8 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
table.columns = table.columns.filter( |
|
|
|
table.columns = table.columns.filter( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.rtn !== deleteTable.table_name || |
|
|
|
c.ref_table_name !== deleteTable.table_name || |
|
|
|
c.rcn !== deleteColumn.column_name |
|
|
|
c.ref_column_name !== deleteColumn.column_name |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
deleteTable.columns.splice(j, 1) |
|
|
|
deleteTable.columns.splice(j, 1) |
|
|
@ -1072,10 +1079,10 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
this.project.tables.push({ |
|
|
|
this.project.tables.push({ |
|
|
|
tn: m[1], |
|
|
|
table_name: m[1], |
|
|
|
columns: (m[2] ? m[2].split(/\s*,\s*/) : []) |
|
|
|
columns: (m[2] ? m[2].split(/\s*,\s*/) : []) |
|
|
|
.map(col => ({ |
|
|
|
.map(col => ({ |
|
|
|
cn: col, |
|
|
|
column_name: col, |
|
|
|
...defaultColProp |
|
|
|
...defaultColProp |
|
|
|
})) |
|
|
|
})) |
|
|
|
.filter( |
|
|
|
.filter( |
|
|
@ -1105,7 +1112,7 @@ export default { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
table.columns.push({ |
|
|
|
table.columns.push({ |
|
|
|
cn: col, |
|
|
|
column_name: col, |
|
|
|
...defaultColProp |
|
|
|
...defaultColProp |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
@ -1148,7 +1155,7 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
addNewColumnRow(table, uidt) { |
|
|
|
addNewColumnRow(table, uidt) { |
|
|
|
table.columns.push({ |
|
|
|
table.columns.push({ |
|
|
|
cn: `title${table.columns.length + 1}`, |
|
|
|
column_name: `title${table.columns.length + 1}`, |
|
|
|
...defaultColProp, |
|
|
|
...defaultColProp, |
|
|
|
uidt, |
|
|
|
uidt, |
|
|
|
...(uidt === LinkToAnotherRecord |
|
|
|
...(uidt === LinkToAnotherRecord |
|
|
@ -1286,41 +1293,41 @@ export default { |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
|
...columns, |
|
|
|
...columns, |
|
|
|
...manyToMany.map(mm => ({ |
|
|
|
...manyToMany.map(mm => ({ |
|
|
|
cn: mm.title || `${rest.table_name} <=> ${mm.rtn}`, |
|
|
|
column_name: mm.title || `${rest.table_name} <=> ${mm.ref_table_name}`, |
|
|
|
uidt: LinkToAnotherRecord, |
|
|
|
uidt: LinkToAnotherRecord, |
|
|
|
type: 'mm', |
|
|
|
type: 'mm', |
|
|
|
...mm |
|
|
|
...mm |
|
|
|
})), |
|
|
|
})), |
|
|
|
...hasMany.map(hm => ({ |
|
|
|
...hasMany.map(hm => ({ |
|
|
|
cn: hm.title || `${rest.table_name} => ${hm.table_name}`, |
|
|
|
column_name: hm.title || `${rest.table_name} => ${hm.table_name}`, |
|
|
|
uidt: LinkToAnotherRecord, |
|
|
|
uidt: LinkToAnotherRecord, |
|
|
|
type: 'hm', |
|
|
|
type: 'hm', |
|
|
|
rtn: hm.table_name, |
|
|
|
ref_table_name: hm.table_name, |
|
|
|
...hm |
|
|
|
...hm |
|
|
|
})), |
|
|
|
})), |
|
|
|
...belongsTo.map(bt => ({ |
|
|
|
...belongsTo.map(bt => ({ |
|
|
|
cn: bt.title || `${rest.table_name} => ${bt.rtn}`, |
|
|
|
column_name: bt.title || `${rest.table_name} => ${bt.ref_table_name}`, |
|
|
|
uidt: UITypes.ForeignKey, |
|
|
|
uidt: UITypes.ForeignKey, |
|
|
|
rtn: bt.table_name, |
|
|
|
ref_table_name: bt.table_name, |
|
|
|
...bt |
|
|
|
...bt |
|
|
|
})), |
|
|
|
})), |
|
|
|
...v.map((v) => { |
|
|
|
...v.map((v) => { |
|
|
|
const res = { |
|
|
|
const res = { |
|
|
|
cn: v.title, |
|
|
|
column_name: v.title, |
|
|
|
rtn: { |
|
|
|
ref_table_name: { |
|
|
|
...v |
|
|
|
...v |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (v.lk) { |
|
|
|
if (v.lk) { |
|
|
|
res.uidt = Lookup |
|
|
|
res.uidt = Lookup |
|
|
|
res.rtn.table_name = v.lk.ltn |
|
|
|
res.ref_table_name.table_name = v.lk.ltn |
|
|
|
res.rcn = v.lk.lcn |
|
|
|
res.ref_column_name = v.lk.lcn |
|
|
|
res.rtn.type = v.lk.type |
|
|
|
res.ref_table_name.type = v.lk.type |
|
|
|
} else if (v.rl) { |
|
|
|
} else if (v.rl) { |
|
|
|
res.uidt = Rollup |
|
|
|
res.uidt = Rollup |
|
|
|
res.rtn.table_name = v.rl.rltn |
|
|
|
res.ref_table_name.table_name = v.rl.rltn |
|
|
|
res.rcn = v.rl.rlcn |
|
|
|
res.ref_column_name = v.rl.rlcn |
|
|
|
res.rtn.type = v.rl.type |
|
|
|
res.ref_table_name.type = v.rl.type |
|
|
|
res.fn = v.rl.fn |
|
|
|
res.fn = v.rl.fn |
|
|
|
} |
|
|
|
} |
|
|
|
return res |
|
|
|
return res |
|
|
@ -1472,26 +1479,26 @@ export default { |
|
|
|
c !== col && |
|
|
|
c !== col && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.type === col.type && |
|
|
|
c.type === col.type && |
|
|
|
c.rtn === col.rtn |
|
|
|
c.ref_table_name === col.ref_table_name |
|
|
|
) || |
|
|
|
) || |
|
|
|
'Duplicate relation is not allowed' |
|
|
|
'Duplicate relation is not allowed' |
|
|
|
}, |
|
|
|
}, |
|
|
|
onTableNameUpdate(oldTable, newVal) { |
|
|
|
onTableNameUpdate(oldTable, newVal) { |
|
|
|
const oldVal = oldTable.table_name |
|
|
|
const oldVal = oldTable.table_name |
|
|
|
this.$set(oldTable, 'tn', newVal) |
|
|
|
this.$set(oldTable, 'table_name', newVal) |
|
|
|
|
|
|
|
|
|
|
|
for (const table of this.project.tables) { |
|
|
|
for (const table of this.project.tables) { |
|
|
|
for (const col of table.columns) { |
|
|
|
for (const col of table.columns) { |
|
|
|
if (col.uidt === UITypes.LinkToAnotherRecord) { |
|
|
|
if (col.uidt === UITypes.LinkToAnotherRecord) { |
|
|
|
if (col.rtn === oldVal) { |
|
|
|
if (col.ref_table_name === oldVal) { |
|
|
|
this.$set(col, 'rtn', newVal) |
|
|
|
this.$set(col, 'ref_table_name', newVal) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if ( |
|
|
|
} else if ( |
|
|
|
col.uidt === UITypes.Rollup || |
|
|
|
col.uidt === UITypes.Rollup || |
|
|
|
col.uidt === UITypes.Lookup |
|
|
|
col.uidt === UITypes.Lookup |
|
|
|
) { |
|
|
|
) { |
|
|
|
if (col.rtn && col.rtn.table_name === oldVal) { |
|
|
|
if (col.ref_table_name && col.ref_table_name.table_name === oldVal) { |
|
|
|
this.$set(col.rtn, 'tn', newVal) |
|
|
|
this.$set(col.ref_table_name, 'table_name', newVal) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1499,20 +1506,20 @@ export default { |
|
|
|
}, |
|
|
|
}, |
|
|
|
onColumnNameUpdate(oldCol, newVal, tn) { |
|
|
|
onColumnNameUpdate(oldCol, newVal, tn) { |
|
|
|
const oldVal = oldCol.column_name |
|
|
|
const oldVal = oldCol.column_name |
|
|
|
this.$set(oldCol, 'cn', newVal) |
|
|
|
this.$set(oldCol, 'column_name', newVal) |
|
|
|
|
|
|
|
|
|
|
|
for (const table of this.project.tables) { |
|
|
|
for (const table of this.project.tables) { |
|
|
|
for (const col of table.columns) { |
|
|
|
for (const col of table.columns) { |
|
|
|
if (col.uidt === UITypes.Rollup || col.uidt === UITypes.Lookup) { |
|
|
|
if (col.uidt === UITypes.Rollup || col.uidt === UITypes.Lookup) { |
|
|
|
if (col.rtn && col.rcn === oldVal && col.rtn.table_name === tn) { |
|
|
|
if (col.ref_table_name && col.ref_column_name === oldVal && col.ref_table_name.table_name === tn) { |
|
|
|
this.$set(col, 'rcn', newVal) |
|
|
|
this.$set(col, 'ref_column_name', newVal) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
}, |
|
|
|
async onRtnChange(oldVal, newVal, col, table) { |
|
|
|
async onRtnChange(oldVal, newVal, col, table) { |
|
|
|
this.$set(col, 'rtn', newVal) |
|
|
|
this.$set(col, 'ref_table_name', newVal) |
|
|
|
|
|
|
|
|
|
|
|
await this.$nextTick() |
|
|
|
await this.$nextTick() |
|
|
|
|
|
|
|
|
|
|
@ -1532,7 +1539,7 @@ export default { |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'mm' |
|
|
|
c.type === 'mm' |
|
|
|
) |
|
|
|
) |
|
|
|
} else if ( |
|
|
|
} else if ( |
|
|
@ -1540,13 +1547,13 @@ export default { |
|
|
|
col.type === 'hm' |
|
|
|
col.type === 'hm' |
|
|
|
) { |
|
|
|
) { |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.rtn === table.table_name |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.ref_table_name === table.table_name |
|
|
|
) |
|
|
|
) |
|
|
|
} else if (col.uidt === UITypes.ForeignKey) { |
|
|
|
} else if (col.uidt === UITypes.ForeignKey) { |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'hm' |
|
|
|
c.type === 'hm' |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -1565,15 +1572,15 @@ export default { |
|
|
|
!rTable.columns.find( |
|
|
|
!rTable.columns.find( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'mm' |
|
|
|
c.type === 'mm' |
|
|
|
) |
|
|
|
) |
|
|
|
) { |
|
|
|
) { |
|
|
|
rTable.columns.push({ |
|
|
|
rTable.columns.push({ |
|
|
|
cn: `title${rTable.columns.length + 1}`, |
|
|
|
column_name: `title${rTable.columns.length + 1}`, |
|
|
|
uidt: UITypes.LinkToAnotherRecord, |
|
|
|
uidt: UITypes.LinkToAnotherRecord, |
|
|
|
type: 'mm', |
|
|
|
type: 'mm', |
|
|
|
rtn: table.table_name |
|
|
|
ref_table_name: table.table_name |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if ( |
|
|
|
} else if ( |
|
|
@ -1582,13 +1589,13 @@ export default { |
|
|
|
) { |
|
|
|
) { |
|
|
|
if ( |
|
|
|
if ( |
|
|
|
!rTable.columns.find( |
|
|
|
!rTable.columns.find( |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.rtn === table.table_name |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.ref_table_name === table.table_name |
|
|
|
) |
|
|
|
) |
|
|
|
) { |
|
|
|
) { |
|
|
|
rTable.columns.push({ |
|
|
|
rTable.columns.push({ |
|
|
|
cn: `title${rTable.columns.length + 1}`, |
|
|
|
column_name: `title${rTable.columns.length + 1}`, |
|
|
|
uidt: UITypes.ForeignKey, |
|
|
|
uidt: UITypes.ForeignKey, |
|
|
|
rtn: table.table_name |
|
|
|
ref_table_name: table.table_name |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (col.uidt === UITypes.ForeignKey) { |
|
|
|
} else if (col.uidt === UITypes.ForeignKey) { |
|
|
@ -1596,15 +1603,15 @@ export default { |
|
|
|
!rTable.columns.find( |
|
|
|
!rTable.columns.find( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'hm' |
|
|
|
c.type === 'hm' |
|
|
|
) |
|
|
|
) |
|
|
|
) { |
|
|
|
) { |
|
|
|
rTable.columns.push({ |
|
|
|
rTable.columns.push({ |
|
|
|
cn: `title${rTable.columns.length + 1}`, |
|
|
|
column_name: `title${rTable.columns.length + 1}`, |
|
|
|
uidt: UITypes.LinkToAnotherRecord, |
|
|
|
uidt: UITypes.LinkToAnotherRecord, |
|
|
|
type: 'hm', |
|
|
|
type: 'hm', |
|
|
|
rtn: table.table_name |
|
|
|
ref_table_name: table.table_name |
|
|
|
}) |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -1613,7 +1620,7 @@ export default { |
|
|
|
onRTypeChange(oldType, newType, col, table) { |
|
|
|
onRTypeChange(oldType, newType, col, table) { |
|
|
|
this.$set(col, 'type', newType) |
|
|
|
this.$set(col, 'type', newType) |
|
|
|
|
|
|
|
|
|
|
|
const rTable = this.project.tables.find(t => t.table_name === col.rtn) |
|
|
|
const rTable = this.project.tables.find(t => t.table_name === col.ref_table_name) |
|
|
|
|
|
|
|
|
|
|
|
let index = -1 |
|
|
|
let index = -1 |
|
|
|
|
|
|
|
|
|
|
@ -1622,20 +1629,20 @@ export default { |
|
|
|
|
|
|
|
|
|
|
|
if (oldType === 'hm') { |
|
|
|
if (oldType === 'hm') { |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.rtn === table.table_name |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.ref_table_name === table.table_name |
|
|
|
) |
|
|
|
) |
|
|
|
} else if (oldType === 'mm') { |
|
|
|
} else if (oldType === 'mm') { |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'mm' |
|
|
|
c.type === 'mm' |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const rCol = |
|
|
|
const rCol = |
|
|
|
index === -1 |
|
|
|
index === -1 |
|
|
|
? { cn: `title${rTable.columns.length + 1}` } |
|
|
|
? { column_name: `title${rTable.columns.length + 1}` } |
|
|
|
: { ...rTable.columns[index] } |
|
|
|
: { ...rTable.columns[index] } |
|
|
|
index = index === -1 ? rTable.columns.length : index |
|
|
|
index = index === -1 ? rTable.columns.length : index |
|
|
|
|
|
|
|
|
|
|
@ -1646,7 +1653,7 @@ export default { |
|
|
|
rCol.type = 'bt' |
|
|
|
rCol.type = 'bt' |
|
|
|
rCol.uidt = UITypes.ForeignKey |
|
|
|
rCol.uidt = UITypes.ForeignKey |
|
|
|
} |
|
|
|
} |
|
|
|
rCol.rtn = table.table_name |
|
|
|
rCol.ref_table_name = table.table_name |
|
|
|
|
|
|
|
|
|
|
|
this.$set(rTable.columns, index, rCol) |
|
|
|
this.$set(rTable.columns, index, rCol) |
|
|
|
}, |
|
|
|
}, |
|
|
@ -1661,28 +1668,28 @@ export default { |
|
|
|
let rTable |
|
|
|
let rTable |
|
|
|
|
|
|
|
|
|
|
|
if (oldVal === UITypes.LinkToAnotherRecord) { |
|
|
|
if (oldVal === UITypes.LinkToAnotherRecord) { |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.rtn) |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.ref_table_name) |
|
|
|
if (rTable) { |
|
|
|
if (rTable) { |
|
|
|
if (col.type === 'hm') { |
|
|
|
if (col.type === 'hm') { |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.rtn === table.table_name |
|
|
|
c => c.uidt === UITypes.ForeignKey && c.ref_table_name === table.table_name |
|
|
|
) |
|
|
|
) |
|
|
|
} else if (col.type === 'mm') { |
|
|
|
} else if (col.type === 'mm') { |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'mm' |
|
|
|
c.type === 'mm' |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else if (oldVal === UITypes.ForeignKey) { |
|
|
|
} else if (oldVal === UITypes.ForeignKey) { |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.rtn) |
|
|
|
rTable = this.project.tables.find(t => t.table_name === col.ref_table_name) |
|
|
|
if (rTable) { |
|
|
|
if (rTable) { |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
index = rTable.columns.findIndex( |
|
|
|
c => |
|
|
|
c => |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.uidt === UITypes.LinkToAnotherRecord && |
|
|
|
c.rtn === table.table_name && |
|
|
|
c.ref_table_name === table.table_name && |
|
|
|
c.type === 'hm' |
|
|
|
c.type === 'hm' |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
@ -1691,9 +1698,9 @@ export default { |
|
|
|
rTable.columns.splice(index, 1) |
|
|
|
rTable.columns.splice(index, 1) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
col.rtn = undefined |
|
|
|
col.ref_table_name = undefined |
|
|
|
col.type = undefined |
|
|
|
col.type = undefined |
|
|
|
col.rcn = undefined |
|
|
|
col.ref_column_name = undefined |
|
|
|
|
|
|
|
|
|
|
|
if (col.uidt === LinkToAnotherRecord) { |
|
|
|
if (col.uidt === LinkToAnotherRecord) { |
|
|
|
col.type = col.type || 'mm' |
|
|
|
col.type = col.type || 'mm' |
|
|
|