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-23 18:10:47 +00:00
parent 29d0f737d5
commit 47bf1a5859
3 changed files with 23 additions and 4 deletions

View File

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

View File

@ -100,6 +100,11 @@ app.classes.admin = AppJS.extend(
case 'admin.categories.index':
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');
},
/**
* 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>
<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()+']'))||'');
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]'));"/>
<customfields-types statustext="Type of customfield" id="cf_type" class="et2_fullWidth" span="2" onchange="app.admin.cf_type_change"/>
<hbox span="2">
<description value="Required"/>
<checkbox id="cf_needed"/>