allow deletion of relationships
This commit is contained in:
parent
7fb9673217
commit
f58ad3a12c
|
@ -33,6 +33,7 @@
|
||||||
let fieldDefinitions = cloneDeep(FIELDS)
|
let fieldDefinitions = cloneDeep(FIELDS)
|
||||||
const { hide } = getContext(Context.Modal)
|
const { hide } = getContext(Context.Modal)
|
||||||
|
|
||||||
|
export let onClosed = () => {}
|
||||||
export let field = {
|
export let field = {
|
||||||
type: "string",
|
type: "string",
|
||||||
constraints: fieldDefinitions.STRING.constraints,
|
constraints: fieldDefinitions.STRING.constraints,
|
||||||
|
@ -56,9 +57,8 @@
|
||||||
)
|
)
|
||||||
$: required = !!field?.constraints?.presence || primaryDisplay
|
$: required = !!field?.constraints?.presence || primaryDisplay
|
||||||
$: uneditable =
|
$: uneditable =
|
||||||
($tables.selected?._id === TableNames.USERS &&
|
$tables.selected?._id === TableNames.USERS &&
|
||||||
UNEDITABLE_USER_FIELDS.includes(field.name)) ||
|
UNEDITABLE_USER_FIELDS.includes(field.name)
|
||||||
(originalName && field.type === LINK_TYPE)
|
|
||||||
$: invalid =
|
$: invalid =
|
||||||
!field.name ||
|
!field.name ||
|
||||||
(field.type === LINK_TYPE && !field.tableId) ||
|
(field.type === LINK_TYPE && !field.tableId) ||
|
||||||
|
@ -98,7 +98,8 @@
|
||||||
} else {
|
} else {
|
||||||
tables.deleteField(field)
|
tables.deleteField(field)
|
||||||
notifications.success(`Column ${field.name} deleted.`)
|
notifications.success(`Column ${field.name} deleted.`)
|
||||||
hide()
|
confirmDeleteDialog.hide()
|
||||||
|
deletion = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +194,11 @@
|
||||||
onConfirm={saveColumn}
|
onConfirm={saveColumn}
|
||||||
disabled={invalid}
|
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
|
<Select
|
||||||
disabled={originalName}
|
disabled={originalName}
|
||||||
|
|
|
@ -17,7 +17,9 @@
|
||||||
|
|
||||||
$: urlDisplay =
|
$: urlDisplay =
|
||||||
schema.urlDisplay &&
|
schema.urlDisplay &&
|
||||||
`${datasource.config.url}${query.fields.path}${query.fields.queryString}`
|
`${datasource.config.url}${query.fields.path ?? ""}${
|
||||||
|
query.fields.queryString ?? ""
|
||||||
|
}`
|
||||||
|
|
||||||
function updateQuery({ detail }) {
|
function updateQuery({ detail }) {
|
||||||
query.fields[schema.type] = detail.value
|
query.fields[schema.type] = detail.value
|
||||||
|
|
|
@ -19,7 +19,14 @@ function enrichQueries(input) {
|
||||||
|
|
||||||
function formatResponse(resp) {
|
function formatResponse(resp) {
|
||||||
if (typeof resp === "string") {
|
if (typeof resp === "string") {
|
||||||
|
try {
|
||||||
resp = JSON.parse(resp)
|
resp = JSON.parse(resp)
|
||||||
|
} catch (err) {
|
||||||
|
console.error(
|
||||||
|
"Error parsing JSON response. Returning string in array instead."
|
||||||
|
)
|
||||||
|
resp = { response: resp }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!Array.isArray(resp)) {
|
if (!Array.isArray(resp)) {
|
||||||
resp = [resp]
|
resp = [resp]
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
const sqlServer = require("mssql")
|
const sqlServer = require("mssql")
|
||||||
const { FIELD_TYPES } = require("./Integration")
|
const { FIELD_TYPES } = require("./Integration")
|
||||||
|
|
||||||
|
let pool
|
||||||
|
|
||||||
const SCHEMA = {
|
const SCHEMA = {
|
||||||
docs: "https://github.com/tediousjs/node-mssql",
|
docs: "https://github.com/tediousjs/node-mssql",
|
||||||
description:
|
description:
|
||||||
|
@ -49,11 +51,14 @@ const SCHEMA = {
|
||||||
class SqlServerIntegration {
|
class SqlServerIntegration {
|
||||||
constructor(config) {
|
constructor(config) {
|
||||||
this.config = config
|
this.config = config
|
||||||
this.client = sqlServer
|
if (!pool) {
|
||||||
|
pool = new sqlServer.ConnectionPool(this.config)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async connect() {
|
async connect() {
|
||||||
return await this.client.connect(this.config)
|
const client = await pool.connect()
|
||||||
|
this.client = client.request()
|
||||||
}
|
}
|
||||||
|
|
||||||
async read(query) {
|
async read(query) {
|
||||||
|
|
|
@ -111,7 +111,7 @@ class RestIntegration {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async create({ path, queryString, headers = {}, json }) {
|
async create({ path = "", queryString = "", headers = {}, json }) {
|
||||||
this.headers = {
|
this.headers = {
|
||||||
...this.config.defaultHeaders,
|
...this.config.defaultHeaders,
|
||||||
...headers,
|
...headers,
|
||||||
|
@ -126,7 +126,7 @@ class RestIntegration {
|
||||||
return await this.parseResponse(response)
|
return await this.parseResponse(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
async read({ path, queryString, headers = {} }) {
|
async read({ path = "", queryString = "", headers = {} }) {
|
||||||
this.headers = {
|
this.headers = {
|
||||||
...this.config.defaultHeaders,
|
...this.config.defaultHeaders,
|
||||||
...headers,
|
...headers,
|
||||||
|
@ -139,7 +139,7 @@ class RestIntegration {
|
||||||
return await this.parseResponse(response)
|
return await this.parseResponse(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
async update({ path, queryString, headers = {}, json }) {
|
async update({ path = "", queryString = "", headers = {}, json }) {
|
||||||
this.headers = {
|
this.headers = {
|
||||||
...this.config.defaultHeaders,
|
...this.config.defaultHeaders,
|
||||||
...headers,
|
...headers,
|
||||||
|
@ -154,7 +154,7 @@ class RestIntegration {
|
||||||
return await this.parseResponse(response)
|
return await this.parseResponse(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete({ path, queryString, headers = {} }) {
|
async delete({ path = "", queryString = "", headers = {} }) {
|
||||||
this.headers = {
|
this.headers = {
|
||||||
...this.config.defaultHeaders,
|
...this.config.defaultHeaders,
|
||||||
...headers,
|
...headers,
|
||||||
|
|
Loading…
Reference in New Issue