add app.js to infolog application, add ajax=true to index (enable drag-and-drop), and run infolog app by et2

This commit is contained in:
Hadi Nategh 2013-08-26 09:19:47 +00:00
parent 0de6ab1b35
commit 589e4ecfbc
7 changed files with 33 additions and 205 deletions

View File

@ -100,7 +100,7 @@ class infolog_ui
$this->bo = new infolog_bo();
$this->tmpl = new etemplate();
$this->tmpl = new etemplate_new();
$this->user = $GLOBALS['egw_info']['user']['account_id'];
@ -289,17 +289,6 @@ class infolog_ui
}
$orginal_colfilter = $query['col_filter'];
if (isset($parent_id)) $query['col_filter']['info_id_parent'] = (int)$parent_id;
if ($query['filter'] == 'bydate')
{
$query['header_left'] = 'infolog.index.dates';
$GLOBALS['egw']->js->set_onload("set_style_by_class('table','custom_hide','visibility','visible');");
}
else
{
unset($query['header_left']);
unset($query['startdate']);
unset($query['enddate']);
}
//echo "<p>infolog_ui.get_rows(start=$query[start],search='$query[search]',filter='$query[filter]',cat_id=$query[cat_id],action='$query[action]/$query[action_id]',col_filter=".print_r($query['col_filter'],True).",sort=$query[sort],order=$query[order])</p>\n";
if (!isset($query['start'])) $query['start'] = 0;
@ -327,7 +316,7 @@ class infolog_ui
unset($query['custom_fields']);
if ($query['col_filter']['info_type'])
{
$tpl = new etemplate;
$tpl = new etemplate_new;
if ($tpl->read('infolog.index.rows.'.$query['col_filter']['info_type']))
{
$query['template'] =& $tpl;
@ -818,35 +807,13 @@ class infolog_ui
'all' => 'details',
);
if(!isset($values['nm']['filter2'])) $values['nm']['filter2'] = $this->prefs['show_links'];
$values['nm']['filter2_onchange'] = "
if(typeof widget != 'undefined') {
// Show / hide descriptions
show_details(jQuery(this).val() == 'all');
// Change preference location - widget is nextmatch
widget.options.settings.columnselection_pref = 'infolog.index.rows'+(jQuery(this).val()=='all'?'-details':'');
//apply infolog_filter_change javascript method (hide/show of date filter form) over onchange filter
$values['nm']['filter_onchange'] = "app.infolog.infolog_filter_change();";
// Load new preferences
var colData = []
for(var i = 0; i < widget.columns.length; i++) colData[i] = {disabled: true, width: '0'};
widget._applyUserPreferences(widget.columns, colData);
for(var i = 0; i < colData.length; i++)
{
// Wants a string
widget.dataview.getColumnMgr().columns[i].set_width(colData[i].width + 'px');
widget.dataview.getColumnMgr().columns[i].set_visibility(!colData[i].disabled);
}
//apply infolog_filter2_change javascript method (show/hide details each rows) over onchange filter2
$values['nm']['filter2_onchange'] = "app.infolog.infolog_filter2_change();";
widget.dataview.getColumnMgr().updated = true;
// Update page
widget.dataview.updateColumns();
}
else
{
this.form.submit();
}
";
// disable columns for main entry as set in the pref for details or no details
if ($action == 'sp')
{
@ -865,19 +832,9 @@ else
}
}
$values['nm']['header_right'] = 'infolog.index.header_right';
if ($extra_app_header && $values['nm']['filter']!='bydate')
{
$values['nm']['header_left'] = 'infolog.index.header_left';
}
if ($values['nm']['filter']=='bydate')
{
foreach (array_keys($values['nm']['col_filter']) as $colfk) if (is_int($colfk)) unset($values['nm']['col_filter']);
$values['nm']['header_left'] = 'infolog.index.dates';
$GLOBALS['egw']->js->set_onload("set_style_by_class('table','custom_hide','visibility','visible');");
}
if ($values['nm']['filter2'] == 'no_describtion')
{
$GLOBALS['egw']->js->set_onload("show_details(false);");
}
$values['nm']['bottom_too'] = True;
$values['nm']['never_hide'] = isset($this->prefs['never_hide']) ?
@ -1170,7 +1127,7 @@ else
'caption' => 'Delete',
'group' => ++$group,
'disableClass' => 'rowNoDelete',
'onExecute' => 'javaScript:confirm_delete',
'onExecute' => 'app.infolog.infolog_confirm_delete',
);
if ($query['col_filter']['info_status'] == 'deleted')
{
@ -1595,10 +1552,6 @@ else
$button = 'apply'; // need to store infolog first
}
}
if ($button == 'print')
{
$content['js'] = $this->custom_print($content,!$content['info_id'])."\n".$js; // first open the new window and then update the view
}
//echo "<p>infolog_ui::edit(info_id=$info_id) '$button' button pressed, content="; _debug_array($content);
if (($button == 'save' || $button == 'apply') && isset($content['info_subject']) && empty($content['info_subject']))
{
@ -1659,7 +1612,7 @@ else
else
{
$content['msg'] = lang('InfoLog entry saved');
$content['js'] = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','infolog',$info_id,'$operation');";
egw_framework::refresh_opener($content['msg'],'infolog',$info_id,$operation);
}
$content['tabs'] = $active_tab;
if ((int) $content['pm_id'] != (int) $content['old_pm_id'])
@ -1722,12 +1675,12 @@ else
);
if (!($content['msg'] = $this->delete($info_id,$referer,'edit'))) return; // checks ACL first
$content['js'] = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','infolog',$info_id,'delete');";
egw_framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
}
// called again after delete confirmation dialog
elseif ($button == 'deleted' && $content['msg'])
{
$content['js'] = "opener.egw_refresh('".str_replace("'","\\'",$content['msg'])."','infolog',$info_id,'delete');";
egw_framework::refresh_opener($content['msg'],'infolog',$info_id,'delete');
}
if ($button == 'save' || $button == 'cancel' || $button == 'delete' || $button == 'deleted')
{
@ -1735,11 +1688,8 @@ else
{
egw::redirect_link($referer,array('msg' => $content['msg']));
}
$content['js'] .= 'window.close();';
echo '<html><body onload="'.$content['js'].'"></body></html>';
common::egw_exit();
egw_framework::window_close();
}
if ($content['js']) $content['js'] = '<script>'.$content['js'].'</script>';
}
// on a type-change, set the status to the default status of that type, if the actual status is not supported by the new type
if (!array_key_exists($content['info_status'],$this->bo->status[$content['info_type']]))
@ -2409,7 +2359,6 @@ else
if (!empty($_to_emailAddress))
{
$GLOBALS['egw_info']['flags']['currentapp'] = 'infolog';
echo '<script>window.resizeTo(750,550);</script>';
if (is_array($_attachments))
{

View File

@ -1,90 +0,0 @@
/**
* Javascript used on the infolog edit popup
*/
function add_email_from_ab(ab_id,info_cc)
{
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
*/
function status_changed(changed_id, status_id, percent_id, datecompleted_id)
{
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
}
}

View File

@ -1,40 +0,0 @@
/**
* EGroupware infolog javascript code used on index page
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package infolog
* @link http://www.egroupware.org
* @version $Id$
*/
/**
* Confirm delete
* If entry has children, asks if you want to delete children too
*
* @param _action
* @param _senders
*/
function confirm_delete(_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('rowHasSubs')) {
children = true;
break;
}
}
child_button.style.display = children ? 'block' : 'none';
}
nm_open_popup(_action, _senders);
}
/**
* Show or hide details by changing the CSS class
*/
function show_details(show)
{
// Show / hide descriptions
egw.css(".et2_box.infoDes","display:" + (show ? "block;" : "none;"));
}

