Skip to content

Commit

Permalink
Merge pull request cypht-org#887 from josaphatim/sieve-pages-in-bs
Browse files Browse the repository at this point in the history
Ported sieve module to bootstrap
  • Loading branch information
marclaporte authored Feb 12, 2024
2 parents 77930b4 + cca887c commit 2c635a4
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 123 deletions.
Binary file removed modules/core/assets/images/spinner.gif
Binary file not shown.
2 changes: 1 addition & 1 deletion modules/core/site.js
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,7 @@ var Hm_Folders = {
$('.src_name').on("click", function() { return Hm_Utils.toggle_section($(this).data('source')); });
$('.update_message_list').on("click", function(e) {
var text = e.target.innerHTML;
e.target.innerHTML = '<img src="'+hm_web_root_path()+'modules/core/assets/images/spinner.gif" />';
e.target.innerHTML = '<div class="spinner-border spinner-border-sm text-dark role="status"><span class="visually-hidden">Loading...</span></div>';
Hm_Folders.update_folder_list();
Hm_Ajax.add_callback_hook('hm_reload_folders', function() {
e.target.innerHTML = text;
Expand Down
2 changes: 2 additions & 0 deletions modules/imap/site.css
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
.imap_update a { color: teal; font-size: 75%; vertical-align: 1px; text-decoration: none; padding-left: 10px; letter-spacing: 0px; }
.close_link { float: right; padding-right: 20px; text-decoration: none; color: teal; font-size: 90%; margin-bottom: 10px;}
.header_links { padding-top: 10px !important; }
.header_links #dropdownMenuSnooze { padding: 0; border: unset; }
.header_links #dropdownMenuSnooze:hover { background-color: inherit; color: inherit; }
.overlay {position: fixed; height: 100%; width: 100%; z-index: 100; background-color: #ccc; opacity: .7; }
.account_row { cursor: pointer; }
.expand_link { margin-right: 0px; margin-left: 0px; font-size: 16px; text-align: left; }
Expand Down
152 changes: 76 additions & 76 deletions modules/sievefilters/modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,7 @@ function get_blocked_senders($mailbox, $mailbox_id, $icon_svg, $icon_block_domai
$action = 'default';
$ret .= 'Default';
}
$ret .= '<a href="#" mailbox_id="'.$mailbox_id.'" data-action="'.$action.'" data-reject-message="'.$reject_message.'" title="'.$module->trans('Change Behavior').'" class="block_sender_link toggle-behavior-dropdown"> <img width="15" height="15" alt="'.
$module->trans('Change Behavior').'" src="'.Hm_Image_Sources::$edit.'" /></a>';
$ret .= '<a href="#" mailbox_id="'.$mailbox_id.'" data-action="'.$action.'" data-reject-message="'.$reject_message.'" title="'.$module->trans('Change Behavior').'" class="block_sender_link toggle-behavior-dropdown"> <i class="bi bi-pencil-fill ms-3"></i></a>';
$ret .= '</td><td><img class="unblock_button" mailbox_id="'.$mailbox_id.'" src="'.$icon_svg.'" />';
if (!strstr($sender, '*')) {
$ret .= ' <img class="block_domain_button" mailbox_id="'.$mailbox_id.'" src="'.$icon_block_domain_svg.'" />';
Expand Down Expand Up @@ -1307,23 +1306,24 @@ protected function output() {
if (array_key_exists($idx, $reject_messages)) {
$default_reject_message = $reject_messages[$idx];
}
$default_behaviour_html = 'Default Behaviour: <select class="select_default_behaviour" imap_account="'.$idx.'">'

$default_behaviour_html = '<div class="col-sm-7 mb-4"><div class="input-group"><span class="input-group-text">Default Behaviour:</span> <select class="select_default_behaviour form-control" imap_account="'.$idx.'">'
.'<option value="Discard"'.($default_behaviour == 'Discard'? ' selected': '').'>Discard</option>'
.'<option value="Reject"'.($default_behaviour == 'Reject'? ' selected': '').'>'.$this->trans('Reject').'</option>'
.'<option value="Move" '.($default_behaviour == 'Move'? ' selected': '').'>'.$this->trans('Move To Blocked Folder').'</option></select>';
if ($default_behaviour == 'Reject') {
$default_behaviour_html .= '<input type="text" class="select_default_reject_message" value="'.$default_reject_message.'" placeholder="'.$this->trans('Reject message').'" />';
$default_behaviour_html .= '<input type="text" class="select_default_reject_message form-control" value="'.$default_reject_message.'" placeholder="'.$this->trans('Reject message').'" />';
}
$default_behaviour_html .= '<button class="submit_default_behavior">Submit</button>';
$default_behaviour_html .= '<button class="submit_default_behavior btn btn-success">Submit</button></div></div>';
$blocked_senders = get_blocked_senders_array($mailbox, $this->get('site_config'), $this->get('user_config'));
$num_blocked = $blocked_senders ? sizeof($blocked_senders) : 0;
$res .= '<div class="sievefilters_accounts_item">';
$res .= '<div class="sievefilters_accounts_title settings_subtitle py-2 border-bottom cursor-pointer d-flex justify-content-between">' . $mailbox['name'];
$res .= '<span class="filters_count"><span id="filter_num_'.$idx.'">'.$num_blocked.'</span> '.$this->trans('blocked'). '</span></div>';
$res .= '<div class="sievefilters_accounts filter_block px-5 py-3" style="display: none;"><div class="filter_subblock">';
$res .= '<div class="sievefilters_accounts filter_block px-5 py-3 d-none"><div class="filter_subblock">';
$res .= $default_behaviour_html;
$res .= '<table class="filter_details"><tbody>';
$res .= '<tr><th style="width: 20px;">Sender</th><th style="width: 40%;">Behavior</th><th style="width: 15%;">Actions</th></tr>';
$res .= '<table class="filter_details table"><tbody>';
$res .= '<tr><th class="col-sm-6">Sender</th><th class="col-sm-3">Behavior</th><th class="col-sm-3">Actions</th></tr>';
$res .= get_blocked_senders($mailbox, $idx, $this->html_safe(Hm_Image_Sources::close('#d80f0f')), $this->html_safe(Hm_Image_Sources::$globe), $this->get('site_config'), $this->get('user_config'), $this);
$res .= '</tbody></table>';
$res .= '</div></div></div>';
Expand Down Expand Up @@ -1352,33 +1352,31 @@ protected function output() {
$res .= '<div class="sievefilters_accounts_item">';
$res .= '<div class="sievefilters_accounts_title settings_subtitle py-2 d-flex justify-content-between border-bottom cursor-pointer">' . $mailbox['name'];
$res .= '<span class="filters_count">' . sprintf($this->trans('%s filters'), $num_filters) . '</span></div>';
$res .= '<div class="sievefilters_accounts filter_block p-3" style="display: none;"><div class="filter_subblock">';
$res .= '<div class="sievefilters_accounts filter_block p-3 d-none"><div class="filter_subblock">';
$res .= '<button class="add_filter btn btn-success" account="'.$mailbox['name'].'">Add Filter</button> <button account="'.$mailbox['name'].'" class="add_script btn btn-light border">Add Script</button>';
$res .= '<table class="filter_details table my-3"><tbody>';
$res .= '<tr><th class="text-secondary fw-light" style="width: 80px;">Priority</th><th class="text-secondary fw-light">Name</th><th class="text-secondary fw-light" style="width: 15%;">Actions</th></tr>';
$res .= '<tr><th class="text-secondary fw-light col-sm-1">Priority</th><th class="text-secondary fw-light col-sm-9">Name</th><th class="text-secondary fw-light col-sm-2">Actions</th></tr>';
$res .= get_mailbox_filters($mailbox, $this->get('site_config'), $this->get('user_config'), true);
$res .= '</tbody></table>';
$res .= '<div style="height: 40px; margin-bottom: 10px; display: none;">
<div style="width: 90%;">
<h3 style="margin-bottom: 2px;">If conditions are not met</h3>
$res .= '<div class="mb-3 d-none">
<div class="d-block">
<h3 class="mb-1">If conditions are not met</h3>
<small>Define the actions if conditions are not met. If no actions are provided the next filter will be executed. If there are no other filters to be executed, the email will be delivered as expected.</small>
</div>
</div>
<div style="background-color: #f7f2ef; margin-top: 25px; width: 90%; display: none;">
<div style="padding: 10px;">
<div style="display: flex; height: 30px;">
<div style="width: 80%;">
<h5 style="margin-top: 0">Actions</h5>
</div>
<div style="flex-grow: 1; text-align: right;">
<button style="margin-right: 10px;" class="filter_modal_add_else_action_btn">Add Action</button>
</div>
<div class="col-sm-12 mt-5 d-none" style="background-color: #f7f2ef;">
<div class="d-flex p-3">
<div class="d-block">
<h5 class="mt-0">Actions</h5>
</div>
<div style="width: 100%;">
<table class="filter_else_actions_modal_table">
</table>
<div class="text-end flex-grow-1">
<button class="filter_modal_add_else_action_btn me-2">Add Action</button>
</div>
</div>
<div class="d-block">
<table class="filter_else_actions_modal_table">
</table>
</div>
</div>';
$res .= '</div></div></div>';
}
Expand Down Expand Up @@ -1456,27 +1454,27 @@ public function process() {
if (!hm_exists('get_script_modal_content')) {
function get_script_modal_content()
{
return '<div id="edit_script_modal" style="display: none;">
return '<div id="edit_script_modal" class="d-none">
<h1 class="script_modal_title"></h1>
<hr/>
<div style="display: flex; height: 70px; margin-bottom: 10px;">
<div style="width: 100%;">
<h3 style="margin-bottom: 2px;">General</h3>
<small>Input a name and order for your filter. In filters, the order of execution is important. You can define an order value (or priority value) for your filter. Filters will run from lowest to highest priority value.</small>
</div>
<div class="mb-2">
<h3 class="mb-1">General</h3>
<small>Input a name and order for your filter. In filters, the order of execution is important. You can define an order value (or priority value) for your filter. Filters will run from lowest to highest priority value.</small>
</div>
<div style="margin-bottom: 10px; margin-top: 45px; display:flex; justify-content: end; align-items:stretch; flex-direction: column;">
<b style="margin:5px 0px;">Filter Name:</b><input style="margin:5px 0px; padding:5px;" class="modal_sieve_script_name" type="text" placeholder="Your filter name" />
<b style="margin:5px 0px;">Priority:</b><input style="margin:5px 0px; padding:5px;" class="modal_sieve_script_priority" type="number" placeholder="0" />
<div class="mb-2 mt-4">
<label for="sieve-script-name" class="form-label fw-bold">Filter Name:</label>
<input class="modal_sieve_script_name form-control" type="text" placeholder="Your filter name" id="sieve-script-name" />
</div>
<div style="display: flex; height: 70px; margin-bottom: 10px;">
<div style="width: 100%;">
<h3 style="margin-bottom: 2px;">Sieve Script</h3>
<small>Paste the Sieve script in the field below. Manually added scripts cannot be edited with the filters interface.</small>
</div>
<div class="mb-2">
<label for="sieve-script-priority" class="form-label fw-bold">Priority:</label>
<input class="modal_sieve_script_priority form-control" type="number" placeholder="0" id="sieve-script-priority"" />
</div>
<div class="mb-2">
<h3 class="mb-1">Sieve Script</h3>
<small>Paste the Sieve script in the field below. Manually added scripts cannot be edited with the filters interface.</small>
</div>
<div style="margin-bottom: 10px; margin-top:22px;">
<textarea style="width: 100%;" rows="20" class="modal_sieve_script_textarea"></textarea>
<div class="mb-2 mt-4">
<textarea rows="20" class="modal_sieve_script_textarea form-control"></textarea>
</div>
</div>';
}
Expand All @@ -1486,56 +1484,58 @@ function get_script_modal_content()
if (!hm_exists('get_classic_filter_modal_content')) {
function get_classic_filter_modal_content()
{
return '<div id="edit_filter_modal" style="display: none;">
return '<div id="edit_filter_modal" class="d-none">
<h1 class="filter_modal_title"></h1>
<hr/>
<div style="display: flex; height: 70px; margin-bottom: 10px;">
<div style="width: 100%;">
<h3 style="margin-bottom: 2px;">General</h3>
<small>Input a name and order for your filter. In filters, the order of execution is important. You can define an order value (or priority value) for your filter. Filters will run from lowest to highest priority value.</small>
</div>
<div class="mb-2">
<h3 class="mb-1">General</h3>
<small>Input a name and order for your filter. In filters, the order of execution is important. You can define an order value (or priority value) for your filter. Filters will run from lowest to highest priority value.</small>
</div>
<div style="margin-bottom: 10px; margin-top: 45px; display:flex; justify-content: end; align-items:stretch; flex-direction: column;">
<b style="margin:5px 0px;">Filter Name:</b><input style="margin:5px 0px; padding:5px;" type="text" class="modal_sieve_filter_name" placeholder="Your filter name" style="margin-left: 10px;" />
<b style="margin:5px 0px;">Priority:</b><input style="margin:5px 0px; padding:5px;" class="modal_sieve_filter_priority" type="number" placeholder="0" style="margin-left: 10px;" />
<b style="margin:5px 0px;">Test:</b>
<select class="modal_sieve_filter_test" name="test_type" placeholder="0" style="margin:5px 0px; padding:5px;" >
<option value="ANYOF">ANYOF (OR)</option>
<option value="ALLOF" selected>ALLOF (AND)</option>
</select>
<div class="mb-2 mt-4">
<label for="sieve-filter-name" class="form-label fw-bold">Filter Name:</label>
<input type="text" class="modal_sieve_filter_name form-control" placeholder="Your filter name" id="sieve-filter-name" />
</div>
<div style="display: flex; height: 70px; margin-bottom: 10px;">
<div style="width: 100%;">
<h3 style="margin-bottom: 2px;">Conditions & Actions</h3>
<small>Filters must have at least one action and one condition</small>
</div>
<div class="mb-2">
<label for="sieve-filter-priority" class="form-label fw-bold">Priority:</label>
<input class="modal_sieve_filter_priority form-control" type="number" placeholder="0" id="sieve-filter-priority" />
</div>
<div class="mb-2">
<label for="sieve-filter-test" class="form-label fw-bold">Test:</label>
<select class="modal_sieve_filter_test form-control" name="test_type" placeholder="0" id="sieve-filter-test">
<option value="ANYOF">ANYOF (OR)</option>
<option value="ALLOF" selected>ALLOF (AND)</option>
</select>
</div>
<div class="d-block mb-2 mt-4">
<h3 class="mb-1">Conditions & Actions</h3>
<small>Filters must have at least one action and one condition</small>
</div>
<div style="background-color: #f7f2ef; margin-top: 10px;">
<div style="padding: 10px;">
<div style="display: flex; height: 30px;">
<div style="width: 80%;">
<h5 style="margin-top: 0">Conditions</h5>
<div style="background-color: #f7f2ef;" class="mt-2 rounded">
<div class="p-2">
<div class="d-flex">
<div class="col-sm-10">
<h5 class="mt-0">Conditions</h5>
</div>
<div style="flex-grow: 1; text-align: right;">
<button style="margin-right: 10px;" class="sieve_add_condition_modal_button">Add Condition</button>
<div class="flex-grow-1 text-end">
<button class="sieve_add_condition_modal_button btn btn-sm border bg-white">Add Condition</button>
</div>
</div>
<div style="width: 100%; margin-top:20px;">
<div class="d-block mt-3">
<table class="sieve_list_conditions_modal">
</table>
</div>
</div>
<hr/>
<div style="padding: 10px;">
<div style="display: flex; height: 30px;">
<div style="width: 80%;">
<h5 style="margin-top: 0">Actions</h5>
<div class="p-2">
<div class="d-flex">
<div class="col-sm-10">
<h5 class="mt-0">Actions</h5>
</div>
<div style="flex-grow: 1; text-align: right;">
<button style="margin-right: 10px;" class="filter_modal_add_action_btn">Add Action</button>
<div class="flex-grow-1 text-end">
<button class="filter_modal_add_action_btn btn btn-sm border bg-white">Add Action</button>
</div>
</div>
<div style="width: 100%; margin-top:20px;">
<div class="d-block mt-3">
<table class="filter_actions_modal_table">
</table>
</div>
Expand Down Expand Up @@ -1595,7 +1595,7 @@ function get_mailbox_filters($mailbox, $site_config, $user_config, $html=false)
<a href="#" script_name_parsed="'.$parsed_name.'" priority="'.$exp_name[sizeof($exp_name) - 2].'" imap_account="'.$mailbox['name'].'" script_name="'.$script_name.'" class="edit_'.$base_class.'">
<i class="bi bi-pencil-fill"></i>
</a>
<a href="#" script_name_parsed="'.$parsed_name.'" priority="'.$exp_name[sizeof($exp_name) - 2].'" imap_account="'.$mailbox['name'].'" style="padding-left: 5px;" script_name="'.$script_name.'" class="delete_'.$base_class.'">
<a href="#" script_name_parsed="'.$parsed_name.'" priority="'.$exp_name[sizeof($exp_name) - 2].'" imap_account="'.$mailbox['name'].'" script_name="'.$script_name.'" class="delete_'.$base_class.' ps-2">
<i class="bi bi-trash3 text-danger"></i>
</a>
</td>
Expand Down
Loading

0 comments on commit 2c635a4

Please sign in to comment.