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

[EHN]Email filtering: Cypht Sieve filters: Better handling of 'Stop processing more rules' #1098

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
9 changes: 9 additions & 0 deletions modules/sievefilters/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,15 @@ function get_classic_filter_modal_content()
</table>
</div>
</div>
<hr/>
<div class="p-3">
<div class="d-flex">
<div class="col-sm-10">
<input type="checkbox" id="stop_filtering"/>
<label for="stop_filtering" class="form-label">Stop filtering</label>
</div>
</div>
</div>
</div>
</div>';
}
Expand Down
41 changes: 26 additions & 15 deletions modules/sievefilters/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ var hm_sieve_possible_actions = function() {
type: 'none',
extra_field: false
},
{
name: 'stop',
description: 'Stop Filtering',
type: 'none',
extra_field: false
},
{
name: 'copy',
description: 'Copy email to mailbox',
Expand Down Expand Up @@ -456,6 +450,16 @@ $(function () {
idx = idx + 1;
});

if ($('#stop_filtering').is(':checked')) {
actions_parsed.push(
{
'action': "stop",
'value': "",
'extra_option': "",
'extra_option_value': "",
}
)
}
if ($('.modal_sieve_filter_name').val() == "") {
Hm_Utils.add_sys_message(hm_trans('Filter name is required'), 'danger');
return false;
Expand Down Expand Up @@ -523,6 +527,9 @@ $(function () {
});
$('.add_filter').on('click', function () {
edit_filter_modal.setTitle('Add Filter');
$('.modal_sieve_filter_priority').val('');
$('.modal_sieve_filter_test').val('ALLOF');
$('#stop_filtering').prop('checked', false);
current_account = $(this).attr('account');
edit_filter_modal.open();
});
Expand Down Expand Up @@ -648,7 +655,6 @@ $(function () {
}
possible_actions_html += '<option value="'+value.name+'">' + value.description + '</option>';
});

let extra_options = '<td class="col-sm-3"><input type="hidden" class="condition_extra_action_value form-control form-control-sm" name="sieve_selected_extra_action_value[]" /></td>';
$('.filter_actions_modal_table').append(
'<tr class="border" default_value="'+default_value+'">' +
Expand Down Expand Up @@ -905,6 +911,7 @@ $(function () {
is_editing_filter = true;
current_editing_filter_name = $(this).attr('script_name');
current_account = $(this).attr('imap_account');
// $('#stop_filtering').prop('checked', false);
$('.modal_sieve_filter_name').val($(this).attr('script_name_parsed'));
$('.modal_sieve_filter_priority').val($(this).attr('priority'));
$('.sieve_list_conditions_modal').html('');
Expand All @@ -930,14 +937,18 @@ $(function () {
});

actions.forEach(function (action) {
add_filter_action(action.value);
$(".sieve_actions_select").last().val(action.action);
$(".sieve_actions_select").last().trigger('change');
$("[name^=sieve_selected_extra_action_value]").last().val(action.extra_option_value);
if ($("[name^=sieve_selected_action_value]").last().is('input')) {
$("[name^=sieve_selected_action_value]").last().val(action.value);
} else if ($("[name^=sieve_selected_action_value]").last().is('textarea')) {
$("[name^=sieve_selected_action_value]").last().text(action.value);
if (action.action === "stop") {
$('#stop_filtering').prop('checked', true);
} else {
add_filter_action(action.value);
$(".sieve_actions_select").last().val(action.action);
$(".sieve_actions_select").last().trigger('change');
$("[name^=sieve_selected_extra_action_value]").last().val(action.extra_option_value);
if ($("[name^=sieve_selected_action_value]").last().is('input')) {
$("[name^=sieve_selected_action_value]").last().val(action.value);
} else if ($("[name^=sieve_selected_action_value]").last().is('textarea')) {
$("[name^=sieve_selected_action_value]").last().text(action.value);
}
}
});
}
Expand Down