visible fields for fileschema

This commit is contained in:
2024-10-01 22:41:10 +03:00
parent fa388ea302
commit 4389dba49d
6 changed files with 13 additions and 7 deletions
+1 -4
View File
@@ -1,7 +1,3 @@
@php
@endphp
<div class="table mt-5 "> <div class="table mt-5 ">
<table> <table>
<thead> <thead>
@@ -11,6 +7,7 @@
<x-lucent::checkbox value=""></x-lucent::checkbox> <x-lucent::checkbox value=""></x-lucent::checkbox>
</th> </th>
@endif @endif
@foreach($schema->visible as $visibleColumn) @foreach($schema->visible as $visibleColumn)
@php @php
$schemaField = $schema->fields->firstWhere("name", $visibleColumn); $schemaField = $schema->fields->firstWhere("name", $visibleColumn);
+1
View File
@@ -20,6 +20,7 @@ class GenerateFileSchema extends Command
$schema = new FilesSchema( $schema = new FilesSchema(
name: $name, name: $name,
label: $name, label: $name,
visible: [],
fields: Collection::make(), fields: Collection::make(),
disk: "lucent", disk: "lucent",
path: $name, path: $name,
+3 -3
View File
@@ -16,6 +16,7 @@ use Lucent\Record\Manager;
use Lucent\Record\QueryRecord; use Lucent\Record\QueryRecord;
use Lucent\Record\RecordService; use Lucent\Record\RecordService;
use Lucent\Record\Status; use Lucent\Record\Status;
use Lucent\Schema\SchemaService;
use Lucent\Schema\System; use Lucent\Schema\System;
use Lucent\Schema\Validator\ValidatorException; use Lucent\Schema\Validator\ValidatorException;
use Lucent\Svelte\Svelte; use Lucent\Svelte\Svelte;
@@ -26,6 +27,7 @@ class RecordController extends Controller
{ {
public function __construct( public function __construct(
private readonly RecordService $recordService, private readonly RecordService $recordService,
private readonly SchemaService $schemaService,
private readonly AccountService $accountService, private readonly AccountService $accountService,
private readonly ChannelService $channelService, private readonly ChannelService $channelService,
private readonly Svelte $svelte, private readonly Svelte $svelte,
@@ -79,15 +81,13 @@ class RecordController extends Controller
->runWithCount(); ->runWithCount();
$data = [ $data = [
"schemas" => $this->channelService->channel->schemas, "schemas" => $this->channelService->channel->schemas,
"schema" => $schema, "schema" => $schema,
"users" => $users, "users" => $users,
"records" => $graph->tree(), "records" => $graph->tree(),
"graph" => toArray($graph), "graph" => toArray($graph),
"visibleFields" => array_values(System::list()), "visibleFields" => $this->schemaService->getVisibleFields($schema),
"systemFields" => array_values(System::list()), "systemFields" => array_values(System::list()),
"operators" => $this->operatorRegistry->all(), "operators" => $this->operatorRegistry->all(),
"sortParam" => $sort, "sortParam" => $sort,
+2
View File
@@ -30,4 +30,6 @@ class CollectionSchema implements Schema
{ {
} }
} }
+1
View File
@@ -16,6 +16,7 @@ class FilesSchema implements Schema
function __construct( function __construct(
public string $name, public string $name,
public string $label, public string $label,
public array $visible,
public Collection $fields, public Collection $fields,
public string $disk, public string $disk,
public string $path, public string $path,
+5
View File
@@ -35,6 +35,7 @@ class SchemaService
"files" => new FilesSchema( "files" => new FilesSchema(
name: $schemaArr["name"], name: $schemaArr["name"],
label: $schemaArr["label"], label: $schemaArr["label"],
visible: $schemaArr["visible"] ?? [],
fields: (new Collection($schemaArr["fields"]))->map([$this, 'mapFields']), fields: (new Collection($schemaArr["fields"]))->map([$this, 'mapFields']),
disk: $schemaArr["disk"] ?? "lucent", disk: $schemaArr["disk"] ?? "lucent",
path: $schemaArr["path"] ?? $schemaArr["name"], path: $schemaArr["path"] ?? $schemaArr["name"],
@@ -82,4 +83,8 @@ class SchemaService
return new $ui(...$field); return new $ui(...$field);
} }
public function getVisibleFields(Schema $schema):array{
return $schema->fields->whereIn("name",$schema->visible)->filter()->toArray();
}
} }