View File

@ -12,10 +12,11 @@
*/
$setup_info['infolog']['name'] = 'infolog';
$setup_info['infolog']['version'] = '1.9.004';
$setup_info['infolog']['version'] = '1.10.001';
$setup_info['infolog']['app_order'] = 5;
$setup_info['infolog']['tables'] = array('egw_infolog','egw_infolog_extra');
$setup_info['infolog']['enable'] = 1;
$setup_info['infolog']['index'] = 'infolog.infolog_ui.index&ajax=true';
$setup_info['infolog']['author'] =
$setup_info['infolog']['maintainer'] = array(

View File

@ -713,4 +713,10 @@ function infolog_upgrade1_9_003()
return $GLOBALS['setup_info']['infolog']['currentver'] = '1.9.004';
}
/**
* Enable ajax=true
*/
function infolog_upgrade1_9_004()
{
return $GLOBALS['setup_info']['infolog']['currentver'] = '1.10.001';
}

View File

@ -71,7 +71,7 @@
<rows>
<row>
<textbox id="info_cc" maxlength="254" class="inputFullWidth"/>
<buttononly label="Add from Addressbook" onclick="return add_email_from_ab(form::name('ab[id]'),form::name('info_cc'));" options="users"/>
<buttononly label="Add from Addressbook" onclick="return app.infolog.infolog_add_email_from_ab(form::name('ab[id]'),form::name('info_cc'));" options="users"/>
</row>
<row class="hiddenRow">
<link-entry blur="Search" id="ab" options="addressbook-email" span="all"/>
@ -242,18 +242,18 @@
<row class="row">
<description value="Status" for="info_status"/>
<menulist>
<menupopup statustext="@status_help" id="info_status" onchange="status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
<menupopup statustext="@status_help" id="info_status" onchange="app.infolog_status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
</menulist>
<description/>
<description/>
<description value="Completed" for="info_percent"/>
<menulist>
<menupopup type="select-percent" statustext="Percent completed" id="info_percent" onchange="status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
<menupopup type="select-percent" statustext="Percent completed" id="info_percent" onchange="app.infolog_status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
</menulist>
</row>
<row class="row">
<description value="Date completed" for="info_datecompleted"/>
<date-time statustext="Date completed (leave it empty to have it automatic set if status is done or billed)" id="info_datecompleted" onchange="status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
<date-time statustext="Date completed (leave it empty to have it automatic set if status is done or billed)" id="info_datecompleted" onchange="app.infolog_status_changed(this.id, form::name('info_status'), form::name('info_percent'), form::name('info_datecompleted'))"/>
<description/>
<description/>
<description value="Private" for="info_access"/>
@ -283,9 +283,8 @@
<button statustext="Apply the changes" label="Apply" id="button[apply]"/>
<button statustext="leave without saveing the entry" label="Cancel" id="button[cancel]" onclick="window.close();"/>
<menulist>
<menupopup statustext="Execute a further action for this entry" id="action" onchange="this.form.submit(); this.value='';" options="Actions..."/>
<menupopup statustext="Execute a further action for this entry" id="action" onchange="app.infolog.infolog_edit_actions()" options="Actions..."/>
</menulist>
<html id="js"/>
</hbox>
<description/>
<hbox span="2">

View File

@ -1,9 +1,13 @@
<?xml version="1.0"?>
<!-- $Id$ -->
<overlay>
<template id="infolog.index.header_left" template="" lang="" group="0" version="1.0.1.001">
<description value="InfoLog" class="headertext bold"/>
<styles>.bold { font-weight: bold; }</styles>
<template id="infolog.index.dates" template="" lang="" group="0" version="1.7.001">
<hbox class="custom_hide">
<description value="Start"/>
<date id="startdate"/>
<description value="End"/>
<date statustext="Leave it empty for a full week" id="enddate"/>
</hbox>
</template>
<template id="infolog.index.header_right" template="" lang="" group="0" version="1.7.001">
<hbox>
@ -176,11 +180,10 @@
<description/>
</row>
<row disabled="1">
<template id="header_left"/>
<template id="header_right"/>
</row>
<row>
<nextmatch id="nm" options="infolog.index.rows" span="all"/>
<nextmatch id="nm" options="infolog.index.rows" span="all" header_left="infolog.index.dates"/>
</row>
<row class="noPrint" disabled="!@nm[selectcols]=/actions/">
<hbox>