More Home progress (favorites):

- Put show header button into header
 - Fix mixing columns between multiple favorites on home
 - Fix changing column spacing when hiding header
 - Fix add favorite from context menu didn't load properly
This commit is contained in:
Nathan Gray 2014-11-25 21:50:42 +00:00
parent baa7cbe38e
commit dd0e95d232
6 changed files with 47 additions and 29 deletions

View File

@ -338,8 +338,13 @@ var et2_portlet = et2_valueWidget.extend(
*/ */
set_title: function(value) set_title: function(value)
{ {
this.header.contents()
.filter(function() {
return this.nodeType === 3;
})
.remove();
this.options.title = value; this.options.title = value;
this.header.html(value); this.header.append(value);
}, },
/** /**

View File

@ -81,7 +81,7 @@ class home_favorite_portlet extends home_portlet
if($this->favorite) if($this->favorite)
{ {
$this->nm_settings['favorite'] = $this->context['favorite']; $this->nm_settings['favorite'] = $this->context['favorite'];
$this->nm_settings['columnselection_pref'] = 'nextmatch-home'; $this->nm_settings['columnselection_pref'] = "nextmatch-home.{$this->context['id']}";
if(is_array($this->favorite['state'])) if(is_array($this->favorite['state']))
{ {
$this->nm_settings += $this->favorite['state']; $this->nm_settings += $this->favorite['state'];
@ -99,6 +99,7 @@ class home_favorite_portlet extends home_portlet
$etemplate->set_dom_id($id); $etemplate->set_dom_id($id);
$content = $this->context + array('nm' => $this->nm_settings); $content = $this->context + array('nm' => $this->nm_settings);
$content['header_node'] = "home-index_{$id}_header";
$sel_options = $content['sel_options'] ? $content['sel_options'] : array(); $sel_options = $content['sel_options'] ? $content['sel_options'] : array();
unset($content['sel_options']); unset($content['sel_options']);
$etemplate->setElementAttribute('nm', 'template',$this->nm_settings['template']); $etemplate->setElementAttribute('nm', 'template',$this->nm_settings['template']);

View File

@ -85,18 +85,22 @@ class home_ui
{ {
$portlets = $this->get_portlet_list(); $portlets = $this->get_portlet_list();
$add_portlets = $portlets; $add_portlets = $portlets;
$change_for_add = function(&$add_portlets) use (&$change_for_add)
{
foreach($add_portlets as $id => &$add) foreach($add_portlets as $id => &$add)
{ {
if(!$add['id'] && is_array($add['children'])) if(is_array($add['children']))
{ {
foreach($add['children'] as $sub_id => &$sub_add) $change_for_add($add['children']);
}
if($id && !$add['children'])
{ {
$sub_add['id'] = 'add_'.$sub_id;
}
}
$add['id'] = 'add_' . $id; $add['id'] = 'add_' . $id;
$add['class'] = $id; $add['class'] = 'add_'.$id;
} }
}
};
$change_for_add($add_portlets);
$actions = array( $actions = array(
'add' => array( 'add' => array(
'type' => 'popup', 'type' => 'popup',

View File

@ -188,10 +188,10 @@ app.classes.home = AppJS.extend(
} }
var portlet = et2_createWidget('portlet',attrs, this.portlet_container); var portlet = et2_createWidget('portlet',attrs, this.portlet_container);
// Override content ID so etemplate loads
portlet.content.attr('id', attrs.id);
portlet.loadingFinished(); portlet.loadingFinished();
// Immediately add content ID so etemplate loads into the right place
portlet.content.append('<div id="'+ attrs.id+'" class="et2_container"/>');
// Get actual attributes & settings, since they're not available client side yet // Get actual attributes & settings, since they're not available client side yet
portlet._process_edit(et2_dialog.OK_BUTTON, attrs); portlet._process_edit(et2_dialog.OK_BUTTON, attrs);
@ -233,8 +233,8 @@ app.classes.home = AppJS.extend(
} }
var portlet = et2_createWidget('portlet',attrs, this.portlet_container); var portlet = et2_createWidget('portlet',attrs, this.portlet_container);
// Override content ID so etemplate loads // Immediately add content ID so etemplate loads into the right place
portlet.content.attr('id', attrs.id); portlet.content.append('<div id="'+ attrs.id+'" class="et2_container"/>');
portlet.loadingFinished(); portlet.loadingFinished();
// Get actual attributes & settings, since they're not available client side yet // Get actual attributes & settings, since they're not available client side yet
@ -563,11 +563,10 @@ app.classes.home = AppJS.extend(
// We operate on the DOM here, nm should be unaware of our fiddling // We operate on the DOM here, nm should be unaware of our fiddling
var nm = widget.getParent().getWidgetById('nm'); var nm = widget.getParent().getWidgetById('nm');
if(!nm) return; if(!nm) return;
var header = nm.header;
var header_height = header.div.innerHeight();
// Hide header // Hide header
nm.div.toggleClass('header_hidden'); nm.div.toggleClass('header_hidden');
nm.set_hide_header(nm.div.hasClass('header_hidden')); nm.set_hide_header(nm.div.hasClass('header_hidden'));
nm.resize();
} }
}); });

View File

@ -91,28 +91,37 @@
} }
/* Favorite / nextmatch /* Favorite / nextmatch
* NB: No favorite sub-class added here, as they have an app-specific prefix * NB: using class attribute contains as favorites have an app-specific prefix
*/ */
.et2_portlet .et2_container > div > .et2_button { [class*="favorite_portlet"].et2_portlet .ui-widget-header > .et2_button {
position:absolute; float: left;
top: 0px;
left: 100%;
margin-left: -16px;
margin-bottom: -16px;
padding: 0px !important; padding: 0px !important;
margin-top: 3px;
height: 12px; height: 12px;
width: 12px; width: 12px;
z-index: 50; z-index: 50;
} }
.et2_portlet .et2_container > div > button.et2_button_with_image.closed { [class*="favorite_portlet"].et2_portlet .ui-widget-header > button.et2_button_with_image.closed {
background-position: 0 0 !important; background-position: 0 0 !important;
} }
.et2_portlet .et2_container > div > button.et2_button_with_image.opened { [class*="favorite_portlet"].et2_portlet .ui-widget-header > button.et2_button_with_image.opened {
background-position: -10px 0 !important; background-position: -10px 0 !important;
} }
.et2_portlet .et2_nextmatch.header_hidden {
padding-top: 16px; /* We can't just set display:none for the header as that changes the column spacing */
[class*="favorite_portlet"].et2_portlet .et2_nextmatch.header_hidden {
padding-top: 0px;
} }
.et2_portlet .et2_nextmatch.header_hidden .egwGridView_outer thead:first-of-type { [class*="favorite_portlet"].et2_portlet .et2_nextmatch.header_hidden .egwGridView_outer thead:first-of-type th,
display: none; [class*="favorite_portlet"].et2_portlet .et2_nextmatch.header_hidden .egwGridView_outer thead:first-of-type div.innerContainer,
[class*="favorite_portlet"].et2_portlet .et2_nextmatch.header_hidden .egwGridView_outer thead:first-of-type th.optcol span.selectcols {
height: 0px;
padding-top: 0px;
padding-bottom: 0px;
margin-top: 0px;
margin-bottom: 0px;
line-height: 0px;
}
[class*="favorite_portlet"].et2_portlet .et2_nextmatch.header_hidden .egwGridView_outer thead:first-of-type th {
visibility:hidden;
} }

View File

@ -2,7 +2,7 @@
<!-- $Id$ --> <!-- $Id$ -->
<overlay> <overlay>
<template id="home.favorite" template="" lang="" group="0" version="1.9.001"> <template id="home.favorite" template="" lang="" group="0" version="1.9.001">
<button id="header_toggle" background_image="true" image="egw_action/arrows" class="closed" onclick="app.home.nextmatch_toggle_header"/> <button id="header_toggle" background_image="true" image="egw_action/arrows" class="closed" onclick="app.home.nextmatch_toggle_header" parent_node="@header_node"/>
<nextmatch id="nm" class="header_hidden" hide_header="true"/> <nextmatch id="nm" class="header_hidden" hide_header="true"/>
</template> </template>
</overlay> </overlay>