Lint and tidying up

This commit is contained in:
Dean 2024-06-26 14:29:42 +01:00
parent 9adae8a9fd
commit 21c335caab
7 changed files with 16 additions and 22 deletions

View File

@ -7,7 +7,6 @@
export let disabled = true export let disabled = true
</script> </script>
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class:container={!!tooltip}> <div class:container={!!tooltip}>
<slot /> <slot />
{#if tooltip} {#if tooltip}

View File

@ -272,7 +272,7 @@
*/ */
const onRowTriggerUpdate = async update => { const onRowTriggerUpdate = async update => {
if ( if (
update.hasOwnProperty("tableId") && Object.hasOwn(update, "tableId") &&
$selectedAutomation.testData?.row?.tableId !== update.tableId $selectedAutomation.testData?.row?.tableId !== update.tableId
) { ) {
try { try {
@ -301,7 +301,7 @@
return return
} catch (e) { } catch (e) {
console.error("Error saving automation", error) console.error("Error saving automation", e)
notifications.error("Error saving automation") notifications.error("Error saving automation")
} }
} }
@ -328,7 +328,7 @@
// Exclude default or invalid data from the test data // Exclude default or invalid data from the test data
let updatedFields = {} let updatedFields = {}
for (const key of Object.keys(block?.inputs?.fields || {})) { for (const key of Object.keys(block?.inputs?.fields || {})) {
if (update.fields.hasOwnProperty(key)) { if (Object.hasOwn(update.fields, key)) {
if (key !== "") { if (key !== "") {
updatedFields[key] = updatedAutomation.testData?.fields?.[key] updatedFields[key] = updatedAutomation.testData?.fields?.[key]
} }
@ -343,7 +343,7 @@
}, },
}) })
} catch (e) { } catch (e) {
console.error("Error saving automation", error) console.error("Error saving automation", e)
notifications.error("Error saving automation") notifications.error("Error saving automation")
} }
} }

View File

