From 4d2cafdf1185bec72167842f5fcc0c60f0e7ae58 Mon Sep 17 00:00:00 2001 From: lexx Date: Mon, 22 Jul 2024 18:00:58 +0300 Subject: [PATCH] stuff --- front/js/svelte/common/SwitchButton.svelte | 13 ++++ .../js/svelte/records/form/SaveButtons.svelte | 2 +- .../svelte/records/form/StatusSelect.svelte | 75 ++++++++++++------- package-lock.json | 6 ++ .../Record/Contracts/NewDocumentData.php | 4 +- src/Http/Controller/RecordController.php | 1 - src/Schema/Sidebar/SidebarService.php | 7 +- 7 files changed, 72 insertions(+), 36 deletions(-) create mode 100644 front/js/svelte/common/SwitchButton.svelte create mode 100644 package-lock.json diff --git a/front/js/svelte/common/SwitchButton.svelte b/front/js/svelte/common/SwitchButton.svelte new file mode 100644 index 0000000..d03a014 --- /dev/null +++ b/front/js/svelte/common/SwitchButton.svelte @@ -0,0 +1,13 @@ + + + +
+ + +
+ diff --git a/front/js/svelte/records/form/SaveButtons.svelte b/front/js/svelte/records/form/SaveButtons.svelte index f1844b4..284751c 100644 --- a/front/js/svelte/records/form/SaveButtons.svelte +++ b/front/js/svelte/records/form/SaveButtons.svelte @@ -13,7 +13,7 @@
diff --git a/front/js/svelte/records/form/StatusSelect.svelte b/front/js/svelte/records/form/StatusSelect.svelte index ba3a3ec..ba85863 100644 --- a/front/js/svelte/records/form/StatusSelect.svelte +++ b/front/js/svelte/records/form/StatusSelect.svelte @@ -1,5 +1,6 @@ {#if status} -
-
- - - -
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {/if} \ No newline at end of file diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..2713515 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,6 @@ +{ + "name": "lucent-package", + "lockfileVersion": 3, + "requires": true, + "packages": {} +} diff --git a/src/Graph/Record/Contracts/NewDocumentData.php b/src/Graph/Record/Contracts/NewDocumentData.php index 47eb48a..838f6e7 100644 --- a/src/Graph/Record/Contracts/NewDocumentData.php +++ b/src/Graph/Record/Contracts/NewDocumentData.php @@ -4,7 +4,7 @@ namespace Lucent\Graph\Record\Contracts; use Lucent\Graph\Record\Status; use Lucent\Support\Collection; -use PhpOption\Option; +use Lucent\Support\Option\Option; class NewDocumentData { @@ -18,7 +18,7 @@ class NewDocumentData public function __construct( public string $schemaName, public array $data, - public Option $id, + public Option $id, public Collection $edges, public Status $status = Status::DRAFT, ) diff --git a/src/Http/Controller/RecordController.php b/src/Http/Controller/RecordController.php index a0d7fa7..5a1d185 100644 --- a/src/Http/Controller/RecordController.php +++ b/src/Http/Controller/RecordController.php @@ -320,7 +320,6 @@ class RecordController extends Controller field: $item["field"], data: Option::fromValue(data_get($item, "data")), )); - $res = match ($request->input("isCreateMode")) { true => $this->recordService->createDocument(new NewDocumentData( schemaName: $request->input("schemaName"), diff --git a/src/Schema/Sidebar/SidebarService.php b/src/Schema/Sidebar/SidebarService.php index 2734052..c5109dc 100644 --- a/src/Schema/Sidebar/SidebarService.php +++ b/src/Schema/Sidebar/SidebarService.php @@ -44,13 +44,13 @@ class SidebarService ); })->toArray(); - $usedSchemaNames =$sidebar->get()->sections->reduce(fn(array $carry, Section $section) => array_merge($carry, $section->items->pluck("schema")->toArray()), []); + $usedSchemaNames = $sidebar->get()->sections->reduce(fn(array $carry, Section $section) => array_merge($carry, $section->items->pluck("schema")->toArray()), []); } $sections[] = new SectionData( label: $sidebar->isDefined() ? "Rest" : "Content", - isOpen: $schemas->whereNotIn("name",$usedSchemaNames)->where("name",$currentSchema)->isNotEmpty(), - items: array_map(fn($item) => $this->renderItem($currentSchema, $item), $schemas->whereNotIn("name",$usedSchemaNames)->toArray()) + isOpen: $schemas->whereNotIn("name", $usedSchemaNames)->where("name", $currentSchema)->isNotEmpty(), + items: array_map(fn($item) => $this->renderItem($currentSchema, $item), $schemas->whereNotIn("name", $usedSchemaNames)->toArray()) ); return view('lucent::sidebar.sidebar', [ @@ -61,6 +61,7 @@ class SidebarService private function renderItem(string $currentSchema, Item|Schema $item): ItemData { + return match (get_class($item)) { LinkItem::class => new ItemData($item->label, $item->href, false, true), SchemaItem::class => new ItemData($item->label, $this->channelService->channel->lucentUrl . "/content/" . $item->schema, $currentSchema === $item->schema, false),