diff --git a/infolog/inc/class.infolog_favorite_portlet.inc.php b/infolog/inc/class.infolog_favorite_portlet.inc.php new file mode 100644 index 0000000000..1cc6274c7f --- /dev/null +++ b/infolog/inc/class.infolog_favorite_portlet.inc.php @@ -0,0 +1,125 @@ +context['template'] = 'infolog.index.rows'; + $this->nm_settings += array( + 'get_rows' => 'infolog.infolog_ui.get_rows', + // Use a different template so it can be accessed from client side + 'template' => 'infolog.home', + // Don't overwrite infolog + 'session_for' => 'home', + + // Allow add actions even when there's no rows + 'placeholder_actions' => array(), + 'sel_options' => array( + 'info_type' => $ui->bo->enums['type'], + 'pm_id' => array(lang('No project')), + 'info_priority' => $ui->bo->enums['priority'], + ) + ); + } + + /** + * Here we need to handle any incoming data. Setup is done in the constructor, + * output is handled by parent. + * + * @param type $id + * @param etemplate_new $etemplate + */ + public static function process($values = array()) + { + parent::process($values); + $ui = new infolog_ui(); + if (is_array($values) && !empty($values['nm']['multi_action'])) + { + if (!count($values['nm']['selected']) && !$values['nm']['select_all']) + { + egw_framework::message(lang('You need to select some entries first')); + } + else + { + // Some processing to add values in for links and cats + $multi_action = $values['nm']['multi_action']; + // Action has an additional action - add / delete, etc. Buttons named _action[action_name] + if(in_array($multi_action, array('link', 'responsible'))) + { + // eTemplate ignores the _popup namespace, but et2 doesn't + if($values[$multi_action.'_popup']) + { + $popup =& $values[$multi_action.'_popup']; + } + else + { + $popup =& $values; + } + $values['nm']['multi_action'] .= '_' . key($popup[$multi_action . '_action']); + if($multi_action == 'link') + { + $popup[$multi_action] = $popup['link']['app'] . ':'.$popup['link']['id']; + } + else if(is_array($popup[$multi_action])) + { + $popup[$multi_action] = implode(',',$popup[$multi_action]); + } + $values['nm']['multi_action'] .= '_' . $popup[$multi_action]; + unset($values[$multi_action.'_popup']); + unset($values[$multi_action]); + } + $success = $failed = $action_msg = null; + if ($ui->action($values['nm']['multi_action'], $values['nm']['selected'], $values['nm']['select_all'], + $success, $failed, $action_msg, $values['nm'], $msg, $values['nm']['checkboxes']['no_notifications'])) + { + $msg .= lang('%1 entries %2',$success,$action_msg); + egw_json_response::get()->apply('egw.message',array($msg,'success')); + foreach($values['nm']['selected'] as &$id) + { + $id = 'infolog::'.$id; + } + // Directly request an update - this will get infolog tab too + egw_json_response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected'])); + } + elseif(is_null($msg)) + { + $msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed); + egw_json_response::get()->apply('egw.message',array($msg,'error')); + } + elseif($msg) + { + $msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed); + egw_json_response::get()->apply('egw.message',array($msg,'error')); + } + unset($values['nm']['multi_action']); + unset($values['nm']['select_all']); + } + } + } + } \ No newline at end of file diff --git a/infolog/templates/default/home.xet b/infolog/templates/default/home.xet new file mode 100644 index 0000000000..eab009b415 --- /dev/null +++ b/infolog/templates/default/home.xet @@ -0,0 +1,134 @@ + + + + + diff --git a/phpgwapi/js/jsapi/app_base.js b/phpgwapi/js/jsapi/app_base.js index a343f31da7..22068e8291 100644 --- a/phpgwapi/js/jsapi/app_base.js +++ b/phpgwapi/js/jsapi/app_base.js @@ -361,11 +361,20 @@ var AppJS = Class.extend( }) .addClass("ui-helper-clearfix"); - //Add Sortable handler to sideBox fav. menu - jQuery('ul','#favorite_sidebox_'+this.appname).sortable({ - + //Add Sortable handler to sideBox fav. menu + jQuery('ul','#favorite_sidebox_'+this.appname).sortable({ items:'li:not([data-id$="add"])', placeholder:'ui-fav-sortable-placeholder', + helper: function(event, item) { + // We'll need to know which app this is for + item.attr('data-appname',self.appname); + // Create custom helper so it can be dragged to Home + var h_parent = item.parent().parent().clone(); + h_parent.find('li').not('[data-id="'+item.attr('data-id')+'"]').remove(); + h_parent.appendTo('body'); + return h_parent; + }, + refreshPositions: true, update: function (event, ui) { var favSortedList = jQuery(this).sortable('toArray', {attribute:'data-id'});