From c5bd3149310735a689b24cd7b9dd13dc93a8a2c1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Tue, 23 Jun 2020 16:20:06 +0100 Subject: [PATCH] lint :sparkles: --- .../common/LinkedRecordSelector.svelte | 10 +- .../ModelDataTable/LinkedRecord.svelte | 21 +- .../ModelDataTable/ModelDataTable.svelte | 28 +- .../ModelDataTable/modals/DeleteRecord.svelte | 3 +- .../modals/RecordFieldControl.svelte | 2 +- .../nav/ModelNavigator/BlockNavigator.svelte | 4 +- .../nav/ModelNavigator/EmptyModel.svelte | 13 +- .../nav/ModelSetupNav/ModelSetupNav.svelte | 4 +- .../Colorpicker/CheckedBackground.svelte | 25 +- .../Colorpicker/Colorpicker.svelte | 201 +++++++------ .../Colorpicker/Colorpreview.svelte | 277 ++++++++++-------- .../userInterface/Colorpicker/Input.svelte | 7 +- .../userInterface/Colorpicker/Palette.svelte | 22 +- .../userInterface/Colorpicker/Slider.svelte | 42 ++- .../userInterface/Colorpicker/Swatch.svelte | 54 ++-- .../builder/src/constants/backend/index.js | 6 +- packages/server/src/api/controllers/record.js | 8 +- packages/standard-components/src/Login.svelte | 5 +- 18 files changed, 397 insertions(+), 335 deletions(-) diff --git a/packages/builder/src/components/common/LinkedRecordSelector.svelte b/packages/builder/src/components/common/LinkedRecordSelector.svelte index 8bb64ca2e8..4323ba6164 100644 --- a/packages/builder/src/components/common/LinkedRecordSelector.svelte +++ b/packages/builder/src/components/common/LinkedRecordSelector.svelte @@ -12,7 +12,13 @@ let linkedRecords = new Set(linked) $: linked = [...linkedRecords] - $: FIELDS_TO_HIDE = ["modelId", "type", "_id", "_rev", $backendUiStore.selectedModel.name] + $: FIELDS_TO_HIDE = [ + "modelId", + "type", + "_id", + "_rev", + $backendUiStore.selectedModel.name, + ] async function fetchRecords() { const FETCH_RECORDS_URL = `/api/${modelId}/records` @@ -26,7 +32,7 @@ function linkRecord(id) { if (linkedRecords.has(id)) { - linkedRecords.delete(id); + linkedRecords.delete(id) } else { linkedRecords.add(id) } diff --git a/packages/builder/src/components/database/ModelDataTable/LinkedRecord.svelte b/packages/builder/src/components/database/ModelDataTable/LinkedRecord.svelte index 1d22751033..9402c26003 100644 --- a/packages/builder/src/components/database/ModelDataTable/LinkedRecord.svelte +++ b/packages/builder/src/components/database/ModelDataTable/LinkedRecord.svelte @@ -4,18 +4,23 @@ import { backendUiStore } from "builderStore" import api from "builderStore/api" - export let ids = [] export let header let records = [] let open = false - $: FIELDS_TO_HIDE = ["modelId", "type", "_id", "_rev", $backendUiStore.selectedModel.name] + $: FIELDS_TO_HIDE = [ + "modelId", + "type", + "_id", + "_rev", + $backendUiStore.selectedModel.name, + ] async function fetchRecords() { - const response = await api.post("/api/records/search", { - keys: ids + const response = await api.post("/api/records/search", { + keys: ids, }) records = await response.json() } @@ -35,10 +40,10 @@ {records.length} {#if open}
-
-

{header}

- -
+
+

{header}

+ +
{#each records as record}
diff --git a/packages/builder/src/components/database/ModelDataTable/ModelDataTable.svelte b/packages/builder/src/components/database/ModelDataTable/ModelDataTable.svelte index 14d050be36..8424c12048 100644 --- a/packages/builder/src/components/database/ModelDataTable/ModelDataTable.svelte +++ b/packages/builder/src/components/database/ModelDataTable/ModelDataTable.svelte @@ -4,7 +4,7 @@ import { Button } from "@budibase/bbui" import Select from "components/common/Select.svelte" import ActionButton from "components/common/ActionButton.svelte" - import LinkedRecord from "./LinkedRecord.svelte"; + import LinkedRecord from "./LinkedRecord.svelte" import TablePagination from "./TablePagination.svelte" import { DeleteRecordModal, CreateEditRecordModal } from "./modals" import * as api from "./api" @@ -46,14 +46,12 @@ $: { if ($backendUiStore.selectedView) { - api - .fetchDataForView($backendUiStore.selectedView) - .then(records => { - data = records || [] - headers = Object.keys($backendUiStore.selectedModel.schema).filter( - key => !INTERNAL_HEADERS.includes(key) - ) - }) + api.fetchDataForView($backendUiStore.selectedView).then(records => { + data = records || [] + headers = Object.keys($backendUiStore.selectedModel.schema).filter( + key => !INTERNAL_HEADERS.includes(key) + ) + }) } } @@ -91,10 +89,6 @@
- @@ -135,11 +129,9 @@ {#each headers as header} {/each} diff --git a/packages/builder/src/components/database/ModelDataTable/modals/DeleteRecord.svelte b/packages/builder/src/components/database/ModelDataTable/modals/DeleteRecord.svelte index 323a7eac00..cf44389fd3 100644 --- a/packages/builder/src/components/database/ModelDataTable/modals/DeleteRecord.svelte +++ b/packages/builder/src/components/database/ModelDataTable/modals/DeleteRecord.svelte @@ -6,7 +6,6 @@ export let record export let onClosed -
@@ -26,7 +25,7 @@ alert on:click={async () => { await api.deleteRecord(record) - notifier.danger("Record deleted") + notifier.danger('Record deleted') backendUiStore.actions.records.delete(record) onClosed() }}> diff --git a/packages/builder/src/components/database/ModelDataTable/modals/RecordFieldControl.svelte b/packages/builder/src/components/database/ModelDataTable/modals/RecordFieldControl.svelte index 0d82ecddde..a77e2146fa 100644 --- a/packages/builder/src/components/database/ModelDataTable/modals/RecordFieldControl.svelte +++ b/packages/builder/src/components/database/ModelDataTable/modals/RecordFieldControl.svelte @@ -63,4 +63,4 @@ input { color: var(--dark-grey); } - \ No newline at end of file + diff --git a/packages/builder/src/components/nav/ModelNavigator/BlockNavigator.svelte b/packages/builder/src/components/nav/ModelNavigator/BlockNavigator.svelte index 3be5ebc715..61476849df 100644 --- a/packages/builder/src/components/nav/ModelNavigator/BlockNavigator.svelte +++ b/packages/builder/src/components/nav/ModelNavigator/BlockNavigator.svelte @@ -1,6 +1,6 @@ @@ -60,7 +59,11 @@

Blocks are pre-made fields and help you build your model quicker.

{#each Object.values(MODELS) as model} - createModel(model)}/> + createModel(model)} /> {/each}
diff --git a/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte b/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte index 40b12d527e..6097210d51 100644 --- a/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte +++ b/packages/builder/src/components/nav/ModelSetupNav/ModelSetupNav.svelte @@ -30,12 +30,11 @@ async function deleteModel() { const model = $backendUiStore.selectedModel - const instanceId = $backendUiStore.selectedDatabase._id const field = $backendUiStore.selectedField if (field) { delete model.schema[field] - backendUiStore.actions.models.save({ model, instanceId }) + backendUiStore.actions.models.save({ model }) notifier.danger(`Field ${field} deleted.`) return } @@ -52,7 +51,6 @@ async function saveModel() { await backendUiStore.actions.models.save({ - instanceId: $backendUiStore.selectedDatabase._id, model: $backendUiStore.draftModel, }) notifier.success( diff --git a/packages/builder/src/components/userInterface/Colorpicker/CheckedBackground.svelte b/packages/builder/src/components/userInterface/Colorpicker/CheckedBackground.svelte index 19d54523b2..e612fb5393 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/CheckedBackground.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/CheckedBackground.svelte @@ -1,17 +1,20 @@ +
+ +
+ - -
- -
\ No newline at end of file diff --git a/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte b/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte index 1bc7970124..aff8e22c91 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/Colorpicker.svelte @@ -1,9 +1,9 @@
@@ -174,6 +173,73 @@
+ +
+ +
+ +
+ +
+
+
+ +
+ +
+
+ setHue(hue.detail)} + on:dragend={dispatchValue} /> + + + setAlpha(alpha.detail, isDrag)} + on:dragend={dispatchValue} /> + + +
+
+ + {#if !disableSwatches} +
+ {#if swatches.length > 0} + {#each swatches as color, idx} + applySwatch(color)} + on:removeswatch={() => removeSwatch(idx)} /> + {/each} + {/if} + {#if swatches.length !== 12} +
+ + +
+ {/if} +
+ {/if} + +
+ + handleColorInput(event.target.value)} + on:change={dispatchInputChange} /> +
+
+
- -
- -
- -
- -
-
-
- -
- -
-
- setHue(hue.detail)} on:dragend={dispatchValue} /> - - - setAlpha(alpha.detail, isDrag)} - on:dragend={dispatchValue} - /> - - -
-
- - {#if !disableSwatches} -
- {#if swatches.length > 0} - {#each swatches as color, idx} - applySwatch(color)} on:removeswatch={() => removeSwatch(idx)} /> - {/each} - {/if} - {#if swatches.length !== 12} -
- + -
- {/if} -
- {/if} - -
- - handleColorInput(event.target.value)} on:change={dispatchInputChange} /> -
-
- -
diff --git a/packages/builder/src/components/userInterface/Colorpicker/Colorpreview.svelte b/packages/builder/src/components/userInterface/Colorpicker/Colorpreview.svelte index 4e61b65902..72da43181e 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/Colorpreview.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/Colorpreview.svelte @@ -1,151 +1,184 @@
- {#if !errorMsg} - -
- + {#if !errorMsg} + +
+ - {#if open} -
- -
-
open = false} class="overlay">
- {/if} - {:else} -
- × -
+ {#if open} +
+ +
+
(open = false)} class="overlay" /> {/if} + {:else} +
+ × +
+ {/if}
- diff --git a/packages/builder/src/components/userInterface/Colorpicker/Input.svelte b/packages/builder/src/components/userInterface/Colorpicker/Input.svelte index 5e0c3a2b3f..c148d6bf30 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/Input.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/Input.svelte @@ -5,6 +5,9 @@
+
+ +
- -
- -
diff --git a/packages/builder/src/components/userInterface/Colorpicker/Palette.svelte b/packages/builder/src/components/userInterface/Colorpicker/Palette.svelte index 4077086f87..78e9a24751 100644 --- a/packages/builder/src/components/userInterface/Colorpicker/Palette.svelte +++ b/packages/builder/src/components/userInterface/Colorpicker/Palette.svelte @@ -1,5 +1,5 @@ +
+ +
(hovered = true)} + on:mouseleave={() => (hovered = false)}> + {#if hovered} +
dispatch('removeswatch')}> + dispatch('removeswatch')}>× +
+ {/if} +
+
+
+ - -
- -
hovered = true} on:mouseleave={() => hovered = false}> - {#if hovered} -
dispatch("removeswatch")}> - dispatch("removeswatch")}>× -
- {/if} -
-
-
\ No newline at end of file diff --git a/packages/builder/src/constants/backend/index.js b/packages/builder/src/constants/backend/index.js index 620cd4ad48..89861b8ac7 100644 --- a/packages/builder/src/constants/backend/index.js +++ b/packages/builder/src/constants/backend/index.js @@ -162,7 +162,7 @@ export const MODELS = { Name: BLOCKS.NAME, Cuisine: { ...FIELDS.PLAIN_TEXT, - name: "Cuisine" + name: "Cuisine", }, }, }, @@ -173,8 +173,8 @@ export const MODELS = { Name: BLOCKS.NAME, Championships: { ...FIELDS.NUMBER, - name: "Championships" - } + name: "Championships", + }, }, }, } diff --git a/packages/server/src/api/controllers/record.js b/packages/server/src/api/controllers/record.js index 4d6b353329..273175c2b1 100644 --- a/packages/server/src/api/controllers/record.js +++ b/packages/server/src/api/controllers/record.js @@ -1,7 +1,6 @@ const CouchDB = require("../../db") const validateJs = require("validate.js") const newid = require("../../db/newid") -const { link } = require("pouchdb-adapter-memory") exports.save = async function(ctx) { const db = new CouchDB(ctx.user.instanceId) @@ -46,7 +45,6 @@ exports.save = async function(ctx) { // create links in other tables for (let key in record) { - // link if (Array.isArray(record[key])) { const linked = await db.allDocs({ include_docs: true, @@ -58,7 +56,9 @@ exports.save = async function(ctx) { const doc = row.doc return { ...doc, - [model.name]: doc[model.name] ? [...doc[model.name], record._id] : [record._id] + [model.name]: doc[model.name] + ? [...doc[model.name], record._id] + : [record._id], } }) @@ -105,7 +105,7 @@ exports.find = async function(ctx) { const db = new CouchDB(ctx.user.instanceId) const record = await db.get(ctx.params.recordId) if (record.modelId !== ctx.params.modelId) { - ctx.throw(400, "Supplied modelId doe not match the record's modelId") + ctx.throw(400, "Supplied modelId does not match the records modelId") return } ctx.body = record diff --git a/packages/standard-components/src/Login.svelte b/packages/standard-components/src/Login.svelte index 0675c65f46..d09cd0ff2b 100644 --- a/packages/standard-components/src/Login.svelte +++ b/packages/standard-components/src/Login.svelte @@ -23,7 +23,10 @@ const login = async () => { loading = true - const response = await _bb.api.post("/api/authenticate", { username, password }) + const response = await _bb.api.post("/api/authenticate", { + username, + password, + }) if (response.status === 200) { const json = await response.json() localStorage.setItem("budibase:token", json.token)
- {#if Array.isArray(row[header])} - - {:else} - {row[header] || 0} - {/if} + {#if Array.isArray(row[header])} + + {:else}{row[header] || 0}{/if}