Minor refactoring and icon updates
This commit is contained in:
parent
5b85215e10
commit
cbf3041bc1
|
@ -359,7 +359,8 @@ const getProviderContextBindings = (asset, dataProviders) => {
|
||||||
providerId,
|
providerId,
|
||||||
// Table ID is used by JSON fields to know what table the field is in
|
// Table ID is used by JSON fields to know what table the field is in
|
||||||
tableId: table?._id,
|
tableId: table?._id,
|
||||||
category: "Data",
|
category: "Dataprovider",
|
||||||
|
display: { name: readableBinding, type: fieldSchema.type },
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -387,6 +388,7 @@ const getUserBindings = () => {
|
||||||
fieldSchema,
|
fieldSchema,
|
||||||
providerId: "user",
|
providerId: "user",
|
||||||
category: "Current User",
|
category: "Current User",
|
||||||
|
display: fieldSchema,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
return bindings
|
return bindings
|
||||||
|
@ -404,12 +406,14 @@ const getDeviceBindings = () => {
|
||||||
runtimeBinding: `${safeDevice}.${makePropSafe("mobile")}`,
|
runtimeBinding: `${safeDevice}.${makePropSafe("mobile")}`,
|
||||||
readableBinding: `Device.Mobile`,
|
readableBinding: `Device.Mobile`,
|
||||||
category: "Device",
|
category: "Device",
|
||||||
|
display: { type: "string", name: "mobile" },
|
||||||
})
|
})
|
||||||
bindings.push({
|
bindings.push({
|
||||||
type: "context",
|
type: "context",
|
||||||
runtimeBinding: `${safeDevice}.${makePropSafe("tablet")}`,
|
runtimeBinding: `${safeDevice}.${makePropSafe("tablet")}`,
|
||||||
readableBinding: `Device.Tablet`,
|
readableBinding: `Device.Tablet`,
|
||||||
category: "Device",
|
category: "Device",
|
||||||
|
display: { type: "string", name: "tablet" },
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return bindings
|
return bindings
|
||||||
|
@ -433,6 +437,7 @@ const getSelectedRowsBindings = asset => {
|
||||||
"selectedRows"
|
"selectedRows"
|
||||||
)}`,
|
)}`,
|
||||||
readableBinding: `${table._instanceName}.Selected rows`,
|
readableBinding: `${table._instanceName}.Selected rows`,
|
||||||
|
category: "Dataprovider",
|
||||||
}))
|
}))
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -465,6 +470,7 @@ const getStateBindings = () => {
|
||||||
runtimeBinding: `${safeState}.${makePropSafe(key)}`,
|
runtimeBinding: `${safeState}.${makePropSafe(key)}`,
|
||||||
readableBinding: `State.${key}`,
|
readableBinding: `State.${key}`,
|
||||||
category: "State",
|
category: "State",
|
||||||
|
display: { name: key },
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
return bindings
|
return bindings
|
||||||
|
@ -505,6 +511,7 @@ const getRoleBindings = () => {
|
||||||
runtimeBinding: `trim "${role._id}"`,
|
runtimeBinding: `trim "${role._id}"`,
|
||||||
readableBinding: `Role.${role.name}`,
|
readableBinding: `Role.${role.name}`,
|
||||||
category: "Role",
|
category: "Role",
|
||||||
|
display: { name: role.name },
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,15 +53,15 @@
|
||||||
Device: "DevicePhone",
|
Device: "DevicePhone",
|
||||||
"Current User": "User",
|
"Current User": "User",
|
||||||
Helpers: "MagicWand",
|
Helpers: "MagicWand",
|
||||||
Data: "Data",
|
Dataprovider: "Data",
|
||||||
State: "AutomatedSegment",
|
State: "AutomatedSegment",
|
||||||
URL: "RailTop",
|
URL: "RailTop",
|
||||||
Role: "UsersLock",
|
Role: "UserGroup",
|
||||||
}
|
}
|
||||||
|
|
||||||
let popover
|
let popover
|
||||||
let popoverAnchor
|
let popoverAnchor
|
||||||
let hoverHelper
|
let hoverTarget
|
||||||
|
|
||||||
$: usingJS = mode === "JavaScript"
|
$: usingJS = mode === "JavaScript"
|
||||||
$: searchRgx = new RegExp(search, "ig")
|
$: searchRgx = new RegExp(search, "ig")
|
||||||
|
@ -179,21 +179,15 @@
|
||||||
bind:this={popover}
|
bind:this={popover}
|
||||||
anchor={popoverAnchor}
|
anchor={popoverAnchor}
|
||||||
maxWidth={300}
|
maxWidth={300}
|
||||||
observe={false}
|
|
||||||
>
|
>
|
||||||
<Layout gap="S">
|
<Layout gap="S">
|
||||||
{#if selectedCategory === "Helpers" || search}
|
<div class="helper">
|
||||||
<div class="helper">
|
<div class="helper__name">{hoverTarget.title}</div>
|
||||||
<div class="helper__name">{hoverHelper.displayText}</div>
|
<div class="helper__description">
|
||||||
<div class="helper__description">
|
{@html hoverTarget.description}
|
||||||
{@html hoverHelper.description}
|
|
||||||
</div>
|
|
||||||
<pre class="helper__example">{getHelperExample(
|
|
||||||
hoverHelper,
|
|
||||||
usingJS
|
|
||||||
)}</pre>
|
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
<pre class="helper__example">{hoverTarget.example}</pre>
|
||||||
|
</div>
|
||||||
</Layout>
|
</Layout>
|
||||||
</Popover>
|
</Popover>
|
||||||
</span>
|
</span>
|
||||||
|
@ -244,21 +238,53 @@
|
||||||
</div>
|
</div>
|
||||||
<ul>
|
<ul>
|
||||||
{#each category.bindings as binding}
|
{#each category.bindings as binding}
|
||||||
<!-- {JSON.stringify(binding)} -->
|
<li
|
||||||
<li class="binding" on:click={() => addBinding(binding)}>
|
class="binding"
|
||||||
<span class="binding__label">{binding.readableBinding}</span>
|
on:mouseenter={e => {
|
||||||
<!-- {#if binding.type}
|
popoverAnchor = e.target
|
||||||
<span class="binding__typeWrap">
|
if (!binding.name && !binding.description) {
|
||||||
<span class="binding__type">{binding.type}</span>
|
return
|
||||||
</span>
|
}
|
||||||
{/if} -->
|
hoverTarget = {
|
||||||
{#if binding.fieldSchema?.type}
|
title: binding.name,
|
||||||
|
description: binding.description,
|
||||||
|
}
|
||||||
|
popover.show()
|
||||||
|
e.stopPropagation()
|
||||||
|
}}
|
||||||
|
on:mouseleave={() => {
|
||||||
|
popover.hide()
|
||||||
|
popoverAnchor = null
|
||||||
|
hoverTarget = null
|
||||||
|
}}
|
||||||
|
on:focus={() => {}}
|
||||||
|
on:blur={() => {}}
|
||||||
|
on:click={() => addBinding(binding)}
|
||||||
|
>
|
||||||
|
<span class="binding__label">
|
||||||
|
{#if binding.display?.name}
|
||||||
|
{binding.display.name}
|
||||||
|
{:else if binding.fieldSchema?.name}
|
||||||
|
{binding.fieldSchema?.name}
|
||||||
|
{:else}
|
||||||
|
{binding.readableBinding}
|
||||||
|
{/if}
|
||||||
|
</span>
|
||||||
|
|
||||||
|
{#if binding.display?.type}
|
||||||
<span class="binding__typeWrap">
|
<span class="binding__typeWrap">
|
||||||
<span class="binding__type">
|
<span class="binding__type">
|
||||||
{binding.fieldSchema.type}
|
{binding.display.type}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
{:else if binding.fieldSchema?.type}
|
||||||
|
<span class="binding__typeWrap">
|
||||||
|
<span class="binding__type">
|
||||||
|
{binding.fieldSchema?.type}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
{#if binding.description}
|
{#if binding.description}
|
||||||
<br />
|
<br />
|
||||||
<div class="binding__description">
|
<div class="binding__description">
|
||||||
|
@ -277,28 +303,33 @@
|
||||||
<ul class="helpers">
|
<ul class="helpers">
|
||||||
{#each filteredHelpers as helper}
|
{#each filteredHelpers as helper}
|
||||||
<li
|
<li
|
||||||
|
class="binding"
|
||||||
on:click={() => addHelper(helper, usingJS)}
|
on:click={() => addHelper(helper, usingJS)}
|
||||||
on:mouseenter={e => {
|
on:mouseenter={e => {
|
||||||
// if (e.target !== this) return
|
|
||||||
popoverAnchor = e.target
|
popoverAnchor = e.target
|
||||||
hoverHelper = helper
|
if (!helper.displayText && helper.description) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hoverTarget = {
|
||||||
|
title: helper.displayText,
|
||||||
|
description: helper.description,
|
||||||
|
example: getHelperExample(helper, usingJS),
|
||||||
|
}
|
||||||
popover.show()
|
popover.show()
|
||||||
e.stopPropagation()
|
e.stopPropagation()
|
||||||
}}
|
}}
|
||||||
on:mouseleave={() => {
|
on:mouseleave={() => {
|
||||||
popover.hide()
|
popover.hide()
|
||||||
popoverAnchor = null
|
popoverAnchor = null
|
||||||
hoverHelper = null
|
hoverTarget = null
|
||||||
}}
|
}}
|
||||||
on:focus={() => {}}
|
on:focus={() => {}}
|
||||||
on:blur={() => {}}
|
on:blur={() => {}}
|
||||||
>
|
>
|
||||||
<span class="binding__label">{helper.displayText}</span>
|
<span class="binding__label">{helper.displayText}</span>
|
||||||
{#if helper.type}
|
<span class="binding__typeWrap">
|
||||||
<span class="binding__typeWrap">
|
<span class="binding__type">function</span>
|
||||||
<span class="binding__type">{helper.type}</span>
|
</span>
|
||||||
</span>
|
|
||||||
{/if}
|
|
||||||
</li>
|
</li>
|
||||||
{/each}
|
{/each}
|
||||||
</ul>
|
</ul>
|
||||||
|
|
Loading…
Reference in New Issue