Updating where utilities are held in builder and then making user table relationships autocolumn aware too.

This commit is contained in:
mike12345567 2021-02-16 15:41:50 +00:00
parent 02a68beee1
commit 8b0f99b0b1
7 changed files with 20 additions and 15 deletions

View File

@ -1,10 +1,10 @@
import { TableNames } from "../../constants" import { TableNames } from "../constants"
import { import {
AUTO_COLUMN_DISPLAY_NAMES, AUTO_COLUMN_DISPLAY_NAMES,
AUTO_COLUMN_SUB_TYPES, AUTO_COLUMN_SUB_TYPES,
FIELDS, FIELDS,
isAutoColumnUserRelationship isAutoColumnUserRelationship
} from "../../constants/backend" } from "../constants/backend"
export function getAutoColumnInformation(enabled = true) { export function getAutoColumnInformation(enabled = true) {
let info = {} let info = {}

View File

@ -13,10 +13,9 @@
import CreateEditUser from "./modals/CreateEditUser.svelte" import CreateEditUser from "./modals/CreateEditUser.svelte"
import CreateEditRow from "./modals/CreateEditRow.svelte" import CreateEditRow from "./modals/CreateEditRow.svelte"
let hideAutocolumns
let data = [] let data = []
let loading = false let loading = false
let hideAutocolumns
$: isUsersTable = $backendUiStore.selectedTable?._id === TableNames.USERS $: isUsersTable = $backendUiStore.selectedTable?._id === TableNames.USERS
$: title = $backendUiStore.selectedTable.name $: title = $backendUiStore.selectedTable.name
$: schema = $backendUiStore.selectedTable.schema $: schema = $backendUiStore.selectedTable.schema
@ -52,10 +51,12 @@
modalContentComponent={isUsersTable ? CreateEditUser : CreateEditRow} /> modalContentComponent={isUsersTable ? CreateEditUser : CreateEditRow} />
<CreateViewButton /> <CreateViewButton />
<ManageAccessButton resourceId={$backendUiStore.selectedTable?._id} /> <ManageAccessButton resourceId={$backendUiStore.selectedTable?._id} />
<ExportButton view={tableView} /> {#if isUsersTable}
<EditRolesButton />
{/if}
<HideAutocolumnButton bind:hideAutocolumns /> <HideAutocolumnButton bind:hideAutocolumns />
<!-- always have the export last -->
<ExportButton view={tableView} />
{/if} {/if}
{#if isUsersTable}
<EditRolesButton />
{/if}
</Table> </Table>

View File

@ -13,10 +13,11 @@
<div bind:this={anchor}> <div bind:this={anchor}>
<TextButton text small on:click={hideOrUnhide}> <TextButton text small on:click={hideOrUnhide}>
<i class="ri-magic-fill"></i>
{#if hideAutocolumns} {#if hideAutocolumns}
<i class="ri-magic-fill"></i>
Show Auto Columns Show Auto Columns
{:else} {:else}
<i class="ri-magic-line"></i>
Hide Auto Columns Hide Auto Columns
{/if} {/if}
</TextButton> </TextButton>

View File

@ -17,7 +17,7 @@
import { import {
getAutoColumnInformation, getAutoColumnInformation,
buildAutoColumn, buildAutoColumn,
} from "utilities/backend" } from "builderStore/utils"
import { notifier } from "builderStore/store/notifications" import { notifier } from "builderStore/store/notifications"
import ValuesList from "components/common/ValuesList.svelte" import ValuesList from "components/common/ValuesList.svelte"
import DatePicker from "components/common/DatePicker.svelte" import DatePicker from "components/common/DatePicker.svelte"

View File

@ -6,10 +6,10 @@
import TableDataImport from "../TableDataImport.svelte" import TableDataImport from "../TableDataImport.svelte"
import analytics from "analytics" import analytics from "analytics"
import screenTemplates from "builderStore/store/screenTemplates" import screenTemplates from "builderStore/store/screenTemplates"
import { buildAutoColumn, getAutoColumnInformation } from "builderStore/utils"
import { NEW_ROW_TEMPLATE } from "builderStore/store/screenTemplates/newRowScreen" import { NEW_ROW_TEMPLATE } from "builderStore/store/screenTemplates/newRowScreen"
import { ROW_DETAIL_TEMPLATE } from "builderStore/store/screenTemplates/rowDetailScreen" import { ROW_DETAIL_TEMPLATE } from "builderStore/store/screenTemplates/rowDetailScreen"
import { ROW_LIST_TEMPLATE } from "builderStore/store/screenTemplates/rowListScreen" import { ROW_LIST_TEMPLATE } from "builderStore/store/screenTemplates/rowListScreen"
import { buildAutoColumn, getAutoColumnInformation } from "utilities/backend"
const defaultScreens = [ const defaultScreens = [
NEW_ROW_TEMPLATE, NEW_ROW_TEMPLATE,

View File

@ -259,14 +259,18 @@ class LinkController {
} catch (err) { } catch (err) {
continue continue
} }
// create the link field in the other table const linkConfig = {
linkedTable.schema[field.fieldName] = {
name: field.fieldName, name: field.fieldName,
type: FieldTypes.LINK, type: FieldTypes.LINK,
// these are the props of the table that initiated the link // these are the props of the table that initiated the link
tableId: table._id, tableId: table._id,
fieldName: fieldName, 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) const response = await this._db.put(linkedTable)
// special case for when linking back to self, make sure rev updated // special case for when linking back to self, make sure rev updated
if (linkedTable._id === table._id) { if (linkedTable._id === table._id) {

View File

@ -1,7 +1,6 @@
const CouchDB = require("../index") const CouchDB = require("../index")
const Sentry = require("@sentry/node") const Sentry = require("@sentry/node")
const { ViewNames, getQueryIndex } = require("../utils") const { ViewNames, getQueryIndex } = require("../utils")
const { FieldTypes } = require("../../constants")
/** /**
* Only needed so that boolean parameters are being used for includeDocs * Only needed so that boolean parameters are being used for includeDocs