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

Misc Fixes 12 #2025

Merged
merged 2 commits into from
Aug 31, 2023
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
151 changes: 0 additions & 151 deletions lib/Controller/Action.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@

use Slim\Http\Response as Response;
use Slim\Http\ServerRequest as Request;
use Xibo\Entity\Widget;
use Xibo\Factory\ActionFactory;
use Xibo\Factory\LayoutFactory;
use Xibo\Factory\ModuleFactory;
Expand Down Expand Up @@ -219,25 +218,6 @@ public function grid(Request $request, Response $response) : Response
// dynamic field to display in the grid instead of regionId
$action->setUnmatchedProperty('regionName', $region->name);
}

if ($this->isApi($request)) {
continue;
}

$action->includeProperty('buttons');
$action->buttons = [];

$action->buttons[] = [
'id' => 'action_edit_button',
'url' => $this->urlFor($request, 'action.edit.form', ['id' => $action->actionId]),
'text' => __('Edit')
];

$action->buttons[] = [
'id' => 'action_delete_button',
'url' => $this->urlFor($request, 'action.delete.form', ['id' => $action->actionId]),
'text' => __('Delete')
];
}

$this->getState()->template = 'grid';
Expand All @@ -247,64 +227,6 @@ public function grid(Request $request, Response $response) : Response
return $this->render($request, $response);
}

