removed js sdk dto helpers
This commit is contained in:
@@ -162,7 +162,7 @@
|
||||
<span class="txt">API Preview</span>
|
||||
</button>
|
||||
|
||||
{#if !$activeCollection.$isView}
|
||||
{#if $activeCollection.type !== "view"}
|
||||
<button type="button" class="btn btn-expanded" on:click={() => recordUpsertPanel?.show()}>
|
||||
<i class="ri-add-line" />
|
||||
<span class="txt">New record</span>
|
||||
@@ -184,7 +184,7 @@
|
||||
bind:filter
|
||||
bind:sort
|
||||
on:select={(e) => {
|
||||
$activeCollection.$isView
|
||||
$activeCollection.type === "view"
|
||||
? recordPreviewPanel.show(e?.detail)
|
||||
: recordUpsertPanel?.show(e?.detail);
|
||||
}}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script>
|
||||
import { Record } from "pocketbase";
|
||||
import OverlayPanel from "@/components/base/OverlayPanel.svelte";
|
||||
import RecordFieldValue from "./RecordFieldValue.svelte";
|
||||
import CopyIcon from "@/components/base/CopyIcon.svelte";
|
||||
@@ -8,7 +7,7 @@
|
||||
export let collection;
|
||||
|
||||
let recordPanel;
|
||||
let record = new Record();
|
||||
let record = {};
|
||||
|
||||
$: hasEditorField = !!collection?.schema?.find((f) => f.type === "editor");
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script>
|
||||
import { createEventDispatcher, tick } from "svelte";
|
||||
import { slide } from "svelte/transition";
|
||||
import { Record } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
@@ -46,6 +45,8 @@
|
||||
let isNew = true;
|
||||
let isLoaded = false;
|
||||
|
||||
$: isAuthCollection = collection?.type === "auth";
|
||||
|
||||
$: hasEditorField = !!collection?.schema?.find((f) => f.type === "editor");
|
||||
|
||||
$: hasFileChanges =
|
||||
@@ -55,7 +56,7 @@
|
||||
|
||||
$: hasChanges = hasFileChanges || originalSerializedData != serializedData;
|
||||
|
||||
$: isNew = !original || original.$isNew;
|
||||
$: isNew = !original || !original.id;
|
||||
|
||||
$: canSave = isNew || hasChanges;
|
||||
|
||||
@@ -80,8 +81,8 @@
|
||||
async function load(model) {
|
||||
isLoaded = false;
|
||||
setErrors({}); // reset errors
|
||||
original = model || new Record();
|
||||
record = original.$clone();
|
||||
original = model || {};
|
||||
record = structuredClone(original);
|
||||
uploadedFilesMap = {};
|
||||
deletedFileNamesMap = {};
|
||||
|
||||
@@ -102,13 +103,13 @@
|
||||
|
||||
async function replaceOriginal(newOriginal) {
|
||||
setErrors({}); // reset errors
|
||||
original = newOriginal || new Record();
|
||||
original = newOriginal || {};
|
||||
uploadedFilesMap = {};
|
||||
deletedFileNamesMap = {};
|
||||
|
||||
// to avoid layout shifts we replace only the file and non-schema fields
|
||||
const skipFields = collection?.schema?.filter((f) => f.type != "file")?.map((f) => f.name) || [];
|
||||
for (let k in newOriginal.$export()) {
|
||||
for (let k in newOriginal) {
|
||||
if (skipFields.includes(k)) {
|
||||
continue;
|
||||
}
|
||||
@@ -150,20 +151,20 @@
|
||||
}
|
||||
|
||||
function areRecordsEqual(recordA, recordB) {
|
||||
const cloneA = recordA?.$clone();
|
||||
const cloneB = recordB?.$clone();
|
||||
const cloneA = structuredClone(recordA || {});
|
||||
const cloneB = structuredClone(recordB || {});
|
||||
|
||||
const fileFields = collection?.schema?.filter((f) => f.type === "file");
|
||||
for (let field of fileFields) {
|
||||
delete cloneA?.[field.name];
|
||||
delete cloneB?.[field.name];
|
||||
delete cloneA[field.name];
|
||||
delete cloneB[field.name];
|
||||
}
|
||||
|
||||
// delete password props
|
||||
delete cloneA?.password;
|
||||
delete cloneA?.passwordConfirm;
|
||||
delete cloneB?.password;
|
||||
delete cloneB?.passwordConfirm;
|
||||
delete cloneA.password;
|
||||
delete cloneA.passwordConfirm;
|
||||
delete cloneB.password;
|
||||
delete cloneB.passwordConfirm;
|
||||
|
||||
return JSON.stringify(cloneA) == JSON.stringify(cloneB);
|
||||
}
|
||||
@@ -232,7 +233,7 @@
|
||||
}
|
||||
|
||||
function exportFormData() {
|
||||
const data = record?.$export() || {};
|
||||
const data = structuredClone(record || {});
|
||||
const formData = new FormData();
|
||||
|
||||
const exportableFields = {
|
||||
@@ -243,7 +244,7 @@
|
||||
exportableFields[field.name] = true;
|
||||
}
|
||||
|
||||
if (collection?.isAuth) {
|
||||
if (isAuthCollection) {
|
||||
exportableFields["username"] = true;
|
||||
exportableFields["email"] = true;
|
||||
exportableFields["emailVisibility"] = true;
|
||||
@@ -331,7 +332,7 @@
|
||||
}
|
||||
|
||||
async function duplicate() {
|
||||
const clone = original?.$clone();
|
||||
let clone = original ? structuredClone(original) : null;
|
||||
|
||||
if (clone) {
|
||||
clone.id = "";
|
||||
@@ -369,7 +370,7 @@
|
||||
class="
|
||||
record-panel
|
||||
{hasEditorField ? 'overlay-panel-xl' : 'overlay-panel-lg'}
|
||||
{collection?.$isAuth && !isNew ? 'colored-header' : ''}
|
||||
{isAuthCollection && !isNew ? 'colored-header' : ''}
|
||||
"
|
||||
beforeHide={() => {
|
||||
if (hasChanges && confirmClose) {
|
||||
@@ -400,7 +401,7 @@
|
||||
<button type="button" aria-label="More" class="btn btn-sm btn-circle btn-transparent flex-gap-0">
|
||||
<i class="ri-more-line" />
|
||||
<Toggler class="dropdown dropdown-right dropdown-nowrap">
|
||||
{#if collection.$isAuth && !original.verified && original.email}
|
||||
{#if isAuthCollection && !original.verified && original.email}
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item closable"
|
||||
@@ -410,7 +411,7 @@
|
||||
<span class="txt">Send verification email</span>
|
||||
</button>
|
||||
{/if}
|
||||
{#if collection.$isAuth && original.email}
|
||||
{#if isAuthCollection && original.email}
|
||||
<button
|
||||
type="button"
|
||||
class="dropdown-item closable"
|
||||
@@ -436,7 +437,7 @@
|
||||
</button>
|
||||
{/if}
|
||||
|
||||
{#if collection.$isAuth && !isNew}
|
||||
{#if isAuthCollection && !isNew}
|
||||
<div class="tabs-header stretched">
|
||||
<button
|
||||
type="button"
|
||||
@@ -523,7 +524,7 @@
|
||||
/>
|
||||
</Field>
|
||||
|
||||
{#if collection?.isAuth}
|
||||
{#if isAuthCollection}
|
||||
<AuthFields bind:record {isNew} {collection} />
|
||||
|
||||
{#if collection?.schema?.length}
|
||||
@@ -564,7 +565,7 @@
|
||||
{/each}
|
||||
</form>
|
||||
|
||||
{#if collection.$isAuth && !isNew}
|
||||
{#if isAuthCollection && !isNew}
|
||||
<div class="tab-item" class:active={activeTab === tabProviderKey}>
|
||||
<ExternalAuthsList {record} />
|
||||
</div>
|
||||
|
||||
@@ -37,6 +37,10 @@
|
||||
clearList();
|
||||
}
|
||||
|
||||
$: isView = collection?.type === "view";
|
||||
|
||||
$: isAuth = collection?.type === "auth";
|
||||
|
||||
$: fields = collection?.schema || [];
|
||||
|
||||
$: relFields = fields.filter((field) => field.type === "relation");
|
||||
@@ -57,12 +61,12 @@
|
||||
updateStoredHiddenColumns();
|
||||
}
|
||||
|
||||
$: hasCreated = !collection?.$isView || (records.length > 0 && records[0].created != "");
|
||||
$: hasCreated = !isView || (records.length > 0 && records[0].created != "");
|
||||
|
||||
$: hasUpdated = !collection?.$isView || (records.length > 0 && records[0].updated != "");
|
||||
$: hasUpdated = !isView || (records.length > 0 && records[0].updated != "");
|
||||
|
||||
$: collumnsToHide = [].concat(
|
||||
collection.$isAuth
|
||||
isAuth
|
||||
? [
|
||||
{ id: "@username", name: "username" },
|
||||
{ id: "@email", name: "email" },
|
||||
@@ -278,7 +282,7 @@
|
||||
<table class="table" class:table-loading={isLoading}>
|
||||
<thead>
|
||||
<tr>
|
||||
{#if !collection.$isView}
|
||||
{#if !isView}
|
||||
<th class="bulk-select-col min-width">
|
||||
{#if isLoading}
|
||||
<span class="loader loader-sm" />
|
||||
@@ -306,7 +310,7 @@
|
||||
</SortHeader>
|
||||
{/if}
|
||||
|
||||
{#if collection.$isAuth}
|
||||
{#if isAuth}
|
||||
{#if !hiddenColumns.includes("@username")}
|
||||
<SortHeader class="col-type-text col-field-id" name="username" bind:sort>
|
||||
<div class="col-header-content">
|
||||
@@ -371,7 +375,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each records as record (!collection.$isView ? record.id : record)}
|
||||
{#each records as record (!isView ? record.id : record)}
|
||||
<tr
|
||||
tabindex="0"
|
||||
class="row-handle"
|
||||
@@ -383,7 +387,7 @@
|
||||
}
|
||||
}}
|
||||
>
|
||||
{#if !collection.$isView}
|
||||
{#if !isView}
|
||||
<td class="bulk-select-col min-width">
|
||||
<!-- svelte-ignore a11y-click-events-have-key-events -->
|
||||
<div class="form-field" on:click|stopPropagation>
|
||||
@@ -406,7 +410,7 @@
|
||||
<div class="txt">{record.id}</div>
|
||||
</div>
|
||||
|
||||
{#if collection.$isAuth}
|
||||
{#if isAuth}
|
||||
{#if record.verified}
|
||||
<i
|
||||
class="ri-checkbox-circle-fill txt-sm txt-success"
|
||||
@@ -423,7 +427,7 @@
|
||||
</td>
|
||||
{/if}
|
||||
|
||||
{#if collection.$isAuth}
|
||||
{#if isAuth}
|
||||
{#if !hiddenColumns.includes("@username")}
|
||||
<td class="col-type-text col-field-username">
|
||||
{#if CommonHelper.isEmpty(record.username)}
|
||||
@@ -489,7 +493,7 @@
|
||||
>
|
||||
<span class="txt">Clear filters</span>
|
||||
</button>
|
||||
{:else if !collection?.$isView}
|
||||
{:else if !isView}
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-secondary btn-expanded m-t-sm"
|
||||
|
||||
@@ -40,6 +40,8 @@
|
||||
loadList(true); // reset list on filter change
|
||||
}
|
||||
|
||||
$: isView = collection?.type === "view";
|
||||
|
||||
$: isLoading = isLoadingList || isLoadingSelected;
|
||||
|
||||
$: canLoadMore = lastItemsCount == batchSize;
|
||||
@@ -139,7 +141,7 @@
|
||||
|
||||
const result = await ApiClient.collection(collectionId).getList(page, batchSize, {
|
||||
filter: CommonHelper.normalizeSearchFilter(filter, fallbackSearchFields),
|
||||
sort: !collection?.$isView ? "-created" : "",
|
||||
sort: !isView ? "-created" : "",
|
||||
skipTotal: 1,
|
||||
$cancelKey: uniqueId + "loadList",
|
||||
});
|
||||
@@ -208,7 +210,7 @@
|
||||
autocompleteCollection={collection}
|
||||
on:submit={(e) => (filter = e.detail)}
|
||||
/>
|
||||
{#if !collection?.$isView}
|
||||
{#if !isView}
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-transparent btn-hint p-l-sm p-r-sm"
|
||||
@@ -252,7 +254,7 @@
|
||||
<div class="content">
|
||||
<RecordInfo {record} {displayFields} />
|
||||
</div>
|
||||
{#if !collection?.$isView}
|
||||
{#if !isView}
|
||||
<div class="actions nonintrusive">
|
||||
<button
|
||||
type="button"
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
<script>
|
||||
import { slide } from "svelte/transition";
|
||||
import { Collection, Record } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
import { confirm } from "@/stores/confirmation";
|
||||
import { removeError } from "@/stores/errors";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let record = new Record();
|
||||
export let isNew = record.$isNew;
|
||||
export let record;
|
||||
export let collection;
|
||||
export let isNew = !!record.id;
|
||||
|
||||
let originalUsername = record.username || null;
|
||||
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = false;
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import Flatpickr from "svelte-flatpickr";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
|
||||
let pickerValue = value;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
import TinyMCE from "@tinymce/tinymce-svelte";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
@@ -10,10 +9,10 @@
|
||||
import { onMount } from "svelte";
|
||||
|
||||
export let record;
|
||||
export let field;
|
||||
export let value = "";
|
||||
export let uploadedFiles = []; // Array<File> array
|
||||
export let deletedFileNames = []; // Array<string> array
|
||||
export let field = new SchemaField();
|
||||
|
||||
let fileInput;
|
||||
let filesListElem;
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
|
||||
let serialized = JSON.stringify(typeof value === "undefined" ? null : value, null, 2);
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<script>
|
||||
import { onDestroy } from "svelte";
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
@@ -11,9 +10,9 @@
|
||||
|
||||
const batchSize = 100;
|
||||
|
||||
export let field;
|
||||
export let value;
|
||||
export let picker;
|
||||
export let field = new SchemaField();
|
||||
|
||||
let fieldRef;
|
||||
let list = [];
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Select from "@/components/base/Select.svelte";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
|
||||
$: isMultiple = field.options?.maxSelect > 1;
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
import AutoExpandTextarea from "@/components/base/AutoExpandTextarea.svelte";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
</script>
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script>
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
|
||||
export let field = new SchemaField();
|
||||
export let field;
|
||||
export let value = undefined;
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user