final tidy up

This commit is contained in:
Martin McKeaveney 2020-02-12 10:12:08 +00:00
parent 67db93bb39
commit 5729f46ae6
3 changed files with 21 additions and 20 deletions

View File

@ -461,10 +461,10 @@ const saveScreen = store => screen => {
}) })
} }
const _saveScreen = (store, s, screen) => { const _saveScreen = async (store, s, screen) => {
const currentPageScreens = s.pages[s.currentPageName]._screens const currentPageScreens = s.pages[s.currentPageName]._screens
api await api
.post(`/_builder/api/${s.appname}/pages/${s.currentPageName}/screen`, screen) .post(`/_builder/api/${s.appname}/pages/${s.currentPageName}/screen`, screen)
.then(async savedScreen => { .then(async savedScreen => {
_savePage(s); _savePage(s);

View File

@ -38,8 +38,6 @@
component.component && component.component &&
$store.currentPreviewItem && $store.currentPreviewItem &&
component.component.name === $store.currentPreviewItem.name component.component.name === $store.currentPreviewItem.name
$: console.log(_screens)
</script> </script>
<div class="root"> <div class="root">

View File

@ -12,12 +12,11 @@
let bindingPath = ""; let bindingPath = "";
let bindingFallbackValue = ""; let bindingFallbackValue = "";
let bindingSource = "store"; let bindingSource = "store";
let bindingValue = "";
const clearBinding = () => onChanged("");
const bind = (path, fallback, source) => { const bind = (path, fallback, source) => {
if (!path) { if (!path) {
clearBinding(""); onChanged(fallback);
return; return;
} }
const binding = setBinding({ path, fallback, source }); const binding = setBinding({ path, fallback, source });
@ -36,11 +35,8 @@
const binding = getBinding(value); const binding = getBinding(value);
if (bindingPath !== binding.path) isOpen = false; if (bindingPath !== binding.path) isOpen = false;
bindingPath = binding.path; bindingPath = binding.path;
bindingFallbackValue = binding.fallback bindingValue = typeof value === "object" ? "" : value;
? binding.fallback bindingFallbackValue = binding.fallback || bindingValue;
: typeof value === "object"
? ""
: value;
const currentScreen = $store.screens.find( const currentScreen = $store.screens.find(
({ name }) => name === $store.currentPreviewItem.name ({ name }) => name === $store.currentPreviewItem.name
@ -52,8 +48,9 @@
<div class="cascader"> <div class="cascader">
<div class="input-box"> <div class="input-box">
<input <input
class:bold={!bindingFallbackValue && bindingPath}
class="uk-input uk-form-small" class="uk-input uk-form-small"
value={bindingFallbackValue} value={bindingFallbackValue || bindingPath}
on:change={e => { on:change={e => {
setBindingFallback(e.target.value); setBindingFallback(e.target.value);
onChanged(e.target.value); onChanged(e.target.value);
@ -61,10 +58,8 @@
<button on:click={() => (isOpen = !isOpen)}> <button on:click={() => (isOpen = !isOpen)}>
<div <div
class="icon" class="icon"
style={` class:highlighted={bindingPath}
transform: rotate(${isOpen ? 0 : 90}deg); style={`transform: rotate(${isOpen ? 0 : 90}deg);`}>
color: ${bindingPath ? 'rgba(0, 85, 255, 0.8);' : 'inherit;'}
`}>
<ArrowDownIcon size={36} /> <ArrowDownIcon size={36} />
</div> </div>
</button> </button>
@ -73,7 +68,7 @@
<ul class="options"> <ul class="options">
{#each Object.keys(stateBindings) as stateBinding} {#each Object.keys(stateBindings) as stateBinding}
<li <li
style={stateBinding === bindingPath && 'font-weight: bold;'} class:bold={stateBinding === bindingPath}
on:click={() => { on:click={() => {
setBindingPath(stateBinding === bindingPath ? null : stateBinding); setBindingPath(stateBinding === bindingPath ? null : stateBinding);
}}> }}>
@ -85,6 +80,14 @@
</div> </div>
<style> <style>
.bold {
font-weight: bold;
}
.highlighted {
color: rgba(0, 85, 255, 0.8);
}
button { button {
cursor: pointer; cursor: pointer;
outline: none; outline: none;