/**
* Action Add Form
* @param Request $request
* @param Response $response
* @param string $source
* @param int $id
* @return \Psr\Http\Message\ResponseInterface|Response
* @throws GeneralException
*/
public function addForm(Request $request, Response $response, string $source, int $id) : Response
{
$sourceObject = $this->checkIfSourceExists($source, $id);

if ($source === 'layout') {
/** @var \Xibo\Entity\Layout $layout */
$layout = $sourceObject;
} elseif ($source === 'region') {
/** @var \Xibo\Entity\Region $region */
$region = $sourceObject;
$layout = $this->layoutFactory->getById($region->layoutId);
} else {
/** @var Widget $widget */
$widget = $sourceObject;
$region = $this->regionFactory->getByPlaylistId($widget->playlistId)[0];
$layout = $this->layoutFactory->getById($region->layoutId);
}

// Make sure the Layout is checked out to begin with
if (!$layout->isEditable()) {
throw new InvalidArgumentException(__('Layout is not checked out'), 'publishedStatusId');
}

$layout->load();

// all widgets
$widgets = $layout->getDrawerWidgets();

foreach ($widgets as $widget) {
$module = $this->moduleFactory->getByType($widget->type);
// if we don't have a name set in the Widget
$widget->setUnmatchedProperty(
'name',
sprintf('%s [%s]', $widget->getOptionValue('name', $module->name), $module->type)
);
}

$this->getState()->template = 'action-form-add';
$this->getState()->setData([
'sourceObject' => $sourceObject,
'source' => $source,
'id' => $id,
'regions' => $layout->regions,
'widgets' => $widgets,
]);

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

/**
* Add a new Action
*
Expand Down Expand Up @@ -460,52 +382,6 @@ public function add(Request $request, Response $response) : Response
return $this->render($request, $response);
}

/**
* Action Edit Form
* @param Request $request
* @param Response $response
* @param int $id
* @return \Psr\Http\Message\ResponseInterface|Response
* @throws GeneralException
*/
public function editForm(Request $request, Response $response, int $id) : Response
{
$action = $this->actionFactory->getById($id);
$layout = $this->layoutFactory->getById($action->layoutId);

$layout->load();

// all widgets, assigned to this layout or drawer
$widgets = $layout->getDrawerWidgets();

foreach ($widgets as $widget) {
$module = $this->moduleFactory->getByType($widget->type);
$widget->name = $widget->getOptionValue('name', $module->name);
}

// Make sure the Layout is checked out to begin with
if (!$layout->isEditable()) {
throw new InvalidArgumentException(__('Layout is not checked out'), 'statusId');
}

try {
$code = (($action->layoutCode != null) ? [$this->layoutFactory->getByCode($action->layoutCode)] : []);
} catch (NotFoundException $notFoundException) {
$code = [];
}

$this->getState()->template = 'action-form-edit';
$this->getState()->setData([
'action' => $action,
'source' => $action->source,
'regions' => $layout->regions,
'widgets' => $widgets,
'layout' => $code
]);

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

/**
* Edit Action
*
Expand Down Expand Up @@ -649,33 +525,6 @@ public function edit(Request $request, Response $response, int $id) : Response
return $this->render($request, $response);
}

/**
* Shows the Delete Group Form
* @param Request $request
* @param Response $response
* @param int $id
* @return \Psr\Http\Message\ResponseInterface|Response
* @throws GeneralException
*/
function deleteForm(Request $request, Response $response, int $id) : Response
{
$action = $this->actionFactory->getById($id);
$layout = $this->layoutFactory->getById($action->layoutId);

// Make sure the Layout is checked out to begin with
if (!$layout->isEditable()) {
throw new InvalidArgumentException(__('Layout is not checked out'), 'publishedStatusId');
}

$this->getState()->template = 'action-form-delete';
$this->getState()->setData([
'action' => $action,
'source' => $action->source,
]);

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

/**
* Delete Action
* @param Request $request
Expand Down
7 changes: 0 additions & 7 deletions lib/routes-web.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
//
// Dashboards
//
$app->group('', function(RouteCollectorProxy $group) {

Check failure on line 34 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 space after FUNCTION keyword; 0 found
$group->get('/statusdashboard', ['\Xibo\Controller\StatusDashboard', 'displayPage'])
->setName('statusdashboard.view');
$group->get('/statusdashboard/displays', ['\Xibo\Controller\StatusDashboard', 'displays'])
Expand Down Expand Up @@ -93,7 +93,7 @@
->add(new FeatureAuth($app->getContainer(), ['schedule.add']))
->setName('schedule.add.form');

$app->group('', function(\Slim\Routing\RouteCollectorProxy $group) {

Check failure on line 96 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 space after FUNCTION keyword; 0 found
$group->get('/schedule/form/edit/{id}', ['\Xibo\Controller\Schedule', 'editForm'])
->setName('schedule.edit.form');

Expand All @@ -119,7 +119,7 @@
->addMiddleware(new FeatureAuth($app->getContainer(), ['notification.add']))
->setName('notification.add.form');

$app->group('', function(\Slim\Routing\RouteCollectorProxy $group) {

Check failure on line 122 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 space after FUNCTION keyword; 0 found
$group->get('/notification/form/edit/{id}', ['\Xibo\Controller\Notification', 'editForm'])
->setName('notification.edit.form');
$group->get('/notification/form/delete/{id}', ['\Xibo\Controller\Notification', 'deleteForm'])
Expand All @@ -133,11 +133,11 @@
->addMiddleware(new FeatureAuth($app->getContainer(), ['layout.view']))
->setName('layout.view');

$app->group('', function(\Slim\Routing\RouteCollectorProxy $group) {

Check failure on line 136 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Expected 1 space after FUNCTION keyword; 0 found
$group->get('/layout/preview/{id}', ['\Xibo\Controller\Preview', 'show'])->setName('layout.preview');
$group->get('/layout/xlf/{id}', ['\Xibo\Controller\Preview', 'getXlf'])->setName('layout.getXlf');
$group->get('/layout/background/{id}', ['\Xibo\Controller\Layout', 'downloadBackground'])->setName('layout.download.background');

Check warning on line 139 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 133 characters
$group->get('/layout/thumbnail/{id}', ['\Xibo\Controller\Layout', 'downloadThumbnail'])->setName('layout.download.thumbnail');

Check warning on line 140 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 130 characters
$group->get('/layout/playerBundle', ['\Xibo\Controller\Preview', 'playerBundle'])->setName('layout.preview.bundle');
$group->get('/connector/widget/preview', ['\Xibo\Controller\Connector', 'connectorPreview'])->setName('layout.preview.connector');
})->addMiddleware(new FeatureAuth($app->getContainer(), ['layout.view', 'template.view']));
Expand All @@ -150,15 +150,15 @@
$app->group('', function(\Slim\Routing\RouteCollectorProxy $group) {
$group->get('/layout/designer[/{id}]', ['\Xibo\Controller\Layout','displayDesigner'])->setName('layout.designer');
$group->get('/layout/form/edit/{id}', ['\Xibo\Controller\Layout', 'editForm'])->setName('layout.edit.form');
$group->get('/layout/form/background/{id}', ['\Xibo\Controller\Layout', 'editBackgroundForm'])->setName('layout.background.form');

Check warning on line 153 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 134 characters
$group->get('/layout/form/copy/{id}', ['\Xibo\Controller\Layout', 'copyForm'])->setName('layout.copy.form');
$group->get('/layout/form/delete/{id}', ['\Xibo\Controller\Layout', 'deleteForm'])->setName('layout.delete.form');
$group->get('/layout/form/checkout/{id}', ['\Xibo\Controller\Layout', 'checkoutForm'])->setName('layout.checkout.form');

Check warning on line 156 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 124 characters
$group->get('/layout/form/publish/{id}', ['\Xibo\Controller\Layout', 'publishForm'])->setName('layout.publish.form');

Check warning on line 157 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 121 characters
$group->get('/layout/form/discard/{id}', ['\Xibo\Controller\Layout', 'discardForm'])->setName('layout.discard.form');

Check warning on line 158 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 121 characters
$group->get('/layout/form/retire/{id}', ['\Xibo\Controller\Layout', 'retireForm'])->setName('layout.retire.form');
$group->get('/layout/form/unretire/{id}', ['\Xibo\Controller\Layout', 'unretireForm'])->setName('layout.unretire.form');

Check warning on line 160 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 124 characters
$group->get('/layout/form/setenablestat/{id}', ['\Xibo\Controller\Layout', 'setEnableStatForm'])->setName('layout.setenablestat.form');

Check warning on line 161 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 139 characters
})->addMiddleware(new FeatureAuth($app->getContainer(), ['layout.modify', 'template.modify']));

$app->group('', function(\Slim\Routing\RouteCollectorProxy $group) {
Expand All @@ -185,7 +185,7 @@
$group->get('/region/form/delete/{id}', ['\Xibo\Controller\Region', 'deleteForm'])->setName('region.delete.form');

// Designer
$group->get('/playlist/form/library/assign/{id}', ['\Xibo\Controller\Playlist','libraryAssignForm'])->setName('playlist.library.assign.form');

Check warning on line 188 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 146 characters

// Outputs
$group->get('/playlist/widget/resource/{regionId}[/{id}]', [
Expand All @@ -199,7 +199,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');

Check warning on line 202 in lib/routes-web.php

View workflow job for this annotation

GitHub Actions / phpcs

Line exceeds 120 characters; contains 133 characters
$group->get('/playlist/widget/form/delete/{id}', ['\Xibo\Controller\Widget','deleteWidgetForm'])->setName('module.widget.delete.form');
$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');
Expand Down Expand Up @@ -706,13 +706,6 @@
$group->get('/tag/form/usage/{id}', ['\Xibo\Controller\Tag', 'usageForm'])->setName('tag.usage.form');
})->addMiddleware(new FeatureAuth($app->getContainer(), ['tag.view']));

// Actions
$app->group('', function(\Slim\Routing\RouteCollectorProxy $group) {
$group->get('/action/form/add/{source}/{id}', ['\Xibo\Controller\Action', 'addForm'])->setName('action.add.form');
$group->get('/action/form/edit/{id}', ['\Xibo\Controller\Action', 'editForm'])->setName('action.edit.form');
$group->get('/action/form/delete/{id}', ['\Xibo\Controller\Action', 'deleteForm'])->setName('action.delete.form');
})->addMiddleware(new FeatureAuth($app->getContainer(), ['layout.modify', 'playlist.modify']));

// Menu Boards
$app->group('', function (\Slim\Routing\RouteCollectorProxy $group) {
$group->get('/menuboard/view', ['\Xibo\Controller\MenuBoard','displayPage'])->setName('menuBoard.view');
Expand Down
23 changes: 22 additions & 1 deletion ui/src/editor-core/properties-panel.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
* Xibo is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* Xibo is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
*/

/* eslint-disable new-cap */
// PROPERTIES PANEL Module

Expand Down Expand Up @@ -1899,7 +1920,7 @@ PropertiesPanel.prototype.openEditAction = function(action) {
$newActionContainer.data(actionData);

// Form conditions
forms.setConditions($newActionContainer);
forms.setConditions($newActionContainer, null, 'actions');

// Initialise tooltips
app.common.reloadTooltips(
Expand Down
34 changes: 20 additions & 14 deletions ui/src/editor-core/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ Toolbar.prototype.init = function({isPlaylist = false} = {}) {
moduleId: 'playlist',
name: toolbarTrans.playlist,
type: 'playlist',
icon: 'fa fa-list-ol',
dataType: '',
regionSpecific: 1,
group: [],
Expand All @@ -181,6 +182,7 @@ Toolbar.prototype.init = function({isPlaylist = false} = {}) {
moduleId: 'zone',
name: toolbarTrans.zone,
type: 'zone',
icon: 'fas fa-border-none',
dataType: '',
target: 'layout',
});
Expand Down Expand Up @@ -233,43 +235,43 @@ Toolbar.prototype.init = function({isPlaylist = false} = {}) {
this.interactiveList = [
{
name: toolbarTrans.interactive.actions.navWidget,
icon: 'fa fa-arrows-alt',
icon: 'fa fa-square-o',
type: 'navWidget',
target: '["frame"]',
dataType: '',
},
{
name: toolbarTrans.interactive.actions.navLayout,
icon: 'fa fa-arrows-alt',
icon: 'fa fa-desktop',
type: 'navLayout',
target: '["layout"]',
dataType: '',
},
{
name: toolbarTrans.interactive.actions.nextWidget,
icon: 'fa-arrow-right-alt',
type: 'nextWidget',
name: toolbarTrans.interactive.actions.previousWidget,
icon: 'fa fa-caret-square-o-left',
type: 'previousWidget',
target: '["playlist"]',
dataType: '',
},
{
name: toolbarTrans.interactive.actions.previousWidget,
icon: 'fa-arrow-left-alt',
type: 'previousWidget',
name: toolbarTrans.interactive.actions.nextWidget,
icon: 'fa fa-caret-square-o-right',
type: 'nextWidget',
target: '["playlist"]',
dataType: '',
},
{
name: toolbarTrans.interactive.actions.nextLayout,
icon: 'fa-arrow-right',
type: 'nextLayout',
name: toolbarTrans.interactive.actions.previousLayout,
icon: 'fa fa-arrow-circle-left',
type: 'previousLayout',
target: '["layout"]',
dataType: '',
},
{
name: toolbarTrans.interactive.actions.previousLayout,
icon: 'fa-arrow-left',
type: 'previousLayout',
name: toolbarTrans.interactive.actions.nextLayout,
icon: 'fa fa-arrow-circle-right',
type: 'nextLayout',
target: '["layout"]',
dataType: '',
},
Expand Down Expand Up @@ -1540,6 +1542,10 @@ Toolbar.prototype.mediaContentPopulate = function(menu) {
element.videoThumbnail = element.thumbnail;
}

// Resolve the icon
element.icon = modulesList.filter((el) =>
el.type === element.type)[0]?.icon || null;

// Use template
const $card = $(ToolbarCardMediaTemplate(element));

Expand Down
9 changes: 6 additions & 3 deletions ui/src/layout-editor/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3944,8 +3944,9 @@ lD.populateDropdownWithLayoutElements = function(
let typeInputValue = $dropdown.find(':selected').data('type');

// Update targetId and target
// Input fields are prepended with input_
if (
$typeInput.attr('id') === 'target'
$typeInput.attr('id') === 'input_target'
) {
// Update targetId and target
actionData.targetId = $dropdown.val();
Expand All @@ -3954,7 +3955,7 @@ lD.populateDropdownWithLayoutElements = function(

// Update sourceId and source
if (
$typeInput.attr('id') === 'source'
$typeInput.attr('id') === 'input_source'
) {
// Update sourceId and source
actionData.sourceId = $dropdown.val();
Expand All @@ -3971,7 +3972,9 @@ lD.populateDropdownWithLayoutElements = function(
}

// For target, if target is layout, change it to screen
if ($typeInput.attr('id') === 'target' && typeInputValue === 'layout') {
if ($typeInput.attr('id') === 'input_target' &&
typeInputValue === 'layout'
) {
typeInputValue = 'screen';
}

Expand Down
25 changes: 0 additions & 25 deletions ui/src/style/common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -271,31 +271,6 @@ $fa-font-path: "~font-awesome/fonts";
@extend .fa, .fa-user-secret;
}

/* Actions icons */
.actions-icon-navLayout {
@extend .fa, .fa-desktop;
}

.actions-icon-navWidget {
@extend .fa, .fa-square-o;
}

.actions-icon-nextWidget {
@extend .fa, .fa-caret-square-o-right;
}

.actions-icon-previousWidget {
@extend .fa, .fa-caret-square-o-left;
}

.actions-icon-nextLayout {
@extend .fa, .fa-arrow-circle-right;
}

.actions-icon-previousLayout {
@extend .fa, .fa-arrow-circle-left;
}

/* Form icons */
.bg_not_found_icon {
@extend .fa, .fa-exclamation-triangle;
Expand Down
Loading
Loading