Save as default checkbox - still a problem getting value on server

This commit is contained in:
Nathan Gray 2011-10-05 16:12:40 +00:00
parent 87ac5880db
commit dfe5d21ea4
2 changed files with 14 additions and 18 deletions

View File

@ -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');
}
}

View File

@ -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