Skip to content

Commit b2daa1c

Browse files
Enhanced filtering on the schedule page - Front-End (#3150)
relates to xibosignageltd/xibo-private#1043
1 parent 74fd723 commit b2daa1c

File tree

19 files changed

+1543
-1019
lines changed

19 files changed

+1543
-1019
lines changed

lib/Controller/DataTablesDotNetTrait.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ protected function gridRenderFilter(array $extraFilter, $sanitizedRequestParams
4545
}
4646

4747
// Handle filtering
48-
$filter = [
49-
'start' => $sanitizedRequestParams->getInt('start', ['default' => 0]),
50-
'length' => $sanitizedRequestParams->getInt('length', ['default' => 10])
51-
];
48+
$filter = [];
49+
if ($sanitizedRequestParams->getInt('disablePaging') != 1) {
50+
$filter['start'] = $sanitizedRequestParams->getInt('start', ['default' => 0]);
51+
$filter['length'] = $sanitizedRequestParams->getInt('length', ['default' => 10]);
52+
}
5253

5354
$search = $sanitizedRequestParams->getArray('search', ['default' => []]);
5455
if (is_array($search) && isset($search['value'])) {

lib/Controller/Schedule.php

Lines changed: 41 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -471,9 +471,29 @@ public function eventData(Request $request, Response $response)
471471
* required=true
472472
* ),
473473
* @SWG\Parameter(
474+
* name="singlePointInTime",
475+
* in="query",
476+
* required=false,
477+
* type="integer",
478+
* ),
479+
* @SWG\Parameter(
474480
* name="date",
475481
* in="query",
476-
* required=true,
482+
* required=false,
483+
* type="string",
484+
* description="Date in Y-m-d H:i:s"
485+
* ),
486+
* @SWG\Parameter(
487+
* name="startDate",
488+
* in="query",
489+
* required=false,
490+
* type="string",
491+
* description="Date in Y-m-d H:i:s"
492+
* ),
493+
* @SWG\Parameter(
494+
* name="endDate",
495+
* in="query",
496+
* required=false,
477497
* type="string",
478498
* description="Date in Y-m-d H:i:s"
479499
* ),
@@ -495,15 +515,24 @@ public function eventList(Request $request, Response $response, $id)
495515
// Setting for whether we show Layouts with out permissions
496516
$showLayoutName = ($this->getConfig()->getSetting('SCHEDULE_SHOW_LAYOUT_NAME') == 1);
497517

498-
$date = $sanitizedParams->getDate('date');
518+
$singlePointInTime = $sanitizedParams->getInt('singlePointInTime');
519+
if ($singlePointInTime == 1) {
520+
$startDate = $sanitizedParams->getDate('date');
521+
$endDate = $sanitizedParams->getDate('date');
522+
} else {
523+
$startDate = $sanitizedParams->getDate('startDate');
524+
$endDate = $sanitizedParams->getDate('endDate');
525+
}
499526

500527
// Reset the seconds
501-
$date->second(0);
528+
$startDate->second(0);
529+
$endDate->second(0);
502530

503531
$this->getLog()->debug(
504532
sprintf(
505-
'Generating eventList for DisplayGroupId ' . $id . ' on date '
506-
. $date->format(DateFormatHelper::getSystemFormat())
533+
'Generating eventList for DisplayGroupId ' . $id . ' from date '
534+
. $startDate->format(DateFormatHelper::getSystemFormat()) . ' to '
535+
. $endDate->format(DateFormatHelper::getSystemFormat())
507536
)
508537
);
509538

@@ -529,7 +558,12 @@ public function eventList(Request $request, Response $response, $id)
529558
}
530559

531560
// Get list of events
532-
$scheduleForXmds = $this->scheduleFactory->getForXmds(($display === null) ? null : $display->displayId, $date, $date, $options);
561+
$scheduleForXmds = $this->scheduleFactory->getForXmds(
562+
($display === null) ? null : $display->displayId,
563+
$startDate,
564+
$endDate,
565+
$options
566+
);
533567

534568
$this->getLog()->debug(count($scheduleForXmds) . ' events returned for displaygroup and date');
535569

@@ -551,7 +585,7 @@ public function eventList(Request $request, Response $response, $id)
551585

