From ebdf3310c26c00dd2cb3e97fe1bec2b6c8a4ce7c Mon Sep 17 00:00:00 2001 From: nathan Date: Mon, 13 Mar 2023 09:25:55 -0600 Subject: [PATCH] Home: Fix missing templates & sneaky failures with some favorite combinations --- addressbook/templates/default/index.rows.xet | 188 ++++++++++++++++++ home/inc/class.home_favorite_portlet.inc.php | 1 + home/inc/class.home_ui.inc.php | 29 ++- .../class.infolog_favorite_portlet.inc.php | 22 +- .../class.resources_favorite_portlet.inc.php | 24 +-- resources/templates/default/show.rows.xet | 22 +- 6 files changed, 244 insertions(+), 42 deletions(-) create mode 100644 addressbook/templates/default/index.rows.xet diff --git a/addressbook/templates/default/index.rows.xet b/addressbook/templates/default/index.rows.xet new file mode 100644 index 0000000000..64feb032f4 --- /dev/null +++ b/addressbook/templates/default/index.rows.xet @@ -0,0 +1,188 @@ + + + + + + \ No newline at end of file diff --git a/home/inc/class.home_favorite_portlet.inc.php b/home/inc/class.home_favorite_portlet.inc.php index 4c9a6cf393..278440742c 100644 --- a/home/inc/class.home_favorite_portlet.inc.php +++ b/home/inc/class.home_favorite_portlet.inc.php @@ -122,6 +122,7 @@ class home_favorite_portlet extends home_portlet $content = $this->context + array('nm' => $this->nm_settings); $content['header_node'] = "home-index_{$id}_header"; + unset($content['template']); $sel_options = $content['sel_options'] ? $content['sel_options'] : array(); unset($content['sel_options']); $etemplate->setElementAttribute('nm', 'template',$this->nm_settings['template']); diff --git a/home/inc/class.home_ui.inc.php b/home/inc/class.home_ui.inc.php index 73be169eed..cfa6f68502 100644 --- a/home/inc/class.home_ui.inc.php +++ b/home/inc/class.home_ui.inc.php @@ -76,8 +76,19 @@ class home_ui { $id = $p_data['id']; - if(!$id) continue; - $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); + if(!$id) + { + continue; + } + try + { + $portlet = $this->get_portlet($id, $p_data, $content, $attrs, true); + } + catch (Exception $e) + { + error_log($e); + } + } } @@ -302,6 +313,7 @@ class home_ui if($full_exec) { $content = $portlet->exec($id, $etemplate, $full_exec ? 2 : -1); + Etemplate::reset_request(); } return $portlet; @@ -407,15 +419,16 @@ class home_ui } foreach($classes[$appname] as $portlet) { - $instance = new $portlet(); + $context = ['id' => $portlet]; + $instance = new $portlet($context); $desc = $instance->get_description(); $add_to[$portlet] = array( - 'id' => $portlet, - 'caption' => $desc['displayName'], - 'hint' => $desc['description'], - 'onExecute' => 'javaScript:app.home.add', - 'acceptedTypes' => $instance->accept_drop(), + 'id' => $portlet, + 'caption' => $desc['displayName'], + 'hint' => $desc['description'], + 'onExecute' => 'javaScript:app.home.add', + 'acceptedTypes' => $instance->accept_drop(), 'allowOnMultiple' => $instance->accept_multiple() ); } diff --git a/infolog/inc/class.infolog_favorite_portlet.inc.php b/infolog/inc/class.infolog_favorite_portlet.inc.php index e2da50e276..1f5d4a9a9a 100644 --- a/infolog/inc/class.infolog_favorite_portlet.inc.php +++ b/infolog/inc/class.infolog_favorite_portlet.inc.php @@ -32,28 +32,28 @@ class infolog_favorite_portlet extends home_favorite_portlet $context['appname'] = 'infolog'; // Let parent handle the basic stuff - parent::__construct($context,$need_reload); + parent::__construct($context, $need_reload); $ui = new infolog_ui(); $this->context['template'] = 'infolog.index.rows'; $this->context['sel_options'] = array( 'info_type' => $ui->bo->enums['type'], - 'pm_id' => array(lang('No project')), + 'pm_id' => array(lang('No project')), 'info_priority' => $ui->bo->enums['priority'], ); - $this->nm_settings += array( - 'get_rows' => 'infolog_favorite_portlet::get_rows', + $this->nm_settings = array_merge($this->nm_settings, array( + 'get_rows' => 'infolog_favorite_portlet::get_rows', // Use a different template so it can be accessed from client side - 'template' => 'infolog.home', - 'default_cols' => self::$default_cols, + 'template' => 'infolog.home', + 'default_cols' => self::$default_cols, // Don't overwrite infolog - 'session_for' => 'home', - 'no_filter2' => true, - 'options-filter'=> $ui->filters, + 'session_for' => 'home', + 'no_filter2' => true, + 'options-filter' => $ui->filters, // Allow add actions even when there's no rows - 'placeholder_actions' => array(), - ); + 'placeholder_actions' => array(), + )); } /** diff --git a/resources/inc/class.resources_favorite_portlet.inc.php b/resources/inc/class.resources_favorite_portlet.inc.php index a9c6240597..ec5b9a334b 100644 --- a/resources/inc/class.resources_favorite_portlet.inc.php +++ b/resources/inc/class.resources_favorite_portlet.inc.php @@ -28,24 +28,24 @@ class resources_favorite_portlet extends home_favorite_portlet $context['appname'] = 'resources'; // Let parent handle the basic stuff - parent::__construct($context,$need_reload); + parent::__construct($context, $need_reload); $this->context['template'] = 'resources.show.rows'; - $this->nm_settings += array( - 'get_rows' => 'resources.resources_bo.get_rows', + $this->nm_settings = array_merge($this->nm_settings, array( + 'get_rows' => 'resources.resources_bo.get_rows', // Use a different template so it can be accessed from client side - 'template' => 'resources.show.rows', + 'template' => 'resources.show.rows', // Don't store in session, there's no point - 'store_state' => false, + 'store_state' => false, // Use a reduced column set for home, user can change if needed - 'default_cols' => 'image,name_short_description,useable_quantity', - 'row_id' => 'res_id', - 'row_modified' => 'ts_modified', + 'default_cols' => 'image,name_short_description,useable_quantity', + 'row_id' => 'res_id', + 'row_modified' => 'ts_modified', - 'no_cat' => true, - 'filter_label' => lang('Category'), - 'filter2' => -1, - ); + 'no_cat' => true, + 'filter_label' => lang('Category'), + 'filter2' => -1, + )); } public function exec($id = null, Etemplate &$etemplate = null) diff --git a/resources/templates/default/show.rows.xet b/resources/templates/default/show.rows.xet index 19e94eebee..20336c2604 100644 --- a/resources/templates/default/show.rows.xet +++ b/resources/templates/default/show.rows.xet @@ -1,17 +1,17 @@ -