From c872af2fb5f0f12a339c336208e71d23f29b840f Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 27 Aug 2020 10:34:44 +0100 Subject: [PATCH 01/22] comment for node/jest polyfill --- packages/builder/scripts/jestSetup.js | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/builder/scripts/jestSetup.js b/packages/builder/scripts/jestSetup.js index 52053d4092..ed2b7da3fd 100644 --- a/packages/builder/scripts/jestSetup.js +++ b/packages/builder/scripts/jestSetup.js @@ -1,3 +1,4 @@ +// Array.flat needs polyfilled in < Node 11 if (!Array.prototype.flat) { Object.defineProperty(Array.prototype, "flat", { configurable: true, From fd9e4577aea00277103035629a0233f5f3d37c10 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 27 Aug 2020 14:48:12 +0100 Subject: [PATCH 02/22] bump bbui --- packages/builder/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/builder/package.json b/packages/builder/package.json index 6886388981..6b278d9cdd 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -60,7 +60,7 @@ ] }, "dependencies": { - "@budibase/bbui": "^1.27.0", + "@budibase/bbui": "^1.28.0", "@budibase/client": "^0.1.19", "@budibase/colorpicker": "^1.0.1", "@sentry/browser": "5.19.1", From 838144c5b308b5e8fb57bb289390f6abd82a0207 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 27 Aug 2020 14:49:21 +0100 Subject: [PATCH 03/22] yarn lock (bbui) --- packages/builder/yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/builder/yarn.lock b/packages/builder/yarn.lock index 8da0f325b2..547507115b 100644 --- a/packages/builder/yarn.lock +++ b/packages/builder/yarn.lock @@ -688,10 +688,10 @@ lodash "^4.17.13" to-fast-properties "^2.0.0" -"@budibase/bbui@^1.27.0": - version "1.27.0" - resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.27.0.tgz#948102a29c203c503745c69c2cdea4440e257a74" - integrity sha512-7YPWD9gASfUiAmPsvYdGvBtVOdVoOKFRV+q3on8mZ9v/NlupZ2gVJy4m6NsRuoCJBhRF1Uq6bR716KFFxqZXVg== +"@budibase/bbui@^1.28.0": + version "1.28.0" + resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.28.0.tgz#200adca026bc3498eafdc17dd0f7da39af4bb732" + integrity sha512-KyzW0BLFl6CWYr4w/U3SoEJlUuMqL0i5wfZ6kdejfHhiou4yS9v4cul1tc0IPUNKioQLpnW1A6NpuVmGc1e16Q== dependencies: sirv-cli "^0.4.6" From f988d2d9c7f18d3cb49befd51e600afb70638180 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Tue, 1 Sep 2020 10:12:01 +0100 Subject: [PATCH 04/22] event panel rework backup --- packages/builder/package.json | 2 +- .../EventsEditor/EventEditorModal.svelte | 256 ++++++++++-------- .../EventsEditor/EventPropertyControl.svelte | 17 +- .../EventsEditor/actions/CreateRecord.svelte | 5 + .../EventsEditor/actions/NavigateTo.svelte | 16 ++ .../EventsEditor/actions/UpdateRecord.svelte | 5 + .../EventsEditor/actions/index.js | 18 ++ .../userInterface/PropertyControl.svelte | 5 +- packages/builder/yarn.lock | 8 +- packages/client/src/state/eventHandlers.js | 2 + 10 files changed, 201 insertions(+), 133 deletions(-) create mode 100644 packages/builder/src/components/userInterface/EventsEditor/actions/CreateRecord.svelte create mode 100644 packages/builder/src/components/userInterface/EventsEditor/actions/NavigateTo.svelte create mode 100644 packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte create mode 100644 packages/builder/src/components/userInterface/EventsEditor/actions/index.js diff --git a/packages/builder/package.json b/packages/builder/package.json index 6b278d9cdd..ace69a028a 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -60,7 +60,7 @@ ] }, "dependencies": { - "@budibase/bbui": "^1.28.0", + "@budibase/bbui": "^1.28.2", "@budibase/client": "^0.1.19", "@budibase/colorpicker": "^1.0.1", "@sentry/browser": "5.19.1", diff --git a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte index d2e6cc5693..5ef8a3075d 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte @@ -1,170 +1,194 @@ -
-
-
-

- {eventData.name ? `${eventData.name} Event` : 'Create a New Component Event'} -

-
-
-
-

Event Type

- -
-
+
-
-

Event Action(s)