552586
// Get scheduled events based on recurrence
553587
try {
554-
$scheduleEvents = $schedule->getEvents($date, $date);
588+
$scheduleEvents = $schedule->getEvents($startDate, $endDate);
555589
} catch (GeneralException $e) {
556590
$this->getLog()->error('Unable to getEvents for ' . $schedule->eventId);
557591
continue;

lib/Factory/ScheduleFactory.php

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -658,29 +658,49 @@ public function query($sortOrder = null, $filterBy = [])
658658
}
659659
}
660660

661-
// Future schedules?
661+
// Future schedules FROM a date?
662662
if ($parsedFilter->getInt('futureSchedulesFrom') !== null
663663
&& $parsedFilter->getInt('futureSchedulesTo') === null
664664
) {
665665
// Get schedules that end after this date, or that recur after this date
666666
$body .= ' AND (IFNULL(`schedule`.toDt, `schedule`.fromDt) >= :futureSchedulesFrom
667-
OR `schedule`.recurrence_range >= :futureSchedulesFrom OR (IFNULL(`schedule`.recurrence_range, 0) = 0)
668-
AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\') ';
667+
OR `schedule`.recurrence_range >= :futureSchedulesFrom OR (IFNULL(`schedule`.recurrence_range, 0) = 0)
668+
AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\') ';
669669
$params['futureSchedulesFrom'] = $parsedFilter->getInt('futureSchedulesFrom');
670670
}
671671

672+
// Future schedules BETWEEN two dates?
672673
if ($parsedFilter->getInt('futureSchedulesFrom') !== null
673674
&& $parsedFilter->getInt('futureSchedulesTo') !== null
674675
) {
675-
// Get schedules that end after this date, or that recur after this date
676-
$body .= ' AND ((schedule.fromDt < :futureSchedulesTo
677-
AND IFNULL(`schedule`.toDt, `schedule`.fromDt) >= :futureSchedulesFrom)
678-
OR `schedule`.recurrence_range >= :futureSchedulesFrom OR (IFNULL(`schedule`.recurrence_range, 0) = 0
679-
AND IFNULL(`schedule`.recurrence_type, \'\') <> \'\') ) ';
676+
// Get schedules that overlap the range OR recur within the range
677+
$body .= ' AND (
678+
(
679+
schedule.fromDt < :futureSchedulesTo
680+
AND IFNULL(`schedule`.toDt, `schedule`.fromDt) >= :futureSchedulesFrom
681+
)
682+
OR (
683+
IFNULL(`schedule`.recurrence_type, \'\') <> \'\'
684+
AND `schedule`.fromDt < :futureSchedulesTo
685+
AND (
686+
`schedule`.recurrence_range >= :futureSchedulesFrom
687+
OR IFNULL(`schedule`.recurrence_range, 0) = 0
688+
)
689+
)
690+
) ';
680691
$params['futureSchedulesFrom'] = $parsedFilter->getInt('futureSchedulesFrom');
681692
$params['futureSchedulesTo'] = $parsedFilter->getInt('futureSchedulesTo');
682693
}
683694

695+
// Future schedules UNTIL a date?
696+
if ($parsedFilter->getInt('futureSchedulesFrom') === null
697+
&& $parsedFilter->getInt('futureSchedulesTo') !== null
698+
) {
699+
// Get schedules that start before this date.
700+
$body .= ' AND `schedule`.fromDt < :futureSchedulesTo ';
701+
$params['futureSchedulesTo'] = $parsedFilter->getInt('futureSchedulesTo');
702+
}
703+
684704
// Restrict to mediaId - meaning layout schedules of which the layouts contain the selected mediaId
685705
if ($parsedFilter->getInt('mediaId') !== null) {
686706
$body .= '

ui/bundle_templates.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ window.templates = {
112112
year: require('./src/templates/calendar/year.hbs'),
113113
'year-month': require('./src/templates/calendar/year-month.hbs'),
114114
agenda: require('./src/templates/calendar/agenda.hbs'),
115+
agendaFilter: require('./src/templates/calendar/agenda-filter.hbs'),
115116
'agenda-layouts': require('./src/templates/calendar/agenda-layouts.hbs'),
116117
'agenda-displaygroups':
117118
require('./src/templates/calendar/agenda-display-groups.hbs'),

0 commit comments

Comments
 (0)