@ -20,7 +20,6 @@
$: { $: {
let fields = {} let fields = {}
// DEAN - review this
for (const [key, type] of Object.entries(block?.inputs?.fields ?? {})) { for (const [key, type] of Object.entries(block?.inputs?.fields ?? {})) {
fields = { fields = {
...fields, ...fields,

View File

@ -1,7 +1,6 @@
<script> <script>
import { tables } from "stores/builder" import { tables } from "stores/builder"
import { import {
Label,
ActionButton, ActionButton,
Popover, Popover,
Icon, Icon,
@ -74,8 +73,8 @@
schemaFields = Object.entries(table?.schema ?? {}) schemaFields = Object.entries(table?.schema ?? {})
.filter(entry => { .filter(entry => {
const [key, field] = entry const [, field] = entry
return field.type !== "formula" && !field.autocolumn // DEAN - revise autocolumn exclusion for testmodal return field.type !== "formula" && !field.autocolumn
}) })
.sort( .sort(
([, schemaA], [, schemaB]) => ([, schemaA], [, schemaB]) =>
@ -84,7 +83,7 @@
// Parse out any data not in the schema. // Parse out any data not in the schema.
for (const column in editableFields) { for (const column in editableFields) {
if (!(column in table?.schema)) { if (!Object.hasOwn(table?.schema, column)) {
delete editableFields[column] delete editableFields[column]
} }
} }
@ -99,7 +98,7 @@
editableRow[key] == null || editableRow[key]?.length === 0 editableRow[key] == null || editableRow[key]?.length === 0
// Put non-empty elements into the update and add their key to the fields list. // Put non-empty elements into the update and add their key to the fields list.
if (!emptyField && !editableFields.hasOwnProperty(key)) { if (!emptyField && !Object.hasOwn(editableFields, key)) {
editableFields = { editableFields = {
...editableFields, ...editableFields,
[key]: key, [key]: key,
@ -111,7 +110,7 @@
if (emptyField) { if (emptyField) {
if (editableFields[key]?.clearRelationships === true) { if (editableFields[key]?.clearRelationships === true) {
const emptyField = coerce( const emptyField = coerce(
!$memoStore?.row.hasOwnProperty(key) ? "" : $memoStore?.row[key], !Object.hasOwn($memoStore?.row, key) ? "" : $memoStore?.row[key],
fieldSchema.type fieldSchema.type
) )
@ -209,7 +208,6 @@
let outcome = Object.keys(result).reduce((acc, key) => { let outcome = Object.keys(result).reduce((acc, key) => {
if (result[key] !== null) { if (result[key] !== null) {
acc[key] = result[key] acc[key] = result[key]
} else {
} }
return acc return acc
}, {}) }, {})
@ -234,7 +232,7 @@
</script> </script>
{#each schemaFields || [] as [field, schema]} {#each schemaFields || [] as [field, schema]}
{#if !schema.autocolumn && editableFields.hasOwnProperty(field)} {#if !schema.autocolumn && Object.hasOwn(editableFields, field)}
<PropField label={field} fullWidth={isFullWidth(schema.type)}> <PropField label={field} fullWidth={isFullWidth(schema.type)}>
<div class="prop-control-wrap"> <div class="prop-control-wrap">
{#if isTestModal} {#if isTestModal}
@ -329,9 +327,9 @@
{#if !schema.autocolumn} {#if !schema.autocolumn}
<li <li
class="table_field spectrum-Menu-item" class="table_field spectrum-Menu-item"
class:is-selected={editableFields.hasOwnProperty(field)} class:is-selected={Object.hasOwn(editableFields, field)}
on:click={e => { on:click={() => {
if (editableFields.hasOwnProperty(field)) { if (Object.hasOwn(editableFields, field)) {
editableFields[field] = null editableFields[field] = null
} else { } else {
editableFields[field] = {} editableFields[field] = {}

View File

@ -42,7 +42,6 @@
function handleAttachmentParams(keyValueObj) { function handleAttachmentParams(keyValueObj) {
let params = {} let params = {}
// DEAN - review this
if (!keyValueObj) { if (!keyValueObj) {
return null return null
} }

View File

@ -93,7 +93,7 @@ export async function run({ inputs, appId, emitter }: AutomationStepInput) {
if (isEmpty) { if (isEmpty) {
if ( if (
inputs.meta?.fields.hasOwnProperty(key) && Object.hasOwn(inputs.meta?.fields, key) &&
fieldConfig?.clearRelationships === true fieldConfig?.clearRelationships === true
) { ) {
// Explicitly clear the field on update // Explicitly clear the field on update
@ -113,11 +113,11 @@ export async function run({ inputs, appId, emitter }: AutomationStepInput) {
(acc: Record<string, any>, key: string) => { (acc: Record<string, any>, key: string) => {
const fieldConfig = inputs.meta?.fields?.[key] const fieldConfig = inputs.meta?.fields?.[key]
// Ignore legacy config. // Ignore legacy config.
if (fieldConfig.hasOwnProperty("clearRelationships")) { if (Object.hasOwn(fieldConfig, "clearRelationships")) {
return acc return acc
} }
acc[key] = acc[key] =
inputs.row.hasOwnProperty(key) && Object.hasOwn(inputs.row, key) &&
(!inputs.row[key] || inputs.row[key]?.length === 0) (!inputs.row[key] || inputs.row[key]?.length === 0)
? null ? null
: inputs.row[key] : inputs.row[key]

View File

@ -21,7 +21,6 @@ const parseArrayString = (value: any) => {
*/ */
export const TYPE_TRANSFORM_MAP: any = { export const TYPE_TRANSFORM_MAP: any = {
[FieldType.LINK]: { [FieldType.LINK]: {
null: [],
"": [], "": [],
//@ts-ignore //@ts-ignore
[null]: [], [null]: [],