mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-22 21:30:54 +01:00
Add set_value() so selectbox can show current value
This commit is contained in:
parent
db3f408f18
commit
29501fc027
@ -78,7 +78,7 @@ var et2_inputWidget = et2_valueWidget.extend(et2_IInput, {
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
// Check whether an validation error entry exists
|
||||
if (this.id)
|
||||
if (this.id && this.getArrayMgr("validation_errors"))
|
||||
{
|
||||
var val = this.getArrayMgr("validation_errors").getEntry(this.id);
|
||||
if (val)
|
||||
|
@ -515,14 +515,17 @@ var et2_widget = Class.extend({
|
||||
console.log(this.id);
|
||||
}
|
||||
|
||||
var data = this.getArrayMgr("modifications").getEntry(this.id);
|
||||
if (data instanceof Object)
|
||||
if(this.getArrayMgr("modifications"))
|
||||
{
|
||||
for (var key in data)
|
||||
var data = this.getArrayMgr("modifications").getEntry(this.id);
|
||||
if (data instanceof Object)
|
||||
{
|
||||
if (!(data[key] instanceof Object))
|
||||
for (var key in data)
|
||||
{
|
||||
_attrs[key] = data[key];
|
||||
if (!(data[key] instanceof Object))
|
||||
{
|
||||
_attrs[key] = data[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -477,20 +477,21 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
|
||||
|
||||
var self = this;
|
||||
var nm_div = this.nextmatch.div;
|
||||
var settings = this.nextmatch.options.settings;
|
||||
|
||||
this.div.prependTo(nm_div);
|
||||
|
||||
// Left
|
||||
|
||||
// Record count
|
||||
this.count = jQuery(document.createElement("span"))
|
||||
this.count = jQuery(document.createElement("div"))
|
||||
.addClass("header_count")
|
||||
.appendTo(this.div);
|
||||
|
||||
this.count.append("? - ? ").append(egw.lang("of")).append(" ");
|
||||
this.count_total = jQuery(document.createElement("span"))
|
||||
.appendTo(this.count)
|
||||
.text(this.nextmatch.options.settings.total + "");
|
||||
.text(settings.total + "");
|
||||
|
||||
// Set up so if row count changes, display is updated
|
||||
nm_div.bind('nm_data', function(e) { // Have to bind to DOM node, not et2 widget
|
||||
@ -499,13 +500,39 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
|
||||
|
||||
// Right
|
||||
|
||||
var filters = jQuery(document.createElement("div")).appendTo(this.div);
|
||||
|
||||
|
||||
// Add category
|
||||
if(!settings.no_cat) {
|
||||
this.category = this._build_select('cat_id', 'select-cat', settings.cat_id, true);
|
||||
filters.append(this.category.getDOMNode());
|
||||
}
|
||||
|
||||
// Filter 1
|
||||
if(!settings.no_filter) {
|
||||
this.filter = this._build_select('filter', 'select', settings.filter, settings.filter_no_lang);
|
||||
filters.append(this.filter.getDOMNode());
|
||||
}
|
||||
|
||||
// Filter 2
|
||||
if(!settings.no_filter2) {
|
||||
this.filter2 = this._build_select('filter2', 'select', settings.filter2, settings.filter2_no_lang);
|
||||
filters.append(this.filter2.getDOMNode());
|
||||
}
|
||||
|
||||
// Search
|
||||
this.search = et2_createWidget("textbox", {}, this.nextmatch);
|
||||
this.search.input.attr("type", "search");
|
||||
filters.append(this.search.getDOMNode());
|
||||
|
||||
jQuery(document.createElement("button"))
|
||||
.appendTo(filters)
|
||||
.text(">")
|
||||
.click(this.nextmatch, function(event) {
|
||||
event.data.activeFilters.search = self.search.getValue()
|
||||
event.data.applyFilters();
|
||||
});
|
||||
|
||||
// Export
|
||||
|
||||
@ -545,7 +572,16 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
|
||||
event.data.applyFilters();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_build_select: function(name, type, value, lang) {
|
||||
var select = et2_createWidget(type, {
|
||||
"id": this.nextmatch.id + "_"+name,
|
||||
},this.nextmatch);
|
||||
select.set_value(value);
|
||||
return select;
|
||||
}
|
||||
|
||||
});
|
||||
et2_register_widget(et2_nextmatch_header_bar, ["nextmatch_header_bar"]);
|
||||
|
||||
|
@ -77,7 +77,10 @@ var et2_selectbox = et2_inputWidget.extend({
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
// Try to find the options inside the "sel-options" array
|
||||
_attrs["select_options"] = this.getArrayMgr("sel_options").getEntry(this.id);
|
||||
if(this.getArrayMgr("sel_options"))
|
||||
{
|
||||
_attrs["select_options"] = this.getArrayMgr("sel_options").getEntry(this.id);
|
||||
}
|
||||
|
||||
// Check whether the options entry was found, if not read it from the
|
||||
// content array.
|
||||
@ -145,6 +148,15 @@ var et2_selectbox = et2_inputWidget.extend({
|
||||
}
|
||||
},
|
||||
|
||||
set_value: function(_value) {
|
||||
jQuery("option",this.input).attr("selected", false);
|
||||
this.value = null;
|
||||
if(jQuery("option[value='"+_value+"']", this.input).attr("selected", true).length > 0)
|
||||
{
|
||||
this.value = _value;
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* The set_select_options function is added, as the select options have to be
|
||||
* added after the "option"-widgets were added to selectbox.
|
||||
@ -171,7 +183,7 @@ var et2_selectbox = et2_inputWidget.extend({
|
||||
}
|
||||
});
|
||||
|
||||
et2_register_widget(et2_selectbox, ["menupopup", "listbox", "select-cat",
|
||||
et2_register_widget(et2_selectbox, ["menupopup", "listbox", "select", "select-cat",
|
||||
"select-account", "select-percent", 'select-priority', 'select-access',
|
||||
'select-country', 'select-state', 'select-year', 'select-month',
|
||||
'select-day', 'select-dow', 'select-hour', 'select-number', 'select-app',
|
||||
|
Loading…
Reference in New Issue
Block a user