2013-08-26 11:45:43 +02:00
/ * *
* EGroupware - Infolog - Javascript UI
*
* @ link http : //www.egroupware.org
* @ package infolog
* @ author Hadi Nategh < hn - AT - stylite . de >
* @ copyright ( c ) 2008 - 13 by Ralf Becker < RalfBecker - AT - outdoor - training . de >
* @ license http : //opensource.org/licenses/gpl-license.php GPL - GNU General Public License
2013-11-04 21:54:23 +01:00
* @ version $Id$
2013-08-26 11:45:43 +02:00
* /
/ * *
* UI for Infolog
*
* @ augments AppJS
* /
2013-11-04 21:54:23 +01:00
app . classes . infolog = AppJS . extend (
2013-08-26 11:45:43 +02:00
{
appname : 'infolog' ,
/ * *
* et2 widget container
* /
et2 : null ,
/ * *
* path widget
* /
/ * *
* Constructor
*
* @ memberOf app . infolog
* /
init : function ( )
{
// call parent
this . _super . apply ( this , arguments ) ;
} ,
/ * *
* Destructor
* /
destroy : function ( )
{
delete this . et2 ;
// call parent
this . _super . apply ( this , arguments ) ;
} ,
/ * *
* This function is called when the etemplate2 object is loaded
* and ready . If you must store a reference to the et2 object ,
* make sure to clean it up in destroy ( ) .
*
* @ param et2 etemplate2 Newly ready object
* /
et2 _ready : function ( et2 )
{
// call parent
this . _super . apply ( this , arguments ) ;
if ( typeof et2 . templates [ 'infolog.index' ] != 'undefined' )
{
2013-08-28 15:28:15 +02:00
this . filter _change ( ) ;
2013-08-26 11:45:43 +02:00
}
} ,
/ * *
*
* /
2013-08-27 12:46:42 +02:00
filter _change : function ( )
2013-08-26 11:45:43 +02:00
{
var filter = this . et2 . getWidgetById ( 'filter' ) ;
var temp _header _left = this . et2 . getWidgetById ( 'infolog.index.dates' ) ;
if ( filter && temp _header _left )
{
temp _header _left . set _disabled ( filter . value !== "bydate" ) ;
}
} ,
/ * *
* show or hide the details of rows by selecting the filter2 option
* either 'all' for details or 'no_description' for no details
*
* /
2013-08-27 12:46:42 +02:00
filter2 _change : function ( )
2013-08-26 11:45:43 +02:00
{
var nm = this . et2 . getWidgetById ( 'nm' ) ;
var filter2 = this . et2 . getWidgetById ( 'filter2' ) ;
if ( nm && filter2 )
{
// Show / hide descriptions
this . show _details ( filter2 . value == 'all' ) ;
// Change preference location - widget is nextmatch
nm . options . settings . columnselection _pref = 'infolog.index.rows' + ( filter2 . value == 'all' ? '-details' : '' ) ;
// Load new preferences
var colData = [ ]
for ( var i = 0 ; i < nm . columns . length ; i ++ ) colData [ i ] = { disabled : true , width : '0' } ;
nm . _applyUserPreferences ( nm . columns , colData ) ;
for ( var i = 0 ; i < colData . length ; i ++ )
{
// Wants a string
nm . dataview . getColumnMgr ( ) . columns [ i ] . set _width ( colData [ i ] . width + 'px' ) ;
nm . dataview . getColumnMgr ( ) . columns [ i ] . set _visibility ( ! colData [ i ] . disabled ) ;
}
nm . dataview . getColumnMgr ( ) . updated = true ;
// Update page
nm . dataview . updateColumns ( ) ;
}
} ,
/ * *
* Show or hide details by changing the CSS class
*
* @ param show
* /
show _details : function ( show )
{
// Show / hide descriptions
egw . css ( ".et2_box.infoDes" , "display:" + ( show ? "block;" : "none;" ) ) ;
} ,
2013-09-19 14:52:50 +02:00
confirm _delete _2 : function ( _action , _senders )
{
var children = false ;
var child _button = jQuery ( '#delete_sub' ) . get ( 0 ) || jQuery ( '[id*="delete_sub"]' ) . get ( 0 ) ;
if ( child _button )
{
for ( var i = 0 ; i < _senders . length ; i ++ )
{
if ( $j ( _senders [ i ] . iface . node ) . hasClass ( 'infolog_rowHasSubs' ) )
{
children = true ;
break ;
}
}
child _button . style . display = children ? 'block' : 'none' ;
}
var callbackDeleteDialog = function ( button _id )
{
if ( button _id == et2 _dialog . YES _BUTTON )
{
2013-09-19 15:47:02 +02:00
2013-09-19 14:52:50 +02:00
}
}
2013-10-07 18:53:13 +02:00
var confirmDeleteDialog = et2 _dialog . show _dialog ( callbackDeleteDialog , this . egw . lang ( "Do you really want to DELETE this Rule" ) , this . egw . lang ( "Delete" ) , { } , et2 _dialog . BUTTONS _YES _NO _CANCEL , et2 _dialog . WARNING _MESSAGE ) ;
2013-09-19 14:52:50 +02:00
} ,
2013-08-26 11:45:43 +02:00
/ * *
* Confirm delete
* If entry has children , asks if you want to delete children too
*
* @ param _action
* @ param _senders
* /
2013-08-27 12:46:42 +02:00
confirm _delete : function ( _action , _senders )
2013-08-26 11:45:43 +02:00
{
var children = false ;
var child _button = jQuery ( '#delete_sub' ) . get ( 0 ) || jQuery ( '[id*="delete_sub"]' ) . get ( 0 ) ;
if ( child _button )
{
for ( var i = 0 ; i < _senders . length ; i ++ )
{
2013-09-19 14:52:50 +02:00
if ( $j ( _senders [ i ] . iface . node ) . hasClass ( 'infolog_rowHasSubs' ) )
2013-08-26 11:45:43 +02:00
{
children = true ;
break ;
}
}
child _button . style . display = children ? 'block' : 'none' ;
}
nm _open _popup ( _action , _senders ) ;
} ,
/ * *
* Add email from addressbook
*
* @ param ab _id
* @ param info _cc
* /
2013-08-27 12:46:42 +02:00
add _email _from _ab : function ( ab _id , info _cc )
2013-08-26 11:45:43 +02:00
{
var ab = document . getElementById ( ab _id ) ;
if ( ! ab || ! ab . value )
{
jQuery ( "tr.hiddenRow" ) . css ( "display" , "table-row" ) ;
}
else
{
var cc = document . getElementById ( info _cc ) ;
for ( var i = 0 ; i < ab . options . length && ab . options [ i ] . value != ab . value ; ++ i ) ;
if ( i < ab . options . length )
{
cc . value += ( cc . value ? ', ' : '' ) + ab . options [ i ] . text . replace ( /^.* <(.*)>$/ , '$1' ) ;
ab . value = '' ;
ab . onchange ( ) ;
jQuery ( "tr.hiddenRow" ) . css ( "display" , "none" ) ;
}
}
return false ;
} ,
/ * *
* If one of info _status , info _percent or info _datecompleted changed -- > set others to reasonable values
*
* @ param string changed _id id of changed element
* @ param string status _id
* @ param string percent _id
* @ param string datecompleted _id
* /
2013-08-27 12:46:42 +02:00
status _changed : function ( changed _id , status _id , percent _id , datecompleted _id )
2013-08-26 11:45:43 +02:00
{
var status = document . getElementById ( status _id ) ;
var percent = document . getElementById ( percent _id ) ;
var datecompleted = document . getElementById ( datecompleted _id + '[str]' ) ;
if ( ! datecompleted )
{
datecompleted = jQuery ( '#' + datecompleted _id + ' input' ) . get ( 0 ) ;
}
var completed ;
switch ( changed _id )
{
case status _id :
completed = status . value == 'done' || status . value == 'billed' ;
if ( completed || status . value == 'not-started' ||
( status . value == 'ongoing' ) != ( percent . value > 0 && percent . value < 100 ) )
{
percent . value = completed ? 100 : ( status . value == 'not-started' ? 0 : 10 ) ;
}
break ;
case percent _id :
completed = percent . value == 100 ;
if ( completed != ( status . value == 'done' || status . value == 'billed' ) ||
( status . value == 'not-started' ) != ( percent . value == 0 ) )
{
status . value = percent . value == 0 ? 'not-started' : ( percent . value == 100 ? 'done' : 'ongoing' ) ;
}
break ;
case datecompleted _id + '[str]' :
case datecompleted _id :
completed = datecompleted . value != '' ;
if ( completed != ( status . value == 'done' || status . value == 'billed' ) )
{
status . value = completed ? 'done' : 'not-started' ;
}
if ( completed != ( percent . value == 100 ) )
{
percent . value = completed ? 100 : 0 ;
}
break ;
}
if ( ! completed && datecompleted && datecompleted . value != '' )
{
datecompleted . value = '' ;
}
else if ( completed && datecompleted && datecompleted . value == '' )
{
// todo: set current date in correct format
}
} ,
/ * *
* handle "print" action from "Actions" selectbox in edit infolog window .
* check if the template is dirty then submit the template otherwise just open new window as print .
2013-08-27 12:46:42 +02:00
*
2013-08-26 11:45:43 +02:00
* /
2013-08-27 12:46:42 +02:00
edit _actions : function ( )
2013-08-26 11:45:43 +02:00
{
var widget = this . et2 . getWidgetById ( 'action' ) ;
var template = this . et2 . _inst ;
if ( template )
{
var id = template . widgetContainer . getArrayMgr ( 'content' ) . data [ 'info_id' ] ;
}
if ( widget )
{
switch ( widget . get _value ( ) )
{
case 'print' :
if ( template . isDirty ( ) )
{
template . submit ( ) ;
}
egw _open ( id , 'infolog' , 'edit' , { print : 1 } ) ;
break ;
default :
template . submit ( ) ;
}
}
} ,
2013-09-13 15:51:33 +02:00
/ * *
*
* /
add _link _sidemenu : function ( )
{
2013-09-25 11:20:32 +02:00
egw . open ( '' , 'infolog' , 'add' ) ;
2013-09-13 15:51:33 +02:00
} ,
2013-08-26 11:45:43 +02:00
} ) ;