More Home progress (favorites):

- Add favorite for addressbook
 - Fix add favorite from drop didn't load properly
This commit is contained in:
Nathan Gray 2014-11-25 22:42:44 +00:00
parent dd0e95d232
commit 6db1339365
5 changed files with 292 additions and 3 deletions

View File

@ -0,0 +1,107 @@
<?php
/*
* Egroupware - Addressbook - A portlet for displaying a list of entries
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package addressbook
* @subpackage home
* @link http://www.egroupware.org
* @author Nathan Gray
* @version $Id$
*/
/**
* The addressbook_list_portlet uses a nextmatch / favorite
* to display a list of entries.
*/
class addressbook_favorite_portlet extends home_favorite_portlet
{
/**
* Construct the portlet
*
*/
public function __construct(Array &$context = array(), &$need_reload = false)
{
$context['appname'] = 'addressbook';
// Let parent handle the basic stuff
parent::__construct($context,$need_reload);
$ui = new addressbook_ui();
$this->context['template'] = 'addressbook.index.rows';
$this->context['sel_options'] = array();
foreach($ui->content_types as $tid => $data)
{
$this->context['sel_options']['tid'][$tid] = $data['name'];
}
error_log(array2string($this->nm_settings['col_filter']));
$this->nm_settings += array(
'get_rows' => 'addressbook.addressbook_ui.get_rows',
// Use a different template so it can be accessed from client side
'template' => 'addressbook.index.rows',
'default_cols' => 'type,n_fileas_n_given_n_family_n_family_n_given_org_name_n_family_n_given_n_fileas,'.
'business_adr_one_countrycode_adr_one_postalcode,tel_work_tel_cell_tel_home,url_email_email_home',
);
}
public function exec($id = null, etemplate_new &$etemplate = null)
{
$ui = new addressbook_ui();
$this->context['sel_options']['filter'] = $this->context['sel_options']['owner'] = $ui->get_addressbooks(EGW_ACL_READ,lang('All'));
$this->context['sel_options']['filter2'] = $ui->get_lists(EGW_ACL_READ,array('' => lang('none')));
$this->nm_settings['actions'] = $ui->get_actions($this->nm_settings['col_filter']['tid'], $this->nm_settings['org_view']);
parent::exec($id, $etemplate);
}
/**
* Here we need to handle any incoming data. Setup is done in the constructor,
* output is handled by parent.
*
* @param type $id
* @param etemplate_new $etemplate
*/
public static function process($values = array())
{
parent::process($values);
$ui = new addressbook_ui();
if (is_array($values) && !empty($values['nm']['action']))
{
if (!count($values['nm']['selected']) && !$values['nm']['select_all'])
{
egw_framework::message(lang('You need to select some entries first'));
}
else
{
// Some processing to add values in for links and cats
$multi_action = $values['nm']['action'];
$success = $failed = $action_msg = null;
if ($ui->action($values['nm']['action'],$values['nm']['selected'],$values['nm']['select_all'],
$success,$failed,$action_msg,$values['do_email'] ? 'email' : 'index',$msg,$values['nm']['checkboxes']))
{
$msg .= lang('%1 contact(s) %2',$success,$action_msg);
egw_json_response::get()->apply('egw.message',array($msg,'success'));
foreach($values['nm']['selected'] as &$id)
{
$id = 'addressbook::'.$id;
}
// Directly request an update - this will get addressbook tab too
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($values['nm']['selected']));
}
elseif(is_null($msg))
{
$msg .= lang('%1 entries %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
egw_json_response::get()->apply('egw.message',array($msg,'error'));
}
elseif($msg)
{
$msg .= "\n".lang('%1 entries %2, %3 failed.',$success,$action_msg,$failed);
egw_json_response::get()->apply('egw.message',array($msg,'error'));
}
unset($values['nm']['action']);
unset($values['nm']['select_all']);
}
}
}
}

View File