- { - createNewEventHandler(draftEventHandler) - draftEventHandler = { parameters: [] } - }} - handler={draftEventHandler} /> +
+ Actions +
+ + Add Action +
+ +
+
- {#if eventData} - {#each eventData.handlers as handler, index} - deleteEventHandler(index)} - {handler} /> + +
+ {#each actionTypes as actionType} +
+ {actionType.name} +
+ {/each} +
+
+
+ +
+ {#if actions && actions.length > 0} + {#each actions as action, index} +
+
+ + {index + 1}. {action[EVENT_TYPE_MEMBER_NAME]} + +
+ {#if action === selectedAction} +
+ +
+ Delete +
+
+ {/if} +
{/each} {/if} +
-
-
- + Learn more about Actions + +
diff --git a/packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte b/packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte index c1395ad31b..4bacbe9808 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/EventPropertyControl.svelte @@ -1,25 +1,22 @@ -
- -
- + + + - + on:close={eventsModal.hide} /> + diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/NavigateTo.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/NavigateTo.svelte index 4d07c0a719..f3ab468ccc 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/actions/NavigateTo.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/NavigateTo.svelte @@ -5,12 +5,25 @@ export let parameters -
+
- + {/each}
+ + diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte index afd901ed31..22125ee7c3 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte @@ -1,5 +1,101 @@ -
Update Record
+
+ + + + {#if parameters.model && fields} + {#each fields as field} + + + + +
+ + + +
+ {/each} + {/if} + +
+ + From 349f350ee4794f9325e068fc727d58bd4cd1a876 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 9 Sep 2020 15:56:31 +0100 Subject: [PATCH 07/22] backup before a merge --- .../builderStore/fetchBindableProperties.js | 15 +- .../EventsEditor/EventEditorModal.svelte | 8 +- .../EventsEditor/actions/UpdateRecord.svelte | 122 ++++++-- .../userInterface/PropertyControl.svelte | 2 +- packages/builder/yarn.lock | 271 +++++++++++++++++- 5 files changed, 379 insertions(+), 39 deletions(-) diff --git a/packages/builder/src/builderStore/fetchBindableProperties.js b/packages/builder/src/builderStore/fetchBindableProperties.js index f36484fbdf..b2e67ad520 100644 --- a/packages/builder/src/builderStore/fetchBindableProperties.js +++ b/packages/builder/src/builderStore/fetchBindableProperties.js @@ -72,14 +72,21 @@ const componentInstanceToBindable = walkResult => i => { const contextToBindables = walkResult => context => { const contextParentPath = getParentPath(walkResult, context) - return Object.keys(context.model.schema).map(k => ({ + const newBindable = key => ({ type: "context", instance: context.instance, // how the binding expression persists, and is used in the app at runtime - runtimeBinding: `${contextParentPath}data.${k}`, + runtimeBinding: `${contextParentPath}data.${key}`, // how the binding exressions looks to the user of the builder - readableBinding: `${context.instance._instanceName}.${context.model.name}.${k}`, - })) + readableBinding: `${context.instance._instanceName}.${context.model.name}.${key}`, + }) + + return ( + Object.keys(context.model.schema) + .map(newBindable) + // add _id and _rev fields - not part of schema, but always valid + .concat([newBindable("_id"), newBindable("_rev")]) + ) } const getParentPath = (walkResult, context) => { diff --git a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte index 5a9af8de9d..6e804ae3fd 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte @@ -10,7 +10,7 @@ import { AddIcon, ArrowDownIcon } from "components/common/Icons/" import { EVENT_TYPE_MEMBER_NAME } from "../../common/eventHandlers" import actionTypes from "./actions" - import { createEventDispatcher } from "svelte" + import { createEventDispatcher, onMount } from "svelte" const dispatch = createEventDispatcher() @@ -38,7 +38,7 @@ actions[index] = updatedHandler } - const deleteEventHandler = index => { + const deleteAction = index => { actions.splice(index, 1) actions = actions } @@ -107,7 +107,9 @@ this={selectedActionComponent} parameters={selectedAction.parameters} />
- Delete + deleteAction(index)}> + Delete +
{/if} diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte index 22125ee7c3..ff1e824f6f 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte @@ -8,10 +8,14 @@ const emptyField = () => ({ name: "", value: "" }) - $: fields = Object.keys(parameters.fields || emptyField()).map(name => ({ - name, - value: (parameters.fields && parameters.fields[name]) || "", - })) + // this statement initialises fields from parameters.fields + $: fields = + fields || + (parameters && + Object.keys(parameters.fields || { "": "" }).map(name => ({ + name, + value: (parameters.fields && parameters.fields[name]) || "", + }))) $: bindableProperties = fetchBindableProperties({ componentInstanceId: $store.currentComponentInfo._id, @@ -20,6 +24,18 @@ models: $backendUiStore.models, }) + let idFields + $: { + idFields = bindableProperties.filter( + bindable => + bindable.type === "context" && bindable.runtimeBinding.endsWith("._id") + ) + // ensure recordId is always defaulted - there is usually only one option + if (idFields.length > 0 && !parameters.recordId) { + parameters.recordId = idFields[0].runtimeBinding + } + } + const addField = () => { const newFields = fields.filter(f => f.name) newFields.push(emptyField()) @@ -28,46 +44,92 @@ const bindablePropertyName = prop => { if (prop.type === "instance") return prop.instance._instanceName - return instance.readableBinding.split(".")[ - instance.readableBinding.lastIndexOf(".") + return prop.readableBinding.split(".")[ + prop.readableBinding.lastIndexOf(".") ] } - let fieldNames - $: { - fieldNames = - parameters.model && - Object.keys( - $backendUiStore.models.find(model => model._id === parameters.model) - .schema - ) + const fieldNameChanged = e => {} + + const rebuildParameters = () => { + // rebuilds paramters.fields every time a field name or value is added + parameters.fields = {} + for (let field of fields) { + if (field.name) { + parameters.fields[field.name] = field.value + } + } } + + // just wraps binding in {{ ... }} + const toBindingExpression = bindingPath => `{{ ${bindingPath} }}` + + // finds the selected idBinding, then reads the table/view + // from the component instance that it belongs to. + // then returns the field names for that schema + const fieldNamesFromIdBinding = recordId => { + if (!recordId) return [] + + const idBinding = bindableProperties.find( + prop => prop.runtimeBinding === recordId + ) + if (!idBinding) return [] + + const { instance } = idBinding + + const component = $store.components[instance._component] + + // component.context is the name of the prop that holds the modelId + const modelId = instance[component.context] + + if (!modelId) return [] + + const model = $backendUiStore.models.find( + m => m._id === instance[component.context] + ) + + return Object.keys(model.schema) + } + + $: fieldNames = parameters ? fieldNamesFromIdBinding(parameters.recordId) : []
- - + {#if idFields.length === 0} +
+ Update record can only be used within a component that provides data, such + as a List +
+ {:else} + + + {/if} - {#if parameters.model && fields} + {#if parameters.recordId && fields} {#each fields as field} - {/each} - {/each} @@ -98,4 +160,12 @@ .remove-field-container :global(button) { vertical-align: bottom; } + + .cannot-use { + color: var(--red); + font-size: var(--font-size-s); + text-align: center; + width: 70%; + margin: auto; + } diff --git a/packages/builder/src/components/userInterface/PropertyControl.svelte b/packages/builder/src/components/userInterface/PropertyControl.svelte index 886ebd76aa..16ed68ae74 100644 --- a/packages/builder/src/components/userInterface/PropertyControl.svelte +++ b/packages/builder/src/components/userInterface/PropertyControl.svelte @@ -66,7 +66,7 @@ innerVal = props.valueKey ? v.target[props.valueKey] : v.target.value } } - replaceBindings(innerVal) + if (typeof innerVal === "string") replaceBindings(innerVal) } const safeValue = () => { diff --git a/packages/builder/yarn.lock b/packages/builder/yarn.lock index b220539ee6..9073468d9b 100644 --- a/packages/builder/yarn.lock +++ b/packages/builder/yarn.lock @@ -695,6 +695,21 @@ dependencies: sirv-cli "^0.4.6" +"@budibase/client@^0.1.19": + version "0.1.19" + resolved "https://registry.yarnpkg.com/@budibase/client/-/client-0.1.19.tgz#3906781423ab4626118c981657ecf7a4578c547c" + integrity sha512-crxnLgebsh6CR0aMleDahY/1vFPbveG6JuSS/EVZeoBmckzK8hwiUQYQhIlf68nZfzWsCE/M9TX7SJxsrKY3bQ== + dependencies: + "@nx-js/compiler-util" "^2.0.0" + bcryptjs "^2.4.3" + deep-equal "^2.0.1" + lodash "^4.17.15" + lunr "^2.3.5" + mustache "^4.0.1" + regexparam "^1.3.0" + shortid "^2.2.8" + svelte "^3.9.2" + "@budibase/colorpicker@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@budibase/colorpicker/-/colorpicker-1.0.1.tgz#940c180e7ebba0cb0756c4c8ef13f5dfab58e810" @@ -944,6 +959,11 @@ "@nodelib/fs.scandir" "2.1.3" fastq "^1.6.0" +"@nx-js/compiler-util@^2.0.0": + version "2.0.0" + resolved "https://registry.yarnpkg.com/@nx-js/compiler-util/-/compiler-util-2.0.0.tgz#c74c12165fa2f017a292bb79af007e8fce0af297" + integrity sha512-AxSQbwj9zqt8DYPZ6LwZdytqnwfiOEdcFdq4l8sdjkZmU2clTht7RDLCI8xvkp7KqgcNaOGlTeCM55TULWruyQ== + "@polka/url@^0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@polka/url/-/url-0.5.0.tgz#b21510597fd601e5d7c95008b76bf0d254ebfd31" @@ -1362,6 +1382,11 @@ array-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" +array-filter@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-1.0.0.tgz#baf79e62e6ef4c2a4c0b831232daffec251f9d83" + integrity sha1-uveeYubvTCpMC4MSMtr/7CUfnYM= + array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -1416,6 +1441,13 @@ atob@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" +available-typed-arrays@^1.0.0, available-typed-arrays@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz#6b098ca9d8039079ee3f77f7b783c4480ba513f5" + integrity sha512-XWX3OX8Onv97LMk/ftVyBibpGwY5a8SmuxZPzeOxqmuEqUCOM9ZE+uIaD1VNJ5QnvU2UQusvmKbuM1FR8QWGfQ== + dependencies: + array-filter "^1.0.0" + aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" @@ -1490,6 +1522,11 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" +bcryptjs@^2.4.3: + version "2.4.3" + resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb" + integrity sha1-mrVie5PmBiH/fNrF2pczAn3x0Ms= + binary-extensions@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" @@ -2361,6 +2398,26 @@ decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" +deep-equal@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.3.tgz#cad1c15277ad78a5c01c49c2dee0f54de8a6a7b0" + integrity sha512-Spqdl4H+ky45I9ByyJtXteOm9CaIrPmnIPmOhrkKGNYWeDgCvJ8jNYVCTjChxW4FqGuZnLHADc8EKRMX6+CgvA== + dependencies: + es-abstract "^1.17.5" + es-get-iterator "^1.1.0" + is-arguments "^1.0.4" + is-date-object "^1.0.2" + is-regex "^1.0.5" + isarray "^2.0.5" + object-is "^1.1.2" + object-keys "^1.1.1" + object.assign "^4.1.0" + regexp.prototype.flags "^1.3.0" + side-channel "^1.0.2" + which-boxed-primitive "^1.0.1" + which-collection "^1.0.1" + which-typed-array "^1.1.2" + deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -2526,6 +2583,54 @@ es-abstract@^1.17.0-next.1, es-abstract@^1.17.2, es-abstract@^1.17.5: string.prototype.trimleft "^2.1.1" string.prototype.trimright "^2.1.1" +es-abstract@^1.17.4: + version "1.17.6" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" + integrity sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.2.0" + is-regex "^1.1.0" + object-inspect "^1.7.0" + object-keys "^1.1.1" + object.assign "^4.1.0" + string.prototype.trimend "^1.0.1" + string.prototype.trimstart "^1.0.1" + +es-abstract@^1.18.0-next.0: + version "1.18.0-next.0" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0-next.0.tgz#b302834927e624d8e5837ed48224291f2c66e6fc" + integrity sha512-elZXTZXKn51hUBdJjSZGYRujuzilgXo8vSPQzjGYXLvSlGiCo8VO8ZGV3kjo9a0WNJJ57hENagwbtlRuHuzkcQ== + dependencies: + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.1" + is-callable "^1.2.0" + is-negative-zero "^2.0.0" + is-regex "^1.1.1" + object-inspect "^1.8.0" + object-keys "^1.1.1" + object.assign "^4.1.0" + string.prototype.trimend "^1.0.1" + string.prototype.trimstart "^1.0.1" + +es-get-iterator@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.0.tgz#bb98ad9d6d63b31aacdc8f89d5d0ee57bcb5b4c8" + integrity sha512-UfrmHuWQlNMTs35e1ypnvikg6jCz3SK8v8ImvmDsh36fCVUR1MqoFDiyn0/k52C8NqO3YsO8Oe0azeesNuqSsQ== + dependencies: + es-abstract "^1.17.4" + has-symbols "^1.0.1" + is-arguments "^1.0.4" + is-map "^2.0.1" + is-set "^2.0.1" + is-string "^1.0.5" + isarray "^2.0.5" + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -2825,9 +2930,10 @@ for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" -foreach@~2.0.1: +foreach@^2.0.5, foreach@~2.0.1: version "2.0.5" resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" + integrity sha1-C+4AUBiusmDQo6865ljdATbsG5k= forever-agent@~0.6.1: version "0.6.1" @@ -3189,16 +3295,31 @@ is-accessor-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" +is-arguments@^1.0.4: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.0.4.tgz#3faf966c7cba0ff437fb31f6250082fcf0448cf3" + integrity sha512-xPh0Rmt8NE65sNzvyUmWgI1tz3mKq74lGA0mL8LYZcoIzKOzDh6HmrYm3d18k60nHerC8A9Km8kYu87zfSFnLA== + is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" +is-bigint@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.0.tgz#73da8c33208d00f130e9b5e15d23eac9215601c4" + integrity sha512-t5mGUXC/xRheCK431ylNiSkGGpBp8bHENBcENTkDT6ppwPzEVxNGZRvgvmOEfbWkFhA7D2GEuE2mmQTr78sl2g== + is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" dependencies: binary-extensions "^2.0.0" +is-boolean-object@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.0.1.tgz#10edc0900dd127697a92f6f9807c7617d68ac48e" + integrity sha512-TqZuVwa/sppcrhUCAYkGBk7w0yxfQQnxq28fjkO53tnK9FQXmdwz2JS5+GjsWQ6RByES1K40nI+yDic5c9/aAQ== + is-buffer@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" @@ -3207,6 +3328,11 @@ is-callable@^1.1.4, is-callable@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" +is-callable@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb" + integrity sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw== + is-ci@2.0.0, is-ci@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" @@ -3225,7 +3351,7 @@ is-data-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" -is-date-object@^1.0.1: +is-date-object@^1.0.1, is-date-object@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" @@ -3286,10 +3412,25 @@ is-installed-globally@0.1.0: global-dirs "^0.1.0" is-path-inside "^1.0.0" +is-map@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1" + integrity sha512-T/S49scO8plUiAOA2DBTBG3JHpn1yiw0kRp6dgiZ0v2/6twi5eiB0rHtHFH9ZIrvlWc6+4O+m4zg5+Z833aXgw== + is-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" +is-negative-zero@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.0.tgz#9553b121b0fac28869da9ed459e20c7543788461" + integrity sha1-lVOxIbD6wohp2p7UWeIMdUN4hGE= + +is-number-object@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197" + integrity sha512-zohwelOAur+5uXtk8O3GPQ1eAcu4ZX3UwxQhUlfFFMNpUd83gXgjbhJh6HmB6LUNV/ieOLQuDwJO3dWJosUeMw== + is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -3348,6 +3489,18 @@ is-regex@^1.0.5: dependencies: has "^1.0.3" +is-regex@^1.1.0, is-regex@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.1.tgz#c6f98aacc546f6cec5468a07b7b153ab564a57b9" + integrity sha512-1+QkEcxiLlB7VEyFtyBg94e08OAsvq7FUBgApTq/w2ymCLyKJgDPsybBENVtA7XCQEgEXxKPonG+mvYRxh/LIg== + dependencies: + has-symbols "^1.0.1" + +is-set@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.1.tgz#d1604afdab1724986d30091575f54945da7e5f43" + integrity sha512-eJEzOtVyenDs1TMzSQ3kU3K+E0GUS9sno+F0OBT97xsgcJsF9nXMBtkT9/kut5JEpM7oL7X/0qxR17K3mcwIAA== + is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -3356,16 +3509,41 @@ is-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3" +is-string@^1.0.4, is-string@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" + integrity sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ== + is-symbol@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" dependencies: has-symbols "^1.0.1" +is-typed-array@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.3.tgz#a4ff5a5e672e1a55f99c7f54e59597af5c1df04d" + integrity sha512-BSYUBOK/HJibQ30wWkWold5txYwMUXQct9YHAQJr8fSwvZoiglcqB0pd7vEN23+Tsi9IUEjztdOSzl4qLVYGTQ== + dependencies: + available-typed-arrays "^1.0.0" + es-abstract "^1.17.4" + foreach "^2.0.5" + has-symbols "^1.0.1" + is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" +is-weakmap@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.1.tgz#5008b59bdc43b698201d18f62b37b2ca243e8cf2" + integrity sha512-NSBR4kH5oVj1Uwvv970ruUkCV7O1mzgVFO4/rev2cLRda9Tm9HrL70ZPut4rOHgY0FNrUu9BCbXA2sdQ+x0chA== + +is-weakset@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/is-weakset/-/is-weakset-2.0.1.tgz#e9a0af88dbd751589f5e50d80f4c98b780884f83" + integrity sha512-pi4vhbhVHGLxohUw7PhGsueT4vRGFoXhP7+RGN0jKIv9+8PWYCQTqtADngrxOm2g46hoH0+g8uZZBzMrvVGDmw== + is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" @@ -3386,6 +3564,11 @@ isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" +isarray@^2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" + integrity sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw== + isbuffer@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/isbuffer/-/isbuffer-0.0.0.tgz#38c146d9df528b8bf9b0701c3d43cf12df3fc39b" @@ -4189,6 +4372,11 @@ ltgt@^2.1.2: version "2.2.1" resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" +lunr@^2.3.5: + version "2.3.9" + resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1" + integrity sha512-zTU3DaZaF3Rt9rhN3uBMGQD3dD2/vFQqnvZCDv4dl5iOzq2IZQqTxu90r4E5J+nP70J3ilqVCrbho2eWaeW8Ow== + magic-string@^0.22.5: version "0.22.5" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.22.5.tgz#8e9cf5afddf44385c1da5bc2a6a0dbd10b03657e" @@ -4486,6 +4674,19 @@ object-inspect@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" +object-inspect@^1.8.0: + version "1.8.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" + integrity sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA== + +object-is@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.2.tgz#c5d2e87ff9e119f78b7a088441519e2eec1573b6" + integrity sha512-5lHCz+0uufF6wZ7CRFWJN3hp8Jqblpgve06U5CMQ3f//6iDjPr2PEo9MWCjEssDsa+UZEL4PkFpr+BMop6aKzQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.5" + object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -5000,6 +5201,19 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" +regexp.prototype.flags@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz#7aba89b3c13a64509dabcf3ca8d9fbb9bdf5cb75" + integrity sha512-2+Q0C5g951OlYlJz6yu5/M33IcsESLlLfsyIaLJaG4FA2r4yP8MvVMJUUP/fVBkSpbbbZlS5gynbEWLipiiXiQ== + dependencies: + define-properties "^1.1.3" + es-abstract "^1.17.0-next.1" + +regexparam@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-1.3.0.tgz#2fe42c93e32a40eff6235d635e0ffa344b92965f" + integrity sha512-6IQpFBv6e5vz1QAqI+V4k8P2e/3gRrqfCJ9FI+O1FLQTO+Uz6RXZEZOPmTJ6hlGj7gkERzY5BRCv09whKP96/g== + regexpu-core@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.0.tgz#fcbf458c50431b0bb7b45d6967b8192d91f3d938" @@ -5390,12 +5604,21 @@ shellwords@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" -shortid@^2.2.15: +shortid@^2.2.15, shortid@^2.2.8: version "2.2.15" resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.15.tgz#2b902eaa93a69b11120373cd42a1f1fe4437c122" + integrity sha512-5EaCy2mx2Jgc/Fdn9uuDuNIIfWBpzY4XIlhoqtXF6qsf+/+SGZ+FxDdX/ZsMZiWupIWNqAEmiNY4RC+LSmCeOw== dependencies: nanoid "^2.1.0" +side-channel@^1.0.2: + version "1.0.3" + resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.3.tgz#cdc46b057550bbab63706210838df5d4c19519c3" + integrity sha512-A6+ByhlLkksFoUepsGxfj5x1gTSrs+OydsRptUxeNCabQpCFUvcwIczgOigI8vhY/OJCnPnyE9rGiwgvr9cS1g== + dependencies: + es-abstract "^1.18.0-next.0" + object-inspect "^1.8.0" + signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -5614,7 +5837,7 @@ string-width@^3.0.0, string-width@^3.1.0: is-fullwidth-code-point "^2.0.0" strip-ansi "^5.1.0" -string.prototype.trimend@^1.0.0: +string.prototype.trimend@^1.0.0, string.prototype.trimend@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" dependencies: @@ -5637,7 +5860,7 @@ string.prototype.trimright@^2.1.1: es-abstract "^1.17.5" string.prototype.trimend "^1.0.0" -string.prototype.trimstart@^1.0.0: +string.prototype.trimstart@^1.0.0, string.prototype.trimstart@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" dependencies: @@ -5736,6 +5959,11 @@ svelte@3.23.x: version "3.23.0" resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.23.0.tgz#bbcd6887cf588c24a975b14467455abfff9acd3f" +svelte@^3.9.2: + version "3.24.1" + resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.24.1.tgz#aca364937dd1df27fe131e2a4c234acb6061db4b" + integrity sha512-OX/IBVUJSFo1rnznXdwf9rv6LReJ3qQ0PwRjj76vfUWyTfbHbR9OXqJBnUrpjyis2dwYcbT2Zm1DFjOOF1ZbbQ== + symbol-observable@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" @@ -6071,10 +6299,43 @@ whatwg-url@^8.0.0: tr46 "^2.0.2" webidl-conversions "^5.0.0" +which-boxed-primitive@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.1.tgz#cbe8f838ebe91ba2471bb69e9edbda67ab5a5ec1" + integrity sha512-7BT4TwISdDGBgaemWU0N0OU7FeAEJ9Oo2P1PHRm/FCWoEi2VLWC9b6xvxAA3C/NMpxg3HXVgi0sMmGbNUbNepQ== + dependencies: + is-bigint "^1.0.0" + is-boolean-object "^1.0.0" + is-number-object "^1.0.3" + is-string "^1.0.4" + is-symbol "^1.0.2" + +which-collection@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/which-collection/-/which-collection-1.0.1.tgz#70eab71ebbbd2aefaf32f917082fc62cdcb70906" + integrity sha512-W8xeTUwaln8i3K/cY1nGXzdnVZlidBcagyNFtBdD5kxnb4TvGKR7FfSIS3mYpwWS1QUCutfKz8IY8RjftB0+1A== + dependencies: + is-map "^2.0.1" + is-set "^2.0.1" + is-weakmap "^2.0.1" + is-weakset "^2.0.1" + which-module@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" +which-typed-array@^1.1.2: + version "1.1.2" + resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.2.tgz#e5f98e56bda93e3dac196b01d47c1156679c00b2" + integrity sha512-KT6okrd1tE6JdZAy3o2VhMoYPh3+J6EMZLyrxBQsZflI1QCZIxMrIYLkosd8Twf+YfknVIHmYQPgJt238p8dnQ== + dependencies: + available-typed-arrays "^1.0.2" + es-abstract "^1.17.5" + foreach "^2.0.5" + function-bind "^1.1.1" + has-symbols "^1.0.1" + is-typed-array "^1.1.3" + which@^1.2.9, which@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" From 93043c2ab391eb54a62602c81ca07b0040c02c2b Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Wed, 9 Sep 2020 21:16:26 +0100 Subject: [PATCH 08/22] events: Update record workings --- .../src/builderStore/replaceBindings.js | 41 +++ .../EventsEditor/EventEditorModal.svelte | 33 ++- .../EventsEditor/EventPropertyControl.svelte | 2 + .../EventsEditor/actions/UpdateRecord.svelte | 38 ++- .../userInterface/PropertyControl.svelte | 42 +--- packages/builder/yarn.lock | 236 +----------------- 6 files changed, 113 insertions(+), 279 deletions(-) create mode 100644 packages/builder/src/builderStore/replaceBindings.js diff --git a/packages/builder/src/builderStore/replaceBindings.js b/packages/builder/src/builderStore/replaceBindings.js new file mode 100644 index 0000000000..38cb67951d --- /dev/null +++ b/packages/builder/src/builderStore/replaceBindings.js @@ -0,0 +1,41 @@ +export const CAPTURE_VAR_INSIDE_MUSTACHE = /{{([^}]+)}}/g + +export function readableToRuntimeBinding(bindableProperties, textWithBindings) { + // Find all instances of mustasche + const boundValues = textWithBindings.match(CAPTURE_VAR_INSIDE_MUSTACHE) + + // Replace with names: + boundValues && + boundValues.forEach(boundValue => { + const binding = bindableProperties.find(({ readableBinding }) => { + return boundValue === `{{ ${readableBinding} }}` + }) + if (binding) { + textWithBindings = textWithBindings.replace( + boundValue, + `{{ ${binding.runtimeBinding} }}` + ) + } + }) + return textWithBindings +} + +export function runtimeToReadableBinding(bindableProperties, textWithBindings) { + let temp = textWithBindings + const boundValues = + (typeof textWithBindings === "string" && + textWithBindings.match(CAPTURE_VAR_INSIDE_MUSTACHE)) || + [] + + // Replace with names: + boundValues.forEach(v => { + const binding = bindableProperties.find(({ runtimeBinding }) => { + return v === `{{ ${runtimeBinding} }}` + }) + if (binding) { + temp = temp.replace(v, `{{ ${binding.readableBinding} }}`) + } + }) + + return temp +} diff --git a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte index 6e804ae3fd..c1611d0c22 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/EventEditorModal.svelte @@ -1,12 +1,6 @@ -
Create Record
+
+ + + + {#if parameters.modelId} + + {/if} + +
+ + diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/SaveFields.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/SaveFields.svelte new file mode 100644 index 0000000000..d8870e6f18 --- /dev/null +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/SaveFields.svelte @@ -0,0 +1,115 @@ + + +{#if fields} + {#each fields as field} + + + + +
+ + + +
+ {/each} + +
+ + + + Add Field +
+ +
+
+
+{/if} + + diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte index 41f785074c..9e0236c547 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte @@ -1,32 +1,11 @@
@@ -128,45 +83,11 @@ {/if} - {#if parameters.recordId && fields} - {#each fields as field} - - - - -
- - - -
- {/each} - -
- - - - Add Field -
- -
-
-
+ {#if parameters.recordId} + {/if}
@@ -185,10 +106,6 @@ grid-column-end: 6; } - .remove-field-container :global(button) { - vertical-align: bottom; - } - .cannot-use { color: var(--red); font-size: var(--font-size-s); From d63e03b8521823404ce1cb768e41086f7bca99ea Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 10 Sep 2020 09:36:14 +0100 Subject: [PATCH 10/22] added PATCH record route --- packages/server/src/api/controllers/record.js | 34 ++++++++++++ packages/server/src/api/routes/record.js | 5 ++ .../src/api/routes/tests/couchTestUtils.js | 18 +++---- .../src/api/routes/tests/record.spec.js | 53 ++++++++++++++++--- 4 files changed, 91 insertions(+), 19 deletions(-) diff --git a/packages/server/src/api/controllers/record.js b/packages/server/src/api/controllers/record.js index 4685079f68..296f40e326 100644 --- a/packages/server/src/api/controllers/record.js +++ b/packages/server/src/api/controllers/record.js @@ -2,6 +2,40 @@ const CouchDB = require("../../db") const validateJs = require("validate.js") const newid = require("../../db/newid") +exports.patch = async function(ctx) { + const db = new CouchDB(ctx.user.instanceId) + const record = await db.get(ctx.params._id) + const model = await db.get(record.modelId) + const patchfields = ctx.request.body + + for (let key in patchfields) { + if (!model.schema[key]) continue + record[key] = patchfields[key] + } + + const validateResult = await validate({ + record, + model, + }) + + if (!validateResult.valid) { + ctx.status = 400 + ctx.body = { + status: 400, + errors: validateResult.errors, + } + return + } + + const response = await db.put(record) + record._rev = response.rev + record.type = "record" + ctx.body = record + ctx.status = 200 + ctx.message = `${model.name} updated successfully.` + return +} + exports.save = async function(ctx) { const db = new CouchDB(ctx.user.instanceId) const record = ctx.request.body diff --git a/packages/server/src/api/routes/record.js b/packages/server/src/api/routes/record.js index deba513aa9..15fbe29503 100644 --- a/packages/server/src/api/routes/record.js +++ b/packages/server/src/api/routes/record.js @@ -22,6 +22,11 @@ router authorized(WRITE_MODEL, ctx => ctx.params.modelId), recordController.save ) + .patch( + "/api/:modelId/records/:id", + authorized(WRITE_MODEL, ctx => ctx.params.modelId), + recordController.save + ) .post( "/api/:modelId/records/validate", authorized(WRITE_MODEL, ctx => ctx.params.modelId), diff --git a/packages/server/src/api/routes/tests/couchTestUtils.js b/packages/server/src/api/routes/tests/couchTestUtils.js index 594c4a3121..513e1d3f03 100644 --- a/packages/server/src/api/routes/tests/couchTestUtils.js +++ b/packages/server/src/api/routes/tests/couchTestUtils.js @@ -50,6 +50,12 @@ exports.createModel = async (request, appId, instanceId, model) => { constraints: { type: "string", }, + description: { + type: "text", + constraints: { + type: "string", + }, + }, }, }, } @@ -61,18 +67,6 @@ exports.createModel = async (request, appId, instanceId, model) => { return res.body } -exports.createView = async (request, appId, instanceId, view) => { - view = view || { - map: "function(doc) { emit(doc[doc.key], doc._id); } ", - } - - const res = await request - .post(`/api/views`) - .set(exports.defaultHeaders(appId, instanceId)) - .send(view) - return res.body -} - exports.createClientDatabase = async id => await create(id || TEST_CLIENT_ID) exports.createApplication = async (request, name = "test_application") => { diff --git a/packages/server/src/api/routes/tests/record.spec.js b/packages/server/src/api/routes/tests/record.spec.js index 62cf205b1c..68e9f8758f 100644 --- a/packages/server/src/api/routes/tests/record.spec.js +++ b/packages/server/src/api/routes/tests/record.spec.js @@ -30,20 +30,30 @@ describe("/records", () => { model = await createModel(request, app._id, instance._id) record = { name: "Test Contact", + description: "original description", status: "new", modelId: model._id } }) + const createRecord = async r => + await request + .post(`/api/${model._id}/records`) + .send(r || record) + .set(defaultHeaders(app._id, instance._id)) + .expect('Content-Type', /json/) + .expect(200) + + const loadRecord = async id => + await request + .get(`/api/${model._id}/records/${id}`) + .set(defaultHeaders(app._id, instance._id)) + .expect('Content-Type', /json/) + .expect(200) + + describe("save, load, update, delete", () => { - const createRecord = async r => - await request - .post(`/api/${model._id}/records`) - .send(r || record) - .set(defaultHeaders(app._id, instance._id)) - .expect('Content-Type', /json/) - .expect(200) it("returns a success message when the record is created", async () => { const res = await createRecord() @@ -144,6 +154,35 @@ describe("/records", () => { }) }) + describe("patch", () => { + it("should update only the fields that are supplied", async () => { + const rec = await createRecord() + const existing = rec.body + + const res = await request + .patch(`/api/${model._id}/records/${rec._id}`) + .send({ + _id: existing._id, + _rev: existing._rev, + modelId: model._id, + name: "Updated Name", + }) + .set(defaultHeaders(app._id, instance._id)) + .expect('Content-Type', /json/) + .expect(200) + + expect(res.res.statusMessage).toEqual(`${model.name} updated successfully.`) + expect(res.body.name).toEqual("Updated Name") + expect(res.body.description).toEqual(rec.description) + + const savedRecord = await loadRecord(res.body._id) + + expect(savedRecord.body.description).toEqual(rec.description) + expect(savedRecord.body.name).toEqual("Updated Name") + + }) + }) + describe("validate", () => { it("should return no errors on valid record", async () => { const result = await request From 44426b6bf821582e0b801436beb81b2dc45c79c1 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 10 Sep 2020 13:04:45 +0100 Subject: [PATCH 11/22] data form component date picker aware, form component refactor --- package.json | 2 +- packages/standard-components/package.json | 1 + .../standard-components/src/DataForm.svelte | 155 +++++++----------- .../src/DataFormWide.svelte | 155 +++++++----------- 4 files changed, 116 insertions(+), 197 deletions(-) diff --git a/package.json b/package.json index 69f7b0f21d..79935c5dce 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "publishdev": "lerna run publishdev", "publishnpm": "yarn build && lerna publish --force-publish", "clean": "lerna clean", - "dev": "node ./scripts/symlinkDev.js && lerna run --parallel --stream dev:builder", + "dev": "node ./scripts/symlinkDev.js && lerna run --parallel dev:builder", "test": "lerna run test", "lint": "eslint packages", "lint:fix": "eslint --fix packages", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index 1325a3ad32..7cf1a9a47c 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -41,6 +41,7 @@ "d3-selection": "^1.4.2", "fast-sort": "^2.2.0", "fusioncharts": "^3.15.1-sr.1", + "lodash.debounce": "^4.0.8", "svelte-flatpickr": "^2.4.0", "svelte-fusioncharts": "^1.0.0" } diff --git a/packages/standard-components/src/DataForm.svelte b/packages/standard-components/src/DataForm.svelte index 21d4623822..4709097fad 100644 --- a/packages/standard-components/src/DataForm.svelte +++ b/packages/standard-components/src/DataForm.svelte @@ -1,7 +1,8 @@ @@ -164,23 +113,28 @@ {#if title}

{title}

{/if} + {#each errorMessages as error} +

{error}

+ {/each}
{#each fields as field}
{#if schema[field].type === 'string' && schema[field].constraints.inclusion} - {#each schema[field].constraints.inclusion as opt} {/each} - {:else} - + {:else if schema[field].type === 'datetime'} + + {:else if schema[field].type === 'boolean'} + + {:else if schema[field].type === 'number'} + + {:else if schema[field].type === 'string'} + {/if}

@@ -302,4 +256,9 @@ background-position: right 17px top 1.5em, right 10px top 1.5em; background-size: 7px 7px, 7px 7px; } + + .error { + color: red; + font-weight: 500; + } diff --git a/packages/standard-components/src/DataFormWide.svelte b/packages/standard-components/src/DataFormWide.svelte index 56011df569..99c5867d67 100644 --- a/packages/standard-components/src/DataFormWide.svelte +++ b/packages/standard-components/src/DataFormWide.svelte @@ -1,7 +1,8 @@ @@ -164,23 +113,28 @@ {#if title}

{title}

{/if} + {#each errorMessages as error} +

{error}

+ {/each}
{#each fields as field}
{#if schema[field].type === 'string' && schema[field].constraints.inclusion} - {#each schema[field].constraints.inclusion as opt} {/each} - {:else} - + {:else if schema[field].type === 'datetime'} + + {:else if schema[field].type === 'boolean'} + + {:else if schema[field].type === 'number'} + + {:else if schema[field].type === 'string'} + {/if}

@@ -293,4 +247,9 @@ background-position: right 17px top 1.5em, right 10px top 1.5em; background-size: 7px 7px, 7px 7px; } + + .error { + color: red; + font-weight: 500; + } From 2abd6ed7b288bca15dda4507070c73cb6d2df313 Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 10 Sep 2020 13:09:44 +0100 Subject: [PATCH 12/22] tidy up --- packages/standard-components/src/DataForm.svelte | 3 --- packages/standard-components/src/DataFormWide.svelte | 2 -- 2 files changed, 5 deletions(-) diff --git a/packages/standard-components/src/DataForm.svelte b/packages/standard-components/src/DataForm.svelte index 4709097fad..75dffb3301 100644 --- a/packages/standard-components/src/DataForm.svelte +++ b/packages/standard-components/src/DataForm.svelte @@ -41,14 +41,11 @@ ([field, message]) => `${field} ${message}` ) - $: console.log(record) - async function fetchModel() { const FETCH_MODEL_URL = `/api/models/${model}` const response = await _bb.api.get(FETCH_MODEL_URL) modelDef = await response.json() schema = modelDef.schema - // record = createBlankRecord() record = { modelId: model, } diff --git a/packages/standard-components/src/DataFormWide.svelte b/packages/standard-components/src/DataFormWide.svelte index 99c5867d67..fa14380634 100644 --- a/packages/standard-components/src/DataFormWide.svelte +++ b/packages/standard-components/src/DataFormWide.svelte @@ -41,14 +41,12 @@ ([field, message]) => `${field} ${message}` ) - $: console.log(record) async function fetchModel() { const FETCH_MODEL_URL = `/api/models/${model}` const response = await _bb.api.get(FETCH_MODEL_URL) modelDef = await response.json() schema = modelDef.schema - // record = createBlankRecord() record = { modelId: model, } From c4eda0f1e7ba43d245a38228b59c3f8f09dd90bf Mon Sep 17 00:00:00 2001 From: Martin McKeaveney Date: Thu, 10 Sep 2020 13:10:57 +0100 Subject: [PATCH 13/22] bind checked --- packages/standard-components/src/DataForm.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/standard-components/src/DataForm.svelte b/packages/standard-components/src/DataForm.svelte index 75dffb3301..ba5998e5c6 100644 --- a/packages/standard-components/src/DataForm.svelte +++ b/packages/standard-components/src/DataForm.svelte @@ -127,7 +127,7 @@ {:else if schema[field].type === 'datetime'} {:else if schema[field].type === 'boolean'} - + {:else if schema[field].type === 'number'} {:else if schema[field].type === 'string'} From cc154e3ca2856d7ccb3436f5344e64ca5c80f44a Mon Sep 17 00:00:00 2001 From: Conor Mack Date: Thu, 10 Sep 2020 15:58:32 +0100 Subject: [PATCH 14/22] Line Chart - Prop Defaults, Custom Date Formats --- .../userInterface/PropertyControl.svelte | 2 +- .../userInterface/temporaryPanelStructure.js | 10 + packages/builder/yarn.lock | 241 +----------------- packages/standard-components/components.json | 14 +- .../standard-components/src/Chart/Line.svelte | 20 +- 5 files changed, 39 insertions(+), 248 deletions(-) diff --git a/packages/builder/src/components/userInterface/PropertyControl.svelte b/packages/builder/src/components/userInterface/PropertyControl.svelte index 47f94107ed..4fc0af9bb9 100644 --- a/packages/builder/src/components/userInterface/PropertyControl.svelte +++ b/packages/builder/src/components/userInterface/PropertyControl.svelte @@ -67,7 +67,7 @@ innerVal = props.valueKey ? v.target[props.valueKey] : v.target.value } } - if (typeof innerVal !== "object") { + if (typeof innerVal === "string") { replaceBindings(innerVal) } else { onChange(key, innerVal) diff --git a/packages/builder/src/components/userInterface/temporaryPanelStructure.js b/packages/builder/src/components/userInterface/temporaryPanelStructure.js index 5fef88d3af..8943ef8e09 100644 --- a/packages/builder/src/components/userInterface/temporaryPanelStructure.js +++ b/packages/builder/src/components/userInterface/temporaryPanelStructure.js @@ -1051,6 +1051,16 @@ export default { key: "tooltipTitle", control: Input, }, + { + label: "X Ticks", + key: "xTicks", + control: Input, + }, + { + label: "Y Ticks", + key: "yTicks", + control: Input, + }, ], }, }, diff --git a/packages/builder/yarn.lock b/packages/builder/yarn.lock index 5fc90c91c5..fe91590a7e 100644 --- a/packages/builder/yarn.lock +++ b/packages/builder/yarn.lock @@ -691,25 +691,10 @@ "@budibase/bbui@^1.32.0": version "1.32.0" resolved "https://registry.yarnpkg.com/@budibase/bbui/-/bbui-1.32.0.tgz#4b099e51cf8aebfc963a763bb9687994a2ee26a8" - integrity sha512-pY4bhoBhE3EAdaO/wWkbOXaHtGpPxaRFFVUBe9DyoLZ6bv6Pg6y3SDMoMNaKtr3ybtum7pk9eDZOjMMYlGC4AQ== dependencies: sirv-cli "^0.4.6" svelte-flatpickr "^2.4.0" -"@budibase/client@^0.1.19": - version "0.1.19" - resolved "https://registry.yarnpkg.com/@budibase/client/-/client-0.1.19.tgz#3906781423ab4626118c981657ecf7a4578c547c" - dependencies: - "@nx-js/compiler-util" "^2.0.0" - bcryptjs "^2.4.3" - deep-equal "^2.0.1" - lodash "^4.17.15" - lunr "^2.3.5" - mustache "^4.0.1" - regexparam "^1.3.0" - shortid "^2.2.8" - svelte "^3.9.2" - "@budibase/colorpicker@^1.0.1": version "1.0.1" resolved "https://registry.yarnpkg.com/@budibase/colorpicker/-/colorpicker-1.0.1.tgz#940c180e7ebba0cb0756c4c8ef13f5dfab58e810" @@ -959,10 +944,6 @@ "@nodelib/fs.scandir" "2.1.3" fastq "^1.6.0" -"@nx-js/compiler-util@^2.0.0": - version "2.0.0" - resolved "https://registry.yarnpkg.com/@nx-js/compiler-util/-/compiler-util-2.0.0.tgz#c74c12165fa2f017a292bb79af007e8fce0af297" - "@polka/url@^0.5.0": version "0.5.0" resolved "https://registry.yarnpkg.com/@polka/url/-/url-0.5.0.tgz#b21510597fd601e5d7c95008b76bf0d254ebfd31" @@ -982,7 +963,6 @@ "@rollup/pluginutils@^3.0.0": version "3.1.0" resolved "https://registry.yarnpkg.com/@rollup/pluginutils/-/pluginutils-3.1.0.tgz#706b4524ee6dc8b103b3c995533e5ad680c02b9b" - integrity sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg== dependencies: "@types/estree" "0.0.39" estree-walker "^1.0.1" @@ -1390,10 +1370,6 @@ array-equal@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93" -array-filter@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-1.0.0.tgz#baf79e62e6ef4c2a4c0b831232daffec251f9d83" - array-union@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" @@ -1448,12 +1424,6 @@ atob@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" -available-typed-arrays@^1.0.0, available-typed-arrays@^1.0.2: - version "1.0.2" - resolved "https://registry.yarnpkg.com/available-typed-arrays/-/available-typed-arrays-1.0.2.tgz#6b098ca9d8039079ee3f77f7b783c4480ba513f5" - dependencies: - array-filter "^1.0.0" - aws-sign2@~0.7.0: version "0.7.0" resolved "https://registry.yarnpkg.com/aws-sign2/-/aws-sign2-0.7.0.tgz#b46e890934a9591f2d2f6f86d7e6a9f1b3fe76a8" @@ -1528,10 +1498,6 @@ bcrypt-pbkdf@^1.0.0: dependencies: tweetnacl "^0.14.3" -bcryptjs@^2.4.3: - version "2.4.3" - resolved "https://registry.yarnpkg.com/bcryptjs/-/bcryptjs-2.4.3.tgz#9ab5627b93e60621ff7cdac5da9733027df1d0cb" - binary-extensions@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.0.0.tgz#23c0df14f6a88077f5f986c0d167ec03c3d5537c" @@ -2415,25 +2381,6 @@ decode-uri-component@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" -deep-equal@^2.0.1: - version "2.0.3" - resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-2.0.3.tgz#cad1c15277ad78a5c01c49c2dee0f54de8a6a7b0" - dependencies: - es-abstract "^1.17.5" - es-get-iterator "^1.1.0" - is-arguments "^1.0.4" - is-date-object "^1.0.2" - is-regex "^1.0.5" - isarray "^2.0.5" - object-is "^1.1.2" - object-keys "^1.1.1" - object.assign "^4.1.0" - regexp.prototype.flags "^1.3.0" - side-channel "^1.0.2" - which-boxed-primitive "^1.0.1" - which-collection "^1.0.1" - which-typed-array "^1.1.2" - deep-is@~0.1.3: version "0.1.3" resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" @@ -2603,51 +2550,6 @@ es-abstract@^1.17.0-next.1, es-abstract@^1.17.2, es-abstract@^1.17.5: string.prototype.trimleft "^2.1.1" string.prototype.trimright "^2.1.1" -es-abstract@^1.17.4: - version "1.17.6" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.17.6.tgz#9142071707857b2cacc7b89ecb670316c3e2d52a" - dependencies: - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - is-callable "^1.2.0" - is-regex "^1.1.0" - object-inspect "^1.7.0" - object-keys "^1.1.1" - object.assign "^4.1.0" - string.prototype.trimend "^1.0.1" - string.prototype.trimstart "^1.0.1" - -es-abstract@^1.18.0-next.0: - version "1.18.0-next.0" - resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.0-next.0.tgz#b302834927e624d8e5837ed48224291f2c66e6fc" - dependencies: - es-to-primitive "^1.2.1" - function-bind "^1.1.1" - has "^1.0.3" - has-symbols "^1.0.1" - is-callable "^1.2.0" - is-negative-zero "^2.0.0" - is-regex "^1.1.1" - object-inspect "^1.8.0" - object-keys "^1.1.1" - object.assign "^4.1.0" - string.prototype.trimend "^1.0.1" - string.prototype.trimstart "^1.0.1" - -es-get-iterator@^1.1.0: - version "1.1.0" - resolved "https://registry.yarnpkg.com/es-get-iterator/-/es-get-iterator-1.1.0.tgz#bb98ad9d6d63b31aacdc8f89d5d0ee57bcb5b4c8" - dependencies: - es-abstract "^1.17.4" - has-symbols "^1.0.1" - is-arguments "^1.0.4" - is-map "^2.0.1" - is-set "^2.0.1" - is-string "^1.0.5" - isarray "^2.0.5" - es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -2952,7 +2854,6 @@ find-up@^3.0.0: flatpickr@^4.5.2: version "4.6.6" resolved "https://registry.yarnpkg.com/flatpickr/-/flatpickr-4.6.6.tgz#34d2ad80adfa34254e62583a34264d472f1038d6" - integrity sha512-EZ48CJMttMg3maMhJoX+GvTuuEhX/RbA1YeuI19attP3pwBdbYy6+yqAEVm0o0hSBFYBiLbVxscLW6gJXq6H3A== fn-name@~3.0.0: version "3.0.0" @@ -2962,7 +2863,7 @@ for-in@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" -foreach@^2.0.5, foreach@~2.0.1: +foreach@~2.0.1: version "2.0.5" resolved "https://registry.yarnpkg.com/foreach/-/foreach-2.0.5.tgz#0bee005018aeb260d0a3af3ae658dd0136ec1b99" @@ -3335,28 +3236,16 @@ is-accessor-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" -is-arguments@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-arguments/-/is-arguments-1.0.4.tgz#3faf966c7cba0ff437fb31f6250082fcf0448cf3" - is-arrayish@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/is-arrayish/-/is-arrayish-0.2.1.tgz#77c99840527aa8ecb1a8ba697b80645a7a926a9d" -is-bigint@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/is-bigint/-/is-bigint-1.0.0.tgz#73da8c33208d00f130e9b5e15d23eac9215601c4" - is-binary-path@~2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" dependencies: binary-extensions "^2.0.0" -is-boolean-object@^1.0.0: - version "1.0.1" - resolved "https://registry.yarnpkg.com/is-boolean-object/-/is-boolean-object-1.0.1.tgz#10edc0900dd127697a92f6f9807c7617d68ac48e" - is-buffer@^1.1.5: version "1.1.6" resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" @@ -3365,10 +3254,6 @@ is-callable@^1.1.4, is-callable@^1.1.5: version "1.1.5" resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.1.5.tgz#f7e46b596890456db74e7f6e976cb3273d06faab" -is-callable@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/is-callable/-/is-callable-1.2.0.tgz#83336560b54a38e35e3a2df7afd0454d691468bb" - is-ci@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" @@ -3387,7 +3272,7 @@ is-data-descriptor@^1.0.0: dependencies: kind-of "^6.0.0" -is-date-object@^1.0.1, is-date-object@^1.0.2: +is-date-object@^1.0.1: version "1.0.2" resolved "https://registry.yarnpkg.com/is-date-object/-/is-date-object-1.0.2.tgz#bda736f2cd8fd06d32844e7743bfa7494c3bfd7e" @@ -3452,22 +3337,10 @@ is-installed-globally@^0.3.2: global-dirs "^2.0.1" is-path-inside "^3.0.1" -is-map@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-map/-/is-map-2.0.1.tgz#520dafc4307bb8ebc33b813de5ce7c9400d644a1" - is-module@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-module/-/is-module-1.0.0.tgz#3258fb69f78c14d5b815d664336b4cffb6441591" -is-negative-zero@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/is-negative-zero/-/is-negative-zero-2.0.0.tgz#9553b121b0fac28869da9ed459e20c7543788461" - -is-number-object@^1.0.3: - version "1.0.4" - resolved "https://registry.yarnpkg.com/is-number-object/-/is-number-object-1.0.4.tgz#36ac95e741cf18b283fc1ddf5e83da798e3ec197" - is-number@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" @@ -3524,16 +3397,6 @@ is-regex@^1.0.5: dependencies: has "^1.0.3" -is-regex@^1.1.0, is-regex@^1.1.1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.1.1.tgz#c6f98aacc546f6cec5468a07b7b153ab564a57b9" - dependencies: - has-symbols "^1.0.1" - -is-set@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-set/-/is-set-2.0.1.tgz#d1604afdab1724986d30091575f54945da7e5f43" - is-stream@^1.1.0: version "1.1.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" @@ -3542,37 +3405,16 @@ is-stream@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-2.0.0.tgz#bde9c32680d6fae04129d6ac9d921ce7815f78e3" -is-string@^1.0.4, is-string@^1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/is-string/-/is-string-1.0.5.tgz#40493ed198ef3ff477b8c7f92f644ec82a5cd3a6" - is-symbol@^1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/is-symbol/-/is-symbol-1.0.3.tgz#38e1014b9e6329be0de9d24a414fd7441ec61937" dependencies: has-symbols "^1.0.1" -is-typed-array@^1.1.3: - version "1.1.3" - resolved "https://registry.yarnpkg.com/is-typed-array/-/is-typed-array-1.1.3.tgz#a4ff5a5e672e1a55f99c7f54e59597af5c1df04d" - dependencies: - available-typed-arrays "^1.0.0" - es-abstract "^1.17.4" - foreach "^2.0.5" - has-symbols "^1.0.1" - is-typedarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a" -is-weakmap@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.1.tgz#5008b59bdc43b698201d18f62b37b2ca243e8cf2" - -is-weakset@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/is-weakset/-/is-weakset-2.0.1.tgz#e9a0af88dbd751589f5e50d80f4c98b780884f83" - is-windows@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" @@ -3593,10 +3435,6 @@ isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" -isarray@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-2.0.5.tgz#8af1e4c1221244cc62459faf38940d4e644a5723" - isbuffer@~0.0.0: version "0.0.0" resolved "https://registry.yarnpkg.com/isbuffer/-/isbuffer-0.0.0.tgz#38c146d9df528b8bf9b0701c3d43cf12df3fc39b" @@ -4410,10 +4248,6 @@ ltgt@^2.1.2: version "2.2.1" resolved "https://registry.yarnpkg.com/ltgt/-/ltgt-2.2.1.tgz#f35ca91c493f7b73da0e07495304f17b31f87ee5" -lunr@^2.3.5: - version "2.3.9" - resolved "https://registry.yarnpkg.com/lunr/-/lunr-2.3.9.tgz#18b123142832337dd6e964df1a5a7707b25d35e1" - magic-string@^0.22.5: version "0.22.5" resolved "https://registry.yarnpkg.com/magic-string/-/magic-string-0.22.5.tgz#8e9cf5afddf44385c1da5bc2a6a0dbd10b03657e" @@ -4711,17 +4545,6 @@ object-inspect@^1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" -object-inspect@^1.8.0: - version "1.8.0" - resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.8.0.tgz#df807e5ecf53a609cc6bfe93eac3cc7be5b3a9d0" - -object-is@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/object-is/-/object-is-1.1.2.tgz#c5d2e87ff9e119f78b7a088441519e2eec1573b6" - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.5" - object-keys@^1.0.11, object-keys@^1.0.12, object-keys@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/object-keys/-/object-keys-1.1.1.tgz#1c47f272df277f3b1daf061677d9c82e2322c60e" @@ -5232,17 +5055,6 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp.prototype.flags@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz#7aba89b3c13a64509dabcf3ca8d9fbb9bdf5cb75" - dependencies: - define-properties "^1.1.3" - es-abstract "^1.17.0-next.1" - -regexparam@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/regexparam/-/regexparam-1.3.0.tgz#2fe42c93e32a40eff6235d635e0ffa344b92965f" - regexpu-core@^4.7.0: version "4.7.0" resolved "https://registry.yarnpkg.com/regexpu-core/-/regexpu-core-4.7.0.tgz#fcbf458c50431b0bb7b45d6967b8192d91f3d938" @@ -5431,7 +5243,6 @@ rollup-plugin-copy@^3.0.0: rollup-plugin-css-only@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/rollup-plugin-css-only/-/rollup-plugin-css-only-2.1.0.tgz#b9e8505eb01c5257b5eab65bd51eec9050bed9a3" - integrity sha512-pfdcqAWEmRMFy+ABXAQPA/DKyPqLuBTOf+lWSOgtrVs1v/q7DSXzYa9QZg4myd8/1F7NHcdvPkWnfWqMxq9vrw== dependencies: "@rollup/pluginutils" "^3.0.0" fs-extra "^9.0.0" @@ -5641,19 +5452,12 @@ shellwords@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b" -shortid@^2.2.15, shortid@^2.2.8: +shortid@^2.2.15: version "2.2.15" resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.15.tgz#2b902eaa93a69b11120373cd42a1f1fe4437c122" dependencies: nanoid "^2.1.0" -side-channel@^1.0.2: - version "1.0.3" - resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.3.tgz#cdc46b057550bbab63706210838df5d4c19519c3" - dependencies: - es-abstract "^1.18.0-next.0" - object-inspect "^1.8.0" - signal-exit@^3.0.0, signal-exit@^3.0.2: version "3.0.3" resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" @@ -5880,7 +5684,7 @@ string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" -string.prototype.trimend@^1.0.0, string.prototype.trimend@^1.0.1: +string.prototype.trimend@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz#85812a6b847ac002270f5808146064c995fb6913" dependencies: @@ -5903,7 +5707,7 @@ string.prototype.trimright@^2.1.1: es-abstract "^1.17.5" string.prototype.trimend "^1.0.0" -string.prototype.trimstart@^1.0.0, string.prototype.trimstart@^1.0.1: +string.prototype.trimstart@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz#14af6d9f34b053f7cfc89b72f8f2ee14b9039a54" dependencies: @@ -5993,7 +5797,6 @@ supports-color@^7.1.0: svelte-flatpickr@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/svelte-flatpickr/-/svelte-flatpickr-2.4.0.tgz#190871fc3305956c8c8fd3601cd036b8ac71ef49" - integrity sha512-UUC5Te+b0qi4POg7VDwfGh0m5W3Hf64OwkfOTj6FEe/dYZN4cBzpQ82EuuQl0CTbbBAsMkcjJcixV1d2V6EHCQ== dependencies: flatpickr "^4.5.2" @@ -6019,10 +5822,6 @@ svelte@3.23.x: version "3.23.0" resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.23.0.tgz#bbcd6887cf588c24a975b14467455abfff9acd3f" -svelte@^3.9.2: - version "3.24.1" - resolved "https://registry.yarnpkg.com/svelte/-/svelte-3.24.1.tgz#aca364937dd1df27fe131e2a4c234acb6061db4b" - symbol-observable@^1.1.0: version "1.2.0" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.2.0.tgz#c22688aed4eab3cdc2dfeacbb561660560a00804" @@ -6354,40 +6153,10 @@ whatwg-url@^8.0.0: tr46 "^2.0.2" webidl-conversions "^5.0.0" -which-boxed-primitive@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/which-boxed-primitive/-/which-boxed-primitive-1.0.1.tgz#cbe8f838ebe91ba2471bb69e9edbda67ab5a5ec1" - dependencies: - is-bigint "^1.0.0" - is-boolean-object "^1.0.0" - is-number-object "^1.0.3" - is-string "^1.0.4" - is-symbol "^1.0.2" - -which-collection@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/which-collection/-/which-collection-1.0.1.tgz#70eab71ebbbd2aefaf32f917082fc62cdcb70906" - dependencies: - is-map "^2.0.1" - is-set "^2.0.1" - is-weakmap "^2.0.1" - is-weakset "^2.0.1" - which-module@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" -which-typed-array@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/which-typed-array/-/which-typed-array-1.1.2.tgz#e5f98e56bda93e3dac196b01d47c1156679c00b2" - dependencies: - available-typed-arrays "^1.0.2" - es-abstract "^1.17.5" - foreach "^2.0.5" - function-bind "^1.1.1" - has-symbols "^1.0.1" - is-typed-array "^1.1.3" - which@^1.2.9, which@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" diff --git a/packages/standard-components/components.json b/packages/standard-components/components.json index 8c41618aee..170ea7393b 100644 --- a/packages/standard-components/components.json +++ b/packages/standard-components/components.json @@ -537,23 +537,25 @@ "height": "number", "axisTimeCombinations": "string", "color": "string", - "grid": "string", + "grid": {"type":"string", "default": "horizontal"}, "aspectRatio": "number", "dateLabel": "string", - "isAnimated": "bool", + "isAnimated": {"type": "bool", "default": true}, "lineCurve": "string", "locale": "string", "numberFormat": "string", - "shouldShowAllDataPoints": "bool", + "shouldShowAllDataPoints": {"type": "bool", "default": true}, "topicLabel": "string", "valueLabel": "string", - "xAxisValueType": "string", + "xAxisValueType": {"type":"string", "default": "date"}, "xAxisScale": "string", - "xAxisFormat": "string", + "xAxisFormat": {"type":"string", "default": "custom"}, "xAxisCustomFormat": "string", "xAxisLabel": "string", "yAxisLabel": "string", - "tooltipTitle": "string" + "tooltipTitle": "string", + "xTicks": "number", + "yTicks": "number" } }, "brush": { diff --git a/packages/standard-components/src/Chart/Line.svelte b/packages/standard-components/src/Chart/Line.svelte index c3054840f8..b6f5452072 100644 --- a/packages/standard-components/src/Chart/Line.svelte +++ b/packages/standard-components/src/Chart/Line.svelte @@ -62,6 +62,8 @@ export let lines = null //not handled by setting prop export let tooltipThreshold = null export let tooltipTitle = "" + export let xTicks = "" + export let yTicks = "" onMount(async () => { if (!isEmpty(datasource)) { @@ -73,12 +75,15 @@ bindChartEvents() chartContainer.datum(data).call(chart) - // X Axis Label gets cut off unless we do this 👇 + // Hack 🤮 X Axis Label and last tick label gets cut off unless we do this 👇 const chartSvg = document.querySelector(`.${chartClass} .britechart`) if (chartSvg) { let height = chartSvg.getAttribute("height") + let width = chartSvg.getAttribute("width") height = parseInt(height) + 35 + width = parseInt(width) + 15 chartSvg.setAttribute("height", height) + chartSvg.setAttribute("width", width) } bindTooltip() @@ -145,11 +150,10 @@ } function bindChartUIProps() { - chart.grid("horizontal") - chart.isAnimated(true) chart.tooltipThreshold(800) chart.aspectRatio(0.5) - chart.xAxisCustomFormat("custom") + chart.xAxisCustomFormat("%e %b %Y") + chart.xTicks(data.dataByTopic.length) if (notNull(color)) { chart.colorSchema(colorSchema) @@ -214,6 +218,12 @@ if (notNull(lines)) { chart.lines(lines) } + if (notNull(xTicks)) { + chart.xTicks(Number(xTicks)) + } + if (notNull(yTicks)) { + chart.yTicks(Number(yTicks)) + } if (notNull(tooltipTitle)) { tooltip.title(tooltipTitle) } else if (datasource.label) { @@ -243,4 +253,4 @@ $: chartGradient = getChartGradient(lineGradient) -
+
From d3225cb51f09baacb208d1061976869da4a4c3f0 Mon Sep 17 00:00:00 2001 From: Michael Shanks Date: Thu, 10 Sep 2020 21:11:05 +0100 Subject: [PATCH 15/22] events hooked up and working --- .../ComponentPropertiesPanel.svelte | 4 -- .../EventsEditor/actions/UpdateRecord.svelte | 44 ++++++++---- .../userInterface/EventsEditor/index.js | 1 - packages/client/src/api/index.js | 14 ++++ packages/client/src/createApp.js | 1 - packages/client/src/state/bbComponentApi.js | 19 +++-- packages/client/src/state/eventHandlers.js | 45 ++++++++---- packages/client/src/state/runEventHandler.js | 0 packages/client/src/state/stateManager.js | 69 ++----------------- packages/client/tests/testAppDef.js | 3 +- packages/server/src/api/controllers/record.js | 32 ++++++++- packages/server/src/api/routes/record.js | 2 +- .../standard-components/dist/index.js.map | 2 +- .../standard-components/src/Button.svelte | 3 +- .../standard-components/src/Container.svelte | 2 +- .../standard-components/src/Navigation.svelte | 2 +- packages/standard-components/src/Table.svelte | 5 +- 17 files changed, 133 insertions(+), 115 deletions(-) delete mode 100644 packages/builder/src/components/userInterface/EventsEditor/index.js create mode 100644 packages/client/src/state/runEventHandler.js diff --git a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte index 1898fee29b..bc873a1bcc 100644 --- a/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte +++ b/packages/builder/src/components/userInterface/ComponentPropertiesPanel.svelte @@ -9,7 +9,6 @@ CircleIndicator, EventsIcon, } from "components/common/Icons/" - import EventsEditor from "./EventsEditor" import panelStructure from "./temporaryPanelStructure.js" import CategoryTab from "./CategoryTab.svelte" import DesignView from "./DesignView.svelte" @@ -21,7 +20,6 @@ let categories = [ { value: "settings", name: "Settings" }, { value: "design", name: "Design" }, - { value: "events", name: "Events" }, ] let selectedCategory = categories[0] @@ -109,8 +107,6 @@ displayNameField={displayName} onChange={onPropChanged} screenOrPageInstance={$store.currentView !== 'component' && $store.currentPreviewItem} /> - {:else if selectedCategory.value === 'events'} - {/if}
diff --git a/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte b/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte index 9e0236c547..f322ec92a5 100644 --- a/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte +++ b/packages/builder/src/components/userInterface/EventsEditor/actions/UpdateRecord.svelte @@ -3,6 +3,10 @@ import { store, backendUiStore } from "builderStore" import fetchBindableProperties from "builderStore/fetchBindableProperties" import SaveFields from "./SaveFields.svelte" + import { + readableToRuntimeBinding, + runtimeToReadableBinding, + } from "builderStore/replaceBindings" export let parameters @@ -14,25 +18,36 @@ }) let idFields + let recordId $: { idFields = bindableProperties.filter( bindable => bindable.type === "context" && bindable.runtimeBinding.endsWith("._id") ) // ensure recordId is always defaulted - there is usually only one option - if (idFields.length > 0 && !parameters.recordId) { - parameters.recordId = idFields[0].runtimeBinding + if (idFields.length > 0 && !parameters._id) { + recordId = idFields[0].runtimeBinding parameters = parameters + } else if (!recordId && parameters._id) { + recordId = parameters._id + .replace("{{", "") + .replace("}}", "") + .trim() } } + $: parameters._id = `{{ ${recordId} }}` + // just wraps binding in {{ ... }} - const toBindingExpression = bindingPath => `{{ ${bindingPath} }}` + const toBindingExpression = bindingPath => { + console.log("yeo") + return `{{ ${bindingPath} }}` + } // finds the selected idBinding, then reads the table/view // from the component instance that it belongs to. // then returns the field names for that schema - const fieldNamesFromIdBinding = recordId => { + const modelInfoFromIdBinding = recordId => { if (!recordId) return [] const idBinding = bindableProperties.find( @@ -52,14 +67,18 @@ const model = $backendUiStore.models.find( m => m._id === instance[component.context] ) - + parameters.modelId = modelId return Object.keys(model.schema) } - $: fieldNames = - parameters && parameters.recordId - ? fieldNamesFromIdBinding(parameters.recordId) - : [] + let fieldNames + $: { + if (parameters && recordId) { + fieldNames = modelInfoFromIdBinding(recordId) + } else { + fieldNames = [] + } + } const onFieldsChanged = e => { parameters.fields = e.detail @@ -74,16 +93,17 @@
{:else} - + {/each} {/if} - {#if parameters.recordId} + {#if recordId} + await post({ url: `/api/${params.modelId}/records`, body: params.fields }) + +const updateRecord = async params => { + const record = params.fields + record._id = params._id + await patch({ + url: `/api/${params.modelId}/records/${params._id}`, + body: record, + }) +} + export default { authenticate: authenticate(apiOpts), triggerWorkflow: triggerWorkflow(apiOpts), + createRecord, + updateRecord, } diff --git a/packages/client/src/createApp.js b/packages/client/src/createApp.js index 52437f2a7a..233abc0f58 100644 --- a/packages/client/src/createApp.js +++ b/packages/client/src/createApp.js @@ -50,7 +50,6 @@ export const createApp = ({ treeNode, onScreenSlotRendered, setupState: stateManager.setup, - getCurrentState: stateManager.getCurrentState, }) return getInitialiseParams diff --git a/packages/client/src/state/bbComponentApi.js b/packages/client/src/state/bbComponentApi.js index 44b39facbf..d055d4a05b 100644 --- a/packages/client/src/state/bbComponentApi.js +++ b/packages/client/src/state/bbComponentApi.js @@ -1,12 +1,13 @@ import setBindableComponentProp from "./setBindableComponentProp" import { attachChildren } from "../render/attachChildren" +import store from "../state/store" export const trimSlash = str => str.replace(/^\/+|\/+$/g, "") export const bbFactory = ({ componentLibraries, onScreenSlotRendered, - getCurrentState, + runEventActions, }) => { const apiCall = method => (url, body) => { return fetch(url, { @@ -26,13 +27,6 @@ export const bbFactory = ({ delete: apiCall("DELETE"), } - const safeCallEvent = (event, context) => { - const isFunction = obj => - !!(obj && obj.constructor && obj.call && obj.apply) - - if (isFunction(event)) event(context) - } - return (treeNode, setupState) => { const attachParams = { componentLibraries, @@ -44,12 +38,17 @@ export const bbFactory = ({ return { attachChildren: attachChildren(attachParams), props: treeNode.props, - call: safeCallEvent, + call: async eventName => + eventName && + (await runEventActions( + treeNode.props[eventName], + store.getState(treeNode.contextStoreKey) + )), setBinding: setBindableComponentProp(treeNode), api, parent, // these parameters are populated by screenRouter - routeParams: () => getCurrentState()["##routeParams"], + routeParams: () => store.getState()["##routeParams"], } } } diff --git a/packages/client/src/state/eventHandlers.js b/packages/client/src/state/eventHandlers.js index 5fec7cd9a6..3679610fe2 100644 --- a/packages/client/src/state/eventHandlers.js +++ b/packages/client/src/state/eventHandlers.js @@ -1,22 +1,39 @@ import api from "../api" +import renderTemplateString from "./renderTemplateString" export const EVENT_TYPE_MEMBER_NAME = "##eventHandlerType" export const eventHandlers = routeTo => { - const handler = (parameters, execute) => ({ - execute, - parameters, - }) - - return { - "Navigate To": handler(["url"], param => routeTo(param && param.url)), - "Create Record": handler(["url"], param => param), - "Update Record": handler(["url"], param => param), - "Trigger Workflow": handler(["workflow"], api.triggerWorkflow), + const handlers = { + "Navigate To": param => routeTo(param && param.url), + "Create Record": api.createRecord, + "Update Record": api.updateRecord, + "Trigger Workflow": api.triggerWorkflow, } + + // when an event is called, this is what gets run + const runEventActions = async (actions, state) => { + if (!actions) return + for (let action of actions) { + const handler = handlers[action[EVENT_TYPE_MEMBER_NAME]] + const parameters = createParameters(action.parameters, state) + if (handler) { + await handler(parameters) + } + } + } + + return runEventActions } -export const isEventType = prop => - Array.isArray(prop) && - prop.length > 0 && - !prop[0][EVENT_TYPE_MEMBER_NAME] === undefined +const createParameters = (parameterTemplateObj, state) => { + const parameters = {} + for (let key in parameterTemplateObj) { + if (typeof parameterTemplateObj[key] === "string") { + parameters[key] = renderTemplateString(parameterTemplateObj[key], state) + } else if (typeof parameterTemplateObj[key] === "object") { + parameters[key] = createParameters(parameterTemplateObj[key], state) + } + } + return parameters +} diff --git a/packages/client/src/state/runEventHandler.js b/packages/client/src/state/runEventHandler.js new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/client/src/state/stateManager.js b/packages/client/src/state/stateManager.js index fbfb39b7a4..b753d2f346 100644 --- a/packages/client/src/state/stateManager.js +++ b/packages/client/src/state/stateManager.js @@ -1,8 +1,4 @@ -import { - isEventType, - eventHandlers, - EVENT_TYPE_MEMBER_NAME, -} from "./eventHandlers" +import { eventHandlers } from "./eventHandlers" import { bbFactory } from "./bbComponentApi" import renderTemplateString from "./renderTemplateString" import appStore from "./store" @@ -25,33 +21,23 @@ export const createStateManager = ({ onScreenSlotRendered, routeTo, }) => { - let handlerTypes = eventHandlers(routeTo) - - // creating a reference to the current state - // this avoids doing store.get() ... which is expensive on - // hot paths, according to the svelte docs. - // the state object reference never changes (although it's internals do) - // so this should work fine for us - let currentState - appStore.subscribe(s => (currentState = s)) - const getCurrentState = () => currentState + let runEventActions = eventHandlers(routeTo) const bb = bbFactory({ - getCurrentState, componentLibraries, onScreenSlotRendered, + runEventActions, }) - const setup = _setup({ handlerTypes, getCurrentState, bb }) + const setup = _setup(bb) return { setup, destroy: () => {}, - getCurrentState, } } -const _setup = ({ handlerTypes, getCurrentState, bb }) => node => { +const _setup = bb => node => { const props = node.props const initialProps = { ...props } @@ -70,53 +56,10 @@ const _setup = ({ handlerTypes, getCurrentState, bb }) => node => { node.stateBound = true } } - - if (isEventType(propValue)) { - const state = appStore.getState(node.contextStoreKey) - const handlersInfos = [] - for (let event of propValue) { - const handlerInfo = { - handlerType: event[EVENT_TYPE_MEMBER_NAME], - parameters: event.parameters, - } - - const resolvedParams = {} - for (let paramName in handlerInfo.parameters) { - const paramValue = handlerInfo.parameters[paramName] - resolvedParams[paramName] = () => - renderTemplateString(paramValue, state) - } - - handlerInfo.parameters = resolvedParams - handlersInfos.push(handlerInfo) - } - - if (handlersInfos.length === 0) { - initialProps[propName] = doNothing - } else { - initialProps[propName] = async context => { - for (let handlerInfo of handlersInfos) { - const handler = makeHandler(handlerTypes, handlerInfo) - await handler(context) - } - } - } - } } - const setup = _setup({ handlerTypes, getCurrentState, bb }) + const setup = _setup(bb) initialProps._bb = bb(node, setup) return initialProps } - -const makeHandler = (handlerTypes, handlerInfo) => { - const handlerType = handlerTypes[handlerInfo.handlerType] - return async context => { - const parameters = {} - for (let paramName in handlerInfo.parameters) { - parameters[paramName] = handlerInfo.parameters[paramName](context) - } - await handlerType.execute(parameters) - } -} diff --git a/packages/client/tests/testAppDef.js b/packages/client/tests/testAppDef.js index 69fdf551dc..c583d91545 100644 --- a/packages/client/tests/testAppDef.js +++ b/packages/client/tests/testAppDef.js @@ -181,8 +181,7 @@ const maketestlib = window => ({ currentProps = Object.assign(currentProps, props) if (currentProps.onClick) { node.addEventListener("click", () => { - const testText = currentProps.testText || "hello" - currentProps._bb.call(props.onClick, { testText }) + currentProps._bb.call("onClick") }) } } diff --git a/packages/server/src/api/controllers/record.js b/packages/server/src/api/controllers/record.js index 296f40e326..dbd7d7651f 100644 --- a/packages/server/src/api/controllers/record.js +++ b/packages/server/src/api/controllers/record.js @@ -4,7 +4,7 @@ const newid = require("../../db/newid") exports.patch = async function(ctx) { const db = new CouchDB(ctx.user.instanceId) - const record = await db.get(ctx.params._id) + const record = await db.get(ctx.params.id) const model = await db.get(record.modelId) const patchfields = ctx.request.body @@ -13,6 +13,8 @@ exports.patch = async function(ctx) { record[key] = patchfields[key] } + coerceFieldsToCorrectType(record, model) + const validateResult = await validate({ record, model, @@ -47,6 +49,8 @@ exports.save = async function(ctx) { const model = await db.get(record.modelId) + coerceFieldsToCorrectType(record, model) + const validateResult = await validate({ record, model, @@ -182,6 +186,32 @@ exports.validate = async function(ctx) { ctx.body = errors } +// this function modifies an incoming record, to allow for things like +// "boolField": "true" (instead of mandating "boolField": true) +// this allows us to use mustash templating to send non-string fields in a request +const coerceFieldsToCorrectType = (record, model) => { + for (let fieldName in record) { + const fieldValue = record[fieldName] + if (model.schema[fieldName]) { + if ( + model.schema[fieldName].type === "boolean" && + typeof fieldValue !== "boolean" + ) { + if (fieldValue === "true") record[fieldName] = true + if (fieldValue === "false") record[fieldName] = false + continue + } + + if (model.schema[fieldName].type === "number") { + const val = parseFloat(fieldValue) + if (!isNaN(val)) { + record[fieldName] = val + } + } + } + } +} + async function validate({ instanceId, modelId, record, model }) { if (!model) { const db = new CouchDB(instanceId) diff --git a/packages/server/src/api/routes/record.js b/packages/server/src/api/routes/record.js index 15fbe29503..e291a153ce 100644 --- a/packages/server/src/api/routes/record.js +++ b/packages/server/src/api/routes/record.js @@ -25,7 +25,7 @@ router .patch( "/api/:modelId/records/:id", authorized(WRITE_MODEL, ctx => ctx.params.modelId), - recordController.save + recordController.patch ) .post( "/api/:modelId/records/validate", diff --git a/packages/standard-components/dist/index.js.map b/packages/standard-components/dist/index.js.map index 766061eff9..93d6f06b58 100644 --- a/packages/standard-components/dist/index.js.map +++ b/packages/standard-components/dist/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../node_modules/svelte/internal/index.mjs","../src/cssVars.js","../src/Container.svelte","../src/buildStyle.js","../src/Text.svelte","../src/Heading.svelte","../src/Input.svelte","../src/Select.svelte","../src/Textfield.svelte","../src/Checkbox.svelte","../src/Radiobutton.svelte","../src/Option.svelte","../src/Button.svelte","../src/Login.svelte","../src/Templates/saveRecordButton.js","../src/Link.svelte","../src/Image.svelte","../src/Icon.svelte","../src/Navigation.svelte","../node_modules/fast-sort/dist/sort.es.js","../src/api.js","../src/fetchData.js","../node_modules/lodash/lodash.min.js","../node_modules/lodash/fp/_mapping.js","../node_modules/lodash/fp/placeholder.js","../node_modules/lodash/fp/_baseConvert.js","../node_modules/lodash/fp.js","../src/DataTable.svelte","../node_modules/svelte/transition/index.mjs","../src/DataForm.svelte","../src/DataFormWide.svelte","../node_modules/fusioncharts/fusioncharts.js","../node_modules/fusioncharts/fusioncharts.charts.js","../node_modules/fusioncharts/themes/fusioncharts.theme.fusion.js","../node_modules/svelte-fusioncharts/src/events.js","../node_modules/svelte-fusioncharts/src/utils.js","../node_modules/svelte-fusioncharts/src/index.svelte","../src/DataChart.svelte","../src/DataList.svelte","../src/List.svelte","../src/DataSearch.svelte","../src/Embed.svelte","../src/StackedList.svelte","../src/Card.svelte","../src/CardHorizontal.svelte","../src/RecordDetail.svelte","../node_modules/style-inject/dist/style-inject.es.js","../node_modules/britecharts/dist/bundled/britecharts.min.js","../src/Chart/utils.js","../node_modules/d3-selection/src/namespaces.js","../node_modules/d3-selection/src/namespace.js","../node_modules/d3-selection/src/creator.js","../node_modules/d3-selection/src/selector.js","../node_modules/d3-selection/src/selection/select.js","../node_modules/d3-selection/src/selectorAll.js","../node_modules/d3-selection/src/selection/selectAll.js","../node_modules/d3-selection/src/matcher.js","../node_modules/d3-selection/src/selection/filter.js","../node_modules/d3-selection/src/selection/sparse.js","../node_modules/d3-selection/src/selection/enter.js","../node_modules/d3-selection/src/constant.js","../node_modules/d3-selection/src/selection/data.js","../node_modules/d3-selection/src/selection/exit.js","../node_modules/d3-selection/src/selection/join.js","../node_modules/d3-selection/src/selection/merge.js","../node_modules/d3-selection/src/selection/order.js","../node_modules/d3-selection/src/selection/sort.js","../node_modules/d3-selection/src/selection/call.js","../node_modules/d3-selection/src/selection/nodes.js","../node_modules/d3-selection/src/selection/node.js","../node_modules/d3-selection/src/selection/size.js","../node_modules/d3-selection/src/selection/empty.js","../node_modules/d3-selection/src/selection/each.js","../node_modules/d3-selection/src/selection/attr.js","../node_modules/d3-selection/src/window.js","../node_modules/d3-selection/src/selection/style.js","../node_modules/d3-selection/src/selection/property.js","../node_modules/d3-selection/src/selection/classed.js","../node_modules/d3-selection/src/selection/text.js","../node_modules/d3-selection/src/selection/html.js","../node_modules/d3-selection/src/selection/raise.js","../node_modules/d3-selection/src/selection/lower.js","../node_modules/d3-selection/src/selection/append.js","../node_modules/d3-selection/src/selection/insert.js","../node_modules/d3-selection/src/selection/remove.js","../node_modules/d3-selection/src/selection/clone.js","../node_modules/d3-selection/src/selection/datum.js","../node_modules/d3-selection/src/selection/on.js","../node_modules/d3-selection/src/selection/dispatch.js","../node_modules/d3-selection/src/selection/index.js","../node_modules/d3-selection/src/select.js","../src/Chart/Legend.svelte","../node_modules/shortid/lib/random/random-from-seed.js","../node_modules/shortid/lib/alphabet.js","../node_modules/shortid/lib/random/random-byte-browser.js","../node_modules/nanoid/format.browser.js","../node_modules/shortid/lib/generate.js","../node_modules/shortid/lib/build.js","../node_modules/shortid/lib/is-valid.js","../node_modules/shortid/lib/index.js","../node_modules/shortid/index.js","../src/Chart/Donut.svelte","../src/Chart/Bar.svelte","../src/Chart/Line.svelte","../src/Chart/Brush.svelte","../src/Chart/Bullet.svelte","../src/Chart/GroupedBar.svelte","../src/Chart/Heatmap.svelte","../src/Chart/Sparkline.svelte","../src/Chart/ScatterPlot.svelte","../src/Chart/Step.svelte","../src/Chart/StackedArea.svelte","../src/Chart/StackedBar.svelte"],"sourcesContent":["function noop() { }\nconst identity = x => x;\nfunction assign(tar, src) {\n // @ts-ignore\n for (const k in src)\n tar[k] = src[k];\n return tar;\n}\nfunction is_promise(value) {\n return value && typeof value === 'object' && typeof value.then === 'function';\n}\nfunction add_location(element, file, line, column, char) {\n element.__svelte_meta = {\n loc: { file, line, column, char }\n };\n}\nfunction run(fn) {\n return fn();\n}\nfunction blank_object() {\n return Object.create(null);\n}\nfunction run_all(fns) {\n fns.forEach(run);\n}\nfunction is_function(thing) {\n return typeof thing === 'function';\n}\nfunction safe_not_equal(a, b) {\n return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');\n}\nfunction not_equal(a, b) {\n return a != a ? b == b : a !== b;\n}\nfunction is_empty(obj) {\n return Object.keys(obj).length === 0;\n}\nfunction validate_store(store, name) {\n if (store != null && typeof store.subscribe !== 'function') {\n throw new Error(`'${name}' is not a store with a 'subscribe' method`);\n }\n}\nfunction subscribe(store, ...callbacks) {\n if (store == null) {\n return noop;\n }\n const unsub = store.subscribe(...callbacks);\n return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;\n}\nfunction get_store_value(store) {\n let value;\n subscribe(store, _ => value = _)();\n return value;\n}\nfunction component_subscribe(component, store, callback) {\n component.$$.on_destroy.push(subscribe(store, callback));\n}\nfunction create_slot(definition, ctx, $$scope, fn) {\n if (definition) {\n const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);\n return definition[0](slot_ctx);\n }\n}\nfunction get_slot_context(definition, ctx, $$scope, fn) {\n return definition[1] && fn\n ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))\n : $$scope.ctx;\n}\nfunction get_slot_changes(definition, $$scope, dirty, fn) {\n if (definition[2] && fn) {\n const lets = definition[2](fn(dirty));\n if ($$scope.dirty === undefined) {\n return lets;\n }\n if (typeof lets === 'object') {\n const merged = [];\n const len = Math.max($$scope.dirty.length, lets.length);\n for (let i = 0; i < len; i += 1) {\n merged[i] = $$scope.dirty[i] | lets[i];\n }\n return merged;\n }\n return $$scope.dirty | lets;\n }\n return $$scope.dirty;\n}\nfunction update_slot(slot, slot_definition, ctx, $$scope, dirty, get_slot_changes_fn, get_slot_context_fn) {\n const slot_changes = get_slot_changes(slot_definition, $$scope, dirty, get_slot_changes_fn);\n if (slot_changes) {\n const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);\n slot.p(slot_context, slot_changes);\n }\n}\nfunction exclude_internal_props(props) {\n const result = {};\n for (const k in props)\n if (k[0] !== '$')\n result[k] = props[k];\n return result;\n}\nfunction compute_rest_props(props, keys) {\n const rest = {};\n keys = new Set(keys);\n for (const k in props)\n if (!keys.has(k) && k[0] !== '$')\n rest[k] = props[k];\n return rest;\n}\nfunction once(fn) {\n let ran = false;\n return function (...args) {\n if (ran)\n return;\n ran = true;\n fn.call(this, ...args);\n };\n}\nfunction null_to_empty(value) {\n return value == null ? '' : value;\n}\nfunction set_store_value(store, ret, value = ret) {\n store.set(value);\n return ret;\n}\nconst has_prop = (obj, prop) => Object.prototype.hasOwnProperty.call(obj, prop);\nfunction action_destroyer(action_result) {\n return action_result && is_function(action_result.destroy) ? action_result.destroy : noop;\n}\n\nconst is_client = typeof window !== 'undefined';\nlet now = is_client\n ? () => window.performance.now()\n : () => Date.now();\nlet raf = is_client ? cb => requestAnimationFrame(cb) : noop;\n// used internally for testing\nfunction set_now(fn) {\n now = fn;\n}\nfunction set_raf(fn) {\n raf = fn;\n}\n\nconst tasks = new Set();\nfunction run_tasks(now) {\n tasks.forEach(task => {\n if (!task.c(now)) {\n tasks.delete(task);\n task.f();\n }\n });\n if (tasks.size !== 0)\n raf(run_tasks);\n}\n/**\n * For testing purposes only!\n */\nfunction clear_loops() {\n tasks.clear();\n}\n/**\n * Creates a new task that runs on each raf frame\n * until it returns a falsy value or is aborted\n */\nfunction loop(callback) {\n let task;\n if (tasks.size === 0)\n raf(run_tasks);\n return {\n promise: new Promise(fulfill => {\n tasks.add(task = { c: callback, f: fulfill });\n }),\n abort() {\n tasks.delete(task);\n }\n };\n}\n\nfunction append(target, node) {\n target.appendChild(node);\n}\nfunction insert(target, node, anchor) {\n target.insertBefore(node, anchor || null);\n}\nfunction detach(node) {\n node.parentNode.removeChild(node);\n}\nfunction destroy_each(iterations, detaching) {\n for (let i = 0; i < iterations.length; i += 1) {\n if (iterations[i])\n iterations[i].d(detaching);\n }\n}\nfunction element(name) {\n return document.createElement(name);\n}\nfunction element_is(name, is) {\n return document.createElement(name, { is });\n}\nfunction object_without_properties(obj, exclude) {\n const target = {};\n for (const k in obj) {\n if (has_prop(obj, k)\n // @ts-ignore\n && exclude.indexOf(k) === -1) {\n // @ts-ignore\n target[k] = obj[k];\n }\n }\n return target;\n}\nfunction svg_element(name) {\n return document.createElementNS('http://www.w3.org/2000/svg', name);\n}\nfunction text(data) {\n return document.createTextNode(data);\n}\nfunction space() {\n return text(' ');\n}\nfunction empty() {\n return text('');\n}\nfunction listen(node, event, handler, options) {\n node.addEventListener(event, handler, options);\n return () => node.removeEventListener(event, handler, options);\n}\nfunction prevent_default(fn) {\n return function (event) {\n event.preventDefault();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction stop_propagation(fn) {\n return function (event) {\n event.stopPropagation();\n // @ts-ignore\n return fn.call(this, event);\n };\n}\nfunction self(fn) {\n return function (event) {\n // @ts-ignore\n if (event.target === this)\n fn.call(this, event);\n };\n}\nfunction attr(node, attribute, value) {\n if (value == null)\n node.removeAttribute(attribute);\n else if (node.getAttribute(attribute) !== value)\n node.setAttribute(attribute, value);\n}\nfunction set_attributes(node, attributes) {\n // @ts-ignore\n const descriptors = Object.getOwnPropertyDescriptors(node.__proto__);\n for (const key in attributes) {\n if (attributes[key] == null) {\n node.removeAttribute(key);\n }\n else if (key === 'style') {\n node.style.cssText = attributes[key];\n }\n else if (key === '__value') {\n node.value = node[key] = attributes[key];\n }\n else if (descriptors[key] && descriptors[key].set) {\n node[key] = attributes[key];\n }\n else {\n attr(node, key, attributes[key]);\n }\n }\n}\nfunction set_svg_attributes(node, attributes) {\n for (const key in attributes) {\n attr(node, key, attributes[key]);\n }\n}\nfunction set_custom_element_data(node, prop, value) {\n if (prop in node) {\n node[prop] = value;\n }\n else {\n attr(node, prop, value);\n }\n}\nfunction xlink_attr(node, attribute, value) {\n node.setAttributeNS('http://www.w3.org/1999/xlink', attribute, value);\n}\nfunction get_binding_group_value(group, __value, checked) {\n const value = new Set();\n for (let i = 0; i < group.length; i += 1) {\n if (group[i].checked)\n value.add(group[i].__value);\n }\n if (!checked) {\n value.delete(__value);\n }\n return Array.from(value);\n}\nfunction to_number(value) {\n return value === '' ? undefined : +value;\n}\nfunction time_ranges_to_array(ranges) {\n const array = [];\n for (let i = 0; i < ranges.length; i += 1) {\n array.push({ start: ranges.start(i), end: ranges.end(i) });\n }\n return array;\n}\nfunction children(element) {\n return Array.from(element.childNodes);\n}\nfunction claim_element(nodes, name, attributes, svg) {\n for (let i = 0; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeName === name) {\n let j = 0;\n const remove = [];\n while (j < node.attributes.length) {\n const attribute = node.attributes[j++];\n if (!attributes[attribute.name]) {\n remove.push(attribute.name);\n }\n }\n for (let k = 0; k < remove.length; k++) {\n node.removeAttribute(remove[k]);\n }\n return nodes.splice(i, 1)[0];\n }\n }\n return svg ? svg_element(name) : element(name);\n}\nfunction claim_text(nodes, data) {\n for (let i = 0; i < nodes.length; i += 1) {\n const node = nodes[i];\n if (node.nodeType === 3) {\n node.data = '' + data;\n return nodes.splice(i, 1)[0];\n }\n }\n return text(data);\n}\nfunction claim_space(nodes) {\n return claim_text(nodes, ' ');\n}\nfunction set_data(text, data) {\n data = '' + data;\n if (text.wholeText !== data)\n text.data = data;\n}\nfunction set_input_value(input, value) {\n input.value = value == null ? '' : value;\n}\nfunction set_input_type(input, type) {\n try {\n input.type = type;\n }\n catch (e) {\n // do nothing\n }\n}\nfunction set_style(node, key, value, important) {\n node.style.setProperty(key, value, important ? 'important' : '');\n}\nfunction select_option(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n if (option.__value === value) {\n option.selected = true;\n return;\n }\n }\n}\nfunction select_options(select, value) {\n for (let i = 0; i < select.options.length; i += 1) {\n const option = select.options[i];\n option.selected = ~value.indexOf(option.__value);\n }\n}\nfunction select_value(select) {\n const selected_option = select.querySelector(':checked') || select.options[0];\n return selected_option && selected_option.__value;\n}\nfunction select_multiple_value(select) {\n return [].map.call(select.querySelectorAll(':checked'), option => option.__value);\n}\n// unfortunately this can't be a constant as that wouldn't be tree-shakeable\n// so we cache the result instead\nlet crossorigin;\nfunction is_crossorigin() {\n if (crossorigin === undefined) {\n crossorigin = false;\n try {\n if (typeof window !== 'undefined' && window.parent) {\n void window.parent.document;\n }\n }\n catch (error) {\n crossorigin = true;\n }\n }\n return crossorigin;\n}\nfunction add_resize_listener(node, fn) {\n const computed_style = getComputedStyle(node);\n const z_index = (parseInt(computed_style.zIndex) || 0) - 1;\n if (computed_style.position === 'static') {\n node.style.position = 'relative';\n }\n const iframe = element('iframe');\n iframe.setAttribute('style', `display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ` +\n `overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: ${z_index};`);\n iframe.setAttribute('aria-hidden', 'true');\n iframe.tabIndex = -1;\n const crossorigin = is_crossorigin();\n let unsubscribe;\n if (crossorigin) {\n iframe.src = `data:text/html,`;\n unsubscribe = listen(window, 'message', (event) => {\n if (event.source === iframe.contentWindow)\n fn();\n });\n }\n else {\n iframe.src = 'about:blank';\n iframe.onload = () => {\n unsubscribe = listen(iframe.contentWindow, 'resize', fn);\n };\n }\n append(node, iframe);\n return () => {\n if (crossorigin) {\n unsubscribe();\n }\n else if (unsubscribe && iframe.contentWindow) {\n unsubscribe();\n }\n detach(iframe);\n };\n}\nfunction toggle_class(element, name, toggle) {\n element.classList[toggle ? 'add' : 'remove'](name);\n}\nfunction custom_event(type, detail) {\n const e = document.createEvent('CustomEvent');\n e.initCustomEvent(type, false, false, detail);\n return e;\n}\nfunction query_selector_all(selector, parent = document.body) {\n return Array.from(parent.querySelectorAll(selector));\n}\nclass HtmlTag {\n constructor(anchor = null) {\n this.a = anchor;\n this.e = this.n = null;\n }\n m(html, target, anchor = null) {\n if (!this.e) {\n this.e = element(target.nodeName);\n this.t = target;\n this.h(html);\n }\n this.i(anchor);\n }\n h(html) {\n this.e.innerHTML = html;\n this.n = Array.from(this.e.childNodes);\n }\n i(anchor) {\n for (let i = 0; i < this.n.length; i += 1) {\n insert(this.t, this.n[i], anchor);\n }\n }\n p(html) {\n this.d();\n this.h(html);\n this.i(this.a);\n }\n d() {\n this.n.forEach(detach);\n }\n}\n\nconst active_docs = new Set();\nlet active = 0;\n// https://github.com/darkskyapp/string-hash/blob/master/index.js\nfunction hash(str) {\n let hash = 5381;\n let i = str.length;\n while (i--)\n hash = ((hash << 5) - hash) ^ str.charCodeAt(i);\n return hash >>> 0;\n}\nfunction create_rule(node, a, b, duration, delay, ease, fn, uid = 0) {\n const step = 16.666 / duration;\n let keyframes = '{\\n';\n for (let p = 0; p <= 1; p += step) {\n const t = a + (b - a) * ease(p);\n keyframes += p * 100 + `%{${fn(t, 1 - t)}}\\n`;\n }\n const rule = keyframes + `100% {${fn(b, 1 - b)}}\\n}`;\n const name = `__svelte_${hash(rule)}_${uid}`;\n const doc = node.ownerDocument;\n active_docs.add(doc);\n const stylesheet = doc.__svelte_stylesheet || (doc.__svelte_stylesheet = doc.head.appendChild(element('style')).sheet);\n const current_rules = doc.__svelte_rules || (doc.__svelte_rules = {});\n if (!current_rules[name]) {\n current_rules[name] = true;\n stylesheet.insertRule(`@keyframes ${name} ${rule}`, stylesheet.cssRules.length);\n }\n const animation = node.style.animation || '';\n node.style.animation = `${animation ? `${animation}, ` : ``}${name} ${duration}ms linear ${delay}ms 1 both`;\n active += 1;\n return name;\n}\nfunction delete_rule(node, name) {\n const previous = (node.style.animation || '').split(', ');\n const next = previous.filter(name\n ? anim => anim.indexOf(name) < 0 // remove specific animation\n : anim => anim.indexOf('__svelte') === -1 // remove all Svelte animations\n );\n const deleted = previous.length - next.length;\n if (deleted) {\n node.style.animation = next.join(', ');\n active -= deleted;\n if (!active)\n clear_rules();\n }\n}\nfunction clear_rules() {\n raf(() => {\n if (active)\n return;\n active_docs.forEach(doc => {\n const stylesheet = doc.__svelte_stylesheet;\n let i = stylesheet.cssRules.length;\n while (i--)\n stylesheet.deleteRule(i);\n doc.__svelte_rules = {};\n });\n active_docs.clear();\n });\n}\n\nfunction create_animation(node, from, fn, params) {\n if (!from)\n return noop;\n const to = node.getBoundingClientRect();\n if (from.left === to.left && from.right === to.right && from.top === to.top && from.bottom === to.bottom)\n return noop;\n const { delay = 0, duration = 300, easing = identity, \n // @ts-ignore todo: should this be separated from destructuring? Or start/end added to public api and documentation?\n start: start_time = now() + delay, \n // @ts-ignore todo:\n end = start_time + duration, tick = noop, css } = fn(node, { from, to }, params);\n let running = true;\n let started = false;\n let name;\n function start() {\n if (css) {\n name = create_rule(node, 0, 1, duration, delay, easing, css);\n }\n if (!delay) {\n started = true;\n }\n }\n function stop() {\n if (css)\n delete_rule(node, name);\n running = false;\n }\n loop(now => {\n if (!started && now >= start_time) {\n started = true;\n }\n if (started && now >= end) {\n tick(1, 0);\n stop();\n }\n if (!running) {\n return false;\n }\n if (started) {\n const p = now - start_time;\n const t = 0 + 1 * easing(p / duration);\n tick(t, 1 - t);\n }\n return true;\n });\n start();\n tick(0, 1);\n return stop;\n}\nfunction fix_position(node) {\n const style = getComputedStyle(node);\n if (style.position !== 'absolute' && style.position !== 'fixed') {\n const { width, height } = style;\n const a = node.getBoundingClientRect();\n node.style.position = 'absolute';\n node.style.width = width;\n node.style.height = height;\n add_transform(node, a);\n }\n}\nfunction add_transform(node, a) {\n const b = node.getBoundingClientRect();\n if (a.left !== b.left || a.top !== b.top) {\n const style = getComputedStyle(node);\n const transform = style.transform === 'none' ? '' : style.transform;\n node.style.transform = `${transform} translate(${a.left - b.left}px, ${a.top - b.top}px)`;\n }\n}\n\nlet current_component;\nfunction set_current_component(component) {\n current_component = component;\n}\nfunction get_current_component() {\n if (!current_component)\n throw new Error(`Function called outside component initialization`);\n return current_component;\n}\nfunction beforeUpdate(fn) {\n get_current_component().$$.before_update.push(fn);\n}\nfunction onMount(fn) {\n get_current_component().$$.on_mount.push(fn);\n}\nfunction afterUpdate(fn) {\n get_current_component().$$.after_update.push(fn);\n}\nfunction onDestroy(fn) {\n get_current_component().$$.on_destroy.push(fn);\n}\nfunction createEventDispatcher() {\n const component = get_current_component();\n return (type, detail) => {\n const callbacks = component.$$.callbacks[type];\n if (callbacks) {\n // TODO are there situations where events could be dispatched\n // in a server (non-DOM) environment?\n const event = custom_event(type, detail);\n callbacks.slice().forEach(fn => {\n fn.call(component, event);\n });\n }\n };\n}\nfunction setContext(key, context) {\n get_current_component().$$.context.set(key, context);\n}\nfunction getContext(key) {\n return get_current_component().$$.context.get(key);\n}\n// TODO figure out if we still want to support\n// shorthand events, or if we want to implement\n// a real bubbling mechanism\nfunction bubble(component, event) {\n const callbacks = component.$$.callbacks[event.type];\n if (callbacks) {\n callbacks.slice().forEach(fn => fn(event));\n }\n}\n\nconst dirty_components = [];\nconst intros = { enabled: false };\nconst binding_callbacks = [];\nconst render_callbacks = [];\nconst flush_callbacks = [];\nconst resolved_promise = Promise.resolve();\nlet update_scheduled = false;\nfunction schedule_update() {\n if (!update_scheduled) {\n update_scheduled = true;\n resolved_promise.then(flush);\n }\n}\nfunction tick() {\n schedule_update();\n return resolved_promise;\n}\nfunction add_render_callback(fn) {\n render_callbacks.push(fn);\n}\nfunction add_flush_callback(fn) {\n flush_callbacks.push(fn);\n}\nlet flushing = false;\nconst seen_callbacks = new Set();\nfunction flush() {\n if (flushing)\n return;\n flushing = true;\n do {\n // first, call beforeUpdate functions\n // and update components\n for (let i = 0; i < dirty_components.length; i += 1) {\n const component = dirty_components[i];\n set_current_component(component);\n update(component.$$);\n }\n dirty_components.length = 0;\n while (binding_callbacks.length)\n binding_callbacks.pop()();\n // then, once components are updated, call\n // afterUpdate functions. This may cause\n // subsequent updates...\n for (let i = 0; i < render_callbacks.length; i += 1) {\n const callback = render_callbacks[i];\n if (!seen_callbacks.has(callback)) {\n // ...so guard against infinite loops\n seen_callbacks.add(callback);\n callback();\n }\n }\n render_callbacks.length = 0;\n } while (dirty_components.length);\n while (flush_callbacks.length) {\n flush_callbacks.pop()();\n }\n update_scheduled = false;\n flushing = false;\n seen_callbacks.clear();\n}\nfunction update($$) {\n if ($$.fragment !== null) {\n $$.update();\n run_all($$.before_update);\n const dirty = $$.dirty;\n $$.dirty = [-1];\n $$.fragment && $$.fragment.p($$.ctx, dirty);\n $$.after_update.forEach(add_render_callback);\n }\n}\n\nlet promise;\nfunction wait() {\n if (!promise) {\n promise = Promise.resolve();\n promise.then(() => {\n promise = null;\n });\n }\n return promise;\n}\nfunction dispatch(node, direction, kind) {\n node.dispatchEvent(custom_event(`${direction ? 'intro' : 'outro'}${kind}`));\n}\nconst outroing = new Set();\nlet outros;\nfunction group_outros() {\n outros = {\n r: 0,\n c: [],\n p: outros // parent group\n };\n}\nfunction check_outros() {\n if (!outros.r) {\n run_all(outros.c);\n }\n outros = outros.p;\n}\nfunction transition_in(block, local) {\n if (block && block.i) {\n outroing.delete(block);\n block.i(local);\n }\n}\nfunction transition_out(block, local, detach, callback) {\n if (block && block.o) {\n if (outroing.has(block))\n return;\n outroing.add(block);\n outros.c.push(() => {\n outroing.delete(block);\n if (callback) {\n if (detach)\n block.d(1);\n callback();\n }\n });\n block.o(local);\n }\n}\nconst null_transition = { duration: 0 };\nfunction create_in_transition(node, fn, params) {\n let config = fn(node, params);\n let running = false;\n let animation_name;\n let task;\n let uid = 0;\n function cleanup() {\n if (animation_name)\n delete_rule(node, animation_name);\n }\n function go() {\n const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;\n if (css)\n animation_name = create_rule(node, 0, 1, duration, delay, easing, css, uid++);\n tick(0, 1);\n const start_time = now() + delay;\n const end_time = start_time + duration;\n if (task)\n task.abort();\n running = true;\n add_render_callback(() => dispatch(node, true, 'start'));\n task = loop(now => {\n if (running) {\n if (now >= end_time) {\n tick(1, 0);\n dispatch(node, true, 'end');\n cleanup();\n return running = false;\n }\n if (now >= start_time) {\n const t = easing((now - start_time) / duration);\n tick(t, 1 - t);\n }\n }\n return running;\n });\n }\n let started = false;\n return {\n start() {\n if (started)\n return;\n delete_rule(node);\n if (is_function(config)) {\n config = config();\n wait().then(go);\n }\n else {\n go();\n }\n },\n invalidate() {\n started = false;\n },\n end() {\n if (running) {\n cleanup();\n running = false;\n }\n }\n };\n}\nfunction create_out_transition(node, fn, params) {\n let config = fn(node, params);\n let running = true;\n let animation_name;\n const group = outros;\n group.r += 1;\n function go() {\n const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;\n if (css)\n animation_name = create_rule(node, 1, 0, duration, delay, easing, css);\n const start_time = now() + delay;\n const end_time = start_time + duration;\n add_render_callback(() => dispatch(node, false, 'start'));\n loop(now => {\n if (running) {\n if (now >= end_time) {\n tick(0, 1);\n dispatch(node, false, 'end');\n if (!--group.r) {\n // this will result in `end()` being called,\n // so we don't need to clean up here\n run_all(group.c);\n }\n return false;\n }\n if (now >= start_time) {\n const t = easing((now - start_time) / duration);\n tick(1 - t, t);\n }\n }\n return running;\n });\n }\n if (is_function(config)) {\n wait().then(() => {\n // @ts-ignore\n config = config();\n go();\n });\n }\n else {\n go();\n }\n return {\n end(reset) {\n if (reset && config.tick) {\n config.tick(1, 0);\n }\n if (running) {\n if (animation_name)\n delete_rule(node, animation_name);\n running = false;\n }\n }\n };\n}\nfunction create_bidirectional_transition(node, fn, params, intro) {\n let config = fn(node, params);\n let t = intro ? 0 : 1;\n let running_program = null;\n let pending_program = null;\n let animation_name = null;\n function clear_animation() {\n if (animation_name)\n delete_rule(node, animation_name);\n }\n function init(program, duration) {\n const d = program.b - t;\n duration *= Math.abs(d);\n return {\n a: t,\n b: program.b,\n d,\n duration,\n start: program.start,\n end: program.start + duration,\n group: program.group\n };\n }\n function go(b) {\n const { delay = 0, duration = 300, easing = identity, tick = noop, css } = config || null_transition;\n const program = {\n start: now() + delay,\n b\n };\n if (!b) {\n // @ts-ignore todo: improve typings\n program.group = outros;\n outros.r += 1;\n }\n if (running_program) {\n pending_program = program;\n }\n else {\n // if this is an intro, and there's a delay, we need to do\n // an initial tick and/or apply CSS animation immediately\n if (css) {\n clear_animation();\n animation_name = create_rule(node, t, b, duration, delay, easing, css);\n }\n if (b)\n tick(0, 1);\n running_program = init(program, duration);\n add_render_callback(() => dispatch(node, b, 'start'));\n loop(now => {\n if (pending_program && now > pending_program.start) {\n running_program = init(pending_program, duration);\n pending_program = null;\n dispatch(node, running_program.b, 'start');\n if (css) {\n clear_animation();\n animation_name = create_rule(node, t, running_program.b, running_program.duration, 0, easing, config.css);\n }\n }\n if (running_program) {\n if (now >= running_program.end) {\n tick(t = running_program.b, 1 - t);\n dispatch(node, running_program.b, 'end');\n if (!pending_program) {\n // we're done\n if (running_program.b) {\n // intro — we can tidy up immediately\n clear_animation();\n }\n else {\n // outro — needs to be coordinated\n if (!--running_program.group.r)\n run_all(running_program.group.c);\n }\n }\n running_program = null;\n }\n else if (now >= running_program.start) {\n const p = now - running_program.start;\n t = running_program.a + running_program.d * easing(p / running_program.duration);\n tick(t, 1 - t);\n }\n }\n return !!(running_program || pending_program);\n });\n }\n }\n return {\n run(b) {\n if (is_function(config)) {\n wait().then(() => {\n // @ts-ignore\n config = config();\n go(b);\n });\n }\n else {\n go(b);\n }\n },\n end() {\n clear_animation();\n running_program = pending_program = null;\n }\n };\n}\n\nfunction handle_promise(promise, info) {\n const token = info.token = {};\n function update(type, index, key, value) {\n if (info.token !== token)\n return;\n info.resolved = value;\n let child_ctx = info.ctx;\n if (key !== undefined) {\n child_ctx = child_ctx.slice();\n child_ctx[key] = value;\n }\n const block = type && (info.current = type)(child_ctx);\n let needs_flush = false;\n if (info.block) {\n if (info.blocks) {\n info.blocks.forEach((block, i) => {\n if (i !== index && block) {\n group_outros();\n transition_out(block, 1, 1, () => {\n info.blocks[i] = null;\n });\n check_outros();\n }\n });\n }\n else {\n info.block.d(1);\n }\n block.c();\n transition_in(block, 1);\n block.m(info.mount(), info.anchor);\n needs_flush = true;\n }\n info.block = block;\n if (info.blocks)\n info.blocks[index] = block;\n if (needs_flush) {\n flush();\n }\n }\n if (is_promise(promise)) {\n const current_component = get_current_component();\n promise.then(value => {\n set_current_component(current_component);\n update(info.then, 1, info.value, value);\n set_current_component(null);\n }, error => {\n set_current_component(current_component);\n update(info.catch, 2, info.error, error);\n set_current_component(null);\n });\n // if we previously had a then/catch block, destroy it\n if (info.current !== info.pending) {\n update(info.pending, 0);\n return true;\n }\n }\n else {\n if (info.current !== info.then) {\n update(info.then, 1, info.value, promise);\n return true;\n }\n info.resolved = promise;\n }\n}\n\nconst globals = (typeof window !== 'undefined'\n ? window\n : typeof globalThis !== 'undefined'\n ? globalThis\n : global);\n\nfunction destroy_block(block, lookup) {\n block.d(1);\n lookup.delete(block.key);\n}\nfunction outro_and_destroy_block(block, lookup) {\n transition_out(block, 1, 1, () => {\n lookup.delete(block.key);\n });\n}\nfunction fix_and_destroy_block(block, lookup) {\n block.f();\n destroy_block(block, lookup);\n}\nfunction fix_and_outro_and_destroy_block(block, lookup) {\n block.f();\n outro_and_destroy_block(block, lookup);\n}\nfunction update_keyed_each(old_blocks, dirty, get_key, dynamic, ctx, list, lookup, node, destroy, create_each_block, next, get_context) {\n let o = old_blocks.length;\n let n = list.length;\n let i = o;\n const old_indexes = {};\n while (i--)\n old_indexes[old_blocks[i].key] = i;\n const new_blocks = [];\n const new_lookup = new Map();\n const deltas = new Map();\n i = n;\n while (i--) {\n const child_ctx = get_context(ctx, list, i);\n const key = get_key(child_ctx);\n let block = lookup.get(key);\n if (!block) {\n block = create_each_block(key, child_ctx);\n block.c();\n }\n else if (dynamic) {\n block.p(child_ctx, dirty);\n }\n new_lookup.set(key, new_blocks[i] = block);\n if (key in old_indexes)\n deltas.set(key, Math.abs(i - old_indexes[key]));\n }\n const will_move = new Set();\n const did_move = new Set();\n function insert(block) {\n transition_in(block, 1);\n block.m(node, next);\n lookup.set(block.key, block);\n next = block.first;\n n--;\n }\n while (o && n) {\n const new_block = new_blocks[n - 1];\n const old_block = old_blocks[o - 1];\n const new_key = new_block.key;\n const old_key = old_block.key;\n if (new_block === old_block) {\n // do nothing\n next = new_block.first;\n o--;\n n--;\n }\n else if (!new_lookup.has(old_key)) {\n // remove old block\n destroy(old_block, lookup);\n o--;\n }\n else if (!lookup.has(new_key) || will_move.has(new_key)) {\n insert(new_block);\n }\n else if (did_move.has(old_key)) {\n o--;\n }\n else if (deltas.get(new_key) > deltas.get(old_key)) {\n did_move.add(new_key);\n insert(new_block);\n }\n else {\n will_move.add(old_key);\n o--;\n }\n }\n while (o--) {\n const old_block = old_blocks[o];\n if (!new_lookup.has(old_block.key))\n destroy(old_block, lookup);\n }\n while (n)\n insert(new_blocks[n - 1]);\n return new_blocks;\n}\nfunction validate_each_keys(ctx, list, get_context, get_key) {\n const keys = new Set();\n for (let i = 0; i < list.length; i++) {\n const key = get_key(get_context(ctx, list, i));\n if (keys.has(key)) {\n throw new Error(`Cannot have duplicate keys in a keyed each`);\n }\n keys.add(key);\n }\n}\n\nfunction get_spread_update(levels, updates) {\n const update = {};\n const to_null_out = {};\n const accounted_for = { $$scope: 1 };\n let i = levels.length;\n while (i--) {\n const o = levels[i];\n const n = updates[i];\n if (n) {\n for (const key in o) {\n if (!(key in n))\n to_null_out[key] = 1;\n }\n for (const key in n) {\n if (!accounted_for[key]) {\n update[key] = n[key];\n accounted_for[key] = 1;\n }\n }\n levels[i] = n;\n }\n else {\n for (const key in o) {\n accounted_for[key] = 1;\n }\n }\n }\n for (const key in to_null_out) {\n if (!(key in update))\n update[key] = undefined;\n }\n return update;\n}\nfunction get_spread_object(spread_props) {\n return typeof spread_props === 'object' && spread_props !== null ? spread_props : {};\n}\n\n// source: https://html.spec.whatwg.org/multipage/indices.html\nconst boolean_attributes = new Set([\n 'allowfullscreen',\n 'allowpaymentrequest',\n 'async',\n 'autofocus',\n 'autoplay',\n 'checked',\n 'controls',\n 'default',\n 'defer',\n 'disabled',\n 'formnovalidate',\n 'hidden',\n 'ismap',\n 'loop',\n 'multiple',\n 'muted',\n 'nomodule',\n 'novalidate',\n 'open',\n 'playsinline',\n 'readonly',\n 'required',\n 'reversed',\n 'selected'\n]);\n\nconst invalid_attribute_name_character = /[\\s'\">/=\\u{FDD0}-\\u{FDEF}\\u{FFFE}\\u{FFFF}\\u{1FFFE}\\u{1FFFF}\\u{2FFFE}\\u{2FFFF}\\u{3FFFE}\\u{3FFFF}\\u{4FFFE}\\u{4FFFF}\\u{5FFFE}\\u{5FFFF}\\u{6FFFE}\\u{6FFFF}\\u{7FFFE}\\u{7FFFF}\\u{8FFFE}\\u{8FFFF}\\u{9FFFE}\\u{9FFFF}\\u{AFFFE}\\u{AFFFF}\\u{BFFFE}\\u{BFFFF}\\u{CFFFE}\\u{CFFFF}\\u{DFFFE}\\u{DFFFF}\\u{EFFFE}\\u{EFFFF}\\u{FFFFE}\\u{FFFFF}\\u{10FFFE}\\u{10FFFF}]/u;\n// https://html.spec.whatwg.org/multipage/syntax.html#attributes-2\n// https://infra.spec.whatwg.org/#noncharacter\nfunction spread(args, classes_to_add) {\n const attributes = Object.assign({}, ...args);\n if (classes_to_add) {\n if (attributes.class == null) {\n attributes.class = classes_to_add;\n }\n else {\n attributes.class += ' ' + classes_to_add;\n }\n }\n let str = '';\n Object.keys(attributes).forEach(name => {\n if (invalid_attribute_name_character.test(name))\n return;\n const value = attributes[name];\n if (value === true)\n str += \" \" + name;\n else if (boolean_attributes.has(name.toLowerCase())) {\n if (value)\n str += \" \" + name;\n }\n else if (value != null) {\n str += ` ${name}=\"${String(value).replace(/\"/g, '"').replace(/'/g, ''')}\"`;\n }\n });\n return str;\n}\nconst escaped = {\n '\"': '"',\n \"'\": ''',\n '&': '&',\n '<': '<',\n '>': '>'\n};\nfunction escape(html) {\n return String(html).replace(/[\"'&<>]/g, match => escaped[match]);\n}\nfunction each(items, fn) {\n let str = '';\n for (let i = 0; i < items.length; i += 1) {\n str += fn(items[i], i);\n }\n return str;\n}\nconst missing_component = {\n $$render: () => ''\n};\nfunction validate_component(component, name) {\n if (!component || !component.$$render) {\n if (name === 'svelte:component')\n name += ' this={...}';\n throw new Error(`<${name}> is not a valid SSR component. You may need to review your build config to ensure that dependencies are compiled, rather than imported as pre-compiled modules`);\n }\n return component;\n}\nfunction debug(file, line, column, values) {\n console.log(`{@debug} ${file ? file + ' ' : ''}(${line}:${column})`); // eslint-disable-line no-console\n console.log(values); // eslint-disable-line no-console\n return '';\n}\nlet on_destroy;\nfunction create_ssr_component(fn) {\n function $$render(result, props, bindings, slots) {\n const parent_component = current_component;\n const $$ = {\n on_destroy,\n context: new Map(parent_component ? parent_component.$$.context : []),\n // these will be immediately discarded\n on_mount: [],\n before_update: [],\n after_update: [],\n callbacks: blank_object()\n };\n set_current_component({ $$ });\n const html = fn(result, props, bindings, slots);\n set_current_component(parent_component);\n return html;\n }\n return {\n render: (props = {}, options = {}) => {\n on_destroy = [];\n const result = { title: '', head: '', css: new Set() };\n const html = $$render(result, props, {}, options);\n run_all(on_destroy);\n return {\n html,\n css: {\n code: Array.from(result.css).map(css => css.code).join('\\n'),\n map: null // TODO\n },\n head: result.title + result.head\n };\n },\n $$render\n };\n}\nfunction add_attribute(name, value, boolean) {\n if (value == null || (boolean && !value))\n return '';\n return ` ${name}${value === true ? '' : `=${typeof value === 'string' ? JSON.stringify(escape(value)) : `\"${value}\"`}`}`;\n}\nfunction add_classes(classes) {\n return classes ? ` class=\"${classes}\"` : ``;\n}\n\nfunction bind(component, name, callback) {\n const index = component.$$.props[name];\n if (index !== undefined) {\n component.$$.bound[index] = callback;\n callback(component.$$.ctx[index]);\n }\n}\nfunction create_component(block) {\n block && block.c();\n}\nfunction claim_component(block, parent_nodes) {\n block && block.l(parent_nodes);\n}\nfunction mount_component(component, target, anchor) {\n const { fragment, on_mount, on_destroy, after_update } = component.$$;\n fragment && fragment.m(target, anchor);\n // onMount happens before the initial afterUpdate\n add_render_callback(() => {\n const new_on_destroy = on_mount.map(run).filter(is_function);\n if (on_destroy) {\n on_destroy.push(...new_on_destroy);\n }\n else {\n // Edge case - component was destroyed immediately,\n // most likely as a result of a binding initialising\n run_all(new_on_destroy);\n }\n component.$$.on_mount = [];\n });\n after_update.forEach(add_render_callback);\n}\nfunction destroy_component(component, detaching) {\n const $$ = component.$$;\n if ($$.fragment !== null) {\n run_all($$.on_destroy);\n $$.fragment && $$.fragment.d(detaching);\n // TODO null out other refs, including component.$$ (but need to\n // preserve final state?)\n $$.on_destroy = $$.fragment = null;\n $$.ctx = [];\n }\n}\nfunction make_dirty(component, i) {\n if (component.$$.dirty[0] === -1) {\n dirty_components.push(component);\n schedule_update();\n component.$$.dirty.fill(0);\n }\n component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));\n}\nfunction init(component, options, instance, create_fragment, not_equal, props, dirty = [-1]) {\n const parent_component = current_component;\n set_current_component(component);\n const prop_values = options.props || {};\n const $$ = component.$$ = {\n fragment: null,\n ctx: null,\n // state\n props,\n update: noop,\n not_equal,\n bound: blank_object(),\n // lifecycle\n on_mount: [],\n on_destroy: [],\n before_update: [],\n after_update: [],\n context: new Map(parent_component ? parent_component.$$.context : []),\n // everything else\n callbacks: blank_object(),\n dirty,\n skip_bound: false\n };\n let ready = false;\n $$.ctx = instance\n ? instance(component, prop_values, (i, ret, ...rest) => {\n const value = rest.length ? rest[0] : ret;\n if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {\n if (!$$.skip_bound && $$.bound[i])\n $$.bound[i](value);\n if (ready)\n make_dirty(component, i);\n }\n return ret;\n })\n : [];\n $$.update();\n ready = true;\n run_all($$.before_update);\n // `false` as a special case of no DOM component\n $$.fragment = create_fragment ? create_fragment($$.ctx) : false;\n if (options.target) {\n if (options.hydrate) {\n const nodes = children(options.target);\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n $$.fragment && $$.fragment.l(nodes);\n nodes.forEach(detach);\n }\n else {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n $$.fragment && $$.fragment.c();\n }\n if (options.intro)\n transition_in(component.$$.fragment);\n mount_component(component, options.target, options.anchor);\n flush();\n }\n set_current_component(parent_component);\n}\nlet SvelteElement;\nif (typeof HTMLElement === 'function') {\n SvelteElement = class extends HTMLElement {\n constructor() {\n super();\n this.attachShadow({ mode: 'open' });\n }\n connectedCallback() {\n // @ts-ignore todo: improve typings\n for (const key in this.$$.slotted) {\n // @ts-ignore todo: improve typings\n this.appendChild(this.$$.slotted[key]);\n }\n }\n attributeChangedCallback(attr, _oldValue, newValue) {\n this[attr] = newValue;\n }\n $destroy() {\n destroy_component(this, 1);\n this.$destroy = noop;\n }\n $on(type, callback) {\n // TODO should this delegate to addEventListener?\n const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));\n callbacks.push(callback);\n return () => {\n const index = callbacks.indexOf(callback);\n if (index !== -1)\n callbacks.splice(index, 1);\n };\n }\n $set($$props) {\n if (this.$$set && !is_empty($$props)) {\n this.$$.skip_bound = true;\n this.$$set($$props);\n this.$$.skip_bound = false;\n }\n }\n };\n}\nclass SvelteComponent {\n $destroy() {\n destroy_component(this, 1);\n this.$destroy = noop;\n }\n $on(type, callback) {\n const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));\n callbacks.push(callback);\n return () => {\n const index = callbacks.indexOf(callback);\n if (index !== -1)\n callbacks.splice(index, 1);\n };\n }\n $set($$props) {\n if (this.$$set && !is_empty($$props)) {\n this.$$.skip_bound = true;\n this.$$set($$props);\n this.$$.skip_bound = false;\n }\n }\n}\n\nfunction dispatch_dev(type, detail) {\n document.dispatchEvent(custom_event(type, Object.assign({ version: '3.24.1' }, detail)));\n}\nfunction append_dev(target, node) {\n dispatch_dev(\"SvelteDOMInsert\", { target, node });\n append(target, node);\n}\nfunction insert_dev(target, node, anchor) {\n dispatch_dev(\"SvelteDOMInsert\", { target, node, anchor });\n insert(target, node, anchor);\n}\nfunction detach_dev(node) {\n dispatch_dev(\"SvelteDOMRemove\", { node });\n detach(node);\n}\nfunction detach_between_dev(before, after) {\n while (before.nextSibling && before.nextSibling !== after) {\n detach_dev(before.nextSibling);\n }\n}\nfunction detach_before_dev(after) {\n while (after.previousSibling) {\n detach_dev(after.previousSibling);\n }\n}\nfunction detach_after_dev(before) {\n while (before.nextSibling) {\n detach_dev(before.nextSibling);\n }\n}\nfunction listen_dev(node, event, handler, options, has_prevent_default, has_stop_propagation) {\n const modifiers = options === true ? [\"capture\"] : options ? Array.from(Object.keys(options)) : [];\n if (has_prevent_default)\n modifiers.push('preventDefault');\n if (has_stop_propagation)\n modifiers.push('stopPropagation');\n dispatch_dev(\"SvelteDOMAddEventListener\", { node, event, handler, modifiers });\n const dispose = listen(node, event, handler, options);\n return () => {\n dispatch_dev(\"SvelteDOMRemoveEventListener\", { node, event, handler, modifiers });\n dispose();\n };\n}\nfunction attr_dev(node, attribute, value) {\n attr(node, attribute, value);\n if (value == null)\n dispatch_dev(\"SvelteDOMRemoveAttribute\", { node, attribute });\n else\n dispatch_dev(\"SvelteDOMSetAttribute\", { node, attribute, value });\n}\nfunction prop_dev(node, property, value) {\n node[property] = value;\n dispatch_dev(\"SvelteDOMSetProperty\", { node, property, value });\n}\nfunction dataset_dev(node, property, value) {\n node.dataset[property] = value;\n dispatch_dev(\"SvelteDOMSetDataset\", { node, property, value });\n}\nfunction set_data_dev(text, data) {\n data = '' + data;\n if (text.wholeText === data)\n return;\n dispatch_dev(\"SvelteDOMSetData\", { node: text, data });\n text.data = data;\n}\nfunction validate_each_argument(arg) {\n if (typeof arg !== 'string' && !(arg && typeof arg === 'object' && 'length' in arg)) {\n let msg = '{#each} only iterates over array-like objects.';\n if (typeof Symbol === 'function' && arg && Symbol.iterator in arg) {\n msg += ' You can use a spread to convert this iterable into an array.';\n }\n throw new Error(msg);\n }\n}\nfunction validate_slots(name, slot, keys) {\n for (const slot_key of Object.keys(slot)) {\n if (!~keys.indexOf(slot_key)) {\n console.warn(`<${name}> received an unexpected slot \"${slot_key}\".`);\n }\n }\n}\nclass SvelteComponentDev extends SvelteComponent {\n constructor(options) {\n if (!options || (!options.target && !options.$$inline)) {\n throw new Error(`'target' is a required option`);\n }\n super();\n }\n $destroy() {\n super.$destroy();\n this.$destroy = () => {\n console.warn(`Component was already destroyed`); // eslint-disable-line no-console\n };\n }\n $capture_state() { }\n $inject_state() { }\n}\nfunction loop_guard(timeout) {\n const start = Date.now();\n return () => {\n if (Date.now() - start > timeout) {\n throw new Error(`Infinite loop detected`);\n }\n };\n}\n\nexport { HtmlTag, SvelteComponent, SvelteComponentDev, SvelteElement, action_destroyer, add_attribute, add_classes, add_flush_callback, add_location, add_render_callback, add_resize_listener, add_transform, afterUpdate, append, append_dev, assign, attr, attr_dev, beforeUpdate, bind, binding_callbacks, blank_object, bubble, check_outros, children, claim_component, claim_element, claim_space, claim_text, clear_loops, component_subscribe, compute_rest_props, createEventDispatcher, create_animation, create_bidirectional_transition, create_component, create_in_transition, create_out_transition, create_slot, create_ssr_component, current_component, custom_event, dataset_dev, debug, destroy_block, destroy_component, destroy_each, detach, detach_after_dev, detach_before_dev, detach_between_dev, detach_dev, dirty_components, dispatch_dev, each, element, element_is, empty, escape, escaped, exclude_internal_props, fix_and_destroy_block, fix_and_outro_and_destroy_block, fix_position, flush, getContext, get_binding_group_value, get_current_component, get_slot_changes, get_slot_context, get_spread_object, get_spread_update, get_store_value, globals, group_outros, handle_promise, has_prop, identity, init, insert, insert_dev, intros, invalid_attribute_name_character, is_client, is_crossorigin, is_empty, is_function, is_promise, listen, listen_dev, loop, loop_guard, missing_component, mount_component, noop, not_equal, now, null_to_empty, object_without_properties, onDestroy, onMount, once, outro_and_destroy_block, prevent_default, prop_dev, query_selector_all, raf, run, run_all, safe_not_equal, schedule_update, select_multiple_value, select_option, select_options, select_value, self, setContext, set_attributes, set_current_component, set_custom_element_data, set_data, set_data_dev, set_input_type, set_input_value, set_now, set_raf, set_store_value, set_style, set_svg_attributes, space, spread, stop_propagation, subscribe, svg_element, text, tick, time_ranges_to_array, to_number, toggle_class, transition_in, transition_out, update_keyed_each, update_slot, validate_component, validate_each_argument, validate_each_keys, validate_slots, validate_store, xlink_attr };\n","// https://github.com/kaisermann/svelte-css-vars\n\nexport const cssVars = (node, props) => {\n Object.entries(props).forEach(([key, value]) => {\n node.style.setProperty(`--${key}`, value)\n })\n\n return {\n update(new_props) {\n Object.entries(new_props).forEach(([key, value]) => {\n node.style.setProperty(`--${key}`, value)\n delete props[key]\n })\n\n Object.keys(props).forEach(name => node.style.removeProperty(`--${name}`))\n props = new_props\n },\n }\n}\n\nexport const createClasses = classes => {\n let all = \"\"\n for (let cls in classes) {\n if (classes[cls]) {\n all = all + \" \" + cls\n }\n }\n return all\n}\n\nexport default cssVars\n","\n\n{#if type === 'div'}\n
\n{:else if type === 'header'}\n
\n{:else if type === 'main'}\n
\n{:else if type === 'footer'}\n