Skip to content

Commit 0e1c61d

Browse files
Merge pull request #4093 from IgorA100/patch-157
Feat: Show filter "Archive Status" on Events page
2 parents 4c9f6d3 + 119e723 commit 0e1c61d

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

web/includes/Filter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,15 +1120,15 @@ public function simple_widget() {
11201120

11211121
if ( $term['attr'] == 'Archived' ) {
11221122
$html .= '<span class="term-value-wrapper">';
1123-
$html .= htmlSelect("filter[Query][terms][$i][val]", $archiveTypes, $term['val'],['class'=>'chosen chosen-auto-width']).PHP_EOL;
1123+
$html .= htmlSelect("filter[Query][terms][$i][val]", $archiveTypes, $term['val'],['id'=>'filterArchived', 'class'=>'chosen chosen-auto-width']).PHP_EOL;
11241124
$html .= '</span>';
11251125
} else if ( $term['attr'] == 'Tags' ) {
11261126
$selected = explode(',', $term['val']);
11271127
// echo '<pre>selected: '; print_r($selected); echo '</pre>';
11281128
if (count($selected) == 1 and !$selected[0]) {
11291129
$selected = null;
11301130
}
1131-
$options = ['class'=>'chosen chosen-auto-width', 'multiple'=>'multiple', 'data-placeholder'=>translate('All Tags')];
1131+
$options = ['id'=>'filterTags', 'class'=>'chosen chosen-auto-width', 'multiple'=>'multiple', 'data-placeholder'=>translate('All Tags')];
11321132
if (isset($term['cookie'])) {
11331133
$options['data-cookie'] = $term['cookie'];
11341134

@@ -1256,7 +1256,7 @@ public function simple_widget() {
12561256
['class'=>'term-value chosen chosen-auto-width', 'multiple'=>'multiple']).PHP_EOL;
12571257
$html .= '</span>';
12581258
} else if ( $term['attr'] == 'Notes' ) {
1259-
$attrs = ['class'=>'term-value chosen chosen-auto-width', 'multiple'=>'multiple', 'data-placeholder'=>translate('Event Type')];
1259+
$attrs = ['id'=>'filterNotes', 'class'=>'term-value chosen chosen-auto-width', 'multiple'=>'multiple', 'data-placeholder'=>translate('Event Type')];
12601260
$selected = explode(',', $term['val']);
12611261
if (count($selected) == 1 and !$selected[0]) {
12621262
$selected = null;

web/skins/classic/views/events.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@
6464
'val' => $num_terms ? '' : (isset($_COOKIE['eventsTags']) ? $_COOKIE['eventsTags'] : ''),
6565
'cnj' => 'and', 'cookie'=>'eventsTags'));
6666
}
67-
$filter->sort_terms(['Group','Monitor','StartDateTime','EndDateTime','Notes','Tags']);
67+
if (!$filter->has_term('Archived')) {
68+
$filter->addTerm(array('attr' => 'Archived', 'op' => '=',
69+
'val' => $num_terms ? '' : (isset($_COOKIE['zmFilterArchived']) ? $_COOKIE['zmFilterArchived'] : ''),
70+
'cnj' => 'and', 'cookie'=>'zmFilterArchived'));
71+
}
72+
$filter->sort_terms(['Group','Monitor','StartDateTime','EndDateTime','Notes','Tags','Archived']);
6873
#$filter->addTerm(array('cnj'=>'and', 'attr'=>'AlarmFrames', 'op'=> '>', 'val'=>'10'));
6974
#$filter->addTerm(array('cnj'=>'and', 'attr'=>'StartDateTime', 'op'=> '<=', 'val'=>''));
7075
}

web/skins/classic/views/js/events.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,10 @@ function initPage() {
529529
table.show();
530530
}
531531

532-
function filterEvents() {
532+
function filterEvents(clickedElement) {
533+
if (clickedElement.target && clickedElement.target.id == 'filterArchived') {
534+
setCookie('zmFilterArchived', clickedElement.target.value);
535+
}
533536
filterQuery = '';
534537
$j('#fieldsTable input').each(function(index) {
535538
const el = $j(this);

0 commit comments

Comments
 (0)