forked from extern/egroupware
Add select-bitwise selectbox type
This commit is contained in:
parent
53b8d9fbbe
commit
6af45ef40a
@ -576,6 +576,19 @@ var et2_selectbox = (function(){ "use strict"; return et2_inputWidget.extend(
|
|||||||
selected.addClass('et2_country-select flag-'+ _value.toLowerCase());
|
selected.addClass('et2_country-select flag-'+ _value.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(this._type == "select-bitwise" && _value && !isNaN(_value) && this.options.select_options)
|
||||||
|
{
|
||||||
|
var new_value = [];
|
||||||
|
for(var index in this.options.select_options)
|
||||||
|
{
|
||||||
|
var right = this.options.select_options[index].value;
|
||||||
|
if(!!(_value & right))
|
||||||
|
{
|
||||||
|
new_value.push(right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_value = new_value;
|
||||||
|
}
|
||||||
this._oldValue = this.value;
|
this._oldValue = this.value;
|
||||||
if(this.input !== null && (this.options.tags || this.options.search))
|
if(this.input !== null && (this.options.tags || this.options.search))
|
||||||
{
|
{
|
||||||
@ -1040,7 +1053,7 @@ et2_register_widget(et2_selectbox, ["menupopup", "listbox", "select", "select-ca
|
|||||||
"select-percent", 'select-priority',
|
"select-percent", 'select-priority',
|
||||||
'select-country', 'select-state', 'select-year', 'select-month',
|
'select-country', 'select-state', 'select-year', 'select-month',
|
||||||
'select-day', 'select-dow', 'select-hour', 'select-number', 'select-app',
|
'select-day', 'select-dow', 'select-hour', 'select-number', 'select-app',
|
||||||
'select-lang', 'select-bool', 'select-timezone' ]);
|
'select-lang', 'select-bool', 'select-timezone', 'select-bitwise' ]);
|
||||||
|
|
||||||
// Static class stuff
|
// Static class stuff
|
||||||
jQuery.extend(et2_selectbox, //(function(){ "use strict"; return
|
jQuery.extend(et2_selectbox, //(function(){ "use strict"; return
|
||||||
@ -1563,6 +1576,20 @@ var et2_selectbox_ro = (function(){ "use strict"; return et2_selectbox.extend([e
|
|||||||
set_value: function(_value) {
|
set_value: function(_value) {
|
||||||
this.value = _value;
|
this.value = _value;
|
||||||
|
|
||||||
|
if(this._type == "select-bitwise" && _value && !isNaN(_value) && this.options.select_options)
|
||||||
|
{
|
||||||
|
var new_value = [];
|
||||||
|
for(var index in this.options.select_options)
|
||||||
|
{
|
||||||
|
var option = this.options.select_options[index];
|
||||||
|
var right = option && option.value ? option.value : index;
|
||||||
|
if(!!(_value & right))
|
||||||
|
{
|
||||||
|
new_value.push(right);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_value = new_value;
|
||||||
|
}
|
||||||
if(typeof _value == "string")
|
if(typeof _value == "string")
|
||||||
{
|
{
|
||||||
_value = _value.match(this._is_multiple_regexp) !== null ? _value.split(',') : [_value];
|
_value = _value.match(this._is_multiple_regexp) !== null ? _value.split(',') : [_value];
|
||||||
@ -1661,7 +1688,7 @@ et2_register_widget(et2_selectbox_ro, ["menupopup_ro", "listbox_ro", "select_ro"
|
|||||||
"select-percent_ro", 'select-priority_ro', 'select-access_ro',
|
"select-percent_ro", 'select-priority_ro', 'select-access_ro',
|
||||||
'select-country_ro', 'select-state_ro', 'select-year_ro', 'select-month_ro',
|
'select-country_ro', 'select-state_ro', 'select-year_ro', 'select-month_ro',
|
||||||
'select-day_ro', 'select-dow_ro', 'select-hour_ro', 'select-number_ro', 'select-app_ro',
|
'select-day_ro', 'select-dow_ro', 'select-hour_ro', 'select-number_ro', 'select-app_ro',
|
||||||
'select-lang_ro', 'select-bool_ro', 'select-timezone_ro' ]);
|
'select-lang_ro', 'select-bool_ro', 'select-timezone_ro', 'select-bitwise_ro' ]);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Widget class which represents a single option inside a selectbox
|
* Widget class which represents a single option inside a selectbox
|
||||||
|
@ -255,6 +255,15 @@ class Select extends Etemplate\Widget
|
|||||||
$value = self::$request->preserv[$unavailable_name];
|
$value = self::$request->preserv[$unavailable_name];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case 'select-bitwise':
|
||||||
|
// Sum up into a single value
|
||||||
|
$sum = 0;
|
||||||
|
foreach((array) $value as $val)
|
||||||
|
{
|
||||||
|
$sum += $val;
|
||||||
|
}
|
||||||
|
$value = $sum;
|
||||||
|
|
||||||
}
|
}
|
||||||
if (isset($value))
|
if (isset($value))
|
||||||
{
|
{
|
||||||
@ -783,6 +792,25 @@ class Select extends Etemplate\Widget
|
|||||||
$options = $type ? Api\DateTime::getTimezones() : Api\DateTime::getUserTimezones($value);
|
$options = $type ? Api\DateTime::getTimezones() : Api\DateTime::getUserTimezones($value);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'select-bitwise':
|
||||||
|
// type = app name
|
||||||
|
$options = $form_name ? self::selOptions($form_name) : array();
|
||||||
|
$new_value = array();
|
||||||
|
$i = 0;
|
||||||
|
$appname = $type ? $type : ($widget && $widget->attrs['appname'] ?
|
||||||
|
self::expand_name($widget->attrs['appname'], 0, 0,'','',self::$cont) : '');
|
||||||
|
if($appname)
|
||||||
|
{
|
||||||
|
$options += (array)Api\Hooks::single(array('location' => 'acl_rights'), $appname);
|
||||||
|
}
|
||||||
|
foreach((array)$options as $right => $name)
|
||||||
|
{
|
||||||
|
if(!!($value & $right))
|
||||||
|
{
|
||||||
|
$new_value[] = $right;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$value = $new_value;
|
||||||
}
|
}
|
||||||
if ($rows > 1 || $readonly)
|
if ($rows > 1 || $readonly)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user