diff --git a/composer.json b/composer.json index 55bbb02..51804c5 100644 --- a/composer.json +++ b/composer.json @@ -15,7 +15,8 @@ "spatie/image-optimizer": "^1.6", "staudenmeir/laravel-cte": "^1.0", "ext-pdo": "*", - "opis/json-schema": "^2.3" + "opis/json-schema": "^2.3", + "symfony/yaml": "^7.0" }, "require-dev": { "phpstan/phpstan": "^1.8" diff --git a/composer.lock b/composer.lock index 5bdb85f..196986d 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "63bda0f783c53f088a85b8b35874ff00", + "content-hash": "8a508d36870e3e47f5b756acc01e1458", "packages": [ { "name": "brick/math", @@ -1906,6 +1906,85 @@ ], "time": "2023-05-23T14:45:45+00:00" }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.29.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-29T20:11:03+00:00" + }, { "name": "symfony/polyfill-mbstring", "version": "v1.28.0", @@ -2306,6 +2385,77 @@ ], "time": "2023-05-30T17:17:10+00:00" }, + { + "name": "symfony/yaml", + "version": "v7.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "2d4fca631c00700597e9442a0b2451ce234513d3" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/2d4fca631c00700597e9442a0b2451ce234513d3", + "reference": "2d4fca631c00700597e9442a0b2451ce234513d3", + "shasum": "" + }, + "require": { + "php": ">=8.2", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<6.4" + }, + "require-dev": { + "symfony/console": "^6.4|^7.0" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v7.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2024-01-23T15:02:46+00:00" + }, { "name": "voku/portable-ascii", "version": "2.0.1", diff --git a/front/js/svelte/Channel.svelte b/front/js/svelte/Channel.svelte index 5e90282..899747d 100644 --- a/front/js/svelte/Channel.svelte +++ b/front/js/svelte/Channel.svelte @@ -23,7 +23,7 @@ export let data; // export let layout; export let channel; - + export let sidebar; export let axios; export let readableSchemas; @@ -35,7 +35,7 @@ - + diff --git a/front/js/svelte/Navbar.svelte b/front/js/svelte/Navbar.svelte index 6b8581b..29fd10a 100644 --- a/front/js/svelte/Navbar.svelte +++ b/front/js/svelte/Navbar.svelte @@ -1,26 +1,11 @@ -
- - -
-
-
-

- -

-
-
- sc.isEntry)} - schema={schema} - /> -
-
-
- {#if otherSchemas.length > 0} -
-

- -

-
-
- -
-
-
- {/if} - {#if fileSchemas.length > 0} -
-

- -

-
-
- -
-
-
- {/if} - -
+ {@html sidebar}
\ No newline at end of file diff --git a/front/js/svelte/NavbarMenu.svelte b/front/js/svelte/NavbarMenu.svelte deleted file mode 100644 index b81132e..0000000 --- a/front/js/svelte/NavbarMenu.svelte +++ /dev/null @@ -1,16 +0,0 @@ - - -
- - {#each schemas as aschema} - {aschema.label} - {/each} -
diff --git a/front/js/svelte/content/Index.svelte b/front/js/svelte/content/Index.svelte index 737adec..636581f 100644 --- a/front/js/svelte/content/Index.svelte +++ b/front/js/svelte/content/Index.svelte @@ -47,7 +47,7 @@
-
+

{schema.label}

diff --git a/front/js/svelte/home/Index.svelte b/front/js/svelte/home/Index.svelte index e5efa31..cae3f16 100644 --- a/front/js/svelte/home/Index.svelte +++ b/front/js/svelte/home/Index.svelte @@ -23,7 +23,7 @@
-

Latest Content changes

+

Latest Content changes

{#if records.length > 0}
diff --git a/front/sass/_nav.scss b/front/sass/_nav.scss index f422035..a61453a 100644 --- a/front/sass/_nav.scss +++ b/front/sass/_nav.scss @@ -1,16 +1,74 @@ -.lx-nav{ - display: flex; - justify-content: space-between; - align-items: center; - background-color: rgba(255,255,255,1); - margin-bottom:0px ; - .nav-item{ - padding:16px 0; - margin: 0 16px; - color: $primary; +.lx-nav { + display: flex; + justify-content: space-between; + align-items: center; + //background-color: rgba(255,255,255,1); + margin-bottom: 0px; + + .nav-item { + padding: 16px 0; + margin: 0 16px; + color: $primary; + + } + + a { + text-decoration: none; + } + - } - a{ - text-decoration: none; - } } + + +.accordion { + border: none; +} + +.accordion-item { + border: none; + background: transparent; +} + +.accordion-button:not(.collapsed) { + box-shadow: none; +} + + +.offcanvas-body { + padding: 0; + overflow: hidden; +} + +.accordion-button:not(.collapsed) { + background: rgba(11, 93, 30, 0.2) !important; + font-weight: bold; +} + +.accordion .list-group-item { + margin-left: 20px; + border-left: 2px solid rgba(11, 93, 30, 0.2); + border-top: none; + border-bottom: none; +} + +.accordion .list-group-item:hover { + background: rgba(11, 93, 30, 0.1) !important; +} + +.accordion .list-group-item.active { + border-left: 2px solid rgba(11, 93, 30, 0.8); + border-top: none; + border-bottom: none; + background: rgba(11, 93, 30, 0.1) !important; + color: var(--bs-primary); +} + +.sidebar-logo{ + padding: 5px 20px; + border-bottom: 1px solid rgba(11, 93, 30, 0.2); +} +.sidebar-logo a{ + text-decoration: none; + font-size: 25px; + color: var(--bs-primary); +} \ No newline at end of file diff --git a/src/Config/main.php b/src/Config/main.php index e490255..c163799 100644 --- a/src/Config/main.php +++ b/src/Config/main.php @@ -1,14 +1,15 @@ env("LUCENT_ENV", "production"), - "schemas_path" => env("LUCENT_SCHEMAS_PATH", "app/Lucent"), - "json_schemas_path" => env("LUCENT_JSON_SCHEMA_PATH", "json_schemas"), - "database" => env('LUCENT_DB_CONNECTION', env('DB_CONNECTION',"sqlite")), - "name" => env("LUCENT_NAME", "Lucent"), + "env" => env("LUCENT_ENV", "production"), + "schemas_path" => env("LUCENT_SCHEMAS_PATH", "app/Lucent"), + "json_schemas_path" => env("LUCENT_JSON_SCHEMA_PATH", "json_schema"), + "sidebar_path" => env("LUCENT_SIDEBAR_PATH", "app/Lucent"), + "database" => env('LUCENT_DB_CONNECTION', env('DB_CONNECTION', "sqlite")), + "name" => env("LUCENT_NAME", "Lucent"), "url" => env("LUCENT_URL", env('APP_URL')), - "previewTarget" => env("LUCENT_PREVIEW_TARGET", "previewTarget"), - "generateCommand" => env("LUCENT_GENERATE_COMMAND", "generate:static"), + "previewTarget" => env("LUCENT_PREVIEW_TARGET", "previewTarget"), + "generateCommand" => env("LUCENT_GENERATE_COMMAND", "generate:static"), "imageFilters" => [], "canInvite" => ["admin"], "canBuild" => ["admin"], diff --git a/src/Http/Controller/Api/SchemaController.php b/src/Http/Controller/Api/SchemaController.php index 8a2933c..6c43db1 100644 --- a/src/Http/Controller/Api/SchemaController.php +++ b/src/Http/Controller/Api/SchemaController.php @@ -37,7 +37,6 @@ class SchemaController extends Controller name: $request->input("name"), label: $request->input("label"), type: $request->input("type"), - isEntry: $request->input("isEntry"), revisionRetentionDays: $request->input("revisionRetentionDays"), revisionRetentionNumber: $request->input("revisionRetentionNumber"), trashedRetentionDays: $request->input("trashedRetentionDays"), diff --git a/src/JsonSchema/Command/GenerateJsonSchema.php b/src/JsonSchema/Command/GenerateJsonSchema.php index fb90f0d..5410a06 100644 --- a/src/JsonSchema/Command/GenerateJsonSchema.php +++ b/src/JsonSchema/Command/GenerateJsonSchema.php @@ -34,7 +34,7 @@ class GenerateJsonSchema extends Command $definitions = $this->channelService->channel->schemas->whereIn("type", [Type::COLLECTION, Type::FILES])->values()->map(fn(Schema $schema) => $this->fromSchema($schema)); $definitions->map(function (Definition $definition) use ($definitions) { - $this->writeToFile($definition,$definitions); + $this->writeToFile($definition, $definitions); }); } @@ -58,17 +58,17 @@ class GenerateJsonSchema extends Command mkdir($json_schema_dir); } $nameAr = explode("/", $definition->_id); - $name = end($nameAr); + $nameEtx = end($nameAr); + $name = str_replace(".schema.json", "", $nameEtx); - $defArray = $definition->toArray(); - $defArray['$defs'] = $definitions->map(fn($def) => $def->toArray())->keyBy(function ($def){ + $defArray = $definition->toArray(); + $defArray['$defs'] = $definitions->map(fn($def) => $def->toArray())->keyBy(function ($def) { $nameAr = explode("/", $def['$id']); - return str_replace(".json","",end($nameAr)); + return str_replace(".schema.json", "", end($nameAr)); }); - unset($defArray['$defs'][str_replace(".json","",$name)]); - - file_put_contents($json_schema_dir . "/" . $name,json_encode($defArray,JSON_UNESCAPED_SLASHES)); + unset($defArray['$defs'][$name]); + file_put_contents($json_schema_dir . "/" . $nameEtx, json_encode($defArray, JSON_UNESCAPED_SLASHES)); } diff --git a/src/JsonSchema/Definition.php b/src/JsonSchema/Definition.php index 341e4ea..02f6941 100644 --- a/src/JsonSchema/Definition.php +++ b/src/JsonSchema/Definition.php @@ -46,7 +46,7 @@ class Definition private static function getBasePath(string $schemaName): string { - return config("lucent.url") . "/" . config("lucent.json_schemas_path") . "/" . $schemaName . ".json"; + return config("lucent.url") . "/" . config("lucent.json_schemas_path") . "/" . $schemaName . ".schema.json"; } private static function getRefPath(string $schemaName): string @@ -81,22 +81,22 @@ class Definition if ($property->maxItems->getOrElse(null) === 1) { $newProperty["type"] = "object"; if ($property->_ref->count() == 1) { - $newProperty['$ref'] = $property->_ref->map(fn($ref)=>self::getRefPath($ref))->first(); + $newProperty['$ref'] = $property->_ref->map(fn($ref)=>self::getBasePath($ref))->first(); } else { $newProperty["oneOf"] = $property->_ref->map(function (string $ref) { return [ - '$ref' => self::getRefPath($ref) + '$ref' => self::getBasePath($ref) ]; }); } } else { $newProperty["type"] = "array"; if ($property->_ref->count() == 1) { - $newProperty["items"]['$ref'] = $property->_ref->map(fn($ref)=>self::getRefPath($ref))->first(); + $newProperty["items"]['$ref'] = $property->_ref->map(fn($ref)=>self::getBasePath($ref))->first(); } else { $newProperty["items"]["anyOf"] = $property->_ref->map(function (string $ref) { return [ - '$ref' => self::getRefPath($ref) + '$ref' => self::getBasePath($ref) ]; }); } diff --git a/src/LucentServiceProvider.php b/src/LucentServiceProvider.php index 493782b..42a3b80 100644 --- a/src/LucentServiceProvider.php +++ b/src/LucentServiceProvider.php @@ -7,7 +7,6 @@ use Illuminate\Support\Facades\View; use Illuminate\Support\ServiceProvider; use Intervention\Image\ImageManager; use Lucent\Channel\ChannelService; -use Lucent\Commands\CompileSchemas; use Lucent\Commands\LiveLink; use Lucent\Commands\RebuildThumbnails; use Lucent\Commands\RemoveOrphanEdges; @@ -17,6 +16,7 @@ use Lucent\JsonSchema\Command\GenerateJsonSchema; use Lucent\Query\DatabaseGraph\DatabaseGraph; use Lucent\Query\DatabaseGraph\PgsqlDatabaseGraph; use Lucent\Query\DatabaseGraph\SqliteDatabaseGraph; +use Lucent\Schema\Commands\CompileSchemas; class LucentServiceProvider extends ServiceProvider { diff --git a/src/Schema/BlockUi/File.php b/src/Schema/BlockUi/File.php index 8b09955..5fae80f 100644 --- a/src/Schema/BlockUi/File.php +++ b/src/Schema/BlockUi/File.php @@ -2,10 +2,16 @@ namespace Lucent\Schema\BlockUi; +use Lucent\JsonSchema\Property\Property; +use Lucent\JsonSchema\Property\RefProperty; +use Lucent\JsonSchema\Property\TypeProperty; +use Lucent\Primitive\Collection; use Lucent\Schema\FieldInfo; use Lucent\Schema\FieldInterface; use Lucent\Schema\FieldType; +use Lucent\Schema\Type; use Lucent\Schema\Validator\MinMaxInterface; +use PhpOption\Option; class File implements FieldInterface, MinMaxInterface { @@ -19,9 +25,11 @@ class File implements FieldInterface, MinMaxInterface public string $name, public string $label, public string $mime = "", + public string $help = "", public ?int $min = null, public ?int $max = null, public array $collections = [], + public string $group = "", ) { $this->info = new FieldInfo("file", "File", FieldType::FILE); @@ -50,20 +58,20 @@ class File implements FieldInterface, MinMaxInterface return count($value) < $this->min; } + public function isRequired(): bool + { + return false; + } public function toJsonSchema(): Property { - return new TypeProperty( - type: PropertyType::STRING, + return new RefProperty( id: $this->name, title: Option::fromValue($this->label), description: Option::fromValue($this->help, ""), - default: Option::fromValue($this->default, ""), - minLength: Option::fromValue($this->min), - maxLength: Option::fromValue($this->max), - readOnly: Option::fromValue($this->readonly, false), - enum: Option::fromValue($this->selectOptions), + _ref: new Collection($this->collections), + minItems: Option::fromValue($this->min), + maxItems: Option::fromValue($this->max), comment: Option::fromValue($this->group, ""), - format: none(), ); } diff --git a/src/Schema/BlockUi/Heading.php b/src/Schema/BlockUi/Heading.php index c7ea69f..2aef187 100644 --- a/src/Schema/BlockUi/Heading.php +++ b/src/Schema/BlockUi/Heading.php @@ -29,5 +29,9 @@ class Heading implements FieldInterface return $output; } + public function isRequired(): bool + { + return false; + } } diff --git a/src/Schema/BlockUi/Markdown.php b/src/Schema/BlockUi/Markdown.php index 0accf56..af3699a 100644 --- a/src/Schema/BlockUi/Markdown.php +++ b/src/Schema/BlockUi/Markdown.php @@ -28,6 +28,9 @@ class Markdown implements FieldInterface $output[$this->name] = $input[$this->name] ?? ""; return $output; } - + public function isRequired(): bool + { + return false; + } } diff --git a/src/Schema/BlockUi/Reference.php b/src/Schema/BlockUi/Reference.php index bf082cd..19802e0 100644 --- a/src/Schema/BlockUi/Reference.php +++ b/src/Schema/BlockUi/Reference.php @@ -49,6 +49,9 @@ class Reference implements FieldInterface, MinMaxInterface return count($value) < $this->min; } - + public function isRequired(): bool + { + return false; + } } diff --git a/src/Schema/BlockUi/Rich.php b/src/Schema/BlockUi/Rich.php index 6744ba9..21efd35 100644 --- a/src/Schema/BlockUi/Rich.php +++ b/src/Schema/BlockUi/Rich.php @@ -28,6 +28,9 @@ class Rich implements FieldInterface $output[$this->name] = $input[$this->name] ?? ""; return $output; } - + public function isRequired(): bool + { + return false; + } } diff --git a/src/Schema/BlockUi/Textarea.php b/src/Schema/BlockUi/Textarea.php index 03754d6..49a8dcf 100644 --- a/src/Schema/BlockUi/Textarea.php +++ b/src/Schema/BlockUi/Textarea.php @@ -28,6 +28,9 @@ class Textarea implements FieldInterface $output[$this->name] = $input[$this->name] ?? ""; return $output; } - + public function isRequired(): bool + { + return false; + } } diff --git a/src/Schema/CollectionSchema.php b/src/Schema/CollectionSchema.php index 94c7d31..426080b 100644 --- a/src/Schema/CollectionSchema.php +++ b/src/Schema/CollectionSchema.php @@ -18,7 +18,6 @@ class CollectionSchema implements Schema public array $visible, public array $groups, public Collection $fields, - public bool $isEntry = false, public string $color = "", public string $sortBy = "-_sys.updatedAt", public string $titleTemplate = "", diff --git a/src/Commands/CompileSchemas.php b/src/Schema/Commands/CompileSchemas.php similarity index 96% rename from src/Commands/CompileSchemas.php rename to src/Schema/Commands/CompileSchemas.php index ceece05..afbcc11 100644 --- a/src/Commands/CompileSchemas.php +++ b/src/Schema/Commands/CompileSchemas.php @@ -1,12 +1,13 @@ map([$this, 'mapFields']), - isEntry: $schemaArr["isEntry"] ?? false, color: $schemaArr["color"] ?? "", sortBy: $schemaArr["sortBy"] ?? "-_sys.updatedAt", titleTemplate: $schemaArr["titleTemplate"] ?? "", @@ -36,7 +35,6 @@ class SchemaService fields: (new Collection($schemaArr["fields"]))->map([$this, 'mapFields']), path: $schemaArr["path"] ?? $schemaArr["name"], groups: $schemaArr["groups"] ?? [], - isEntry: $schemaArr["isEntry"] ?? false, sortBy: $schemaArr["sortBy"] ?? "-_sys.updatedAt", color: $schemaArr["color"] ?? "", titleTemplate: $schemaArr["titleTemplate"] ?? "", diff --git a/src/Schema/Sidebar/Item/Item.php b/src/Schema/Sidebar/Item/Item.php new file mode 100644 index 0000000..3863fee --- /dev/null +++ b/src/Schema/Sidebar/Item/Item.php @@ -0,0 +1,9 @@ + $items + */ + public function __construct( + public string $label, + public Collection $items + ) + { + } + + public static function fromArray(array $data): self + { + return new self( + label: $data["label"], + items: (new Collection($data["items"]))->map(fn($itemData) => isset($itemData["schema"]) ? SchemaItem::fromArray($itemData) : LinkItem::fromArray($itemData)) + ); + } +} \ No newline at end of file diff --git a/src/Schema/Sidebar/Sidebar.php b/src/Schema/Sidebar/Sidebar.php new file mode 100644 index 0000000..2c28e65 --- /dev/null +++ b/src/Schema/Sidebar/Sidebar.php @@ -0,0 +1,29 @@ + $sections + */ + public function __construct( + public Collection $sections + ) + { + } + + public static function fromArray(array $data): self + { + return new self((new Collection($data))->map(fn($sectionData) => Section::fromArray($sectionData))); + } + + public function getUsedSchemas(): array + { + return $this->sections->reduce(function (array $carry, Section $section) { + return array_merge($carry, $section->items->pluck("schema")->toArray()); + }, []); + } +} \ No newline at end of file diff --git a/src/Schema/Sidebar/SidebarService.php b/src/Schema/Sidebar/SidebarService.php new file mode 100644 index 0000000..591213e --- /dev/null +++ b/src/Schema/Sidebar/SidebarService.php @@ -0,0 +1,58 @@ + $readableSchemas + * @param string $currentSchema + * @return string + */ + public function render(Channel $channel, array $readableSchemas, string $currentSchema): string + { + $schemas = $channel->schemas->whereIn("name", $readableSchemas); + + + return view('lucent::sidebar.sidebar', [ + 'sidebar' => $this->fromConfig(), + 'schemas' => $schemas, + 'channel' => $channel, + 'currentSchema' => $currentSchema, + 'lucentUrl' => $channel->lucentUrl, + ])->render(); + } + + /** + * @return Option + */ + private function fromConfig(): Option + { + $configPath = base_path(config("lucent.sidebar_path")) . "/sidebar.yaml"; + + if (!file_exists($configPath)) { + return none(); + } + + $yaml = Yaml::parse(file_get_contents($configPath)); + + if (empty($yaml)) { + return none(); + } + + $sidebar = Sidebar::fromArray($yaml); + return some($sidebar); + + + } +} \ No newline at end of file diff --git a/src/Schema/Ui/Reference.php b/src/Schema/Ui/Reference.php index 861e188..9269834 100644 --- a/src/Schema/Ui/Reference.php +++ b/src/Schema/Ui/Reference.php @@ -22,7 +22,6 @@ class Reference implements FieldInterface, MinMaxInterface public function __construct( public string $name, public string $label, - public string $mime = "", public string $help = "", public ?int $min = null, public ?int $max = null, diff --git a/src/Svelte/Svelte.php b/src/Svelte/Svelte.php index 0a4b2c7..14aa044 100644 --- a/src/Svelte/Svelte.php +++ b/src/Svelte/Svelte.php @@ -6,27 +6,30 @@ use Illuminate\Contracts\View\Factory; use Illuminate\Contracts\View\View; use Lucent\Account\AccountService; use Lucent\Channel\ChannelService; +use Lucent\Schema\Sidebar\SidebarService; class Svelte { public function __construct( public ChannelService $channelService, - public AccountService $accountService + public AccountService $accountService, + public SidebarService $sidebarService ) { } function render(string $layout, string $view, string $title = "", mixed $data = []): View|Factory { - + $readableSchemas = $this->accountService->currentReadableSchemas(); $context = []; $context["user"] = session('user'); $context["view"] = $view; $context["layout"] = $layout; + $context["sidebar"] = $this->sidebarService->render($this->channelService->channel,$readableSchemas, $data["schema"]?->name ?? ""); $context["title"] = $title; $context["data"] = $data; $context["channel"] = $this->channelService->channel; - $context["readableSchemas"] = $this->accountService->currentReadableSchemas(); + $context["readableSchemas"] = $readableSchemas; $json = json_encode($context); $divTag = sprintf('
', $layout); diff --git a/src/Views/sidebar/accordion-item.blade.php b/src/Views/sidebar/accordion-item.blade.php new file mode 100644 index 0000000..5523938 --- /dev/null +++ b/src/Views/sidebar/accordion-item.blade.php @@ -0,0 +1,33 @@ +
+ @php + $show = $schemas->where("name", $currentSchema)->isNotEmpty() || $main; + @endphp + +

+ +

+ +
+
+ @foreach($schemas as $schema) + + {{$schema->label}} + + @endforeach +
+
+
\ No newline at end of file diff --git a/src/Views/sidebar/sidebar.blade.php b/src/Views/sidebar/sidebar.blade.php new file mode 100644 index 0000000..acbfe10 --- /dev/null +++ b/src/Views/sidebar/sidebar.blade.php @@ -0,0 +1,52 @@ + +
+ @if($sidebar->isEmpty()) + @include("lucent::sidebar.accordion-item", ["schemas" => $schemas, "currentSchema" => $currentSchema, "lucentUrl" => $lucentUrl, "main" => true]) + @else + @foreach($sidebar->get()->sections as $index => $section) + @php + $show = $section->items->where("schema", $currentSchema)->isNotEmpty(); + @endphp +
+

+ +

+ +
+
+ @foreach($section->items as $item) + @if(isset($item->href)) + {{$item->label}} + @else + @php + $schema = $schemas->where("name",$item->schema)->first(); + + @endphp + + {{$item->label}} + @endif + + @endforeach +
+
+
+ @endforeach + @include("lucent::sidebar.accordion-item", ["schemas" => $schemas->whereNotIn("name",$sidebar->get()->getUsedSchemas()), "currentSchema" => $currentSchema, "lucentUrl" => $lucentUrl, "main" => false]) + @endif +
\ No newline at end of file