From dd0e95d232da63f7a02389fd941bf0dc9a6f40a6 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Tue, 25 Nov 2014 21:50:42 +0000 Subject: [PATCH] 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 --- etemplate/js/et2_widget_portlet.js | 7 +++- home/inc/class.home_favorite_portlet.inc.php | 3 +- home/inc/class.home_ui.inc.php | 18 ++++++---- home/js/app.js | 11 +++--- home/templates/default/app.css | 35 ++++++++++++-------- home/templates/default/favorite.xet | 2 +- 6 files changed, 47 insertions(+), 29 deletions(-) diff --git a/etemplate/js/et2_widget_portlet.js b/etemplate/js/et2_widget_portlet.js index a6155a3abc..7b2c9ef55f 100644 --- a/etemplate/js/et2_widget_portlet.js +++ b/etemplate/js/et2_widget_portlet.js @@ -338,8 +338,13 @@ var et2_portlet = et2_valueWidget.extend( */ set_title: function(value) { + this.header.contents() + .filter(function() { + return this.nodeType === 3; + }) + .remove(); this.options.title = value; - this.header.html(value); + this.header.append(value); }, /** diff --git a/home/inc/class.home_favorite_portlet.inc.php b/home/inc/class.home_favorite_portlet.inc.php index 7d43c6e194..e28baf8dd8 100644 --- a/home/inc/class.home_favorite_portlet.inc.php +++ b/home/inc/class.home_favorite_portlet.inc.php @@ -81,7 +81,7 @@ class home_favorite_portlet extends home_portlet if($this->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'])) { $this->nm_settings += $this->favorite['state']; @@ -99,6 +99,7 @@ class home_favorite_portlet extends home_portlet $etemplate->set_dom_id($id); $content = $this->context + array('nm' => $this->nm_settings); + $content['header_node'] = "home-index_{$id}_header"; $sel_options = $content['sel_options'] ? $content['sel_options'] : array(); unset($content['sel_options']); $etemplate->setElementAttribute('nm', 'template',$this->nm_settings['template']); diff --git a/home/inc/class.home_ui.inc.php b/home/inc/class.home_ui.inc.php index a120199262..6790baac99 100644 --- a/home/inc/class.home_ui.inc.php +++ b/home/inc/class.home_ui.inc.php @@ -85,18 +85,22 @@ class home_ui { $portlets = $this->get_portlet_list(); $add_portlets = $portlets; - foreach($add_portlets as $id => &$add) + $change_for_add = function(&$add_portlets) use (&$change_for_add) { - if(!$add['id'] && is_array($add['children'])) + foreach($add_portlets as $id => &$add) { - foreach($add['children'] as $sub_id => &$sub_add) + if(is_array($add['children'])) { - $sub_add['id'] = 'add_'.$sub_id; + $change_for_add($add['children']); + } + if($id && !$add['children']) + { + $add['id'] = 'add_' . $id; + $add['class'] = 'add_'.$id; } } - $add['id'] = 'add_' . $id; - $add['class'] = $id; - } + }; + $change_for_add($add_portlets); $actions = array( 'add' => array( 'type' => 'popup', diff --git a/home/js/app.js b/home/js/app.js index 7f5794ec9b..cec88d7c7c 100644 --- a/home/js/app.js +++ b/home/js/app.js @@ -188,10 +188,10 @@ app.classes.home = AppJS.extend( } var portlet = et2_createWidget('portlet',attrs, this.portlet_container); - // Override content ID so etemplate loads - portlet.content.attr('id', attrs.id); portlet.loadingFinished(); + // Immediately add content ID so etemplate loads into the right place + portlet.content.append('
'); // Get actual attributes & settings, since they're not available client side yet 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); - // Override content ID so etemplate loads - portlet.content.attr('id', attrs.id); + // Immediately add content ID so etemplate loads into the right place + portlet.content.append('
'); portlet.loadingFinished(); // 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 var nm = widget.getParent().getWidgetById('nm'); if(!nm) return; - var header = nm.header; - var header_height = header.div.innerHeight(); // Hide header nm.div.toggleClass('header_hidden'); nm.set_hide_header(nm.div.hasClass('header_hidden')); + nm.resize(); } }); diff --git a/home/templates/default/app.css b/home/templates/default/app.css index bd78a2b627..2ab04d8076 100644 --- a/home/templates/default/app.css +++ b/home/templates/default/app.css @@ -91,28 +91,37 @@ } /* 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 { - position:absolute; - top: 0px; - left: 100%; - margin-left: -16px; - margin-bottom: -16px; +[class*="favorite_portlet"].et2_portlet .ui-widget-header > .et2_button { + float: left; padding: 0px !important; + margin-top: 3px; height: 12px; width: 12px; 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; } -.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; } -.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 { - display: none; +[class*="favorite_portlet"].et2_portlet .et2_nextmatch.header_hidden .egwGridView_outer thead:first-of-type th, +[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; } \ No newline at end of file diff --git a/home/templates/default/favorite.xet b/home/templates/default/favorite.xet index 0bc2506f85..699d03eb9c 100644 --- a/home/templates/default/favorite.xet +++ b/home/templates/default/favorite.xet @@ -2,7 +2,7 @@