* InfoLog: allow to (re-)set view of entries link to contacts via favorites

r49041: reverting r49030 and implementing same functionality with just app.infolog.(get|set)State(), fixes introduced error set you could not filter eg. by type in an action view
This commit is contained in:
Ralf Becker 2014-10-17 12:57:33 +00:00
parent 2ceddce771
commit 0a13a668a7
2 changed files with 57 additions and 18 deletions

View File

@ -1240,7 +1240,7 @@ class infolog_ui
/** /**
* Handles actions on multiple infologs * Handles actions on multiple infologs
* *
* @param action * @param string $_action
* @param array $checked contact id's to use if !$use_all * @param array $checked contact id's to use if !$use_all
* @param boolean $use_all if true use all entries of the current selection (in the session) * @param boolean $use_all if true use all entries of the current selection (in the session)
* @param int &$success number of succeded actions * @param int &$success number of succeded actions
@ -1251,7 +1251,7 @@ class infolog_ui
* @param boolean $skip_notifications true to NOT notify users about changes * @param boolean $skip_notifications true to NOT notify users about changes
* @return boolean true if all actions succeded, false otherwise * @return boolean true if all actions succeded, false otherwise
*/ */
function action($action, $checked, $use_all, &$success, &$failed, &$action_msg, function action($_action, $checked, $use_all, &$success, &$failed, &$action_msg,
array $query, &$msg, $skip_notifications = false) array $query, &$msg, $skip_notifications = false)
{ {
//echo '<p>'.__METHOD__."('$action',".array2string($checked).','.(int)$use_all.",...)</p>\n"; //echo '<p>'.__METHOD__."('$action',".array2string($checked).','.(int)$use_all.",...)</p>\n";
@ -1273,7 +1273,7 @@ class infolog_ui
} }
// Actions with options in the selectbox // Actions with options in the selectbox
list($action, $settings) = explode('_', $action, 2); list($action, $settings) = explode('_', $_action, 2);
// Actions that can handle a list of IDs // Actions that can handle a list of IDs
switch($action) switch($action)
@ -1476,14 +1476,14 @@ class infolog_ui
* Closes an infolog * Closes an infolog
* *
* @param int|array $values=0 info_id (default _GET[info_id]) * @param int|array $values=0 info_id (default _GET[info_id])
* @param string $referer='' * @param string $_referer=''
* @param boolean $closesingle=false * @param boolean $closesingle=false
*/ */
function close($values=0,$referer='',$closesingle=false,$skip_notification = false) function close($values=0,$_referer='',$closesingle=false,$skip_notification = false)
{ {
//echo "<p>".__METHOD__."($values,$referer,$closeall)</p>\n"; //echo "<p>".__METHOD__."($values,$referer,$closeall)</p>\n";
$info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id'])); $info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
$referer = is_array($values) ? $values['referer'] : $referer; $referer = is_array($values) ? $values['referer'] : $_referer;
if ($info_id) if ($info_id)
{ {
@ -1526,14 +1526,14 @@ class infolog_ui
* Deletes an InfoLog entry * Deletes an InfoLog entry
* *
* @param array|int $values info_id (default _GET[info_id]) * @param array|int $values info_id (default _GET[info_id])
* @param string $referer * @param string $_referer
* @param string $called_by * @param string $called_by
* @param boolean $skip_notification Do not send notification of deletion * @param boolean $skip_notification Do not send notification of deletion
*/ */
function delete($values=0,$referer='',$called_by='',$skip_notification=False) function delete($values=0,$_referer='',$called_by='',$skip_notification=False)
{ {
$info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id'])); $info_id = (int) (is_array($values) ? $values['info_id'] : ($values ? $values : $_GET['info_id']));
$referer = is_array($values) ? $values['referer'] : $referer; $referer = is_array($values) ? $values['referer'] : $_referer;
if (!is_array($values) && $info_id > 0 && !$this->bo->anzSubs($info_id)) // entries without subs get confirmed by javascript if (!is_array($values) && $info_id > 0 && !$this->bo->anzSubs($info_id)) // entries without subs get confirmed by javascript
{ {

View File

@ -118,6 +118,43 @@ app.classes.infolog = AppJS.extend(
} }
}, },
/**
* Retrieve the current state of the application for future restoration
*
* Reimplemented to add action/action_id from content set by server
* when eg. viewing infologs linked to contacts.
*
* @return {object} Application specific map representing the current state
*/
getState: function()
{
// call parent
var state = this._super.apply(this, arguments);
var nm = this.et2 ? this.et2.getArrayMgr('content').data.nm : {};
state.action = nm.action || null;
state.action_id = nm.action_id || null;
return state;
},
/**
* Set the application's state to the given state.
*
* Reimplemented to also reset action/action_id.
*
* @param {{name: string, state: object}|string} state Object (or JSON string) for a state.
* Only state is required, and its contents are application specific.
*
* @return {boolean} false - Returns false to stop event propagation
*/
setState: function(state)
{
if (typeof state.state.action == 'undefined') state.state.action = null;
return this._super.apply(this, arguments);
},
/** /**
* Enable or disable the date filter * Enable or disable the date filter
* *
@ -193,7 +230,8 @@ app.classes.infolog = AppJS.extend(
/** /**
* Show or hide details by changing the CSS class * Show or hide details by changing the CSS class
* *
* @param show * @param {boolean} show
* @param {DOMNode} dom_node
*/ */
show_details: function(show, dom_node) show_details: function(show, dom_node)
{ {
@ -403,14 +441,15 @@ app.classes.infolog = AppJS.extend(
isLoadingCompleted = false; isLoadingCompleted = false;
jQuery('#infolog-edit-print').unbind("DOMSubtreeModified"); jQuery('#infolog-edit-print').unbind("DOMSubtreeModified");
}); });
setTimeout(function(){isLoadingCompleted = false},1000); setTimeout(function() {
isLoadingCompleted = false;
}, 1000);
var interval = setInterval(function(){ var interval = setInterval(function(){
if (!isLoadingCompleted) if (!isLoadingCompleted)
{ {
clearInterval(interval); clearInterval(interval);
that.infolog_print_preview(); that.infolog_print_preview();
} }
}, 100); }, 100);
}); });
}, },