mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-09 23:11:57 +01:00
Add onselect attribute for nextmatch
This commit is contained in:
parent
b8609009dc
commit
7f80c74b59
@ -52,6 +52,9 @@ var et2_dataview_selectionManager = Class.extend({
|
|||||||
this._inUpdate = false;
|
this._inUpdate = false;
|
||||||
this._total = 0;
|
this._total = 0;
|
||||||
this._children = [];
|
this._children = [];
|
||||||
|
|
||||||
|
// Callback for when the selection changes
|
||||||
|
this.select_callback = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
@ -74,6 +77,7 @@ var et2_dataview_selectionManager = Class.extend({
|
|||||||
{
|
{
|
||||||
this.unregisterRow(key, this._registeredRows[key].tr);
|
this.unregisterRow(key, this._registeredRows[key].tr);
|
||||||
}
|
}
|
||||||
|
this.select_callback = null;
|
||||||
},
|
},
|
||||||
|
|
||||||
setIndexMap: function (_indexMap) {
|
setIndexMap: function (_indexMap) {
|
||||||
@ -418,6 +422,11 @@ var et2_dataview_selectionManager = Class.extend({
|
|||||||
{
|
{
|
||||||
this._selectRange(this._focusedEntry.idx, _entry.idx);
|
this._selectRange(this._focusedEntry.idx, _entry.idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.select_callback && typeof this.select_callback == "function")
|
||||||
|
{
|
||||||
|
this.select_callback.apply(this._context, arguments);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
_selectRange: function (_start, _stop) {
|
_selectRange: function (_start, _stop) {
|
||||||
|
@ -93,6 +93,11 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
|
|||||||
"description": "Customise the nextmatch - right side. Provided template becomes a child of nextmatch, and any input widgets with onChange can trigger the nextmatch to refresh by returning true.",
|
"description": "Customise the nextmatch - right side. Provided template becomes a child of nextmatch, and any input widgets with onChange can trigger the nextmatch to refresh by returning true.",
|
||||||
"default": ""
|
"default": ""
|
||||||
},
|
},
|
||||||
|
"onselect": {
|
||||||
|
"name": "onselect",
|
||||||
|
"type": "string",
|
||||||
|
"description": "JS code which gets executed when rows are selected. Can also be a app.appname.func(selected) style method"
|
||||||
|
},
|
||||||
"settings": {
|
"settings": {
|
||||||
"name": "Settings",
|
"name": "Settings",
|
||||||
"type": "any",
|
"type": "any",
|
||||||
@ -387,6 +392,29 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
|
|||||||
return {ids:[],inverted:false};
|
return {ids:[],inverted:false};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
onselect: function() {
|
||||||
|
// Execute the JS code connected to the event handler
|
||||||
|
if (this.options.onselect)
|
||||||
|
{
|
||||||
|
if (typeof this.options.onselect == "string" &&
|
||||||
|
this.options.onselect.substr(0,4) == "app." && window.app)
|
||||||
|
{
|
||||||
|
var parts = this.options.onselect.split(".");
|
||||||
|
if(parts.length == 3 && typeof window.app[parts[1]] == "object" &&
|
||||||
|
typeof window.app[parts[1]][parts[2]] == "function")
|
||||||
|
{
|
||||||
|
window.app[parts[1]][parts[2]].call(this, this.getSelection());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Exectute the legacy JS code
|
||||||
|
else if (!(et2_compileLegacyJS(this.options.onselect, this, _node))())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generates the column caption for the given column widget
|
* Generates the column caption for the given column widget
|
||||||
*/
|
*/
|
||||||
@ -1102,7 +1130,6 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
|
|||||||
return path;
|
return path;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
// Input widget
|
// Input widget
|
||||||
getValue: function() { return null;},
|
getValue: function() { return null;},
|
||||||
resetDirty: function() {},
|
resetDirty: function() {},
|
||||||
|
@ -62,6 +62,9 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
|
|||||||
this._actionManager = null;
|
this._actionManager = null;
|
||||||
this._objectManager = _objectManager;
|
this._objectManager = _objectManager;
|
||||||
}
|
}
|
||||||
|
// Add our selection callback to selection manager
|
||||||
|
var self = this;
|
||||||
|
this._objectManager.setSelectedCallback = function() {self._selectCallback(this);};
|
||||||
|
|
||||||
// Call the parent et2_dataview_controller constructor
|
// Call the parent et2_dataview_controller constructor
|
||||||
this._super(_parentController, _grid, this, this._rowCallback,
|
this._super(_parentController, _grid, this, this._rowCallback,
|
||||||
@ -80,6 +83,7 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
|
|||||||
// Directly use the API-Implementation of dataRegisterUID and
|
// Directly use the API-Implementation of dataRegisterUID and
|
||||||
// dataUnregisterUID
|
// dataUnregisterUID
|
||||||
this.dataUnregisterUID = _egw.dataUnregisterUID;
|
this.dataUnregisterUID = _egw.dataUnregisterUID;
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
@ -257,6 +261,14 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
|
|||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Execute the select callback when the row selection changes
|
||||||
|
*/
|
||||||
|
_selectCallback: function(action)
|
||||||
|
{
|
||||||
|
this._widget.onselect.call(this._widget, action);
|
||||||
|
},
|
||||||
|
|
||||||
/** -- Implementation of et2_IDataProvider -- **/
|
/** -- Implementation of et2_IDataProvider -- **/
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user