Parse view v1 schema to fix builder crashed caused by 'groupedby' views
This commit is contained in:
parent
0010e07b47
commit
871891c2a2
|
@ -24,17 +24,21 @@
|
||||||
|
|
||||||
let selectedRows = []
|
let selectedRows = []
|
||||||
let customRenderers = []
|
let customRenderers = []
|
||||||
|
let parsedSchema = {}
|
||||||
|
|
||||||
|
$: if (schema) {
|
||||||
|
parsedSchema = Object.keys(schema).reduce((acc, key) => {
|
||||||
|
acc[key] = { ...schema[key] }
|
||||||
|
if (!canBeSortColumn(acc[key].type)) {
|
||||||
|
acc[key].sortable = false
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
}
|
||||||
|
|
||||||
$: selectedRows, dispatch("selectionUpdated", selectedRows)
|
$: selectedRows, dispatch("selectionUpdated", selectedRows)
|
||||||
$: isUsersTable = tableId === TableNames.USERS
|
$: isUsersTable = tableId === TableNames.USERS
|
||||||
$: data && resetSelectedRows()
|
$: data && resetSelectedRows()
|
||||||
$: {
|
|
||||||
Object.values(schema || {}).forEach(col => {
|
|
||||||
if (!canBeSortColumn(col.type)) {
|
|
||||||
col.sortable = false
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
$: {
|
$: {
|
||||||
if (isUsersTable) {
|
if (isUsersTable) {
|
||||||
customRenderers = [
|
customRenderers = [
|
||||||
|
@ -44,24 +48,24 @@
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
UNEDITABLE_USER_FIELDS.forEach(field => {
|
UNEDITABLE_USER_FIELDS.forEach(field => {
|
||||||
if (schema[field]) {
|
if (parsedSchema[field]) {
|
||||||
schema[field].editable = false
|
parsedSchema[field].editable = false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (schema.email) {
|
if (parsedSchema.email) {
|
||||||
schema.email.displayName = "Email"
|
parsedSchema.email.displayName = "Email"
|
||||||
}
|
}
|
||||||
if (schema.roleId) {
|
if (parsedSchema.roleId) {
|
||||||
schema.roleId.displayName = "Role"
|
parsedSchema.roleId.displayName = "Role"
|
||||||
}
|
}
|
||||||
if (schema.firstName) {
|
if (parsedSchema.firstName) {
|
||||||
schema.firstName.displayName = "First Name"
|
parsedSchema.firstName.displayName = "First Name"
|
||||||
}
|
}
|
||||||
if (schema.lastName) {
|
if (parsedSchema.lastName) {
|
||||||
schema.lastName.displayName = "Last Name"
|
parsedSchema.lastName.displayName = "Last Name"
|
||||||
}
|
}
|
||||||
if (schema.status) {
|
if (parsedSchema.status) {
|
||||||
schema.status.displayName = "Status"
|
parsedSchema.status.displayName = "Status"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -97,7 +101,7 @@
|
||||||
<div class="table-wrapper">
|
<div class="table-wrapper">
|
||||||
<Table
|
<Table
|
||||||
{data}
|
{data}
|
||||||
{schema}
|
schema={parsedSchema}
|
||||||
{loading}
|
{loading}
|
||||||
{customRenderers}
|
{customRenderers}
|
||||||
{rowCount}
|
{rowCount}
|
||||||
|
|
|
@ -19,7 +19,21 @@
|
||||||
let loading = false
|
let loading = false
|
||||||
let type = "internal"
|
let type = "internal"
|
||||||
|
|
||||||
|
// Grouped views have a fixed schema layout
|
||||||
|
const parseSchema = view => {
|
||||||
|
if (!view.groupBy) {
|
||||||
|
return view.schema
|
||||||
|
}
|
||||||
|
const { group, field, value } = view.schema
|
||||||
|
return {
|
||||||
|
group,
|
||||||
|
field: { type: field },
|
||||||
|
value: { type: value },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$: name = view.name
|
$: name = view.name
|
||||||
|
$: schema = parseSchema(view)
|
||||||
$: calculation = view.calculation
|
$: calculation = view.calculation
|
||||||
|
|
||||||
$: supportedFormats = Object.values(ROW_EXPORT_FORMATS).filter(key => {
|
$: supportedFormats = Object.values(ROW_EXPORT_FORMATS).filter(key => {
|
||||||
|
@ -61,7 +75,7 @@
|
||||||
|
|
||||||
<Table
|
<Table
|
||||||
title={decodeURI(name)}
|
title={decodeURI(name)}
|
||||||
schema={view.schema}
|
{schema}
|
||||||
tableId={view.tableId}
|
tableId={view.tableId}
|
||||||
{data}
|
{data}
|
||||||
{loading}
|
{loading}
|
||||||
|
|
Loading…
Reference in New Issue