mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 23:43:17 +01:00
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)
|
||||
{
|
||||
unset($need_reload); // not used, but required by function signature
|
||||
if (false) parent::__construct();
|
||||
|
||||
$this->context = $context;
|
||||
}
|
||||
@ -177,15 +176,15 @@ use EGroupware\Api\Etemplate;
|
||||
$properties = parent::get_properties();
|
||||
|
||||
$properties[] = array(
|
||||
'name' => 'days',
|
||||
'type' => 'listbox',
|
||||
'label' => '',
|
||||
'default' => 3,
|
||||
'name' => 'days',
|
||||
'type' => 'et2-selectbox',
|
||||
'label' => '',
|
||||
'default' => 3,
|
||||
'select_options' => array(
|
||||
1 => lang('Yes, for today and tomorrow'),
|
||||
3 => lang('Yes, for the next three days'),
|
||||
7 => lang('Yes, for the next week'),
|
||||
14=> lang('Yes, for the next two weeks'),
|
||||
1 => lang('Yes, for today and tomorrow'),
|
||||
3 => lang('Yes, for the next three days'),
|
||||
7 => lang('Yes, for the next week'),
|
||||
14 => lang('Yes, for the next two weeks'),
|
||||
),
|
||||
);
|
||||
return $properties;
|
||||
|
@ -59,8 +59,6 @@ class home_favorite_portlet extends home_portlet
|
||||
*/
|
||||
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
|
||||
if($context['dropped_data'])
|
||||
{
|
||||
@ -235,18 +233,7 @@ class home_favorite_portlet extends home_portlet
|
||||
public function 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(
|
||||
'label' => lang('Favorite'),
|
||||
'name' => 'favorite',
|
||||
|
@ -35,7 +35,6 @@ class home_legacy_portlet extends home_portlet
|
||||
public function __construct(array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
unset($need_reload); // not used, but required by function signature
|
||||
if (false) parent::__construct();
|
||||
|
||||
$this->context = $context;
|
||||
|
||||
|
@ -51,8 +51,6 @@ class home_link_portlet extends home_portlet
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
// Process dropped data into something useable
|
||||
if($context['dropped_data'])
|
||||
{
|
||||
|
@ -40,8 +40,6 @@ class home_list_portlet extends home_portlet
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
if(!is_array($context['list'])) $context['list'] = array();
|
||||
|
||||
// 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)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
// Title not set for new widgets created via context menu
|
||||
if(!$context['title'])
|
||||
{
|
||||
|
@ -35,8 +35,6 @@ class home_weather_portlet extends home_portlet
|
||||
*/
|
||||
public function __construct(Array &$context = array(), &$need_reload = false)
|
||||
{
|
||||
if (false) parent::__construct();
|
||||
|
||||
// City not set for new widgets created via context menu
|
||||
if(!$context['city'])
|
||||
{
|
||||
|
@ -2,6 +2,8 @@ import {Et2Portlet} from "../../api/js/etemplate/Et2Portlet/Et2Portlet";
|
||||
import {classMap, css, html} from "@lion/core";
|
||||
import shoelace from "../../api/js/etemplate/Styles/shoelace";
|
||||
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
|
||||
{
|
||||
@ -34,6 +36,33 @@ export class Et2PortletFavorite extends Et2Portlet
|
||||
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()
|
||||
{
|
||||
const hidden = this.classList.contains("header_hidden");
|
||||
|
Loading…
Reference in New Issue
Block a user