From 5c6cceaa53d76f9cb4b0459fdf017e21abaaf174 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 27 Nov 2013 00:17:08 +0000 Subject: [PATCH] - Add js function to open a edit dialog with some fields pre-filled (type, category, action), use for buttons in nm right header - Use different DOM ID for list when called from elsewhere --- infolog/inc/class.infolog_ui.inc.php | 16 ++++++++++---- infolog/js/app.js | 32 ++++++++++++++++++++++++++++ infolog/templates/default/index.xet | 6 +++--- 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/infolog/inc/class.infolog_ui.inc.php b/infolog/inc/class.infolog_ui.inc.php index e600b0505a..f4a5a48fe8 100644 --- a/infolog/inc/class.infolog_ui.inc.php +++ b/infolog/inc/class.infolog_ui.inc.php @@ -711,11 +711,17 @@ class infolog_ui { $nm = egw_cache::getSession('infolog', $this->called_by.'session_data'); unset($nm['rows']); - if ($values === 'reset_action_view' || $_GET['ajax'] === 'true') + if ($values === 'reset_action_view') { - $nm['action'] = $action = ''; - $nm['action_id'] = $action_id = 0; - $nm['action_title'] = $action_title = ''; + $action = ''; + $action_id = 0; + $action_title = ''; + } + if($_GET['ajax'] === 'true') + { + $nm['action'] = ''; + $nm['action_id'] = 0; + $nm['action_title'] = ''; // check if action-view reset filter and restore it if (($filter = egw_cache::getSession('infolog', 'filter_reset_from'))) { @@ -880,6 +886,8 @@ class infolog_ui else { $values['css'] = '"; + // Avoid DOM conflicts + $this->tmpl->set_dom_id("{$this->tmpl->name}-$action-$action_id"); } // add scrollbar to long description, if user choose so in his prefs if ($this->prefs['limit_des_lines'] > 0 || (string)$this->prefs['limit_des_lines'] == ''); diff --git a/infolog/js/app.js b/infolog/js/app.js index e5e38a0450..f17f9d1cf2 100644 --- a/infolog/js/app.js +++ b/infolog/js/app.js @@ -309,4 +309,36 @@ app.classes.infolog = AppJS.extend( { egw.open('','infolog','add'); }, + + /** + * Opens a new edit dialog with some extra url parameters pulled from + * standard locations. Done with a function instead of hardcoding so + * the values can be updated if user changes them in UI. + * + * @param _type string Type of infolog entry + * @param _action string Special action for new infolog entry + * @param _action_id string ID for special action + */ + add_with_extras: function(_type, _action, _action_id) + { + var nm = this.et2.getWidgetById('nm'); + var nm_value = nm.getValue() || {}; + + var extras = { + type: _type || nm_value.filter || null, + cat_id: nm_value.cat_id || null, + action: _action || null, + action_id: _action_id != '0' ? _action_id : null || null + }; + + // Remove any missing values + for(var key in extras) + { + if(extras[key] == null) + { + delete extras[key]; + } + } + egw.open('','infolog','add',extras); + } }); diff --git a/infolog/templates/default/index.xet b/infolog/templates/default/index.xet index 0b8d4a6510..e6006340da 100644 --- a/infolog/templates/default/index.xet +++ b/infolog/templates/default/index.xet @@ -8,9 +8,9 @@