From a627dea3d65e73018880c46684243985227967ba Mon Sep 17 00:00:00 2001 From: Nathan Gray Date: Mon, 20 Apr 2015 22:54:58 +0000 Subject: [PATCH] Customfields: - fix options/attributes not saved under some cirumstances - fix subsequent changes not saved if you click Apply the first time --- admin/inc/class.customfields.inc.php | 19 ++++++++++--------- admin/js/app.js | 6 +++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/admin/inc/class.customfields.inc.php b/admin/inc/class.customfields.inc.php index b156d89504..7bd4d2ba71 100644 --- a/admin/inc/class.customfields.inc.php +++ b/admin/inc/class.customfields.inc.php @@ -335,6 +335,11 @@ class customfields } } egw_customfields::update($update_content); + if(!$cf_id) + { + $this->fields = egw_customfields::get($this->appname,true); + $cf_id = (int)$this->fields[$content['cf_name']]['id']; + } egw_framework::refresh_opener('Saved', 'admin', $cf_id, 'edit'); if ($action != 'save') { @@ -380,8 +385,12 @@ class customfields { $readonlys['cf_name'] = true; } + $content['cf_values'] = json_decode($content['cf_values'], true); + } + else + { + $readonlys['button[delete]'] = true; } - $content['cf_values'] = json_decode($content['cf_values'], true); if (is_array($content['cf_values'])) { $values = ''; @@ -420,14 +429,6 @@ class customfields $content['statustext'] = $content['options'][$content['cf_type']]; $content['attributes'] = self::$type_attribute_flags; - // Start disabled, but don't set read-only as that changes the widget to readonly - $this->tmpl->setElementAttribute('cf_len', 'disabled', true); - $this->tmpl->setElementAttribute('cf_rows', 'disabled', true); - foreach(array('cf_len','cf_rows','cf_values') as $field) - { - $this->tmpl->setElementAttribute($field, 'disabled', !self::$type_attribute_flags[$content['cf_type']][$field]); - } - $this->tmpl->exec('admin.customfields.edit',$content,$sel_options,$readonlys,array( 'cf_id' => $cf_id, 'cf_app' => $this->appname, diff --git a/admin/js/app.js b/admin/js/app.js index 3d95fbd657..21897b9b66 100644 --- a/admin/js/app.js +++ b/admin/js/app.js @@ -798,8 +798,8 @@ app.classes.admin = AppJS.extend( var root = widget.getRoot(); var attributes = widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+']')||{}; root.getWidgetById('cf_values').set_statustext(widget.egw().lang(widget.getArrayMgr('content').getEntry('options['+widget.getValue()+']')||'')); - root.getWidgetById('cf_len').set_disabled(!attributes.cf_len); - root.getWidgetById('cf_rows').set_disabled(!attributes.cf_rows); - root.getWidgetById('cf_values').set_disabled(!attributes.cf_values); + jQuery(root.getWidgetById('cf_len').getDOMNode()).toggle(attributes.cf_len && true); + jQuery(root.getWidgetById('cf_rows').getDOMNode()).toggle(attributes.cf_rows && true); + jQuery(root.getWidgetById('cf_values').getParentDOMNode()).toggle(attributes.cf_values && true); } });