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) {
return []
}
return Array.isArray(currentScreens) ? currentScreens : Object.values(currentScreens)
return Array.isArray(currentScreens)
? currentScreens
: Object.values(currentScreens)
})
export const initialise = async () => {

View File

@ -1,15 +1,24 @@
import { get, writable } from "svelte/store"
import {cloneDeep} from "lodash/fp"
import { createProps, getBuiltin, makePropsSafe } from "components/userInterface/pagesParsing/createProps"
import { cloneDeep } from "lodash/fp"
import {
createProps,
getBuiltin,
makePropsSafe,
} from "components/userInterface/pagesParsing/createProps"
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 { fetchComponentLibDefinitions } from "../loadComponentLibraries"
import api from "../api"
import { DEFAULT_PAGES_OBJECT } from "../../constants"
import getNewComponentName from "../getNewComponentName"
import analytics from "analytics"
import { findChildComponentType, generateNewIdsForComponent, getComponentDefinition, getParent } from "../storeUtils"
import {
findChildComponentType,
generateNewIdsForComponent,
getComponentDefinition,
getParent,
} from "../storeUtils"
const INITIAL_FRONTEND_STATE = {
apps: [],
@ -165,7 +174,9 @@ export const getFrontendStore = () => {
const json = await response.json()
screen._rev = json.rev
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) {
currentPageScreens.splice(foundScreen, 1)
}
@ -318,14 +329,11 @@ export const getFrontendStore = () => {
const instanceId = get(backendUiStore).selectedDatabase._id
const instanceName = getNewComponentName(component, state)
const newComponent = createProps(
component,
{
...presetProps,
_instanceId: instanceId,
_instanceName: instanceName,
}
)
const newComponent = createProps(component, {
...presetProps,
_instanceId: instanceId,
_instanceName: instanceName,
})
const currentComponent =
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 => {
prop._id = uuid()
if (changeName) prop._instanceName = getNewComponentName(prop, state)

View File

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

View File

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

View File

@ -24,15 +24,12 @@
let componentToDelete = ""
const normalizedName = name =>
pipe(
name,
[
trimCharsStart("./"),
trimCharsStart("~/"),
trimCharsStart("../"),
trimChars(" "),
]
)
pipe(name, [
trimCharsStart("./"),
trimCharsStart("~/"),
trimCharsStart("../"),
trimChars(" "),
])
const changeScreen = screen => {
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 get_name = s => (!s ? "" : last(s.split("/")))
const get_capitalised_name = name =>
pipe(
name,
[get_name, capitalise]
)
const get_capitalised_name = name => pipe(name, [get_name, capitalise])
const isScreenslot = name => name === "##builtin/screenslot"
const selectComponent = component => {