default sorting on schemas
This commit is contained in:
@@ -13,6 +13,7 @@ use Lucent\Query\Query;
|
||||
use Lucent\Record\Manager;
|
||||
use Lucent\Record\QueryRecord;
|
||||
use Lucent\Record\RecordService;
|
||||
use Lucent\Schema\FieldInterface;
|
||||
use Lucent\Schema\System;
|
||||
use Lucent\Schema\Validator\ValidatorException;
|
||||
use Lucent\Svelte\Svelte;
|
||||
@@ -37,7 +38,7 @@ class RecordController extends Controller
|
||||
{
|
||||
$schemaName = $request->route("schemaName");
|
||||
|
||||
if(!in_array($schemaName,$this->accountService->currentReadableSchemas())){
|
||||
if (!in_array($schemaName, $this->accountService->currentReadableSchemas())) {
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
@@ -48,7 +49,7 @@ class RecordController extends Controller
|
||||
$users = $this->accountService->all();
|
||||
$schema = $this->channelService->getSchema($schemaName)->get();
|
||||
$urlParams = $request->all();
|
||||
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
||||
$sort = data_get($urlParams, "sort") ?? $schema->sortBy;
|
||||
$filter = data_get($urlParams, "filter") ?? [];
|
||||
|
||||
$arguments = array_merge([
|
||||
@@ -84,13 +85,14 @@ class RecordController extends Controller
|
||||
"graph" => toArray($graph),
|
||||
"systemFields" => array_values(System::list()),
|
||||
"operators" => array_values(Operator::list()),
|
||||
"sort" => $sort,
|
||||
"sortParam" => $sort,
|
||||
"sortField" => $schema->fields->merge(array_values(System::list()))->firstWhere(fn($field) => $field->name === $sort || "-" . $field->name === $sort || "data." . $field->name === $sort || "-data." . $field->name === $sort),
|
||||
"limit" => $limit,
|
||||
"skip" => $skip,
|
||||
"total" => $graph->total ?? 0,
|
||||
"filter" => $request->input("filter") ?? [],
|
||||
"inModal" => true,
|
||||
"isWritable" => in_array($schemaName,$this->accountService->currentWritableSchemas())
|
||||
"isWritable" => in_array($schemaName, $this->accountService->currentWritableSchemas())
|
||||
];
|
||||
|
||||
if ($request->ajax()) {
|
||||
@@ -151,7 +153,7 @@ class RecordController extends Controller
|
||||
|
||||
public function new(Request $request)
|
||||
{
|
||||
if(!in_array($request->input("schema"),$this->accountService->currentWritableSchemas())){
|
||||
if (!in_array($request->input("schema"), $this->accountService->currentWritableSchemas())) {
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
@@ -172,7 +174,7 @@ class RecordController extends Controller
|
||||
"record" => $queryRecord,
|
||||
"recordHistory" => $recordHistory,
|
||||
"isCreateMode" => true,
|
||||
"isWritable" => in_array($record->schema,$this->accountService->currentWritableSchemas())
|
||||
"isWritable" => in_array($record->schema, $this->accountService->currentWritableSchemas())
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -180,7 +182,7 @@ class RecordController extends Controller
|
||||
|
||||
public function newInline(Request $request)
|
||||
{
|
||||
if(!in_array($request->input("schema"),$this->accountService->currentWritableSchemas())){
|
||||
if (!in_array($request->input("schema"), $this->accountService->currentWritableSchemas())) {
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
@@ -224,7 +226,7 @@ class RecordController extends Controller
|
||||
|
||||
$record = $graph->records->first();
|
||||
|
||||
if(!in_array($record->schema,$this->accountService->currentReadableSchemas())){
|
||||
if (!in_array($record->schema, $this->accountService->currentReadableSchemas())) {
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
@@ -244,7 +246,7 @@ class RecordController extends Controller
|
||||
"record" => toArray($record),
|
||||
"users" => $this->accountService->all(),
|
||||
"recordHistory" => $recordHistory,
|
||||
"isWritable" => in_array($record->schema,$this->accountService->currentWritableSchemas())
|
||||
"isWritable" => in_array($record->schema, $this->accountService->currentWritableSchemas())
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user