Layout & some functionallity for nm header

This commit is contained in:
Nathan Gray 2011-09-27 00:16:00 +00:00
parent c5237863c2
commit 4e8fe1bb2c
5 changed files with 79 additions and 8 deletions

View File

@ -509,6 +509,9 @@ var et2_dataview_rowTemplateWidget = et2_widget.extend(et2_IDOMNode, {
this._mgrs = {}; this._mgrs = {};
this._row = _row; this._row = _row;
// Set parent to root widget, so sub-widget calls still work
this._parent = _root;
// Clone the widgets inside the placeholders array // Clone the widgets inside the placeholders array
this._widgets = []; this._widgets = [];
}, },

View File

@ -461,7 +461,7 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
this.nextmatch = nextmatch; this.nextmatch = nextmatch;
this.div = jQuery(document.createElement("div")) this.div = jQuery(document.createElement("div"))
.addClass("et2_nm_header_bar"); .addClass("nextmatch_header");
if(this.nextmatch) this._createHeader(); if(this.nextmatch) this._createHeader();
}, },
@ -508,6 +508,7 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
// Add category // Add category
if(!settings.no_cat) { if(!settings.no_cat) {
settings.cat_id_label = egw.lang("Category");
this.category = this._build_select('cat_id', 'select-cat', settings.cat_id, true); this.category = this._build_select('cat_id', 'select-cat', settings.cat_id, true);
filters.append(this.category.getDOMNode()); filters.append(this.category.getDOMNode());
} }
@ -525,12 +526,15 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
} }
// Search // Search
this.search = et2_createWidget("textbox", {}, this.nextmatch); this.search = et2_createWidget("textbox", {"blur":egw.lang("search")}, this.nextmatch);
this.search.input.attr("type", "search"); this.search.input.attr("type", "search")
.css("left", "40%").css("position", "relative");
this.search.input.val(settings.search);
filters.append(this.search.getDOMNode()); filters.append(this.search.getDOMNode());
jQuery(document.createElement("button")) jQuery(document.createElement("button"))
.appendTo(filters) .appendTo(filters)
.css("left", "40%").css("position", "relative")
.text(">") .text(">")
.click(this.nextmatch, function(event) { .click(this.nextmatch, function(event) {
event.data.activeFilters.search = self.search.getValue() event.data.activeFilters.search = self.search.getValue()
@ -538,6 +542,23 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
}); });
// Export // Export
if(!settings.no_csv_export)
{
var definition = settings.csv_fields;
if(settings.csv_fields === true)
{
definition = egw.preference('nextmatch-export-definition', this.nextmatch.getTemplateApp());
}
var button = et2_createWidget("buttononly", {"label": "Export", image:"phpgwapi/filesave"}, this.nextmatch);
jQuery(button.getDOMNode()).appendTo(filters).css("float", "right")
.click(this.nextmatch, function(event) {
egw_openWindowCentered2( egw.link('/index.php', {
'menuaction': 'importexport.importexport_export_ui.export_dialog',
'appname': event.data.getTemplateApp(),
'definition': definition
}), '_blank', 850, 440, 'yes');
});
}
// Letter search // Letter search
var current_letter = this.nextmatch.options.settings.searchletter ? var current_letter = this.nextmatch.options.settings.searchletter ?
@ -577,14 +598,46 @@ var et2_nextmatch_header_bar = Class.extend(et2_INextmatchHeader, {
} }
}, },
/**
* Build the selectbox filters in the header bar
* Sets value, options, labels, and change handlers
*/
_build_select: function(name, type, value, lang) { _build_select: function(name, type, value, lang) {
var select = et2_createWidget(type, { var select = et2_createWidget(type, {
"id": this.nextmatch.id + "_"+name, "id": this.nextmatch.id + "_"+name,
"label": this.nextmatch.options.settings[name+"_label"]
},this.nextmatch); },this.nextmatch);
select.set_value(value); select.set_value(value);
var mgr = this.nextmatch.getArrayMgr("content").openPerspective(this.nextmatch, this.nextmatch.id); var mgr = this.nextmatch.getArrayMgr("content").openPerspective(this.nextmatch, this.nextmatch.id);
var options = mgr.getEntry("options-" + name); var options = mgr.getEntry("options-" + name);
if(options) select.set_select_options(options); if(options) select.set_select_options(options);
select.set_value(this.nextmatch.options.settings[name]);
var input = select.input;
if(this.nextmatch.options.settings[name+"_onchange"])
{
var onchange = this.nextmatch.options.settings[name+"_onchange"];
// onchange needs to get current values
if(typeof onchange == "string") {
// Don't change original so we can do this again
onchange = et2_js_pseudo_funcs(onchange, this.nextmatch.id);
if(onchange.indexOf("$") >= 0 || onchange.indexOf("@") >= 0) {
var mgr = this.nextmatch.getArrayMgr("content");
if(mgr) onchange = mgr.expandName(onchange);
}
onchange = new Function(onchange);
}
input.change(this.nextmatch, function(event) {
onchange(event);
});
}
else
{
input.change(this.nextmatch, function(event) {
event.data.activeFilters[name] = input.val()
event.data.applyFilters();
});
}
return select; return select;
} }

View File

@ -54,7 +54,7 @@ var et2_selectbox = et2_inputWidget.extend({
init: function() { init: function() {
this._super.apply(this, arguments); this._super.apply(this, arguments);
// Allow no other widgets inside this one // Allow no other widgets inside this one
this.supportedWidgetClasses = []; this.supportedWidgetClasses = [];

View File

@ -85,17 +85,23 @@ var et2_textbox = et2_inputWidget.extend({
this.input = $j(document.createElement("input")); this.input = $j(document.createElement("input"));
} }
if(this.size) { if(this.options.size) {
this.set_size(this.size); this.set_size(this.options.size);
} }
if(this.blur) { if(this.options.blur) {
this.set_blur(this.blur); this.set_blur(this.options.blur);
} }
this.input.addClass("et2_textbox"); this.input.addClass("et2_textbox");
this.setDOMNode(this.input[0]); this.setDOMNode(this.input[0]);
}, },
getValue: function()
{
if(this.options.blur && this.input.val() == this.options.blur) return "";
return this._super.apply(this, arguments);
},
/** /**
* Set input widget size * Set input widget size

View File

@ -512,6 +512,15 @@ label input, label span, label div, label select, label textarea {
/* background-color: silver;*/ /* background-color: silver;*/
} }
.nextmatch_header > .header_count {
text-align: center
}
.nextmatch_header .et2_button_icon {
vertical-align: middle;
}
.nextmatch_header select {
position: relative;
}
.nextmatch_sortheader { .nextmatch_sortheader {
color: #003075; color: #003075;
cursor: pointer; cursor: pointer;