This commit is contained in:
mike12345567 2020-11-06 12:31:47 +00:00
parent 667052e0b4
commit 36d90959ff
7 changed files with 39 additions and 38 deletions

View File

@ -26,7 +26,9 @@ export const currentScreens = derived(store, $store => {
if (currentScreens == null) { if (currentScreens == null) {
return [] return []
} }
return Array.isArray(currentScreens) ? currentScreens : Object.values(currentScreens) return Array.isArray(currentScreens)
? currentScreens
: Object.values(currentScreens)
}) })
export const initialise = async () => { export const initialise = async () => {

View File

@ -1,6 +1,10 @@
import { get, writable } from "svelte/store" import { get, writable } from "svelte/store"
import { cloneDeep } from "lodash/fp" import { cloneDeep } from "lodash/fp"
import { createProps, getBuiltin, makePropsSafe } from "components/userInterface/pagesParsing/createProps" import {
createProps,
getBuiltin,
makePropsSafe,
} from "components/userInterface/pagesParsing/createProps"
import { getExactComponent } from "components/userInterface/pagesParsing/searchComponents" import { getExactComponent } from "components/userInterface/pagesParsing/searchComponents"
import { allScreens, backendUiStore } from "builderStore" import { allScreens, backendUiStore } from "builderStore"
import { generate_screen_css } from "../generate_css" import { generate_screen_css } from "../generate_css"
@ -9,7 +13,12 @@ import api from "../api"
import { DEFAULT_PAGES_OBJECT } from "../../constants" import { DEFAULT_PAGES_OBJECT } from "../../constants"
import getNewComponentName from "../getNewComponentName" import getNewComponentName from "../getNewComponentName"
import analytics from "analytics" import analytics from "analytics"
import { findChildComponentType, generateNewIdsForComponent, getComponentDefinition, getParent } from "../storeUtils" import {
findChildComponentType,
generateNewIdsForComponent,
getComponentDefinition,
getParent,
} from "../storeUtils"
const INITIAL_FRONTEND_STATE = { const INITIAL_FRONTEND_STATE = {
apps: [], apps: [],
@ -165,7 +174,9 @@ export const getFrontendStore = () => {
const json = await response.json() const json = await response.json()
screen._rev = json.rev screen._rev = json.rev
screen._id = json.id screen._id = json.id
const foundScreen = currentPageScreens.findIndex(el => el._id === screen._id) const foundScreen = currentPageScreens.findIndex(
el => el._id === screen._id
)
if (currentPageScreens !== -1) { if (currentPageScreens !== -1) {
currentPageScreens.splice(foundScreen, 1) currentPageScreens.splice(foundScreen, 1)
} }
@ -318,14 +329,11 @@ export const getFrontendStore = () => {
const instanceId = get(backendUiStore).selectedDatabase._id const instanceId = get(backendUiStore).selectedDatabase._id
const instanceName = getNewComponentName(component, state) const instanceName = getNewComponentName(component, state)
const newComponent = createProps( const newComponent = createProps(component, {
component,
{
...presetProps, ...presetProps,
_instanceId: instanceId, _instanceId: instanceId,
_instanceName: instanceName, _instanceName: instanceName,
} })
)
const currentComponent = const currentComponent =
state.components[state.currentComponentInfo._component] state.components[state.currentComponentInfo._component]

View File

@ -36,7 +36,11 @@ export const walkProps = (props, action, cancelToken = null) => {
} }
} }
export const generateNewIdsForComponent = (component, state, changeName = true) => export const generateNewIdsForComponent = (
component,
state,
changeName = true
) =>
walkProps(component, prop => { walkProps(component, prop => {
prop._id = uuid() prop._id = uuid()
if (changeName) prop._instanceName = getNewComponentName(prop, state) if (changeName) prop._instanceName = getNewComponentName(prop, state)

View File

@ -99,9 +99,7 @@
</script> </script>
<div bind:this={anchor} on:click|stopPropagation> <div bind:this={anchor} on:click|stopPropagation>
<div class="icon" on:click={dropdown.show}> <div class="icon" on:click={dropdown.show}><i class="ri-more-line" /></div>
<i class="ri-more-line" />
</div>
<DropdownMenu bind:this={dropdown} width="170px" {anchor} align="left"> <DropdownMenu bind:this={dropdown} width="170px" {anchor} align="left">
<DropdownContainer on:click={hideDropdown}> <DropdownContainer on:click={hideDropdown}>
<DropdownItem <DropdownItem

View File

@ -39,13 +39,9 @@
class="category" class="category"
on:click={() => onCategoryChosen(category, idx)} on:click={() => onCategoryChosen(category, idx)}
class:active={idx === selectedIndex}> class:active={idx === selectedIndex}>
{#if category.icon} {#if category.icon}<i class={category.icon} />{/if}
<i class={category.icon} />
{/if}
<span>{category.name}</span> <span>{category.name}</span>
{#if category.isCategory} {#if category.isCategory}<i class="ri-arrow-down-s-line arrow" />{/if}
<i class="ri-arrow-down-s-line arrow" />
{/if}
</div> </div>
{/each} {/each}
</div> </div>

View File

@ -24,15 +24,12 @@
let componentToDelete = "" let componentToDelete = ""
const normalizedName = name => const normalizedName = name =>
pipe( pipe(name, [
name,
[
trimCharsStart("./"), trimCharsStart("./"),
trimCharsStart("~/"), trimCharsStart("~/"),
trimCharsStart("../"), trimCharsStart("../"),
trimChars(" "), trimChars(" "),
] ])
)
const changeScreen = screen => { const changeScreen = screen => {
store.actions.screens.select(screen.props._instanceName) store.actions.screens.select(screen.props._instanceName)

View File

@ -35,11 +35,7 @@
const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1) const capitalise = s => s.substring(0, 1).toUpperCase() + s.substring(1)
const get_name = s => (!s ? "" : last(s.split("/"))) const get_name = s => (!s ? "" : last(s.split("/")))
const get_capitalised_name = name => const get_capitalised_name = name => pipe(name, [get_name, capitalise])
pipe(
name,
[get_name, capitalise]
)
const isScreenslot = name => name === "##builtin/screenslot" const isScreenslot = name => name === "##builtin/screenslot"
const selectComponent = component => { const selectComponent = component => {