@ -349,7 +349,7 @@ class addressbook_ui extends addressbook_bo
* @param string $org_view=null
* @return array see nextmatch_widget::get_actions()
*/
private function get_actions($tid_filter=null, $org_view=null)
public function get_actions($tid_filter=null, $org_view=null)
{
// we have no org view (view of one org has context menu like regular "add contacts" view, as it shows contacts
if (!isset($this->org_views[(string) $org_view]))

View File

@ -0,0 +1,175 @@
<?xml version="1.0"?>
<!-- $Id: index.xet 48420 2014-09-03 10:55:56Z ralfbecker $ -->
<overlay>
<template id="addressbook.index.rows" template="" lang="" group="0" version="1.9.005">
<grid width="100%">
<columns>
<column width="20"/>
<column width="40%"/>
<column width="70"/>
<column width="100"/>
<column width="60"/>
<column width="80"/>
<column width="180"/>
<column width="180"/>
<column width="180"/>
<column width="180"/>
<column width="40"/>
<column width="80" disabled="@no_customfields"/>
<column width="60%"/>
<column width="80" disabled="@no_distribution_list"/>
<column width="80"/>
<column width="50"/>
<column width="80"/>
<column width="120"/>
</columns>
<rows>
<row class="th">
<nextmatch-header label="Type" id="type" options="1"/>
<grid spacing="0" padding="0">
<columns>
<column/>
<column/>
</columns>
<rows>
<row disabled="!@order=n_fileas">
<nextmatch-sortheader label="own sorting" id="n_fileas" span="all"/>
</row>
<row disabled="!@order=n_given">
<nextmatch-sortheader label="Firstname" id="n_given"/>
<nextmatch-sortheader label="Name" id="n_family"/>
</row>
<row disabled="!@order=n_family">
<nextmatch-sortheader label="Name" id="n_family"/>
<nextmatch-sortheader label="Firstname" id="n_given"/>
</row>
<row>
<nextmatch-sortheader label="Organisation" id="org_name" span="all"/>
</row>
<row disabled="!@order=/^(org_name|n_fileas|adr_one_postalcode|contact_modified|contact_created|#)/">
<nextmatch-sortheader label="Name" id="n_family"/>
<nextmatch-sortheader label="Firstname" id="n_given" class="leftPad5"/>
</row>
<row disabled="@order=n_fileas">
<nextmatch-sortheader label="own sorting" id="n_fileas" span="all"/>
</row>
</rows>
</grid>
<nextmatch-header label="role" id="role"/>
<nextmatch-header label="Category" id="cat_id"/>
<nextmatch-header label="Photo" id="photo"/>
<nextmatch-header label="Birthday" id="bday"/>
<vbox options="0,0">
<nextmatch-header label="Business address" id="business"/>
<nextmatch-customfilter id="adr_one_countrycode" options="select-country,Country,0,No country selected" class="countrySelect"/>
<nextmatch-sortheader label="zip code" id="adr_one_postalcode"/>
</vbox>
<vbox options="0,0">
<nextmatch-header label="Home address" id="home"/>
<nextmatch-customfilter id="adr_two_countrycode" options="select-country,Country,0,No country selected" class="countrySelect"/>
<nextmatch-sortheader label="zip code" id="adr_two_postalcode"/>
</vbox>
<vbox options="0,0">
<nextmatch-header label="Business phone" id="tel_work"/>
<nextmatch-header label="Mobile phone" id="tel_cell"/>
<nextmatch-header label="Home phone" id="tel_home"/>
<description value="Fax"/>
</vbox>
<vbox options="0,0">
<nextmatch-header label="Url" id="url"/>
<nextmatch-header label="Business email" id="email"/>
<nextmatch-header label="Home email" id="email_home"/>
</vbox>
<nextmatch-header label="Room" id="room"/>
<nextmatch-customfields id="customfields"/>
<nextmatch-header label="Note" id="note"/>
<nextmatch-header label="Distribution lists" id="distribution_list"/>
<nextmatch-header label="Addressbook" id="owner"/>
<nextmatch-sortheader label="ID" id="contact_id"/>
<vbox options="0,0">
<nextmatch-header label="Last date" id="calendar"/>
<nextmatch-header label="Next date" id="calendar"/>
</vbox>
<vbox options="0,0">
<nextmatch-sortheader label="Created" id="contact_created" sortmode="DESC"/>
<nextmatch-sortheader label="Last modified" id="contact_modified" sortmode="DESC"/>
</vbox>
</row>
<row class="$row_cont[cat_id] $row_cont[class]" valign="top">
<image align="center" label="$row_cont[type_label]" src="${row}[type]" no_lang="1"/>
<vbox id="${row}[id]" options="0,0">
<description id="${row}[line1]" no_lang="1"/>
<description id="${row}[line2]" no_lang="1"/>
<description id="${row}[org_unit]" no_lang="1"/>
<description id="${row}[title]" no_lang="1"/>
<description id="${row}[first_org]" no_lang="1"/>
</vbox>
<description id="${row}[role]"/>
<listbox type="select-cat" id="${row}[cat_id]" readonly="true" rows="2"/>
<image src="${row}[photo]" class="iphoto"/>
<date id="${row}[bday]" readonly="true" options="Y-m-d"/>
<vbox options="0,0">
<description id="${row}[adr_one_street]" no_lang="1"/>
<description id="${row}[adr_one_street2]" no_lang="1"/>
<hbox orient="0" options="0,0">
<description id="${row}[adr_one_postalcode]" no_lang="1"/>
<description value=" " id="${row}[adr_one_locality]" no_lang="1" class="leftPad5"/>
<description id="${row}[adr_one_region]" no_lang="1" class="leftPad5"/>
</hbox>
<description id="${row}[adr_one_countryname]" no_lang="1"/>
<menulist>
<menupopup type="select-country" id="${row}[adr_one_countrycode]" readonly="true"/>
</menulist>
</vbox>
<vbox options="0,0">
<description id="${row}[adr_two_street]" no_lang="1"/>
<description id="${row}[adr_two_street2]" no_lang="1"/>
<hbox options="0,0">
<description id="${row}[adr_two_postalcode]" no_lang="1"/>
<description value=" " id="${row}[adr_two_locality]" no_lang="1" class="leftPad5"/>
<description id="${row}[adr_two_region]" no_lang="1" class="leftPad5"/>
</hbox>
<description id="${row}[adr_two_countryname]" no_lang="1"/>
<menulist>
<menupopup type="select-country" id="${row}[adr_two_countrycode]" readonly="true"/>
</menulist>
</vbox>
<vbox options="0,0">
<url-phone id="${row}[tel_work]" readonly="true" class="telNumbers"/>
<url-phone id="${row}[tel_cell]" readonly="true" class="telNumbers"/>
<url-phone id="${row}[tel_home]" readonly="true" class="telNumbers"/>
<url-phone id="${row}[tel_fax]" readonly="true"/>
<description id="${row}[tel_prefered]" no_lang="1" href="$row_cont[tel_prefered_link]" extra_link_target="calling" extra_link_popup="$cont[call_popup]"/>
</vbox>
<vbox options="0,0">
<url id="${row}[url]" readonly="true" class="fixedHeight"/>
<url-email id="${row}[email]" readonly="true" class="fixedHeight"/>
<url-email id="${row}[email_home]" readonly="true" class="fixedHeight"/>
</vbox>
<description id="${row}[room]"/>
<customfields-list id="$row" class="customfields"/>
<textbox multiline="true" id="${row}[note]" no_lang="1" readonly="true"/>
<description id="${row}[distrib_lists]"/>
<menulist>
<menupopup id="${row}[owner]" readonly="true"/>
</menulist>
<description id="${row}[id]" class="contactid"/>
<vbox options="0,0">
<link id="${row}[last_link]"/>
<link id="${row}[next_link]"/>
</vbox>
<vbox options="0,0">
<date-time id="${row}[created]" readonly="true" class="noWrap"/>
<menulist>
<menupopup type="select-account" id="${row}[creator]" readonly="true"/>
</menulist>
<date-time id="${row}[modified]" readonly="true" class="noBreak"/>
<menulist>
<menupopup type="select-account" id="${row}[modifier]" readonly="true"/>
</menulist>
</vbox>
</row>
</rows>
</grid>
</template>
</overlay>

View File

@ -13,7 +13,7 @@
/**
* The home_favorite_portlet extends the list portlet to display the entries for a particular
* The home_favorite_portlet uses a nextmatch to display the entries for a particular
* favorite, for a given app.
*/
class home_favorite_portlet extends home_portlet
@ -35,6 +35,8 @@ class home_favorite_portlet extends home_portlet
protected $nm_settings = array(
'lettersearch' => false,
'favorites' => false, // Hide favorite control
'actions' => array(),
'placeholder_actions' => array()
);
/**
@ -45,6 +47,9 @@ class home_favorite_portlet extends home_portlet
* The implementing class is allowed to modify the context, if needed, but it is
* better to use get_properties().
*
* We try to keep the constructor light as it gets called often, and only load
* things needed for display in exec.
*
* @param context Array portlet settings such as size, as well as values for properties
* @param boolean $need_reload Flag to indicate that the portlet needs to be reloaded (exec will be called)
*/
@ -104,6 +109,8 @@ class home_favorite_portlet extends home_portlet
unset($content['sel_options']);
$etemplate->setElementAttribute('nm', 'template',$this->nm_settings['template']);
// Always load app's javascript, so most actions have a chance of working
egw_framework::validate_file('','app',$this->context['appname']);
$etemplate->exec(get_called_class() .'::process',$content,$sel_options);
}

View File

@ -233,9 +233,9 @@ app.classes.home = AppJS.extend(
}
var portlet = et2_createWidget('portlet',attrs, this.portlet_container);
portlet.loadingFinished();
// Immediately add content ID so etemplate loads into the right place
portlet.content.append('<div id="'+ attrs.id+'" class="et2_container"/>');
portlet.loadingFinished();
// Get actual attributes & settings, since they're not available client side yet
var drop_data = [];