removed js sdk dto helpers
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
<script>
|
||||
import { scale, slide } from "svelte/transition";
|
||||
import { Collection } from "pocketbase";
|
||||
import { errors } from "@/stores/errors";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
@@ -8,9 +7,9 @@
|
||||
import MultipleValueInput from "@/components/base/MultipleValueInput.svelte";
|
||||
import Accordion from "@/components/base/Accordion.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
$: if (collection.$isAuth && CommonHelper.isEmpty(collection.options)) {
|
||||
$: if (collection.type === "auth" && CommonHelper.isEmpty(collection.options)) {
|
||||
collection.options = {
|
||||
allowEmailAuth: true,
|
||||
allowUsernameAuth: true,
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import OverlayPanel from "@/components/base/OverlayPanel.svelte";
|
||||
|
||||
const baseTabs = {
|
||||
@@ -81,19 +80,19 @@
|
||||
};
|
||||
|
||||
let docsPanel;
|
||||
let collection = new Collection();
|
||||
let collection = {};
|
||||
let activeTab;
|
||||
let tabs = [];
|
||||
|
||||
$: if (collection.$isAuth) {
|
||||
$: if (collection.type === "auth") {
|
||||
tabs = Object.assign({}, baseTabs, authTabs);
|
||||
if (!collection?.options.allowUsernameAuth && !collection?.options.allowEmailAuth) {
|
||||
if (!collection.options.allowUsernameAuth && !collection.options.allowEmailAuth) {
|
||||
delete tabs["auth-with-password"];
|
||||
}
|
||||
if (!collection?.options.allowOAuth2Auth) {
|
||||
if (!collection.options.allowOAuth2Auth) {
|
||||
delete tabs["auth-with-oauth2"];
|
||||
}
|
||||
} else if (collection.$isView) {
|
||||
} else if (collection.type === "view") {
|
||||
tabs = Object.assign({}, baseTabs);
|
||||
delete tabs.create;
|
||||
delete tabs.update;
|
||||
@@ -127,7 +126,7 @@
|
||||
|
||||
<OverlayPanel bind:this={docsPanel} on:hide on:show class="docs-panel">
|
||||
<div class="docs-content-wrapper">
|
||||
<aside class="docs-sidebar" class:compact={collection?.$isAuth}>
|
||||
<aside class="docs-sidebar" class:compact={collection?.type === "auth"}>
|
||||
<nav class="sidebar-content">
|
||||
{#each Object.entries(tabs) as [key, tab], i (key)}
|
||||
<!-- add a separator before the first auth tab -->
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
<script>
|
||||
import { Collection, SchemaField } from "pocketbase";
|
||||
import { setErrors } from "@/stores/errors";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import IndexesList from "@/components/collections/IndexesList.svelte";
|
||||
@@ -17,7 +16,7 @@
|
||||
import SchemaFieldRelation from "@/components/collections/schema/SchemaFieldRelation.svelte";
|
||||
import Draggable from "@/components/base/Draggable.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
const fieldComponents = {
|
||||
text: SchemaFieldText,
|
||||
@@ -34,7 +33,6 @@
|
||||
};
|
||||
|
||||
$: if (typeof collection.schema === "undefined") {
|
||||
collection = collection || new Collection();
|
||||
collection.schema = [];
|
||||
}
|
||||
|
||||
@@ -48,7 +46,7 @@
|
||||
}
|
||||
|
||||
function newField(fieldType = "text") {
|
||||
const field = new SchemaField({
|
||||
const field = CommonHelper.initSchemaField({
|
||||
name: getUniqueFieldName(),
|
||||
type: fieldType,
|
||||
});
|
||||
@@ -70,7 +68,7 @@
|
||||
}
|
||||
|
||||
function hasFieldWithName(name) {
|
||||
return !!collection.schema.find((field) => field.name === name);
|
||||
return !!collection?.schema?.find((field) => field.name === name);
|
||||
}
|
||||
|
||||
function getSchemaFieldIndex(field) {
|
||||
@@ -95,7 +93,7 @@
|
||||
<code class="txt-sm">id</code> ,
|
||||
<code class="txt-sm">created</code> ,
|
||||
<code class="txt-sm">updated</code>
|
||||
{#if collection.$isAuth}
|
||||
{#if collection.type === "auth"}
|
||||
,
|
||||
<code class="txt-sm">username</code> ,
|
||||
<code class="txt-sm">email</code> ,
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { onMount } from "svelte";
|
||||
import { Collection } from "pocketbase";
|
||||
import { errors, removeError } from "@/stores/errors";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import Field from "@/components/base/Field.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let codeEditorComponent;
|
||||
let isCodeEditorComponentLoading = false;
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { slide } from "svelte/transition";
|
||||
import { Collection } from "pocketbase";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import RuleField from "@/components/collections/RuleField.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
$: fields = CommonHelper.getAllCollectionIdentifiers(collection);
|
||||
|
||||
@@ -80,7 +79,7 @@
|
||||
|
||||
<RuleField label="View rule" formKey="viewRule" {collection} bind:rule={collection.viewRule} />
|
||||
|
||||
{#if !collection?.$isView}
|
||||
{#if collection?.type !== "view"}
|
||||
<RuleField label="Create rule" formKey="createRule" {collection} bind:rule={collection.createRule}>
|
||||
<svelte:fragment slot="afterLabel" let:isAdminOnly>
|
||||
{#if !isAdminOnly}
|
||||
@@ -100,7 +99,7 @@
|
||||
<RuleField label="Delete rule" formKey="deleteRule" {collection} bind:rule={collection.deleteRule} />
|
||||
{/if}
|
||||
|
||||
{#if collection?.$isAuth}
|
||||
{#if collection?.type === "auth"}
|
||||
<RuleField
|
||||
label="Manage rule"
|
||||
formKey="options.manageRule"
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
$: isCollectionRenamed = oldCollection?.name != newCollection?.name;
|
||||
|
||||
$: isNewCollectionView = newCollection?.type === "view";
|
||||
|
||||
$: renamedFields =
|
||||
newCollection?.schema?.filter(
|
||||
(field) => field.id && !field.toDelete && field.originalName != field.name
|
||||
@@ -26,7 +28,7 @@
|
||||
return old.options?.maxSelect != 1 && field.options?.maxSelect == 1;
|
||||
}) || [];
|
||||
|
||||
$: showChanges = !newCollection?.$isView || isCollectionRenamed;
|
||||
$: showChanges = !isNewCollectionView || isCollectionRenamed;
|
||||
|
||||
export async function show(original, changed) {
|
||||
oldCollection = original;
|
||||
@@ -91,7 +93,7 @@
|
||||
</li>
|
||||
{/if}
|
||||
|
||||
{#if !newCollection?.$isView}
|
||||
{#if !isNewCollectionView}
|
||||
{#each multipleToSingleFields as field}
|
||||
<li>
|
||||
Multiple to single value conversion of field
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script>
|
||||
import { createEventDispatcher, tick } from "svelte";
|
||||
import { scale } from "svelte/transition";
|
||||
import { Collection } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import { errors, setErrors, removeError } from "@/stores/errors";
|
||||
@@ -36,13 +35,17 @@
|
||||
let collectionPanel;
|
||||
let confirmChangesPanel;
|
||||
let original = null;
|
||||
let collection = new Collection();
|
||||
let collection = CommonHelper.initCollection();
|
||||
let isSaving = false;
|
||||
let confirmClose = false; // prevent close recursion
|
||||
let activeTab = TAB_SCHEMA;
|
||||
let initialFormHash = calculateFormHash(collection);
|
||||
let schemaTabError = "";
|
||||
|
||||
$: isAuth = collection.type === TYPE_AUTH;
|
||||
|
||||
$: isView = collection.type === TYPE_VIEW;
|
||||
|
||||
$: if ($errors.schema || $errors.options?.query) {
|
||||
// extract the direct schema field error, otherwise - return a generic message
|
||||
schemaTabError = CommonHelper.getNestedVal($errors, "schema.message") || "Has errors";
|
||||
@@ -50,18 +53,18 @@
|
||||
schemaTabError = "";
|
||||
}
|
||||
|
||||
$: isSystemUpdate = !collection.$isNew && collection.system;
|
||||
$: isSystemUpdate = !!collection.id && collection.system;
|
||||
|
||||
$: hasChanges = initialFormHash != calculateFormHash(collection);
|
||||
|
||||
$: canSave = collection.$isNew || hasChanges;
|
||||
$: canSave = !collection.id || hasChanges;
|
||||
|
||||
$: if (activeTab === TAB_OPTIONS && collection.type !== TYPE_AUTH) {
|
||||
$: if (activeTab === TAB_OPTIONS && collection.type !== "auth") {
|
||||
// reset selected tab
|
||||
changeTab(TAB_SCHEMA);
|
||||
}
|
||||
|
||||
$: if (collection.type === TYPE_VIEW) {
|
||||
$: if (collection.type === "view") {
|
||||
// reset non-view fields
|
||||
collection.createRule = null;
|
||||
collection.updateRule = null;
|
||||
@@ -70,7 +73,7 @@
|
||||
}
|
||||
|
||||
// update indexes on collection rename
|
||||
$: if (collection?.name && original?.name != collection?.name) {
|
||||
$: if (collection.name && original?.name != collection.name && collection.indexes.length > 0) {
|
||||
collection.indexes = collection.indexes?.map((idx) =>
|
||||
CommonHelper.replaceIndexTableName(idx, collection.name)
|
||||
);
|
||||
@@ -99,10 +102,10 @@
|
||||
|
||||
if (typeof model !== "undefined") {
|
||||
original = model;
|
||||
collection = model.$clone();
|
||||
collection = structuredClone(model);
|
||||
} else {
|
||||
original = null;
|
||||
collection = new Collection();
|
||||
collection = CommonHelper.initCollection();
|
||||
}
|
||||
|
||||
// normalize
|
||||
@@ -115,7 +118,7 @@
|
||||
}
|
||||
|
||||
function saveConfirm() {
|
||||
if (collection.$isNew) {
|
||||
if (!collection.id) {
|
||||
save();
|
||||
} else {
|
||||
confirmChangesPanel?.show(original, collection);
|
||||
@@ -132,7 +135,7 @@
|
||||
const data = exportFormData();
|
||||
|
||||
let request;
|
||||
if (collection.$isNew) {
|
||||
if (!collection.id) {
|
||||
request = ApiClient.collections.create(data);
|
||||
} else {
|
||||
request = ApiClient.collections.update(collection.id, data);
|
||||
@@ -148,13 +151,11 @@
|
||||
hide();
|
||||
|
||||
addSuccessToast(
|
||||
collection.$isNew
|
||||
? "Successfully created collection."
|
||||
: "Successfully updated collection."
|
||||
!collection.id ? "Successfully created collection." : "Successfully updated collection."
|
||||
);
|
||||
|
||||
dispatch("save", {
|
||||
isNew: collection.$isNew,
|
||||
isNew: !collection.id,
|
||||
collection: result,
|
||||
});
|
||||
})
|
||||
@@ -167,7 +168,7 @@
|
||||
}
|
||||
|
||||
function exportFormData() {
|
||||
const data = collection.$export();
|
||||
const data = Object.assign({}, collection);
|
||||
data.schema = data.schema.slice(0);
|
||||
|
||||
// remove deleted fields
|
||||
@@ -186,12 +187,12 @@
|
||||
return; // nothing to delete
|
||||
}
|
||||
|
||||
confirm(`Do you really want to delete collection "${original?.name}" and all its records?`, () => {
|
||||
confirm(`Do you really want to delete collection "${original.name}" and all its records?`, () => {
|
||||
return ApiClient.collections
|
||||
.delete(original?.id)
|
||||
.delete(original.id)
|
||||
.then(() => {
|
||||
hide();
|
||||
addSuccessToast(`Successfully deleted collection "${original?.name}".`);
|
||||
addSuccessToast(`Successfully deleted collection "${original.name}".`);
|
||||
dispatch("delete", original);
|
||||
removeCollection(original);
|
||||
})
|
||||
@@ -223,7 +224,7 @@
|
||||
}
|
||||
|
||||
async function duplicate() {
|
||||
const clone = original?.$clone();
|
||||
const clone = original ? structuredClone(original) : null;
|
||||
|
||||
if (clone) {
|
||||
clone.id = "";
|
||||
@@ -277,10 +278,10 @@
|
||||
>
|
||||
<svelte:fragment slot="header">
|
||||
<h4 class="upsert-panel-title">
|
||||
{collection.$isNew ? "New collection" : "Edit collection"}
|
||||
{!collection.id ? "New collection" : "Edit collection"}
|
||||
</h4>
|
||||
|
||||
{#if !collection.$isNew && !collection.system}
|
||||
{#if !!collection.id && !collection.system}
|
||||
<div class="flex-fill" />
|
||||
<button type="button" aria-label="More" class="btn btn-sm btn-circle btn-transparent flex-gap-0">
|
||||
<i class="ri-more-line" />
|
||||
@@ -321,8 +322,8 @@
|
||||
required
|
||||
disabled={isSystemUpdate}
|
||||
spellcheck="false"
|
||||
autofocus={collection.$isNew}
|
||||
placeholder={collection.$isAuth ? `eg. "users"` : `eg. "posts"`}
|
||||
autofocus={!collection.id}
|
||||
placeholder={isAuth ? `eg. "users"` : `eg. "posts"`}
|
||||
value={collection.name}
|
||||
on:input={(e) => {
|
||||
collection.name = CommonHelper.slugify(e.target.value);
|
||||
@@ -333,15 +334,13 @@
|
||||
<div class="form-field-addon">
|
||||
<button
|
||||
type="button"
|
||||
class="btn btn-sm p-r-10 p-l-10 {collection.$isNew
|
||||
? 'btn-outline'
|
||||
: 'btn-transparent'}"
|
||||
disabled={!collection.$isNew}
|
||||
class="btn btn-sm p-r-10 p-l-10 {!collection.id ? 'btn-outline' : 'btn-transparent'}"
|
||||
disabled={!!collection.id}
|
||||
>
|
||||
<!-- empty span for alignment -->
|
||||
<span />
|
||||
<span class="txt">Type: {collectionTypes[collection.type] || "N/A"}</span>
|
||||
{#if collection.$isNew}
|
||||
{#if !collection.id}
|
||||
<i class="ri-arrow-down-s-fill" />
|
||||
<Toggler class="dropdown dropdown-right dropdown-nowrap m-t-5">
|
||||
{#each Object.entries(collectionTypes) as [type, label]}
|
||||
@@ -375,7 +374,7 @@
|
||||
class:active={activeTab === TAB_SCHEMA}
|
||||
on:click={() => changeTab(TAB_SCHEMA)}
|
||||
>
|
||||
<span class="txt">{collection?.$isView ? "Query" : "Fields"}</span>
|
||||
<span class="txt">{isView ? "Query" : "Fields"}</span>
|
||||
{#if !CommonHelper.isEmpty(schemaTabError)}
|
||||
<i
|
||||
class="ri-error-warning-fill txt-danger"
|
||||
@@ -401,7 +400,7 @@
|
||||
{/if}
|
||||
</button>
|
||||
|
||||
{#if collection.$isAuth}
|
||||
{#if isAuth}
|
||||
<button
|
||||
type="button"
|
||||
class="tab-item"
|
||||
@@ -424,7 +423,7 @@
|
||||
<div class="tabs-content">
|
||||
<!-- avoid rerendering the fields tab -->
|
||||
<div class="tab-item" class:active={activeTab === TAB_SCHEMA}>
|
||||
{#if collection.$isView}
|
||||
{#if isView}
|
||||
<CollectionQueryTab bind:collection />
|
||||
{:else}
|
||||
<CollectionFieldsTab bind:collection />
|
||||
@@ -437,7 +436,7 @@
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
{#if collection.$isAuth}
|
||||
{#if isAuth}
|
||||
<div class="tab-item" class:active={activeTab === TAB_OPTIONS}>
|
||||
<CollectionAuthOptionsTab bind:collection />
|
||||
</div>
|
||||
@@ -455,7 +454,7 @@
|
||||
disabled={!canSave || isSaving}
|
||||
on:click={() => saveConfirm()}
|
||||
>
|
||||
<span class="txt">{collection.$isNew ? "Create" : "Save changes"}</span>
|
||||
<span class="txt">{!collection.id ? "Create" : "Save changes"}</span>
|
||||
</button>
|
||||
</svelte:fragment>
|
||||
</OverlayPanel>
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
|
||||
export let collectionA = new Collection();
|
||||
export let collectionB = new Collection();
|
||||
export let collectionA = CommonHelper.initCollection();
|
||||
export let collectionB = CommonHelper.initCollection();
|
||||
export let deleteMissing = false;
|
||||
let schemaA = [];
|
||||
let schemaB = [];
|
||||
@@ -39,7 +38,7 @@
|
||||
|
||||
$: hasAnyChange = CommonHelper.hasCollectionChanges(collectionA, collectionB, deleteMissing);
|
||||
|
||||
const mainModelProps = Object.keys(new Collection().$export()).filter(
|
||||
const mainModelProps = Object.keys(CommonHelper.initCollection()).filter(
|
||||
(key) => !["schema", "created", "updated"].includes(key)
|
||||
);
|
||||
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
let baseData = {};
|
||||
|
||||
$: isAuth = collection.type === "auth";
|
||||
|
||||
$: adminsOnly = collection?.createRule === null;
|
||||
|
||||
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
|
||||
@@ -48,7 +49,7 @@
|
||||
},
|
||||
];
|
||||
|
||||
$: if (collection.$isAuth) {
|
||||
$: if (isAuth) {
|
||||
baseData = {
|
||||
username: "test_username",
|
||||
email: "test@example.com",
|
||||
@@ -91,7 +92,7 @@ const pb = new PocketBase('${backendAbsUrl}');
|
||||
const data = ${JSON.stringify(Object.assign({}, baseData, CommonHelper.dummyCollectionSchemaData(collection)), null, 4)};
|
||||
|
||||
const record = await pb.collection('${collection?.name}').create(data);
|
||||
` + (collection?.isAuth ?
|
||||
` + (isAuth ?
|
||||
`
|
||||
// (optional) send an email verification request
|
||||
await pb.collection('${collection?.name}').requestVerification('test@example.com');
|
||||
@@ -108,7 +109,7 @@ final pb = PocketBase('${backendAbsUrl}');
|
||||
final body = <String, dynamic>${JSON.stringify(Object.assign({}, baseData, CommonHelper.dummyCollectionSchemaData(collection)), null, 2)};
|
||||
|
||||
final record = await pb.collection('${collection?.name}').create(body: body);
|
||||
` + (collection?.isAuth ?
|
||||
` + (isAuth ?
|
||||
`
|
||||
// (optional) send an email verification request
|
||||
await pb.collection('${collection?.name}').requestVerification('test@example.com');
|
||||
@@ -156,7 +157,7 @@ await pb.collection('${collection?.name}').requestVerification('test@example.com
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{#if collection?.isAuth}
|
||||
{#if isAuth}
|
||||
<tr>
|
||||
<td colspan="3" class="txt-hint">Auth fields</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import FilterSyntax from "@/components/collections/docs/FilterSyntax.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
|
||||
</script>
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 204;
|
||||
let responses = [];
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
let baseData = {};
|
||||
|
||||
$: isAuth = collection?.type === "auth";
|
||||
|
||||
$: adminsOnly = collection?.updateRule === null;
|
||||
|
||||
$: backendAbsUrl = CommonHelper.getApiExampleUrl(ApiClient.baseUrl);
|
||||
@@ -58,7 +59,7 @@
|
||||
},
|
||||
];
|
||||
|
||||
$: if (collection.$isAuth) {
|
||||
$: if (collection.type === "auth") {
|
||||
baseData = {
|
||||
username: "test_username_update",
|
||||
emailVisibility: false,
|
||||
@@ -159,7 +160,7 @@ final record = await pb.collection('${collection?.name}').update('RECORD_ID', bo
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#if collection?.isAuth}
|
||||
{#if isAuth}
|
||||
<tr>
|
||||
<td colspan="3" class="txt-hint">Auth fields</td>
|
||||
</tr>
|
||||
|
||||
@@ -1,12 +1,11 @@
|
||||
<script>
|
||||
import { Collection } from "pocketbase";
|
||||
import ApiClient from "@/utils/ApiClient";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import CodeBlock from "@/components/base/CodeBlock.svelte";
|
||||
import SdkTabs from "@/components/collections/docs/SdkTabs.svelte";
|
||||
import FieldsQueryParam from "@/components/collections/docs/FieldsQueryParam.svelte";
|
||||
|
||||
export let collection = new Collection();
|
||||
export let collection;
|
||||
|
||||
let responseTab = 200;
|
||||
let responses = [];
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
<script>
|
||||
import { createEventDispatcher, onMount } from "svelte";
|
||||
import { slide } from "svelte/transition";
|
||||
import { SchemaField } from "pocketbase";
|
||||
import CommonHelper from "@/utils/CommonHelper";
|
||||
import tooltip from "@/actions/tooltip";
|
||||
import { errors, setErrors } from "@/stores/errors";
|
||||
@@ -23,7 +22,7 @@
|
||||
};
|
||||
|
||||
export let key = "";
|
||||
export let field = new SchemaField();
|
||||
export let field = CommonHelper.initSchemaField();
|
||||
|
||||
let nameInput;
|
||||
let showOptions = false;
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (selectedColection.isAuth) {
|
||||
if (selectedColection.type === "auth") {
|
||||
displayFieldsList = displayFieldsList.concat(authFields);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user