1
0
Fork 0
mirror of synced 2024-06-30 12:00:31 +12:00

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 {
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
}
}

View file

@ -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>

View file

@ -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>

View file

@ -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"

View file

@ -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,

View file

@ -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) {

View file

@ -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