mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-06-25 20:31:31 +02:00
reverted r42883: Make sure there is a "None" option if the select-account is not required so user is not forced to pick an account
--> if "None" option is wanted, it should be added to template, that is the logic in regular select box too
This commit is contained in:
parent
4bc2595d36
commit
eaaad85521
@ -1,6 +1,6 @@
|
|||||||
/**
|
/**
|
||||||
* EGroupware eTemplate2 - JS Select account widget
|
* EGroupware eTemplate2 - JS Select account widget
|
||||||
*
|
*
|
||||||
* Selecting accounts needs special UI, and displaying needs special consideration
|
* Selecting accounts needs special UI, and displaying needs special consideration
|
||||||
* to avoid sending the entire user list to the client.
|
* to avoid sending the entire user list to the client.
|
||||||
*
|
*
|
||||||
@ -29,7 +29,7 @@
|
|||||||
* - 'popup' => No selectbox, just search. No popup, the search replaces the selectbox
|
* - 'popup' => No selectbox, just search. No popup, the search replaces the selectbox
|
||||||
*
|
*
|
||||||
* Only primary_group and popup need anything different from a normal selectbox
|
* Only primary_group and popup need anything different from a normal selectbox
|
||||||
*
|
*
|
||||||
* @augments et2_selectbox
|
* @augments et2_selectbox
|
||||||
*/
|
*/
|
||||||
var et2_selectAccount = et2_selectbox.extend(
|
var et2_selectAccount = et2_selectbox.extend(
|
||||||
@ -49,7 +49,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param _parent
|
* @param _parent
|
||||||
* @param _attrs
|
* @param _attrs
|
||||||
* @memberOf et2_selectAccount
|
* @memberOf et2_selectAccount
|
||||||
@ -59,7 +59,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
|
|
||||||
// Type in rows or somewhere else?
|
// Type in rows or somewhere else?
|
||||||
if(jQuery.inArray(_attrs['empty_label'], this.account_types) > 0 && (
|
if(jQuery.inArray(_attrs['empty_label'], this.account_types) > 0 && (
|
||||||
jQuery.inArray(_attrs['account_type'], this.account_types) < 0 ||
|
jQuery.inArray(_attrs['account_type'], this.account_types) < 0 ||
|
||||||
_attrs['account_type'] == this.attributes.account_type['default'])
|
_attrs['account_type'] == this.attributes.account_type['default'])
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
@ -70,12 +70,6 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
{
|
{
|
||||||
this.egw().debug("warn", "Invalid account_type: %s Valid options:",_attrs['account_type'], this.account_types);
|
this.egw().debug("warn", "Invalid account_type: %s Valid options:",_attrs['account_type'], this.account_types);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If not required, make sure there's an empty label
|
|
||||||
if(_attrs['rows'] == 1 && !_attrs['empty_label'] && !_attrs['needed'])
|
|
||||||
{
|
|
||||||
_attrs['empty_label'] = 'None';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Holder for search jQuery nodes
|
// Holder for search jQuery nodes
|
||||||
this.search = null;
|
this.search = null;
|
||||||
@ -108,7 +102,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
/**
|
/**
|
||||||
* Single selection - override to add search button
|
* Single selection - override to add search button
|
||||||
*/
|
*/
|
||||||
createInputWidget: function()
|
createInputWidget: function()
|
||||||
{
|
{
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
|
||||||
@ -178,7 +172,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
|
|
||||||
// Fix ID as sent from server - must be numeric
|
// Fix ID as sent from server - must be numeric
|
||||||
selected.item.value = parseInt(selected.item.value);
|
selected.item.value = parseInt(selected.item.value);
|
||||||
|
|
||||||
// This one is important, it makes sure the option is there
|
// This one is important, it makes sure the option is there
|
||||||
old_select.apply(this, arguments);
|
old_select.apply(this, arguments);
|
||||||
|
|
||||||
@ -200,7 +194,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
this.search = jQuery(document.createElement("li"))
|
this.search = jQuery(document.createElement("li"))
|
||||||
.appendTo(this.multiOptions.prev().find('ul'));
|
.appendTo(this.multiOptions.prev().find('ul'));
|
||||||
this.options.multiple = true;
|
this.options.multiple = true;
|
||||||
|
|
||||||
// Add search button
|
// Add search button
|
||||||
var button = jQuery(document.createElement("li"))
|
var button = jQuery(document.createElement("li"))
|
||||||
.addClass("et2_clickable")
|
.addClass("et2_clickable")
|
||||||
@ -296,14 +290,14 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
table.css("width", "100%").css("height", "100%");
|
table.css("width", "100%").css("height", "100%");
|
||||||
var search_col = jQuery('#search_col',table);
|
var search_col = jQuery('#search_col',table);
|
||||||
var select_col = jQuery('#selection_col',table);
|
var select_col = jQuery('#selection_col',table);
|
||||||
|
|
||||||
// Search / Selection
|
// Search / Selection
|
||||||
search_col.append(widget._create_search());
|
search_col.append(widget._create_search());
|
||||||
|
|
||||||
// Currently selected
|
// Currently selected
|
||||||
select_col.append(widget._create_selected());
|
select_col.append(widget._create_selected());
|
||||||
|
|
||||||
var ok_click = function() {
|
var ok_click = function() {
|
||||||
jQuery(this).dialog("close");
|
jQuery(this).dialog("close");
|
||||||
// Update widget with selected
|
// Update widget with selected
|
||||||
var ids = [];
|
var ids = [];
|
||||||
@ -349,7 +343,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
click: update_function
|
click: update_function
|
||||||
},{
|
},{
|
||||||
text: this.egw().lang("cancel"),
|
text: this.egw().lang("cancel"),
|
||||||
click: function() {
|
click: function() {
|
||||||
jQuery(this).dialog("close");
|
jQuery(this).dialog("close");
|
||||||
jQuery(this).dialog("destroy");
|
jQuery(this).dialog("destroy");
|
||||||
}}
|
}}
|
||||||
@ -421,7 +415,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
.css("height", "100%")
|
.css("height", "100%")
|
||||||
.append(results)
|
.append(results)
|
||||||
.appendTo(search);
|
.appendTo(search);
|
||||||
|
|
||||||
// Override link-entry auto-complete for custom display
|
// Override link-entry auto-complete for custom display
|
||||||
// Don't show normal drop-down
|
// Don't show normal drop-down
|
||||||
search_widget.search.data("ui-autocomplete")._suggest = function(items) {
|
search_widget.search.data("ui-autocomplete")._suggest = function(items) {
|
||||||
@ -508,7 +502,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
node = jQuery(document.createElement('li'));
|
node = jQuery(document.createElement('li'));
|
||||||
}
|
}
|
||||||
node.attr("data-id", item.value);
|
node.attr("data-id", item.value);
|
||||||
|
|
||||||
jQuery('<span class="ui-icon ui-icon-arrow-1-e et2_clickable"/>')
|
jQuery('<span class="ui-icon ui-icon-arrow-1-e et2_clickable"/>')
|
||||||
.css("float", "right")
|
.css("float", "right")
|
||||||
.appendTo(node)
|
.appendTo(node)
|
||||||
@ -535,7 +529,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
var label = jQuery(document.createElement('label'))
|
var label = jQuery(document.createElement('label'))
|
||||||
.addClass("loading")
|
.addClass("loading")
|
||||||
.appendTo(node);
|
.appendTo(node);
|
||||||
|
|
||||||
this.egw().link_title('home-accounts', item.value, function(name) {
|
this.egw().link_title('home-accounts', item.value, function(name) {
|
||||||
label.text(name).removeClass("loading");
|
label.text(name).removeClass("loading");
|
||||||
}, label);
|
}, label);
|
||||||
@ -596,7 +590,7 @@ var et2_selectAccount = et2_selectbox.extend(
|
|||||||
there.show();
|
there.show();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var option = jQuery(document.createElement('li'))
|
var option = jQuery(document.createElement('li'))
|
||||||
.attr("data-id",value)
|
.attr("data-id",value)
|
||||||
.appendTo(list);
|
.appendTo(list);
|
||||||
@ -624,10 +618,10 @@ et2_register_widget(et2_selectAccount, ["select-account"]);
|
|||||||
* et2_selectAccount_ro is the readonly implementation of select account
|
* et2_selectAccount_ro is the readonly implementation of select account
|
||||||
* It extends et2_link to avoid needing the whole user list on the client.
|
* It extends et2_link to avoid needing the whole user list on the client.
|
||||||
* Instead, it just asks for the names of the ones needed, as needed.
|
* Instead, it just asks for the names of the ones needed, as needed.
|
||||||
*
|
*
|
||||||
* @augments et2_link_string
|
* @augments et2_link_string
|
||||||
*/
|
*/
|
||||||
var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM],
|
var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM],
|
||||||
{
|
{
|
||||||
attributes: {
|
attributes: {
|
||||||
"empty_label": {
|
"empty_label": {
|
||||||
@ -642,7 +636,7 @@ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM],
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param _parent
|
* @param _parent
|
||||||
* @param options
|
* @param options
|
||||||
* @memberOf et2_selectAccount_ro
|
* @memberOf et2_selectAccount_ro
|
||||||
@ -650,7 +644,7 @@ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM],
|
|||||||
init: function(_parent, options) {
|
init: function(_parent, options) {
|
||||||
/**
|
/**
|
||||||
Resolve some circular dependency problems here
|
Resolve some circular dependency problems here
|
||||||
selectAccount extends link, link is in a file that needs select,
|
selectAccount extends link, link is in a file that needs select,
|
||||||
select has menulist wrapper, which needs to know about selectAccount before it allows it
|
select has menulist wrapper, which needs to know about selectAccount before it allows it
|
||||||
*/
|
*/
|
||||||
if(_parent.supportedWidgetClasses.indexOf(et2_selectAccount_ro) < 0)
|
if(_parent.supportedWidgetClasses.indexOf(et2_selectAccount_ro) < 0)
|
||||||
@ -660,7 +654,7 @@ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM],
|
|||||||
|
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
|
|
||||||
// Legacy options could have row count or empty label in first slot
|
// Legacy options could have row count or empty label in first slot
|
||||||
if(typeof this.options.empty_label == "string")
|
if(typeof this.options.empty_label == "string")
|
||||||
{
|
{
|
||||||
if(isNaN(this.options.empty_label))
|
if(isNaN(this.options.empty_label))
|
||||||
@ -681,7 +675,7 @@ var et2_selectAccount_ro = et2_link_string.extend([et2_IDetachedDOM],
|
|||||||
|
|
||||||
set_value: function(_value) {
|
set_value: function(_value) {
|
||||||
// Explode csv
|
// Explode csv
|
||||||
if(typeof _value == 'string' && _value.indexOf(',') > 0)
|
if(typeof _value == 'string' && _value.indexOf(',') > 0)
|
||||||
{
|
{
|
||||||
_value = _value.split(',');
|
_value = _value.split(',');
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user