Skip to content

Commit 7f03783

Browse files
refactor(frontend): Show sieve filter match type dropdown conditionnaly
1 parent b8c791b commit 7f03783

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

modules/imap/setup.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
/* add stuff to the info page */
1717
add_output('info', 'display_imap_status', true, 'imap', 'server_status_start', 'after');
1818
add_output('info', 'display_imap_capability', true, 'imap', 'server_capabilities_start', 'after');
19+
add_output('info', 'server_capabilities_end', true, 'developer', 'server_capabilities_start', 'after');
20+
add_output('info', 'config_map', true, 'developer', 'server_capabilities_end', 'after');
1921
add_output('info', 'imap_server_ids', true, 'imap', 'page_js', 'before');
2022

2123
/* servers page data */

modules/sievefilters/functions.php

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ function get_classic_filter_modal_content()
4646
<label for="sieve-filter-priority" class="form-label fw-bold">Priority:</label>
4747
<input class="modal_sieve_filter_priority form-control" type="number" placeholder="0" id="sieve-filter-priority" />
4848
</div>
49-
<div class="mb-2">
50-
<label for="sieve-filter-test" class="form-label fw-bold">Test:</label>
51-
<select class="modal_sieve_filter_test form-control" name="test_type" placeholder="0" id="sieve-filter-test">
52-
<option value="ANYOF">ANYOF (OR)</option>
53-
<option value="ALLOF" selected>ALLOF (AND)</option>
54-
</select>
55-
</div>
5649
<div class="d-block mb-2 mt-4">
5750
<h3 class="mb-1">Conditions & Actions</h3>
5851
<small>Filters must have at least one action and one condition</small>

modules/sievefilters/site.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -630,7 +630,7 @@ function sieveFiltersPageHandler() {
630630
});
631631
let extra_options = '<td class="col-sm-3"><input type="hidden" class="condition_extra_value form-control form-control-sm" name="sieve_selected_extra_option_value[]" /></td>';
632632
$('.sieve_list_conditions_modal').append(
633-
' <tr>' +
633+
' <tr class="sieve_condition_row">' +
634634
' <td class="col-sm-2">' +
635635
' <select class="add_condition_sieve_filters form-control form-control-sm" name="sieve_selected_conditions_field[]">' +
636636
' <optgroup label="Message">' +
@@ -674,11 +674,30 @@ function sieveFiltersPageHandler() {
674674
);
675675
}
676676

677+
function add_filter_match_mode() {
678+
let conditionRows = $(".sieve_list_conditions_modal tr").length;
679+
if (conditionRows >= 2) {
680+
if ($(".sieve_match_mode").length === 0) {
681+
$(".sieve_list_conditions_modal").before(
682+
'<div class="sieve_match_mode mb-2">' +
683+
' <label class="me-2">Match</label>' +
684+
' <select name="sieve_match_mode" class="modal_sieve_filter_test form-select-sm d-inline w-auto">' +
685+
' <option value="ALLOF">ALL</option>' +
686+
' <option value="ANYOF">ANY</option>' +
687+
" </select>" +
688+
" of the following rules:" +
689+
"</div>"
690+
);
691+
}
692+
}
693+
}
694+
677695
/**
678696
* Add Condition Button
679697
*/
680698
$(document).on('click', '.sieve_add_condition_modal_button', function () {
681699
add_filter_condition();
700+
add_filter_match_mode();
682701
});
683702

684703
function add_filter_action(default_value = '') {

0 commit comments

Comments
 (0)