diff --git a/mail/inc/class.mail_ui.inc.php b/mail/inc/class.mail_ui.inc.php index 13f8c42100..6d99747eaa 100644 --- a/mail/inc/class.mail_ui.inc.php +++ b/mail/inc/class.mail_ui.inc.php @@ -46,6 +46,7 @@ class mail_ui 'importMessage' => True, 'importMessageFromVFS2DraftAndDisplay'=>True, 'subscription' => True, + 'folderManagement' => true, ); /** @@ -592,6 +593,12 @@ class mail_ui 'onExecute' => 'javaScript:app.mail.unsubscribe_folder', 'group' => $group, ), + 'foldermanagement' => array( + 'caption' => 'Folder Management...', + 'enabled' => 'javaScript:app.mail.mail_CheckFolderNoSelect', + 'onExecute' => 'javaScript:app.mail.folderManagement', + 'group' => ++$group, + ), 'sieve' => array( 'caption' => 'Mail filter', 'onExecute' => 'javaScript:app.mail.edit_sieve', @@ -4584,4 +4591,45 @@ class mail_ui if(mail_bo::$debug) error_log(__METHOD__."-> No messages selected."); } } + + /** + * Autoloading function to load branches of tree node + * of management folder tree + * + * @param type $_id + */ + function ajax_folderMgmtTree_autoloading ($_id = null) + { + $mail_ui = new mail_ui(); + $_id = $_id? $_id:$_GET['id']; + etemplate_widget_tree::send_quote_json($mail_ui->mail_tree->getTree($_id,'',1,true,false,false,false)); + } + + /** + * Main function to handle folder management dialog + * + * @param array $content content of dialog + */ + function folderManagement (array $content = null) + { + $dtmpl = new etemplate_new('mail.folder_management'); + $profileID = $_GET['acc_id']? $_GET['acc_id']: $content['acc_id']; + $sel_options['tree'] = $this->mail_tree->getTree(null,$profileID, 1, true, false, false); + + if (!is_array($content)) + { + $content = array ('acc_id' => $profileID); + } + else + { + + } + + $readonlys = array(); + // Preserv + $preserv = array( + 'acc_id' => $content['acc_id'] // preserve acc id to be used in client-side + ); + $dtmpl->exec('mail.mail_ui.folderManagement', $content,$sel_options,$readonlys,$preserv,2); + } } diff --git a/mail/js/app.js b/mail/js/app.js index 0eb4ade7f1..173e84de44 100644 --- a/mail/js/app.js +++ b/mail/js/app.js @@ -4838,5 +4838,131 @@ app.classes.mail = AppJS.extend( { et2_dialog.alert('You need to save the message as draft first before to be able to save it into VFS','Save into VFS','info'); } + }, + + /** + * Folder Management, opens the folder magnt. dialog + * with the selected acc_id from index tree + * + * @param {egw action object} _action actions + * @param {object} _senders selected node + */ + folderManagement: function (_action,_senders) + { + var acc_id = parseInt(_senders[0].id); + this.egw.open_link('mail.mail_ui.folderManagement&acc_id='+acc_id, '_blank', '720x500'); + }, + + /** + * Show ajax-loader when the autoloading get started + * + * @param {type} _id item id + * @param {type} _widget tree widget + * @returns {Boolean} + */ + folderMgmt_autoloadingStart: function(_id, _widget) + { + return this.subscription_autoloadingStart (_id, _widget); + }, + + /** + * Revert back the icon after autoloading is finished + * @returns {Boolean} + */ + folderMgmt_autoloadingEnd: function(_id, _widget) + { + return true; + }, + + /** + * + * @param {type} _ids + * @param {type} _widget + * @returns {undefined} + */ + folderMgmt_onSelect: function(_ids, _widget) + { + // et2 content + var content = this.et2.getArrayMgr('content').data; + + // Flag to reset selected items + var resetSelection = false; + + var self = this; + + /** + * helper function to multiselect range of nodes in same level + * + * @param {string} _a start node id + * @param {string} _b end node id + * @param {string} _branch totall node ids in the level + */ + var rangeSelector = function(_a,_b, _branch) + { + var branchItems = _branch.split(_widget.input.dlmtr); + var _aIndex = _widget.input.getIndexById(_a); + var _bIndex = _widget.input.getIndexById(_b); + if (_bIndex<_aIndex) + { + var tmpIndex = _aIndex; + _aIndex = _bIndex; + _bIndex = tmpIndex; + } + for(var i =_aIndex;i<=_bIndex;i++) + { + self.folderMgmt_setCheckbox(_widget, branchItems[i], !_widget.input.isItemChecked(branchItems[i])); + } + }; + + if (content) + { + var itemIds = _ids.split(_widget.input.dlmtr); + + if(itemIds.length == 2) // there's a range selected + { + var branch = _widget.input.getSubItems(_widget.input.getParentId(itemIds[0])); + // Set range of selected/unselected + rangeSelector(itemIds[0], itemIds[1], branch); + } + else if(itemIds.length != 1) + { + resetSelection = true; + } + } + + if (resetSelection) + { + _widget.input._unselectItems(); + } + }, + + /** + * Set enable/disable checkbox + * + * @param {object} _widget tree widget + * @param {string} _itemId item tree id + * @param {boolean} _stat - status to be set on checkbox true/false + */ + folderMgmt_setCheckbox: function (_widget, _itemId, _stat) + { + if (_widget) + { + _widget.input.setCheck(_itemId, _stat); + _widget.input.setSubChecked(_itemId,_stat); + } + + }, + + /** + * + * @param {type} _id + * @param {type} _widget + * @TODO: Implement onCheck handler in order to select or deselect subItems + * of a checked parent node + */ + folderMgmt_onCheck: function (_id, _widget) + { + console.log(); } + }); diff --git a/mail/templates/default/app.css b/mail/templates/default/app.css index 1d2edccf29..8c4cdeaac5 100644 --- a/mail/templates/default/app.css +++ b/mail/templates/default/app.css @@ -703,17 +703,19 @@ div.mailPreviewHeaders #mail-index_previewAttachmentArea.visible { background-repeat: no-repeat; } -.mail_subscription_header +.mail_subscription_header, .mail_folder_management_header { font-weight: bold; font-size: 150%; padding-bottom: 20px; } -#mail-subscribe table.et2_grid tr td { +#mail-subscribe table.et2_grid tr td, +#mail-folder_management table.et2_grid tr td { padding: 0px; } -#mail-subscribe table.et2_grid tr td div.et2_box { +#mail-subscribe table.et2_grid tr td div.et2_box, +#mail-folder_management table.et2_grid tr td .mail_subscription_header { height: 500px; overflow: auto; } diff --git a/mail/templates/default/folder_management.xet b/mail/templates/default/folder_management.xet new file mode 100644 index 0000000000..9551afed93 --- /dev/null +++ b/mail/templates/default/folder_management.xet @@ -0,0 +1,26 @@ + + + + + + diff --git a/mail/templates/pixelegg/app.css b/mail/templates/pixelegg/app.css index ef81b47a65..b5395948a2 100755 --- a/mail/templates/pixelegg/app.css +++ b/mail/templates/pixelegg/app.css @@ -701,15 +701,18 @@ div.mailPreviewHeaders #mail-index_previewAttachmentArea.visible { background-position: left top; background-repeat: no-repeat; } -.mail_subscription_header { +.mail_subscription_header, +.mail_folder_management_header { font-weight: bold; font-size: 150%; padding-bottom: 20px; } -#mail-subscribe table.et2_grid tr td { +#mail-subscribe table.et2_grid tr td, +#mail-folder_management table.et2_grid tr td { padding: 0px; } -#mail-subscribe table.et2_grid tr td div.et2_box { +#mail-subscribe table.et2_grid tr td div.et2_box, +#mail-folder_management table.et2_grid tr td .mail_subscription_header { height: 500px; overflow: auto; } @@ -1672,11 +1675,13 @@ div#displayToolbar-menulist img { * * ################################################################################## */ -#mail-subscribe table.et2_grid tr td { +#mail-subscribe table.et2_grid tr td, +#mail-folder_management table.et2_grid tr td { padding: 0px; /*Label*/ } -#mail-subscribe table.et2_grid tr td .mail_subscription_header { +#mail-subscribe table.et2_grid tr td .mail_subscription_header, +#mail-folder_management table.et2_grid tr td .mail_subscription_header { /*line-height: 270%;*/ margin: 0.6em 0 0; font-weight: lighter; @@ -1685,12 +1690,14 @@ div#displayToolbar-menulist img { font-size: 150%; padding-bottom: 20px; } -#mail-subscribe table.et2_grid tr td div.et2_box { +#mail-subscribe table.et2_grid tr td div.et2_box, +#mail-folder_management table.et2_grid tr td div.et2_box { margin-top: 16px; height: 484px; overflow: auto; } -.mail_subscription_header { +.mail_subscription_header, +.mail_folder_management_header { font-weight: bold; font-size: 150%; padding-bottom: 20px; diff --git a/mail/templates/pixelegg/app.less b/mail/templates/pixelegg/app.less index 79bc46f3e9..cb9a4ceaa9 100755 --- a/mail/templates/pixelegg/app.less +++ b/mail/templates/pixelegg/app.less @@ -862,7 +862,7 @@ div#displayToolbar-menulist{ * * ################################################################################## */ -#mail-subscribe{ +#mail-subscribe, #mail-folder_management{ table.et2_grid tr td { padding: 0px; @@ -892,7 +892,7 @@ div#displayToolbar-menulist{ } // #mail-subscribe -.mail_subscription_header +.mail_subscription_header, .mail_folder_management_header { font-weight: bold; font-size: 150%;