fixed views relation picker load action and updated the record preview

This commit is contained in:
Gani Georgiev 2023-03-12 16:44:24 +02:00
parent 94d2f296b2
commit 49227f5436
5 changed files with 36 additions and 14 deletions

View File

@ -8,4 +8,4 @@ PB_DOCS_URL = "https://pocketbase.io/docs/"
PB_JS_SDK_URL = "https://github.com/pocketbase/js-sdk" PB_JS_SDK_URL = "https://github.com/pocketbase/js-sdk"
PB_DART_SDK_URL = "https://github.com/pocketbase/dart-sdk" PB_DART_SDK_URL = "https://github.com/pocketbase/dart-sdk"
PB_RELEASES = "https://github.com/pocketbase/pocketbase/releases" PB_RELEASES = "https://github.com/pocketbase/pocketbase/releases"
PB_VERSION = "v0.13.2" PB_VERSION = "v0.13.3"

View File

@ -2,6 +2,7 @@
import CommonHelper from "@/utils/CommonHelper"; import CommonHelper from "@/utils/CommonHelper";
import tooltip from "@/actions/tooltip"; import tooltip from "@/actions/tooltip";
import FormattedDate from "@/components/base/FormattedDate.svelte"; import FormattedDate from "@/components/base/FormattedDate.svelte";
import CopyIcon from "@/components/base/CopyIcon.svelte";
import RecordFileThumb from "@/components/records/RecordFileThumb.svelte"; import RecordFileThumb from "@/components/records/RecordFileThumb.svelte";
import RecordInfo from "@/components/records/RecordInfo.svelte"; import RecordInfo from "@/components/records/RecordInfo.svelte";
import TinyMCE from "@tinymce/tinymce-svelte"; import TinyMCE from "@tinymce/tinymce-svelte";
@ -14,11 +15,17 @@
</script> </script>
{#if field.type === "json"} {#if field.type === "json"}
<span class="txt txt-ellipsis"> {@const stringifiedJson = JSON.stringify(rawValue)}
{short {#if short}
? CommonHelper.truncate(JSON.stringify(rawValue)) <span class="txt txt-ellipsis">
: CommonHelper.truncate(JSON.stringify(rawValue, null, 2), 2000, true)} {CommonHelper.truncate(stringifiedJson)}
</span> </span>
{:else}
<span class="txt">
{CommonHelper.truncate(stringifiedJson, 500, true)}
</span>
<CopyIcon value={JSON.stringify(rawValue, null, 2)} />
{/if}
{:else if CommonHelper.isEmpty(rawValue)} {:else if CommonHelper.isEmpty(rawValue)}
<span class="txt-hint">N/A</span> <span class="txt-hint">N/A</span>
{:else if field.type === "bool"} {:else if field.type === "bool"}
@ -103,5 +110,12 @@
{CommonHelper.truncate(rawValue)} {CommonHelper.truncate(rawValue)}
</span> </span>
{:else} {:else}
<span class="block txt-break">{CommonHelper.truncate(rawValue, 2000)}</span> <div class="block txt-break fallback-block">{rawValue}</div>
{/if} {/if}
<style>
.fallback-block {
max-height: 100px;
overflow: auto;
}
</style>

View File

@ -33,11 +33,11 @@
<h4><strong>{collection?.name}</strong> record preview</h4> <h4><strong>{collection?.name}</strong> record preview</h4>
</svelte:fragment> </svelte:fragment>
<table class="table-border"> <table class="table-border preview-table">
<tbody> <tbody>
<tr> <tr>
<td class="min-width txt-hint txt-bold">id</td> <td class="min-width txt-hint txt-bold">id</td>
<td> <td class="col-field">
<div class="label"> <div class="label">
<CopyIcon value={record.id} /> <CopyIcon value={record.id} />
<span class="txt">{record.id}</span> <span class="txt">{record.id}</span>
@ -48,7 +48,7 @@
{#each collection?.schema as field} {#each collection?.schema as field}
<tr> <tr>
<td class="min-width txt-hint txt-bold">{field.name}</td> <td class="min-width txt-hint txt-bold">{field.name}</td>
<td> <td class="col-field">
<RecordFieldValue {field} {record} /> <RecordFieldValue {field} {record} />
</td> </td>
</tr> </tr>
@ -57,14 +57,14 @@
{#if record.created} {#if record.created}
<tr> <tr>
<td class="min-width txt-hint txt-bold">created</td> <td class="min-width txt-hint txt-bold">created</td>
<td><FormattedDate date={record.created} /></td> <td class="col-field"><FormattedDate date={record.created} /></td>
</tr> </tr>
{/if} {/if}
{#if record.updated} {#if record.updated}
<tr> <tr>
<td class="min-width txt-hint txt-bold">updated</td> <td class="min-width txt-hint txt-bold">updated</td>
<td><FormattedDate date={record.updated} /></td> <td class="col-field"><FormattedDate date={record.updated} /></td>
</tr> </tr>
{/if} {/if}
</tbody> </tbody>
@ -76,3 +76,9 @@
</button> </button>
</svelte:fragment> </svelte:fragment>
</OverlayPanel> </OverlayPanel>
<style lang="scss">
.col-field {
max-width: 1px; // text overflow workaround
}
</style>

View File

@ -134,7 +134,7 @@
const result = await ApiClient.collection(collectionId).getList(page, batchSize, { const result = await ApiClient.collection(collectionId).getList(page, batchSize, {
filter: filter, filter: filter,
sort: "-created", sort: !collection?.isView ? "-created" : "",
$cancelKey: uniqueId + "loadList", $cancelKey: uniqueId + "loadList",
}); });

View File

@ -25,6 +25,7 @@
try { try {
collections = await ApiClient.collections.getFullList(100, { collections = await ApiClient.collections.getFullList(100, {
$cancelKey: uniqueId, $cancelKey: uniqueId,
sort: "updated",
}); });
// delete timestamps // delete timestamps
for (let collection of collections) { for (let collection of collections) {
@ -70,9 +71,10 @@
</p> </p>
</div> </div>
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<div <div
tabindex="0"
bind:this={previewContainer} bind:this={previewContainer}
tabindex="0"
class="export-preview" class="export-preview"
on:keydown={(e) => { on:keydown={(e) => {
// select all // select all