mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-23 07:09:20 +01:00
For radiobox customfields, implement "empty" first value = extra group label
This commit is contained in:
parent
014a273908
commit
8a2c791be3
@ -411,9 +411,15 @@ var et2_customfields_list = et2_valueWidget.extend([et2_IDetachedDOM, et2_IInput
|
|||||||
return true;
|
return true;
|
||||||
},
|
},
|
||||||
_setup_radio: function(field_name, field, attrs) {
|
_setup_radio: function(field_name, field, attrs) {
|
||||||
// No label on the widget itself
|
// 'Empty' label will be first
|
||||||
delete(attrs.label);
|
delete(attrs.label);
|
||||||
|
|
||||||
|
if(field.values && field.values[''])
|
||||||
|
{
|
||||||
|
attrs.label = field.values[''];
|
||||||
|
delete field.values[''];
|
||||||
|
}
|
||||||
|
|
||||||
field.type = 'radiogroup';
|
field.type = 'radiogroup';
|
||||||
attrs.options = field.values;
|
attrs.options = field.values;
|
||||||
return true;
|
return true;
|
||||||
|
@ -172,6 +172,7 @@ var et2_radiobox_ro = et2_valueWidget.extend([et2_IDetachedDOM],
|
|||||||
this.span.text(this.options.ro_false);
|
this.span.text(this.options.ro_false);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Code for implementing et2_IDetachedDOM
|
* Code for implementing et2_IDetachedDOM
|
||||||
*/
|
*/
|
||||||
@ -199,11 +200,18 @@ et2_register_widget(et2_radiobox_ro, ["radio_ro"]);
|
|||||||
/**
|
/**
|
||||||
* A group of radio buttons
|
* A group of radio buttons
|
||||||
*
|
*
|
||||||
* @augments et2_box
|
* @augments et2_valueWidget
|
||||||
*/
|
*/
|
||||||
var et2_radioGroup = et2_box.extend(
|
var et2_radioGroup = et2_valueWidget.extend(
|
||||||
{
|
{
|
||||||
attributes: {
|
attributes: {
|
||||||
|
"label": {
|
||||||
|
"name": "Label",
|
||||||
|
"default": "",
|
||||||
|
"type": "string",
|
||||||
|
"description": "The label is displayed above the list of radio buttons. The label can contain variables, as descript for name. If the label starts with a '@' it is replaced by the value of the content-array at this index (with the '@'-removed and after expanding the variables).",
|
||||||
|
"translate": true
|
||||||
|
},
|
||||||
"value": {
|
"value": {
|
||||||
"name": "Value",
|
"name": "Value",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
@ -240,8 +248,15 @@ var et2_radioGroup = et2_box.extend(
|
|||||||
* @memberOf et2_radioGroup
|
* @memberOf et2_radioGroup
|
||||||
*/
|
*/
|
||||||
init: function(parent, attrs) {
|
init: function(parent, attrs) {
|
||||||
attrs.type = "vbox";
|
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
this.node = $j(document.createElement("div"))
|
||||||
|
.addClass("et2_vbox")
|
||||||
|
.addClass("et2_box_widget");
|
||||||
|
this.setDOMNode(this.node[0]);
|
||||||
|
|
||||||
|
// The supported widget classes array defines a whitelist for all widget
|
||||||
|
// classes or interfaces child widgets have to support.
|
||||||
|
this.supportedWidgetClasses = [et2_radiobox];
|
||||||
},
|
},
|
||||||
|
|
||||||
set_value: function(_value) {
|
set_value: function(_value) {
|
||||||
@ -253,6 +268,10 @@ var et2_radioGroup = et2_box.extend(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
getValue: function() {
|
||||||
|
return jQuery("input:checked", this.getDOMNode()).val();
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a bunch of radio buttons
|
* Set a bunch of radio buttons
|
||||||
* Options should be {value: label, ...}
|
* Options should be {value: label, ...}
|
||||||
@ -270,10 +289,51 @@ var et2_radioGroup = et2_box.extend(
|
|||||||
readonly: this.options.readonly
|
readonly: this.options.readonly
|
||||||
};
|
};
|
||||||
var radio = et2_createWidget("radio", attrs, this);
|
var radio = et2_createWidget("radio", attrs, this);
|
||||||
// radio.set_name(this.id);
|
|
||||||
}
|
}
|
||||||
this.set_value(this.value);
|
this.set_value(this.value);
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set a label on the group of radio buttons
|
||||||
|
*/
|
||||||
|
set_label: function(_value) {
|
||||||
|
// Abort if ther was no change in the label
|
||||||
|
if (_value == this.label)
|
||||||
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (_value)
|
||||||
|
{
|
||||||
|
// Create the label container if it didn't exist yet
|
||||||
|
if (this._labelContainer == null)
|
||||||
|
{
|
||||||
|
this._labelContainer = $j(document.createElement("label"))
|
||||||
|
this.getSurroundings().insertDOMNode(this._labelContainer[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear the label container.
|
||||||
|
this._labelContainer.empty();
|
||||||
|
|
||||||
|
// Create the placeholder element and set it
|
||||||
|
var ph = document.createElement("span");
|
||||||
|
this.getSurroundings().setWidgetPlaceholder(ph);
|
||||||
|
|
||||||
|
this._labelContainer
|
||||||
|
.append(document.createTextNode(_value))
|
||||||
|
.append(ph);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Delete the labelContainer from the surroundings object
|
||||||
|
if (this._labelContainer)
|
||||||
|
{
|
||||||
|
this.getSurroundings().removeDOMNode(this._labelContainer[0]);
|
||||||
|
}
|
||||||
|
this._labelContainer = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
// No such tag as 'radiogroup', but it needs something
|
// No such tag as 'radiogroup', but it needs something
|
||||||
et2_register_widget(et2_radioGroup, ["radiogroup"]);
|
et2_register_widget(et2_radioGroup, ["radiogroup"]);
|
||||||
|
Loading…
Reference in New Issue
Block a user