Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript structure refactoring: Second version #2781

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 2 additions & 30 deletions lib/Controller/Region.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public function __construct(
}

/**
* Edit Form
* Get region by id
* @param Request $request
* @param Response $response
* @param $id
Expand All @@ -100,15 +100,14 @@ public function __construct(
* @throws NotFoundException
* @throws ControllerNotImplemented
*/
public function editForm(Request $request, Response $response, $id)
public function get(Request $request, Response $response, $id)
{
$region = $this->regionFactory->getById($id);

if (!$this->getUser()->checkEditable($region)) {
throw new AccessDeniedException();
}

$this->getState()->template = 'region-form-edit';
$this->getState()->setData([
'region' => $region,
'layout' => $this->layoutFactory->getById($region->layoutId),
Expand All @@ -118,33 +117,6 @@ public function editForm(Request $request, Response $response, $id)
return $this->render($request, $response);
}

/**
* Delete Form
* @param Request $request
* @param Response $response
* @param $id
* @return \Psr\Http\Message\ResponseInterface|Response
* @throws AccessDeniedException
* @throws GeneralException
* @throws NotFoundException
* @throws ControllerNotImplemented
*/
public function deleteForm(Request $request, Response $response, $id)
{
$region = $this->regionFactory->getById($id);

if (!$this->getUser()->checkDeleteable($region))
throw new AccessDeniedException();

$this->getState()->template = 'region-form-delete';
$this->getState()->setData([
'region' => $region,
'layout' => $this->layoutFactory->getById($region->layoutId),
]);

return $this->render($request, $response);
}

/**
* Add a region
* @param Request $request
Expand Down
42 changes: 2 additions & 40 deletions lib/Controller/Widget.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,14 +310,14 @@ public function addWidget(Request $request, Response $response, $type, $id)
}

/**
* Edit Widget Form
* Get Widget
* @param Request $request
* @param Response $response
* @param $id
* @return \Psr\Http\Message\ResponseInterface|Response
* @throws \Xibo\Support\Exception\GeneralException
*/
public function editWidgetForm(Request $request, Response $response, $id)
public function getWidget(Request $request, Response $response, $id)
{
// Load the widget
$widget = $this->widgetFactory->loadByWidgetId($id);
Expand Down Expand Up @@ -600,44 +600,6 @@ public function editWidget(Request $request, Response $response, $id)
return $this->render($request, $response);
}

/**
* Delete Widget Form
* @param Request $request
* @param Response $response
* @param $id
* @return \Psr\Http\Message\ResponseInterface|Response
* @throws AccessDeniedException
* @throws GeneralException
* @throws NotFoundException
* @throws \Xibo\Support\Exception\ControllerNotImplemented
*/
public function deleteWidgetForm(Request $request, Response $response, $id)
{
$widget = $this->widgetFactory->loadByWidgetId($id);

if (!$this->getUser()->checkDeleteable($widget)) {
throw new AccessDeniedException(__('This Widget is not shared with you with delete permission'));
}

$error = false;
$module = null;
try {
$module = $this->moduleFactory->getByType($widget->type);
} catch (NotFoundException $notFoundException) {
$error = true;
}

// Pass to view
$this->getState()->template = 'module-form-delete';
$this->getState()->setData([
'widgetId' => $id,
'module' => $module,
'error' => $error,
]);

return $this->render($request, $response);
}

/**
* Delete a Widget
* @SWG\Delete(
Expand Down
6 changes: 2 additions & 4 deletions lib/routes-web.php
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@
->setName('region.preview');

$app->group('', function(\Slim\Routing\RouteCollectorProxy $group) {
$group->get('/region/form/edit/{id}', ['\Xibo\Controller\Region', 'editForm'])->setName('region.edit.form');
$group->get('/region/form/delete/{id}', ['\Xibo\Controller\Region', 'deleteForm'])->setName('region.delete.form');
$group->get('/region/{id}', ['\Xibo\Controller\Region', 'get'])->setName('region.get');

// Designer
$group->get('/playlist/form/library/assign/{id}', ['\Xibo\Controller\Playlist','libraryAssignForm'])->setName('playlist.library.assign.form');
Expand All @@ -202,8 +201,7 @@

$app->group('', function (\Slim\Routing\RouteCollectorProxy $group) {
// Widget functions
$group->get('/playlist/widget/form/edit/{id}', ['\Xibo\Controller\Widget','editWidgetForm'])->setName('module.widget.edit.form');
$group->get('/playlist/widget/form/delete/{id}', ['\Xibo\Controller\Widget','deleteWidgetForm'])->setName('module.widget.delete.form');
$group->get('/playlist/widget/{id}', ['\Xibo\Controller\Widget','getWidget'])->setName('module.widget.get');
$group->get('/playlist/widget/form/transition/edit/{type}/{id}', ['\Xibo\Controller\Widget','editWidgetTransitionForm'])->setName('module.widget.transition.edit.form');
$group->get('/playlist/widget/form/audio/{id}', ['\Xibo\Controller\Widget','widgetAudioForm'])->setName('module.widget.audio.form');
$group->get('/playlist/widget/form/expiry/{id}', ['\Xibo\Controller\Widget','widgetExpiryForm'])->setName('module.widget.expiry.form');
Expand Down
1 change: 1 addition & 0 deletions modules/player.bundle.min.js.map

Large diffs are not rendered by default.

Loading
Loading