From dfe5d21ea4616e130ff0328ef79c69ec1c79b885 Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Wed, 5 Oct 2011 16:12:40 +0000 Subject: [PATCH] Save as default checkbox - still a problem getting value on server --- .../class.etemplate_widget_nextmatch.inc.php | 17 +++++++++++------ etemplate/js/et2_extension_nextmatch.js | 15 +++------------ 2 files changed, 14 insertions(+), 18 deletions(-) diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php index 950869b63b..acc971f3b0 100644 --- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php +++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php @@ -76,6 +76,11 @@ class etemplate_widget_nextmatch extends etemplate_widget } } + /** + * Legacy options + */ + protected $legacy_options = 'template'; + /** * Number of rows to send initially */ @@ -578,20 +583,20 @@ class etemplate_widget_nextmatch extends etemplate_widget { $form_name = self::form_name($cname, $this->id); $value = self::get_array($content, $form_name); -error_log("nextmatch value: " . array2string($value)); // Save current column settings as default (admins only) if($value['as_default']) { unset($value['as_default']); - if($GLOBALS['egw_info']['user']['apps']['admin']) + list($app) = explode('.',$this->attrs['template']); + if($GLOBALS['egw_info']['user']['apps']['admin'] && $app) { - list($app) = explode('.',$this->template); - $pref_name = 'nextmatch-' . (isset($this->columnselection_pref) ? $this->columnselection_pref : $this->template); - // Columns already saved to user's preferences + $pref_name = 'nextmatch-' . (isset($value['columnselection_pref']) ? $value['columnselection_pref'] : $this->attrs['template'].'-details'); + // Columns already saved to user's preferences, use from there $cols = $GLOBALS['egw']->preferences->read(); - $cols = $cols[$pref_name]; + $cols = $cols[$app][$pref_name]; $GLOBALS['egw']->preferences->add($app,$pref_name,is_array($cols) ? implode(',',$cols) : $cols,'default'); + $GLOBALS['egw']->preferences->save_repository(false,'default'); } } diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js index 34be96540e..1b4af83640 100644 --- a/etemplate/js/et2_extension_nextmatch.js +++ b/etemplate/js/et2_extension_nextmatch.js @@ -349,10 +349,8 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, { /** * Take current column display settings and store them in egw.preferences * for next time - * - * @param setDefault boolean From checkbox, for admins to set default settings */ - _updateUserPreferences: function(setDefault) { + _updateUserPreferences: function() { var colMgr = this.dataviewContainer.getColumnMgr() if(!this.options.settings.columnselection_pref) { this.options.settings.columnselection_pref = this.options.template; @@ -385,13 +383,6 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, { // Save adjusted column sizes egw.set_preference(app, "nextmatch-"+this.options.settings.columnselection_pref+"-size", colSize); - // Save as default, if set - if(setDefault) - { - this.getInstanceManager().submit(); - return false; - } - // Update query value, so data source can use visible columns to exclude expensive sub-queries var oldCols = this.activeFilters.selectcols ? this.activeFilters.selectcols : []; this.activeFilters.selectcols = colDisplay; @@ -443,7 +434,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, { var self = this; // Register handler to update preferences when column properties are changed - this.dataviewContainer.onUpdateColumns = function(setDefault) { self._updateUserPreferences(setDefault);}; + this.dataviewContainer.onUpdateColumns = function() { self._updateUserPreferences();}; // Register handler for column selection popup this.dataviewContainer.selectColumnsClick = function(event) { self._selectColumnsClick(event);}; @@ -559,7 +550,7 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, { var apps = egw.user('apps'); if(apps['admin']) { - this.selectPopup.append(defaultCheck.getDOMNode()) + this.selectPopup.append(defaultCheck.getSurroundings().getDOMNode(defaultCheck.getDOMNode())) } } else