allow deletion of relationships
This commit is contained in:
parent
7fb9673217
commit
f58ad3a12c
|
@ -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}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -19,7 +19,14 @@ function enrichQueries(input) {
|
|||
|
||||
function formatResponse(resp) {
|
||||
if (typeof resp === "string") {
|
||||
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]
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue