Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/bundle.css

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dist/bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/bundle.js.map

Large diffs are not rendered by default.

61 changes: 39 additions & 22 deletions src/components/CustomJsUi.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script>
import { onMount } from 'svelte';
import { config as configStore, mapObj as mapObjStore } from '../stores';

export let mapId;
Expand All @@ -20,6 +21,19 @@

$: checkboxOptions = validActions.filter(ui => ui.type === 'checkbox');

let checkboxState = null;

$: if (mapId) {
checkboxState = null;
}

$: if (checkboxOptions && !checkboxState) {
checkboxState = checkboxOptions.reduce((acc, co, i) => {
acc[i] = co?.state;
return acc;
}, {});
}

let selectedDropdown = null;

$: {
Expand All @@ -37,11 +51,12 @@
fn();
};

const onClickCheckbox = script => {
const onClickCheckbox = (script, scriptIndex) => {
const relevantState = checkboxState?.[scriptIndex];
const index = mapIdIndex.split('-').pop();
if (!mapObj || !script) return;
const fn = script(mapObj);
fn();
fn(relevantState, v => (checkboxState[scriptIndex] = v));
};

const getInitialCheck = checked => {
Expand Down Expand Up @@ -94,26 +109,28 @@
</select>
{/if}

{#if checkboxOptions.length}
<div class="checkbox-container">
{#each checkboxOptions as checkboxAction, i}
<div class="checkbox-options">
<div class="checkbox-label">{checkboxAction?.label}:</div>
{#each checkboxAction?.options as checkboxOption, iter}
{#if checkboxOption?.script(mapObj)}
<input
type="checkbox"
id={iter}
checked={getInitialCheck(checkboxOption?.checked)}
on:click={() => onClickCheckbox(checkboxOption?.script)}
/>
<label for={iter}>{checkboxOption?.label}</label>
{/if}
{/each}
</div>
{/each}
</div>
{/if}
{#key mapId}
{#if checkboxOptions.length}
<div class="checkbox-container">
{#each checkboxOptions as checkboxAction, i}
<div class="checkbox-options">
<div class="checkbox-label">{checkboxAction?.label}:</div>
{#each checkboxAction?.options as checkboxOption, iter}
{#if checkboxOption?.script(mapObj)}
<input
type="checkbox"
id={iter}
checked={getInitialCheck(checkboxOption?.checked)}
on:click={() => onClickCheckbox(checkboxOption?.script, i)}
/>
<label for={iter}>{checkboxOption?.label}</label>
{/if}
{/each}
</div>
{/each}
</div>
{/if}
{/key}
</div>
{/if}

Expand Down
2 changes: 0 additions & 2 deletions src/components/Map.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,6 @@
$: setMapComponent(mapRenderer);

$: mapStateProps = getMapStateProps($$restProps);

$: console.log(map);
</script>

<div class="map-container">
Expand Down