+
+
{block.meta.label} {block.meta.info.name}
+
+
+
+
+
+ {#if block.meta.info.name === "heading"}
+
+
- {:else if block.ui === "textarea"}
+ {:else if block.meta.info.name === "textarea"}
- {:else if block.ui === "rich"}
+ {:else if block.meta.info.name === "rich"}
- {:else if block.ui === "reference"}
+ {:else if block.meta.info.name === "file"}
+
+ {:else if block.meta.info.name === "reference"}
{/if}
diff --git a/front/js/svelte/records/block/block.js b/front/js/svelte/records/block/block.js
new file mode 100644
index 0000000..2b5cb1d
--- /dev/null
+++ b/front/js/svelte/records/block/block.js
@@ -0,0 +1,25 @@
+import {randomId} from "../../../helpers.js";
+
+export function insertBlock(blockData, blockField, afterBlockId = null) {
+
+ if (!afterBlockId) {
+ return [{
+ meta: blockField,
+ id: randomId(),
+ value: null
+ }, ...blockData];
+ }
+
+ return blockData.reduce((carry, block) => {
+ carry.push(block)
+ if (block.id === afterBlockId) {
+ carry.push({
+ meta: blockField,
+ id: randomId(),
+ value: null
+ });
+ }
+ return carry;
+ }, []);
+
+}
\ No newline at end of file
diff --git a/front/js/svelte/records/block/elements/File.svelte b/front/js/svelte/records/block/elements/File.svelte
new file mode 100644
index 0000000..2ede75a
--- /dev/null
+++ b/front/js/svelte/records/block/elements/File.svelte
@@ -0,0 +1,105 @@
+
+
+
+
+ {#if block.meta.collections.length === 1}
+
+ {:else}
+
+
+
+
+ {/if}
+
+{#if references.length > 0}
+
+ {#each references as reference (reference.id)}
+
+ {/each}
+
+{/if}
+
+
\ No newline at end of file
diff --git a/front/js/svelte/records/block/elements/Text.svelte b/front/js/svelte/records/block/elements/Heading.svelte
similarity index 100%
rename from front/js/svelte/records/block/elements/Text.svelte
rename to front/js/svelte/records/block/elements/Heading.svelte
diff --git a/front/js/svelte/records/block/elements/Reference.svelte b/front/js/svelte/records/block/elements/Reference.svelte
index ea959be..7937f22 100644
--- a/front/js/svelte/records/block/elements/Reference.svelte
+++ b/front/js/svelte/records/block/elements/Reference.svelte
@@ -1,72 +1,52 @@
{#if references.length > 0}
- {#each references as reference (reference.data.id)}
+ {#each references as reference (reference.id)}
$fields
+ */
+ function __construct(
+ public string $name,
+ public string $label,
+ public Collection $fields
+ )
+ {
+ }
+
+
+}
diff --git a/src/Schema/BlockUi/File.php b/src/Schema/BlockUi/File.php
new file mode 100644
index 0000000..cee53fd
--- /dev/null
+++ b/src/Schema/BlockUi/File.php
@@ -0,0 +1,54 @@
+info = new FieldInfo("file", "File", FieldType::FILE);
+ }
+
+ public function format(array $input, array $output): array
+ {
+ return $output;
+ }
+
+ public function failMin(mixed $value): bool
+ {
+ if (is_null($value)) {
+ return false;
+ }
+
+ return count($value) < $this->min;
+ }
+
+ public function failMax(mixed $value): bool
+ {
+ if (is_null($value)) {
+ return false;
+ }
+
+ return count($value) < $this->min;
+ }
+
+}
+
diff --git a/src/Schema/BlockUi/Heading.php b/src/Schema/BlockUi/Heading.php
new file mode 100644
index 0000000..c7ea69f
--- /dev/null
+++ b/src/Schema/BlockUi/Heading.php
@@ -0,0 +1,33 @@
+info = new FieldInfo("heading", "Heading", FieldType::STRING);
+ }
+
+ public function format(array $input, array $output): array
+ {
+ $output[$this->name] = $input[$this->name] ?? "";
+ return $output;
+ }
+
+}
+
diff --git a/src/Schema/BlockUi/Reference.php b/src/Schema/BlockUi/Reference.php
new file mode 100644
index 0000000..bf082cd
--- /dev/null
+++ b/src/Schema/BlockUi/Reference.php
@@ -0,0 +1,54 @@
+info = new FieldInfo("reference", "Reference", FieldType::REFERENCE);
+ }
+
+ public function format(array $input, array $output): array
+ {
+ return $output;
+ }
+
+ public function failMin(mixed $value): bool
+ {
+ if (is_null($value)) {
+ return false;
+ }
+
+ return count($value) < $this->min;
+ }
+
+ public function failMax(mixed $value): bool
+ {
+ if (is_null($value)) {
+ return false;
+ }
+
+ return count($value) < $this->min;
+ }
+
+}
+
diff --git a/src/Schema/BlockUi/Textarea.php b/src/Schema/BlockUi/Textarea.php
new file mode 100644
index 0000000..03754d6
--- /dev/null
+++ b/src/Schema/BlockUi/Textarea.php
@@ -0,0 +1,33 @@
+info = new FieldInfo("textarea", "Textarea", FieldType::STRING);
+ }
+
+ public function format(array $input, array $output): array
+ {
+ $output[$this->name] = $input[$this->name] ?? "";
+ return $output;
+ }
+
+}
+
diff --git a/src/Schema/SchemaService.php b/src/Schema/SchemaService.php
index 256948c..92b35e9 100644
--- a/src/Schema/SchemaService.php
+++ b/src/Schema/SchemaService.php
@@ -35,6 +35,11 @@ class SchemaService
isEntry: $schemaArr["isEntry"] ?? false,
color: $schemaArr["color"] ?? "",
titleTemplate: $schemaArr["titleTemplate"] ?? "",
+ ),
+ "block" => new BlockSchema(
+ name: $schemaArr["name"],
+ label: $schemaArr["label"],
+ fields: (new Collection($schemaArr["fields"]))->map([$this, 'mapBlockFields'])
)
};
@@ -47,6 +52,13 @@ class SchemaService
return new $className(...$field);
}
+ public function mapBlockFields(array $field): FieldInterface
+ {
+ $className = "\\Lucent\Schema\BlockUi\\" . ucfirst($field["ui"]);
+ unset($field["ui"]);
+ return new $className(...$field);
+ }
+
//
// /**
diff --git a/src/Schema/Type.php b/src/Schema/Type.php
index 9a29096..e3de447 100644
--- a/src/Schema/Type.php
+++ b/src/Schema/Type.php
@@ -7,4 +7,5 @@ enum Type: string
{
case COLLECTION = 'collection';
case FILES = 'files';
+ case BLOCK = 'block';
}
diff --git a/src/Schema/Ui/Block.php b/src/Schema/Ui/Block.php
index 9772bd0..41d95a1 100644
--- a/src/Schema/Ui/Block.php
+++ b/src/Schema/Ui/Block.php
@@ -19,6 +19,7 @@ class Block implements FieldInterface, RequiredInterface
public bool $required = false,
public string $default = "",
public bool $readonly = false,
+ public string $schema = "",
public string $group = "",
)
{
diff --git a/src/Views/layouts/account.blade.php b/src/Views/layouts/account.blade.php
index fde805c..e413173 100644
--- a/src/Views/layouts/account.blade.php
+++ b/src/Views/layouts/account.blade.php
@@ -14,7 +14,6 @@
-
diff --git a/src/Views/layouts/channel.blade.php b/src/Views/layouts/channel.blade.php
index 3450e0f..fe4815d 100644
--- a/src/Views/layouts/channel.blade.php
+++ b/src/Views/layouts/channel.blade.php
@@ -7,13 +7,13 @@
@yield('title') - Lucent Data Platform
-{{-- @php--}}
-{{-- echo '';--}}
-{{-- @endphp--}}
-{{-- --}}
+ @php
+ echo '';
+ @endphp
+
-
-
+{{-- --}}
+{{-- --}}