Skip to content

Commit

Permalink
Paging : use paged select2 where needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMis committed Nov 6, 2023
1 parent 62e7418 commit 2ce2606
Show file tree
Hide file tree
Showing 23 changed files with 197 additions and 58 deletions.
1 change: 0 additions & 1 deletion lib/Controller/Applications.php
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,6 @@ public function editForm(Request $request, Response $response, $id)
$this->getState()->setData([
'client' => $client,
'scopes' => $scopes,
'users' => $this->userFactory->query(),
]);

return $this->render($request, $response);
Expand Down
3 changes: 0 additions & 3 deletions lib/Controller/DataSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,6 @@ public function getDataSetFactory()
public function displayPage(Request $request, Response $response)
{
$this->getState()->template = 'dataset-page';
$this->getState()->setData([
'users' => $this->userFactory->query(),
]);

return $this->render($request, $response);
}
Expand Down
1 change: 0 additions & 1 deletion lib/Controller/Display.php
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ function displayPage(Request $request, Response $response)

$this->getState()->setData([
'mapConfig' => $mapConfig,
'displayGroups' => $this->displayGroupFactory->query(),
'displayProfiles' => $displayProfiles
]);

Expand Down
5 changes: 0 additions & 5 deletions lib/Controller/Layout.php
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,6 @@ function displayPage(Request $request, Response $response)
{
// Call to render the template
$this->getState()->template = 'layout-page';
$this->getState()->setData([
'users' => $this->userFactory->query(),
'groups' => $this->userGroupFactory->query(),
'displayGroups' => $this->displayGroupFactory->query(null, ['isDisplaySpecific' => -1])
]);

return $this->render($request, $response);
}
Expand Down
2 changes: 0 additions & 2 deletions lib/Controller/Library.php
Original file line number Diff line number Diff line change
Expand Up @@ -296,9 +296,7 @@ public function displayPage(Request $request, Response $response)
// Users we have permission to see
$this->getState()->template = 'library-page';
$this->getState()->setData([
'users' => $this->userFactory->query(),
'modules' => $this->moduleFactory->getLibraryModules(),
'groups' => $this->userGroupFactory->query(),
'validExt' => implode('|', $this->moduleFactory->getValidExtensions([]))
]);
}
Expand Down
3 changes: 0 additions & 3 deletions lib/Controller/Logging.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ public function __construct($store, $logFactory, $userFactory)
public function displayPage(Request $request, Response $response)
{
$this->getState()->template = 'log-page';
$this->getState()->setData([
'users' => $this->userFactory->query()
]);

return $this->render($request, $response);
}
Expand Down
4 changes: 1 addition & 3 deletions lib/Controller/MenuBoard.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ public function displayPage(Request $request, Response $response)
{
// Call to render the template
$this->getState()->template = 'menuboard-page';
$this->getState()->setData([
'users' => $this->userFactory->query()
]);

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

Expand Down
2 changes: 0 additions & 2 deletions lib/Controller/Playlist.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ public function displayPage(Request $request, Response $response)
// Call to render the template
$this->getState()->template = 'playlist-page';
$this->getState()->setData([
'users' => $this->userFactory->query(),
'groups' => $this->userGroupFactory->query(),
'modules' => $moduleFactory->getAssignableModules()
]);

Expand Down
4 changes: 1 addition & 3 deletions lib/Controller/SavedReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Copyright (C) 2023 Xibo Signage Ltd
*
* Xibo - Digital Signage - http://www.xibo.org.uk
* Xibo - Digital Signage - https://xibosignage.com
*
* This file is part of Xibo.
*
Expand All @@ -24,7 +24,6 @@

use Slim\Http\Response as Response;
use Slim\Http\ServerRequest as Request;
use Xibo\Entity\Media;
use Xibo\Entity\ReportResult;
use Xibo\Factory\MediaFactory;
use Xibo\Factory\ReportScheduleFactory;
Expand Down Expand Up @@ -218,7 +217,6 @@ public function displaySavedReportPage(Request $request, Response $response)
// Call to render the template
$this->getState()->template = 'saved-report-page';
$this->getState()->setData([
'users' => $this->userFactory->query(),
'availableReports' => $availableReports
]);

Expand Down
4 changes: 0 additions & 4 deletions lib/Controller/ScheduleReport.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Slim\Http\Response as Response;
use Slim\Http\ServerRequest as Request;
use Slim\Views\Twig;
use Xibo\Entity\Media;
use Xibo\Entity\ReportSchedule;
use Xibo\Factory\MediaFactory;
use Xibo\Factory\ReportScheduleFactory;
Expand All @@ -37,8 +36,6 @@
use Xibo\Service\ConfigServiceInterface;
use Xibo\Service\LogServiceInterface;
use Xibo\Service\ReportServiceInterface;
use Xibo\Storage\StorageServiceInterface;
use Xibo\Storage\TimeSeriesStoreInterface;
use Xibo\Support\Exception\AccessDeniedException;
use Xibo\Support\Exception\GeneralException;
use Xibo\Support\Exception\InvalidArgumentException;
Expand Down Expand Up @@ -582,7 +579,6 @@ public function displayReportSchedulePage(Request $request, Response $response)
// Call to render the template
$this->getState()->template = 'report-schedule-page';
$this->getState()->setData([
'users' => $this->userFactory->query(),
'availableReports' => $availableReports
]);

Expand Down
1 change: 0 additions & 1 deletion lib/Controller/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -1759,7 +1759,6 @@ public function permissionsForm(Request $request, Response $response, $entity, $
'objectId' => $id,
'permissions' => $currentPermissions,
'canSetOwner' => $object->canChangeOwner(),
'owners' => $this->userFactory->query(),
'object' => $object,
'objectNameOverride' => $this->getSanitizer($request->getParams())->getString('nameOverride'),
];
Expand Down
13 changes: 12 additions & 1 deletion ui/src/core/xibo-cms.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,12 @@ function XiboInitialise(scope, options) {
} else if (field.length > 0) {
field.val(element.value);
}

// if we have pagedSelect as inline filter for the grid
// set the initial value here, to ensure the correct option gets selected.
if (field.parent().hasClass('pagedSelect')) {
field.data('initial-value', element.value)
}
} catch (e) {
console.log("Error populating form saved value with selector input[name=" + element.name + "], select[name=" + element.name + "]");
}
Expand Down Expand Up @@ -3309,10 +3315,15 @@ function makePagedSelect(element, parent) {
) {
var initialValue = element.data("initialValue");
var initialKey = element.data("initialKey");

var dataObj = {};
dataObj[initialKey] = initialValue;

// if we have any filter options, add them here as well
// for example isDisplaySpecific filter is important for displayGroup.search
if (element.data("filterOptions") !== undefined) {
dataObj = $.extend({}, dataObj, element.data("filterOptions"));
}

$.ajax({
url: element.data("searchUrl"),
type: 'GET',
Expand Down
17 changes: 14 additions & 3 deletions views/applications-form-edit.twig
Original file line number Diff line number Diff line change
Expand Up @@ -132,9 +132,20 @@
{% endfor %}

{% set title %}{% trans "Owner" %}{% endset %}
{% set helpText %}{% trans "Set the owner of this Application. If you are not an admin you will not be able to reverse this action." %}{% endset %}
{% set users = [{userId: null, user: ""}]|merge(users) %}
{{ forms.dropdown("userId", "single", title, "", users, "userId", "userName", helpText) }}
{% set helpText %}{% trans "Set the owner of this Application. Leave empty to keep the current owner. If you are not an admin you will not be able to reverse this action" %}{% endset %}
{% set attributes = [
{ name: "data-width", value: "100%" },
{ name: "data-allow-clear", value: "true" },
{ name: "data-placeholder--id", value: null },
{ name: "data-placeholder--value", value: "" },
{ name: "data-search-url", value: url_for("user.search") },
{ name: "data-search-term", value: "userName" },
{ name: "data-search-term-tags", value: "tags" },
{ name: "data-id-property", value: "userId" },
{ name: "data-text-property", value: "userName" },
{ name: "data-anchor-element", value: "#applicationFormSubmit"}
] %}
{{ forms.dropdown("userId", "single", title, "", null, "userId", "userName", helpText, "pagedSelect", "", "", "", attributes) }}
</div>
</div>
</form>
Expand Down
14 changes: 13 additions & 1 deletion views/dataset-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,19 @@

{% set title %}{% trans "Owner" %}{% endset %}
{% set helpText %}{% trans "Show items owned by the selected User." %}{% endset %}
{{ inline.dropdown("userId", "single", title, "", [{userId:null, userName:""}]|merge(users), "userId", "userName", helpText, "selectPicker", "", "", "", attributes) }}
{% set attributes = [
{ name: "data-width", value: "200px" },
{ name: "data-allow-clear", value: "true" },
{ name: "data-placeholder--id", value: null },
{ name: "data-placeholder--value", value: "" },
{ name: "data-search-url", value: url_for("user.search") },
{ name: "data-search-term", value: "userName" },
{ name: "data-search-term-tags", value: "tags" },
{ name: "data-id-property", value: "userId" },
{ name: "data-text-property", value: "userName" },
{ name: "data-initial-key", value: "userId" },
] %}
{{ inline.dropdown("userId", "single", title, "", null, "userId", "userName", helpText, "pagedSelect", "", "", "", attributes) }}

{{ inline.hidden("folderId") }}
</form>
Expand Down
14 changes: 13 additions & 1 deletion views/display-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,19 @@

{% if currentUser.featureEnabled("displaygroup.view") %}
{% set title %}{% trans "Display Group" %}{% endset %}
{{ inline.dropdown("displayGroupId", "single", title, "", [{displayGroupId:null, displayGroup:""}]|merge(displayGroups), "displayGroupId", "displayGroup") }}
{% set attributes = [
{ name: "data-width", value: "200px" },
{ name: "data-allow-clear", value: "true" },
{ name: "data-placeholder--id", value: null },
{ name: "data-placeholder--value", value: "" },
{ name: "data-search-url", value: url_for("displayGroup.search") },
{ name: "data-filter-options", value: '{"isDisplaySpecific":0}' },
{ name: "data-search-term", value: "displayGroup" },
{ name: "data-id-property", value: "displayGroupId" },
{ name: "data-text-property", value: "displayGroup" },
{ name: "data-initial-key", value: "displayGroupId" },
] %}
{{ inline.dropdown("displayGroupId", "single", title, "", null, "displayGroupId", "displayGroup", helpText, "pagedSelect", "", "", "", attributes) }}
{% endif %}

{% if currentUser.featureEnabled("displayprofile.view") %}
Expand Down
47 changes: 38 additions & 9 deletions views/layout-page.twig
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,54 @@
{% set title %}{% trans "Code" %}{% endset %}
{{ inline.input('codeLike', title) }}

{% set attributes = [
{ name: "data-allow-clear", value: "true" },
{ name: "data-placeholder--id", value: null },
{ name: "data-placeholder--value", value: "" }
] %}

{% if currentUser.featureEnabled("displaygroup.view") %}
{% set title %}{% trans "Display Group" %}{% endset %}
{% set helpText %}{% trans "Show Layouts active on the selected Display / Display Group" %}{% endset %}
{{ inline.dropdown("activeDisplayGroupId", "single", title, "", [{displayGroupId:null, displayGroup:""}]|merge(displayGroups), "displayGroupId", "displayGroup", helpText, "selectPicker", "", "", "", attributes) }}
{% set attributes = [
{ name: "data-width", value: "200px" },
{ name: "data-allow-clear", value: "true" },
{ name: "data-placeholder--id", value: null },
{ name: "data-placeholder--value", value: "" },
{ name: "data-search-url", value: url_for("displayGroup.search") },
{ name: "data-filter-options", value: '{"isDisplaySpecific":-1}' },
{ name: "data-search-term", value: "displayGroup" },
{ name: "data-id-property", value: "displayGroupId" },
{ name: "data-text-property", value: "displayGroup" },
{ name: "data-initial-key", value: "displayGroupId" },
] %}
{{ inline.dropdown("activeDisplayGroupId", "single", title, "", null, "displayGroupId", "displayGroup", helpText, "pagedSelect", "", "", "", attributes) }}
{% endif %}

{% set title %}{% trans "Owner" %}{% endset %}
{% set helpText %}{% trans "Show items owned by the selected User." %}{% endset %}
{{ inline.dropdown("userId", "single", title, "", [{userId:null, userName:""}]|merge(users), "userId", "userName", helpText, "selectPicker", "", "", "", attributes) }}
{% set attributes = [
{ name: "data-width", value: "200px" },
{ name: "data-allow-clear", value: "true" },
{ name: "data-placeholder--id", value: null },
{ name: "data-placeholder--value", value: "" },
{ name: "data-search-url", value: url_for("user.search") },
{ name: "data-search-term", value: "userName" },
{ name: "data-search-term-tags", value: "tags" },
{ name: "data-id-property", value: "userId" },
{ name: "data-text-property", value: "userName" },
{ name: "data-initial-key", value: "userId" },
] %}
{{ inline.dropdown("userId", "single", title, "", null, "userId", "userName", helpText, "pagedSelect", "", "", "", attributes) }}

{% set title %}{% trans "Owner User Group" %}{% endset %}
{% set helpText %}{% trans "Show items owned by users in the selected User Group." %}{% endset %}
{{ inline.dropdown("ownerUserGroupId", "single", title, "", [{groupId:null, group:""}]|merge(groups), "groupId", "group", helpText, "selectPicker", "", "", "", attributes) }}
{% set attributes = [
{ name: "data-width", value: "200px" },
{ name: "data-allow-clear", value: "true" },
{ name: "data-placeholder--id", value: null },
{ name: "data-placeholder--value", value: "" },
{ name: "data-search-url", value: url_for("group.search") },
{ name: "data-search-term", value: "group" },
{ name: "data-id-property", value: "groupId" },
{ name: "data-text-property", value: "group" },
{ name: "data-initial-key", value: "userGroupId" },
] %}
{{ inline.dropdown("ownerUserGroupId", "single", title, "", null, "groupId", "group", helpText, "pagedSelect", "", "", "", attributes) }}

{% set title %}{% trans "Orientation" %}{% endset %}
{% set option1 = "All"|trans %}
Expand Down
Loading

0 comments on commit 2ce2606

Please sign in to comment.