forked from extern/egroupware
Home: Pull favorite list live client-side
Also IDE now understands we can't call abstract __construct
This commit is contained in:
parent
c0680a006d
commit
10fc2390f6
@ -32,7 +32,6 @@ use EGroupware\Api\Etemplate;
|
|||||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||||
{
|
{
|
||||||
unset($need_reload); // not used, but required by function signature
|
unset($need_reload); // not used, but required by function signature
|
||||||
if (false) parent::__construct();
|
|
||||||
|
|
||||||
$this->context = $context;
|
$this->context = $context;
|
||||||
}
|
}
|
||||||
@ -178,7 +177,7 @@ use EGroupware\Api\Etemplate;
|
|||||||
|
|
||||||
$properties[] = array(
|
$properties[] = array(
|
||||||
'name' => 'days',
|
'name' => 'days',
|
||||||
'type' => 'listbox',
|
'type' => 'et2-selectbox',
|
||||||
'label' => '',
|
'label' => '',
|
||||||
'default' => 3,
|
'default' => 3,
|
||||||
'select_options' => array(
|
'select_options' => array(
|
||||||
|
@ -59,8 +59,6 @@ class home_favorite_portlet extends home_portlet
|
|||||||
*/
|
*/
|
||||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||||
{
|
{
|
||||||
if (false) parent::__construct();
|
|
||||||
|
|
||||||
// Process dropped data (Should be [appname => <appname>, id => <favorite ID>]) into something useable
|
// Process dropped data (Should be [appname => <appname>, id => <favorite ID>]) into something useable
|
||||||
if($context['dropped_data'])
|
if($context['dropped_data'])
|
||||||
{
|
{
|
||||||
@ -235,18 +233,7 @@ class home_favorite_portlet extends home_portlet
|
|||||||
public function get_properties()
|
public function get_properties()
|
||||||
{
|
{
|
||||||
$properties = parent::get_properties();
|
$properties = parent::get_properties();
|
||||||
$favorites = Framework\Favorites::get_favorites($this->context['appname']);
|
|
||||||
$favorite_list = array();
|
|
||||||
foreach($favorites as $id => $favorite)
|
|
||||||
{
|
|
||||||
if($favorite)
|
|
||||||
{
|
|
||||||
$favorite_list[] = array(
|
|
||||||
'value' => $id,
|
|
||||||
'label' => $favorite['name']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$favorite = array(
|
$favorite = array(
|
||||||
'label' => lang('Favorite'),
|
'label' => lang('Favorite'),
|
||||||
'name' => 'favorite',
|
'name' => 'favorite',
|
||||||
|
@ -35,7 +35,6 @@ class home_legacy_portlet extends home_portlet
|
|||||||
public function __construct(array &$context = array(), &$need_reload = false)
|
public function __construct(array &$context = array(), &$need_reload = false)
|
||||||
{
|
{
|
||||||
unset($need_reload); // not used, but required by function signature
|
unset($need_reload); // not used, but required by function signature
|
||||||
if (false) parent::__construct();
|
|
||||||
|
|
||||||
$this->context = $context;
|
$this->context = $context;
|
||||||
|
|
||||||
|
@ -51,8 +51,6 @@ class home_link_portlet extends home_portlet
|
|||||||
*/
|
*/
|
||||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||||
{
|
{
|
||||||
if (false) parent::__construct();
|
|
||||||
|
|
||||||
// Process dropped data into something useable
|
// Process dropped data into something useable
|
||||||
if($context['dropped_data'])
|
if($context['dropped_data'])
|
||||||
{
|
{
|
||||||
|
@ -40,8 +40,6 @@ class home_list_portlet extends home_portlet
|
|||||||
*/
|
*/
|
||||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||||
{
|
{
|
||||||
if (false) parent::__construct();
|
|
||||||
|
|
||||||
if(!is_array($context['list'])) $context['list'] = array();
|
if(!is_array($context['list'])) $context['list'] = array();
|
||||||
|
|
||||||
// Process dropped data (Should be GUIDs) into something useable
|
// Process dropped data (Should be GUIDs) into something useable
|
||||||
|
@ -32,8 +32,6 @@ class home_note_portlet extends home_portlet
|
|||||||
*/
|
*/
|
||||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||||
{
|
{
|
||||||
if (false) parent::__construct();
|
|
||||||
|
|
||||||
// Title not set for new widgets created via context menu
|
// Title not set for new widgets created via context menu
|
||||||
if(!$context['title'])
|
if(!$context['title'])
|
||||||
{
|
{
|
||||||
|
@ -35,8 +35,6 @@ class home_weather_portlet extends home_portlet
|
|||||||
*/
|
*/
|
||||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||||
{
|
{
|
||||||
if (false) parent::__construct();
|
|
||||||
|
|
||||||
// City not set for new widgets created via context menu
|
// City not set for new widgets created via context menu
|
||||||
if(!$context['city'])
|
if(!$context['city'])
|
||||||
{
|
{
|
||||||
|
@ -2,6 +2,8 @@ import {Et2Portlet} from "../../api/js/etemplate/Et2Portlet/Et2Portlet";
|
|||||||
import {classMap, css, html} from "@lion/core";
|
import {classMap, css, html} from "@lion/core";
|
||||||
import shoelace from "../../api/js/etemplate/Styles/shoelace";
|
import shoelace from "../../api/js/etemplate/Styles/shoelace";
|
||||||
import {etemplate2} from "../../api/js/etemplate/etemplate2";
|
import {etemplate2} from "../../api/js/etemplate/etemplate2";
|
||||||
|
import type {SelectOption} from "../../api/js/etemplate/Et2Select/FindSelectOptions";
|
||||||
|
import {Et2Favorites} from "../../api/js/etemplate/Et2Favorites/Et2Favorites";
|
||||||
|
|
||||||
export class Et2PortletFavorite extends Et2Portlet
|
export class Et2PortletFavorite extends Et2Portlet
|
||||||
{
|
{
|
||||||
@ -34,6 +36,33 @@ export class Et2PortletFavorite extends Et2Portlet
|
|||||||
this.classList.add("header_hidden");
|
this.classList.add("header_hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a list of user-configurable properties
|
||||||
|
* @returns {[{name : string, type : string, select_options? : [SelectOption]}]}
|
||||||
|
*/
|
||||||
|
get portletProperties() : { name : string, type : string, label : string, select_options? : SelectOption[] }[]
|
||||||
|
{
|
||||||
|
// Default blank filter
|
||||||
|
let favorites = [
|
||||||
|
{value: 'blank', label: this.egw().lang("No filters")}
|
||||||
|
];
|
||||||
|
|
||||||
|
// Load favorites
|
||||||
|
let preferences : any = this.egw().preference("*", this.settings.appname);
|
||||||
|
for(let pref_name in preferences)
|
||||||
|
{
|
||||||
|
if(pref_name.indexOf(Et2Favorites.PREFIX) == 0 && typeof preferences[pref_name] == 'object')
|
||||||
|
{
|
||||||
|
let name = pref_name.substr(Et2Favorites.PREFIX.length);
|
||||||
|
favorites.push({value: name, label: preferences[pref_name]['name']});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return [
|
||||||
|
...super.portletProperties,
|
||||||
|
{name: "favorite", type: "et2-select", label: "Favorite", select_options: favorites}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
headerTemplate()
|
headerTemplate()
|
||||||
{
|
{
|
||||||
const hidden = this.classList.contains("header_hidden");
|
const hidden = this.classList.contains("header_hidden");
|
||||||
|
Loading…
Reference in New Issue
Block a user