Custom fields editing:

- Fix length, rows & values fields were not properly enabled on first load
- If label was not provided, use name
This commit is contained in:
Nathan Gray 2015-02-18 18:23:35 +00:00
parent 63cfd63c67
commit 55d5bd98f8
3 changed files with 23 additions and 4 deletions

View File

@ -305,6 +305,10 @@ class customfields
break; break;
case 'save': case 'save':
case 'apply': case 'apply':
if(empty($content['cf_label']))
{
$content['cf_label'] = $content['cf_name'];
}
if (!empty($content['cf_values'])) if (!empty($content['cf_values']))
{ {
$values = array(); $values = array();

View File

@ -100,6 +100,11 @@ app.classes.admin = AppJS.extend(
case 'admin.categories.index': case 'admin.categories.index':
break; break;
case 'admin.customfield_edit':
// Load settings appropriate to currently set type
var widget = _et2.widgetContainer.getWidgetById('cf_type');
this.cf_type_change(null,widget);
break;
} }
}, },
@ -784,5 +789,18 @@ app.classes.admin = AppJS.extend(
} }
}; };
et2_dialog.show_dialog(delDialog_callBack,this.egw.lang("Are you sure you want to delete this category ?"),this.egw.lang("Delete"),{},_buttons,et2_dialog.WARNING_MESSAGE,null,'admin'); et2_dialog.show_dialog(delDialog_callBack,this.egw.lang("Are you sure you want to delete this category ?"),this.egw.lang("Delete"),{},_buttons,et2_dialog.WARNING_MESSAGE,null,'admin');
},
/**
* Change handler for when you change the type of a custom field.
* It toggles options / attributes as appropriate.
*/
cf_type_change: function(e,widget) {
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);
} }
}); });

View File

@ -29,10 +29,7 @@
</row> </row>
<row> <row>
<description value="Type of field"/> <description value="Type of field"/>
<customfields-types statustext="Type of customfield" id="cf_type" class="et2_fullWidth" span="2" onchange="widget.getRoot().getWidgetById('cf_values').set_statustext(widget.egw().lang(widget.getArrayMgr('content').getEntry('options['+widget.getValue()+']'))||''); <customfields-types statustext="Type of customfield" id="cf_type" class="et2_fullWidth" span="2" onchange="app.admin.cf_type_change"/>
widget.getRoot().getWidgetById('cf_len').set_disabled(!widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+'][cf_len]'));
widget.getRoot().getWidgetById('cf_rows').set_disabled(!widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+'][cf_rows]'));
widget.getRoot().getWidgetById('cf_values').set_disabled(!widget.getArrayMgr('content').getEntry('attributes['+widget.getValue()+'][cf_values]'));"/>
<hbox span="2"> <hbox span="2">
<description value="Required"/> <description value="Required"/>
<checkbox id="cf_needed"/> <checkbox id="cf_needed"/>