1
0
Fork 0
mirror of synced 2024-06-14 16:35:02 +12:00

allow deletion of relationships

This commit is contained in:
Martin McKeaveney 2021-05-23 15:06:33 +01:00
parent 8ee874055e
commit f992c650d2
5 changed files with 32 additions and 13 deletions

View file

@ -33,6 +33,7 @@
let fieldDefinitions = cloneDeep(FIELDS)
const { hide } = getContext(Context.Modal)
export let onClosed = () => {}
export let field = {
type: "string",
constraints: fieldDefinitions.STRING.constraints,
@ -56,9 +57,8 @@
)
$: required = !!field?.constraints?.presence || primaryDisplay
$: uneditable =
($tables.selected?._id === TableNames.USERS &&
UNEDITABLE_USER_FIELDS.includes(field.name)) ||
(originalName && field.type === LINK_TYPE)
$tables.selected?._id === TableNames.USERS &&
UNEDITABLE_USER_FIELDS.includes(field.name)
$: invalid =
!field.name ||
(field.type === LINK_TYPE && !field.tableId) ||
@ -98,7 +98,8 @@
} else {
tables.deleteField(field)
notifications.success(`Column ${field.name} deleted.`)
hide()
confirmDeleteDialog.hide()
deletion = false
}
}
@ -193,7 +194,11 @@
onConfirm={saveColumn}
disabled={invalid}
>
<Input label="Name" bind:value={field.name} disabled={uneditable} />
<Input
label="Name"
bind:value={field.name}
disabled={uneditable || field.type === LINK_TYPE}
/>
<Select
disabled={originalName}

View file

@ -17,7 +17,9 @@
$: urlDisplay =
schema.urlDisplay &&
`${datasource.config.url}${query.fields.path}${query.fields.queryString}`
`${datasource.config.url}${query.fields.path ?? ""}${
query.fields.queryString ?? ""
}`
function updateQuery({ detail }) {
query.fields[schema.type] = detail.value

View file

@ -19,7 +19,14 @@ function enrichQueries(input) {
function formatResponse(resp) {
if (typeof resp === "string") {
resp = JSON.parse(resp)
try {
resp = JSON.parse(resp)
} catch (err) {
console.error(
"Error parsing JSON response. Returning string in array instead."
)
resp = { response: resp }
}
}
if (!Array.isArray(resp)) {
resp = [resp]

View file

@ -1,6 +1,8 @@
const sqlServer = require("mssql")
const { FIELD_TYPES } = require("./Integration")
let pool
const SCHEMA = {
docs: "https://github.com/tediousjs/node-mssql",
description:
@ -49,11 +51,14 @@ const SCHEMA = {
class SqlServerIntegration {
constructor(config) {
this.config = config
this.client = sqlServer
if (!pool) {
pool = new sqlServer.ConnectionPool(this.config)
}
}
async connect() {
return await this.client.connect(this.config)
const client = await pool.connect()
this.client = client.request()
}
async read(query) {

View file

@ -111,7 +111,7 @@ class RestIntegration {
}
}
async create({ path, queryString, headers = {}, json }) {
async create({ path = "", queryString = "", headers = {}, json }) {
this.headers = {
...this.config.defaultHeaders,
...headers,
@ -126,7 +126,7 @@ class RestIntegration {
return await this.parseResponse(response)
}
async read({ path, queryString, headers = {} }) {
async read({ path = "", queryString = "", headers = {} }) {
this.headers = {
...this.config.defaultHeaders,
...headers,
@ -139,7 +139,7 @@ class RestIntegration {
return await this.parseResponse(response)
}
async update({ path, queryString, headers = {}, json }) {
async update({ path = "", queryString = "", headers = {}, json }) {
this.headers = {
...this.config.defaultHeaders,
...headers,
@ -154,7 +154,7 @@ class RestIntegration {
return await this.parseResponse(response)
}
async delete({ path, queryString, headers = {} }) {
async delete({ path = "", queryString = "", headers = {} }) {
this.headers = {
...this.config.defaultHeaders,
...headers,