cleanup
This commit is contained in:
@@ -2,7 +2,9 @@
|
||||
|
||||
return [
|
||||
"env" => env("LUCENT_ENV", "production"),
|
||||
// lucent or lunar
|
||||
"auth" => env("LUCENT_AUTH", "lucent"),
|
||||
"disk" => env("LUCENT_DISK", "public"),
|
||||
"schemas_path" => env("LUCENT_SCHEMAS_PATH", "resources/lucent/schemas"),
|
||||
"database" => env("LUCENT_DB_CONNECTION", env("DB_CONNECTION", "sqlite")),
|
||||
"name" => env("LUCENT_NAME", "Lucent"),
|
||||
|
||||
@@ -16,10 +16,7 @@ class Schema
|
||||
public array $visible,
|
||||
public array $groups,
|
||||
public Collection $fields,
|
||||
public bool $isEntry = false,
|
||||
public string $color = "",
|
||||
public string $sortBy = "-_sys.updatedAt",
|
||||
public ?string $cardTitle = null,
|
||||
public ?string $cardImage = null,
|
||||
public int $revisions = 0,
|
||||
public array $read = [],
|
||||
|
||||
@@ -21,7 +21,6 @@ use Lucent\Schema\System;
|
||||
use Lucent\Schema\Ui\Reference;
|
||||
use Lucent\Schema\Validator\ValidatorException;
|
||||
use Lucent\Svelte\Svelte;
|
||||
use Lucent\ViewModel\ViewModel;
|
||||
use function Lucent\Response\fail;
|
||||
use function Lucent\Response\ok;
|
||||
|
||||
@@ -36,7 +35,6 @@ class RecordController extends Controller
|
||||
private readonly Query $query,
|
||||
private readonly Manager $recordManager,
|
||||
private readonly OperatorRegistry $operatorRegistry,
|
||||
private readonly ViewModel $viewModel,
|
||||
) {}
|
||||
|
||||
public function index(Request $request)
|
||||
@@ -217,7 +215,7 @@ class RecordController extends Controller
|
||||
$c[] = "";
|
||||
} elseif (count($fieldRecords) === 1) {
|
||||
$c[] = data_get($fieldRecords, "0.id");
|
||||
$c[] = $this->viewModel->getRecordName($fieldRecords[0]);
|
||||
$c[] = $fieldRecords[0]->data["name"];
|
||||
} else {
|
||||
$c[] = collect($fieldRecords)->pluck("id")->join("::");
|
||||
$c[] = collect($fieldRecords)
|
||||
|
||||
@@ -8,7 +8,6 @@ use Illuminate\Support\Facades\View;
|
||||
use Lucent\Account\AccountService;
|
||||
use Lucent\Account\AuthService;
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\ViewModel\ViewModel;
|
||||
|
||||
readonly class AuthMiddleware
|
||||
{
|
||||
@@ -16,7 +15,6 @@ readonly class AuthMiddleware
|
||||
private AuthService $authService,
|
||||
private AccountService $accountService,
|
||||
private ChannelService $channelService,
|
||||
private ViewModel $viewModel,
|
||||
) {}
|
||||
|
||||
public function handle(Request $request, Closure $next)
|
||||
@@ -38,7 +36,6 @@ readonly class AuthMiddleware
|
||||
)
|
||||
->values(),
|
||||
);
|
||||
View::share("viewModel", $this->viewModel);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
@@ -1,33 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Schema;
|
||||
|
||||
use Lucent\Primitive\Collection;
|
||||
|
||||
class CollectionSchema implements Schema
|
||||
{
|
||||
public Type $type = Type::COLLECTION;
|
||||
|
||||
/**
|
||||
* @param Collection<FieldInterface> $fields
|
||||
* @param array<string> $visible
|
||||
*/
|
||||
function __construct(
|
||||
public string $name,
|
||||
public string $label,
|
||||
public array $visible,
|
||||
public array $groups,
|
||||
public Collection $fields,
|
||||
public bool $isEntry = false,
|
||||
public string $color = "",
|
||||
public string $sortBy = "-_sys.updatedAt",
|
||||
public ?string $cardTitle = null,
|
||||
public ?string $cardImage = null,
|
||||
public int $revisions = 0,
|
||||
public array $read = [],
|
||||
public array $write = [],
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Schema;
|
||||
|
||||
use Lucent\Primitive\Collection;
|
||||
|
||||
class FilesSchema implements Schema
|
||||
{
|
||||
|
||||
public Type $type = Type::FILES;
|
||||
|
||||
/**
|
||||
* @param Collection<FieldInterface> $fields
|
||||
* @param array<string> $groups
|
||||
*/
|
||||
function __construct(
|
||||
public string $name,
|
||||
public string $label,
|
||||
public Collection $fields,
|
||||
public string $disk,
|
||||
public string $path,
|
||||
public array $groups,
|
||||
public bool $isEntry = false,
|
||||
public string $sortBy = "-_sys.updatedAt",
|
||||
public string $color = "",
|
||||
public ?string $cardTitle = null,
|
||||
public ?string $cardImage = null,
|
||||
public int $revisions = 0,
|
||||
public array $read = [],
|
||||
public array $write = [],
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\Schema;
|
||||
|
||||
interface Schema
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@@ -31,11 +31,7 @@ class SchemaService
|
||||
$this,
|
||||
"mapFields",
|
||||
]),
|
||||
isEntry: $schemaArr["isEntry"] ?? false,
|
||||
color: $schemaArr["color"] ?? "",
|
||||
sortBy: $schemaArr["sortBy"] ?? "-_sys.updatedAt",
|
||||
cardTitle: $schemaArr["titleTemplate"] ??
|
||||
($schemaArr["cardTitle"] ?? null),
|
||||
cardImage: $schemaArr["cardImage"] ?? null,
|
||||
revisions: $schemaArr["revisions"] ?? 0,
|
||||
read: $schemaArr["read"] ?? [],
|
||||
|
||||
@@ -38,7 +38,7 @@ class Slug implements FieldInterface, RequiredInterface
|
||||
$value = Str::slug($input[$this->source]);
|
||||
}
|
||||
|
||||
$output[$this->name] = new Nullable(
|
||||
$output[$this->name] = Nullable::make(
|
||||
$this->nullable,
|
||||
$value,
|
||||
"",
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Lucent\ViewModel;
|
||||
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\Record\QueryRecord;
|
||||
use Lucent\Schema\CollectionSchema;
|
||||
use Lucent\Schema\FieldInterface;
|
||||
use Lucent\Schema\FilesSchema;
|
||||
use Mustache_Engine;
|
||||
|
||||
class ViewModel
|
||||
{
|
||||
public function __construct(
|
||||
public ChannelService $channelService
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
public function getRecordName(QueryRecord $record): string
|
||||
{
|
||||
$schema = $this->channelService->getSchema($record->schema)->get();
|
||||
if (empty($schema->cardTitle)) {
|
||||
$title = match (get_class($schema)) {
|
||||
CollectionSchema::class => $record->data[$schema->fields->filter(fn(FieldInterface $f) => $f->info->name === "text")->first()->name],
|
||||
FilesSchema::class => $record->_file->path,
|
||||
};
|
||||
|
||||
if (empty(trim($title))) {
|
||||
return "~Untitled~";
|
||||
}
|
||||
|
||||
return $title;
|
||||
}
|
||||
|
||||
$m = new Mustache_Engine(array('entity_flags' => ENT_QUOTES));
|
||||
return $m->render($schema->cardTitle, $record->data);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user