Updating where utilities are held in builder and then making user table relationships autocolumn aware too.
This commit is contained in:
parent
02a68beee1
commit
8b0f99b0b1
|
@ -1,10 +1,10 @@
|
|||
import { TableNames } from "../../constants"
|
||||
import { TableNames } from "../constants"
|
||||
import {
|
||||
AUTO_COLUMN_DISPLAY_NAMES,
|
||||
AUTO_COLUMN_SUB_TYPES,
|
||||
FIELDS,
|
||||
isAutoColumnUserRelationship
|
||||
} from "../../constants/backend"
|
||||
} from "../constants/backend"
|
||||
|
||||
export function getAutoColumnInformation(enabled = true) {
|
||||
let info = {}
|
||||
|
@ -52,4 +52,4 @@ export function buildAutoColumn(tableName, name, subtype) {
|
|||
base.fieldName = `${tableName}-${name}`
|
||||
}
|
||||
return base
|
||||
}
|
||||
}
|
|
@ -13,10 +13,9 @@
|
|||
import CreateEditUser from "./modals/CreateEditUser.svelte"
|
||||
import CreateEditRow from "./modals/CreateEditRow.svelte"
|
||||
|
||||
let hideAutocolumns
|
||||
let data = []
|
||||
let loading = false
|
||||
let hideAutocolumns
|
||||
|
||||
$: isUsersTable = $backendUiStore.selectedTable?._id === TableNames.USERS
|
||||
$: title = $backendUiStore.selectedTable.name
|
||||
$: schema = $backendUiStore.selectedTable.schema
|
||||
|
@ -52,10 +51,12 @@
|
|||
modalContentComponent={isUsersTable ? CreateEditUser : CreateEditRow} />
|
||||
<CreateViewButton />
|
||||
<ManageAccessButton resourceId={$backendUiStore.selectedTable?._id} />
|
||||
<ExportButton view={tableView} />
|
||||
{#if isUsersTable}
|
||||
<EditRolesButton />
|
||||
{/if}
|
||||
<HideAutocolumnButton bind:hideAutocolumns />
|
||||
<!-- always have the export last -->
|
||||
<ExportButton view={tableView} />
|
||||
{/if}
|
||||
{#if isUsersTable}
|
||||
<EditRolesButton />
|
||||
{/if}
|
||||
|
||||
</Table>
|
||||
|
|
|
@ -13,10 +13,11 @@
|
|||
|
||||
<div bind:this={anchor}>
|
||||
<TextButton text small on:click={hideOrUnhide}>
|
||||
<i class="ri-magic-fill"></i>
|
||||
{#if hideAutocolumns}
|
||||
<i class="ri-magic-fill"></i>
|
||||
Show Auto Columns
|
||||
{:else}
|
||||
<i class="ri-magic-line"></i>
|
||||
Hide Auto Columns
|
||||
{/if}
|
||||
</TextButton>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
import {
|
||||
getAutoColumnInformation,
|
||||
buildAutoColumn,
|
||||
} from "utilities/backend"
|
||||
} from "builderStore/utils"
|
||||
import { notifier } from "builderStore/store/notifications"
|
||||
import ValuesList from "components/common/ValuesList.svelte"
|
||||
import DatePicker from "components/common/DatePicker.svelte"
|
||||
|
|
|
@ -6,10 +6,10 @@
|
|||
import TableDataImport from "../TableDataImport.svelte"
|
||||
import analytics from "analytics"
|
||||
import screenTemplates from "builderStore/store/screenTemplates"
|
||||
import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils"
|
||||
import { NEW_ROW_TEMPLATE } from "builderStore/store/screenTemplates/newRowScreen"
|
||||
import { ROW_DETAIL_TEMPLATE } from "builderStore/store/screenTemplates/rowDetailScreen"
|
||||
import { ROW_LIST_TEMPLATE } from "builderStore/store/screenTemplates/rowListScreen"
|
||||
import { buildAutoColumn, getAutoColumnInformation } from "utilities/backend"
|
||||
|
||||
const defaultScreens = [
|
||||
NEW_ROW_TEMPLATE,
|
||||
|
|
|
@ -259,14 +259,18 @@ class LinkController {
|
|||
} catch (err) {
|
||||
continue
|
||||
}
|
||||
// create the link field in the other table
|
||||
linkedTable.schema[field.fieldName] = {
|
||||
const linkConfig = {
|
||||
name: field.fieldName,
|
||||
type: FieldTypes.LINK,
|
||||
// these are the props of the table that initiated the link
|
||||
tableId: table._id,
|
||||
fieldName: fieldName,
|
||||
}
|
||||
if (field.autocolumn) {
|
||||
linkConfig.autocolumn = field.autocolumn
|
||||
}
|
||||
// create the link field in the other table
|
||||
linkedTable.schema[field.fieldName] = linkConfig
|
||||
const response = await this._db.put(linkedTable)
|
||||
// special case for when linking back to self, make sure rev updated
|
||||
if (linkedTable._id === table._id) {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
const CouchDB = require("../index")
|
||||
const Sentry = require("@sentry/node")
|
||||
const { ViewNames, getQueryIndex } = require("../utils")
|
||||
const { FieldTypes } = require("../../constants")
|
||||
|
||||
/**
|
||||
* Only needed so that boolean parameters are being used for includeDocs
|
||||
|
|
Loading…
Reference in New Issue