permissions
This commit is contained in:
@@ -7,8 +7,6 @@ use Illuminate\Contracts\View\View;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
use Lucent\Account\AccountService;
|
||||
use Lucent\Account\UserRepo;
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\Query\Query;
|
||||
use Lucent\Svelte\Svelte;
|
||||
use function Lucent\Response\ok;
|
||||
@@ -17,7 +15,7 @@ class HomeController extends Controller
|
||||
{
|
||||
public function __construct(
|
||||
private readonly Svelte $svelte,
|
||||
private readonly AccountService $accountService,
|
||||
private readonly AccountService $accountService,
|
||||
private readonly Query $query,
|
||||
)
|
||||
{
|
||||
@@ -36,10 +34,12 @@ class HomeController extends Controller
|
||||
public function records(Request $request): Response
|
||||
{
|
||||
$urlParams = $request->all();
|
||||
$users = $this->accountService->all();
|
||||
|
||||
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
||||
$filter = data_get($urlParams, "filter") ?? [];
|
||||
$arguments = array_merge([
|
||||
"schema_in" => $this->accountService->currentReadableSchemas(),
|
||||
"status_in" => ["draft", "published"]
|
||||
], $filter);
|
||||
|
||||
@@ -53,8 +53,6 @@ class HomeController extends Controller
|
||||
->sort($sort)
|
||||
->run();
|
||||
|
||||
$users = $this->accountService->all();
|
||||
|
||||
return ok([
|
||||
"users" => $users,
|
||||
"records" => $graph->getRootRecords()->toArray(),
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Lucent\Account\AccountService;
|
||||
use Lucent\Account\AuthService;
|
||||
use Lucent\Account\Role;
|
||||
use Lucent\LucentException;
|
||||
use Lucent\Svelte\Svelte;
|
||||
use function Lucent\Response\fail;
|
||||
@@ -31,19 +30,18 @@ class MemberController extends Controller
|
||||
title: "Members",
|
||||
data: [
|
||||
"users" => $this->accountService->allProfiles()->toArray(),
|
||||
"roles" => Role::cases()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
public function invite(Request $request)
|
||||
{
|
||||
if (empty($request->input("role"))) {
|
||||
if (empty($request->input("roles"))) {
|
||||
return fail("Select a role for the user");
|
||||
}
|
||||
|
||||
try {
|
||||
$user = $this->authService->invite($request->input("name"), $request->input("email"), $request->input("role"));
|
||||
$user = $this->authService->invite($request->input("name"), $request->input("email"), $request->input("roles"));
|
||||
} catch (LucentException $th) {
|
||||
return fail($th);
|
||||
}
|
||||
@@ -56,7 +54,7 @@ class MemberController extends Controller
|
||||
public function update(Request $request)
|
||||
{
|
||||
try {
|
||||
$this->authService->changeRole($request->input("id"), $request->input("role"));
|
||||
$this->authService->changeRoles($request->input("id"), $request->input("roles"));
|
||||
} catch (LucentException $th) {
|
||||
return fail($th);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Lucent\Account\AccountService;
|
||||
use Lucent\Account\AuthService;
|
||||
use Lucent\Account\UserRepo;
|
||||
use Lucent\Channel\ChannelService;
|
||||
use Lucent\LucentException;
|
||||
use Lucent\Query\Operator;
|
||||
@@ -28,7 +27,6 @@ class RecordController extends Controller
|
||||
private readonly AuthService $authService,
|
||||
private readonly ChannelService $channelService,
|
||||
private readonly Svelte $svelte,
|
||||
private readonly UserRepo $userRepo,
|
||||
private readonly Query $query,
|
||||
private readonly Manager $recordManager
|
||||
)
|
||||
@@ -38,11 +36,21 @@ class RecordController extends Controller
|
||||
public function index(Request $request)
|
||||
{
|
||||
$schemaName = $request->route("schemaName");
|
||||
|
||||
if(!in_array($schemaName,$this->accountService->currentReadableSchemas())){
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
title: "Schema Not Found",
|
||||
);
|
||||
}
|
||||
|
||||
$users = $this->accountService->all();
|
||||
$schema = $this->channelService->getSchema($schemaName)->get();
|
||||
$urlParams = $request->all();
|
||||
$sort = data_get($urlParams, "sort") ?? "-_sys.updatedAt";
|
||||
$filter = data_get($urlParams, "filter") ?? [];
|
||||
|
||||
$arguments = array_merge([
|
||||
"schema" => $schema->name,
|
||||
"status_in" => "draft,published",
|
||||
@@ -82,6 +90,7 @@ class RecordController extends Controller
|
||||
"total" => $graph->total ?? 0,
|
||||
"filter" => $request->input("filter") ?? [],
|
||||
"inModal" => true,
|
||||
"isWritable" => in_array($schemaName,$this->accountService->currentWritableSchemas())
|
||||
];
|
||||
|
||||
if ($request->ajax()) {
|
||||
@@ -142,6 +151,14 @@ class RecordController extends Controller
|
||||
|
||||
public function new(Request $request)
|
||||
{
|
||||
if(!in_array($request->input("schema"),$this->accountService->currentWritableSchemas())){
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
title: "Schema Not Found",
|
||||
);
|
||||
}
|
||||
|
||||
$schema = $this->channelService->channel->schemas->where("name", $request->input("schema"))->first();
|
||||
$recordHistory = $this->recordManager->fromSession($request->session())->getRecords();
|
||||
$record = $this->recordService->createEmpty($schema, $this->authService->currentUserId());
|
||||
@@ -162,6 +179,14 @@ class RecordController extends Controller
|
||||
|
||||
public function newInline(Request $request)
|
||||
{
|
||||
if(!in_array($request->input("schema"),$this->accountService->currentWritableSchemas())){
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
title: "Schema Not Found",
|
||||
);
|
||||
}
|
||||
|
||||
$schema = $this->channelService->getSchema($request->input("schema"))->get();
|
||||
$record = $this->recordService->createEmpty($schema);
|
||||
$queryRecord = QueryRecord::fromRecord($record);
|
||||
@@ -198,9 +223,17 @@ class RecordController extends Controller
|
||||
}
|
||||
|
||||
$record = $graph->records->first();
|
||||
|
||||
if(!in_array($record->schema,$this->accountService->currentReadableSchemas())){
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordNotFound",
|
||||
title: "Schema Not Found",
|
||||
);
|
||||
}
|
||||
|
||||
$schema = $this->channelService->getSchema($record->schema)->get();
|
||||
$recordHistory = $this->recordManager->fromSession($request->session())->push($rid)->getRecords($rid);
|
||||
$users = $this->userRepo->all();
|
||||
return $this->svelte->render(
|
||||
layout: "channel",
|
||||
view: "recordEdit",
|
||||
@@ -209,33 +242,42 @@ class RecordController extends Controller
|
||||
"schema" => $schema,
|
||||
"graph" => toArray($graph),
|
||||
"record" => toArray($record),
|
||||
"users" => $users,
|
||||
"users" => $this->accountService->all(),
|
||||
"recordHistory" => $recordHistory,
|
||||
"isWritable" => in_array($record->schema,$this->accountService->currentWritableSchemas())
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function editInline(Request $request)
|
||||
{
|
||||
$rid = $request->route("rid");
|
||||
|
||||
$graph = $this->query
|
||||
->filter(["id" => $rid])
|
||||
->limit(1)
|
||||
->childrenDepth(2)
|
||||
->parentsDepth(1)
|
||||
->run();
|
||||
|
||||
$record = $graph->records->first();
|
||||
|
||||
return ok(
|
||||
[
|
||||
"graph" => toArray($graph),
|
||||
"record" => toArray($record)
|
||||
]
|
||||
);
|
||||
}
|
||||
// public function editInline(Request $request)
|
||||
// {
|
||||
// $rid = $request->route("rid");
|
||||
//
|
||||
// $graph = $this->query
|
||||
// ->filter(["id" => $rid])
|
||||
// ->limit(1)
|
||||
// ->childrenDepth(2)
|
||||
// ->parentsDepth(1)
|
||||
// ->run();
|
||||
//
|
||||
// $record = $graph->records->first();
|
||||
//
|
||||
// if(!in_array($record->schema,$this->accountService->currentReadableSchemas())){
|
||||
// return $this->svelte->render(
|
||||
// layout: "channel",
|
||||
// view: "recordNotFound",
|
||||
// title: "Schema Not Found",
|
||||
// );
|
||||
// }
|
||||
//
|
||||
// return ok(
|
||||
// [
|
||||
// "graph" => toArray($graph),
|
||||
// "record" => toArray($record)
|
||||
// ]
|
||||
// );
|
||||
// }
|
||||
|
||||
|
||||
public function suggestions(Request $request)
|
||||
|
||||
Reference in New Issue
Block a user