mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 23:29:20 +01:00
More Home progress:
- Add support for resources favorites
This commit is contained in:
parent
35ebfc4f9f
commit
244e859413
123
resources/inc/class.resources_favorite_portlet.inc.php
Normal file
123
resources/inc/class.resources_favorite_portlet.inc.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Egroupware - Resources - A portlet for displaying a list of entries
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package resources
|
||||
* @subpackage home
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* The resources_list_portlet uses a nextmatch / favorite
|
||||
* to display a list of entries.
|
||||
*/
|
||||
class resources_favorite_portlet extends home_favorite_portlet
|
||||
{
|
||||
|
||||
/**
|
||||
* Construct the portlet
|
||||
*
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
$context['appname'] = 'resources';
|
||||
|
||||
// Let parent handle the basic stuff
|
||||
parent::__construct($context,$need_reload);
|
||||
|
||||
$ui = new resources_ui();
|
||||
|
||||
$this->context['template'] = 'resources.show.rows';
|
||||
$this->nm_settings += array(
|
||||
'get_rows' => 'resources.resources_bo.get_rows',
|
||||
// Use a different template so it can be accessed from client side
|
||||
'template' => 'resources.show.rows',
|
||||
// Don't store in session, there's no point
|
||||
'store_state' => false,
|
||||
// Use a reduced column set for home, user can change if needed
|
||||
'default_cols' => 'image,name_short_description',
|
||||
'row_id' => 'res_id',
|
||||
'row_modified' => 'ts_modified',
|
||||
|
||||
'no_cat' => true,
|
||||
'filter_label' => lang('Category'),
|
||||
'filter2' => -1,
|
||||
);
|
||||
}
|
||||
|
||||
public function exec($id = null, etemplate_new &$etemplate = null)
|
||||
{
|
||||
$ui = new resources_ui();
|
||||
|
||||
$this->context['sel_options']['filter']= array(''=>lang('all categories'))+(array)$ui->bo->acl->get_cats(EGW_ACL_READ);
|
||||
$this->context['sel_options']['filter2'] = resources_bo::$filter_options;
|
||||
if(!$content['nm']['filter2'])
|
||||
{
|
||||
$content['nm']['filter2'] = key(resources_bo::$filter_options);
|
||||
}
|
||||
$this->nm_settings['actions'] = $ui->get_actions();
|
||||
|
||||
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($content = array())
|
||||
{
|
||||
parent::process($content);
|
||||
$ui = new resources_ui();
|
||||
|
||||
// This is just copy+pasted from resources_ui line 816, but we don't want
|
||||
// the etemplate exec to fire again.
|
||||
if (is_array($content) && isset($content['nm']['rows']['document'])) // handle insert in default document button like an action
|
||||
{
|
||||
list($id) = @each($content['nm']['rows']['document']);
|
||||
$content['nm']['action'] = 'document';
|
||||
$content['nm']['selected'] = array($id);
|
||||
}
|
||||
if ($content['nm']['action'])
|
||||
{
|
||||
// remove sum-* rows from checked rows
|
||||
$content['nm']['selected'] = array_filter($content['nm']['selected'], function($id)
|
||||
{
|
||||
return $id > 0;
|
||||
});
|
||||
if (!count($content['nm']['selected']) && !$content['nm']['select_all'])
|
||||
{
|
||||
$msg = lang('You need to select some entries first!');
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
else
|
||||
{
|
||||
$success = $failed = $action_msg = null;
|
||||
if ($ui->action($content['nm']['action'],$content['nm']['selected'],$content['nm']['select_all'],
|
||||
$success,$failed,$action_msg,'index',$msg))
|
||||
{
|
||||
$msg .= lang('%1 resource(s) %2',$success,$action_msg);
|
||||
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'success'));
|
||||
foreach($content['nm']['selected'] as &$id)
|
||||
{
|
||||
$id = 'resources::'.$id;
|
||||
}
|
||||
// Directly request an update - this will get resources tab too
|
||||
egw_json_response::get()->apply('egw.dataRefreshUIDs',array($content['nm']['selected']));
|
||||
}
|
||||
elseif(empty($msg))
|
||||
{
|
||||
$msg .= lang('%1 resource(s) %2, %3 failed because of insufficent rights !!!',$success,$action_msg,$failed);
|
||||
egw_json_response::get()->apply('egw.message',array($msg,'error'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -181,7 +181,7 @@ class resources_ui
|
||||
*
|
||||
* @return array see nextmatch_widget::egw_actions()
|
||||
*/
|
||||
protected function get_actions()
|
||||
public function get_actions()
|
||||
{
|
||||
$actions = array(
|
||||
'edit' => array(
|
||||
|
77
resources/templates/default/show.rows.xet
Normal file
77
resources/templates/default/show.rows.xet
Normal file
@ -0,0 +1,77 @@
|
||||
<?xml version="1.0"?>
|
||||
<!-- $Id: show.xet 48785 2014-09-29 16:34:16Z hnategh $ -->
|
||||
<overlay>
|
||||
<template id="resources.show.rows" template="" lang="" group="0" version="1.9.003">
|
||||
<grid width="100%">
|
||||
<columns>
|
||||
<column width="70"/>
|
||||
<column width="50%"/>
|
||||
<column width="50"/>
|
||||
<column width="15%"/>
|
||||
<column width="15%"/>
|
||||
<column width="15%"/>
|
||||
<column width="15%" disabled="@no_customfields"/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row class="th">
|
||||
<nextmatch-sortheader label="Image" id="image"/>
|
||||
<vbox>
|
||||
<nextmatch-sortheader label="Name" id="name"/>
|
||||
<nextmatch-sortheader label="Short description" id="short_description"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<nextmatch-sortheader statustext="How many of this resource are usable" label="Useable" id="useable"/>
|
||||
<nextmatch-sortheader statustext="How many of this resource exists" label="Quantity" id="quantity"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<nextmatch-sortheader label="Category" id="cat_id"/>
|
||||
<description value="Administrator"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<nextmatch-sortheader label="Location" id="location"/>
|
||||
<description value="Storage information"/>
|
||||
</vbox>
|
||||
<nextmatch-header label="Resource / Accessories"/>
|
||||
<nextmatch-customfields id="customfields"/>
|
||||
</row>
|
||||
<row class="$row_cont[class]">
|
||||
<image id="${row}[picture_thumb]" width="100%" image_tooltip="true" height="auto" extra_link_target="_blank" href="webdav.php/apps/resources/${row_cont[res_id]}/.picture.jpg" src="${row}[picture_thumb]" />
|
||||
<vbox>
|
||||
<description id="${row}[name]" no_lang="1"/>
|
||||
<description id="${row}[short_description]" no_lang="1"/>
|
||||
</vbox>
|
||||
<vbox align="left">
|
||||
<description align="left" id="${row}[useable]" no_lang="1"/>
|
||||
<description align="left" id="${row}[quantity]" no_lang="1"/>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<menulist>
|
||||
<menupopup type="select-cat" id="{$row}[cat_id]" no_lang="1" readonly="true"/>
|
||||
</menulist>
|
||||
<menulist>
|
||||
<menupopup type="select-account" id="{$row}[admin]" no_lang="1" readonly="true"/>
|
||||
</menulist>
|
||||
</vbox>
|
||||
<vbox>
|
||||
<description id="${row}[location]" no_lang="1"/>
|
||||
<description id="${row}[storage_info]" no_lang="1"/>
|
||||
</vbox>
|
||||
<vbox no_lang="1">
|
||||
<description extra_link_popup="850x600" href="resources.resources_ui.edit&res_id=$row_cont[accessory_of]" id="${row}[accessory_of_label]" no_lang="1"/>
|
||||
<grid width="100%" id="${row}[accessories]">
|
||||
<columns>
|
||||
<column/>
|
||||
</columns>
|
||||
<rows>
|
||||
<row>
|
||||
<description extra_link_popup="850x600" href="resources.resources_ui.edit&res_id=$row_cont[acc_id]" id="${row}[name]" no_lang="1"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</vbox>
|
||||
<customfields-list id="$row"/>
|
||||
</row>
|
||||
</rows>
|
||||
</grid>
|
||||
</template>
|
||||
</overlay>
|
Loading…
Reference in New Issue
Block a user