diff --git a/etemplate/js/et2_dataview_controller.js b/etemplate/js/et2_dataview_controller.js
index 62eda33e65..97adf29fad 100644
--- a/etemplate/js/et2_dataview_controller.js
+++ b/etemplate/js/et2_dataview_controller.js
@@ -15,6 +15,7 @@
et2_core_inheritance;
et2_dataview_interfaces;
+ et2_dataview_controller_selection;
et2_dataview_view_aoi;
et2_dataview_view_row;
@@ -78,10 +79,17 @@ var et2_dataview_controller = Class.extend({
// Register the dataFetch callback
this._grid.setDataCallback(this._gridCallback, this);
+
+ // Create the selection manager
+ this._selectionMgr = new et2_dataview_selectionManager(this._indexMap);
},
destroy: function () {
+ // Destroy the selection manager
+ this._selectionMgr.free();
+
+ // Clear the selection timeout
this._clearTimer();
this._super();
@@ -143,6 +151,16 @@ var et2_dataview_controller = Class.extend({
this.update();
},
+ /**
+ * Loads the initial order. Do not call multiple times.
+ */
+ loadInitialOrder: function (order) {
+ for (var i = 0; i < order.length; i++)
+ {
+ this._getIndexEntry(i).uid = order[i];
+ }
+ },
+
/* -- PRIVATE FUNCTIONS -- */
@@ -446,15 +464,16 @@ var et2_dataview_controller = Class.extend({
this.entry.uid
);
- // Create the action object
- var aom = this.self._actionObjectManager;
- this.entry.ao = aom.addObject(
- this.entry.uid,
- new et2_dataview_rowAOI(tr)
- );
+ // Create the action object interface
+ var aoi = new et2_dataview_rowAOI(tr);
- // Update the action links
- this.entry.ao.updateActionLinks(links);
+ // Create the action object
+ var ao = this.entry.ao =
+ this.self._actionObjectManager.addObject(this.entry.uid, aoi);
+ ao.updateActionLinks(links);
+
+ // Hook the action object into the selection manager
+ this.self._selectionMgr.hook(ao, aoi, this.entry.uid);
}
// Invalidate the current row entry
diff --git a/etemplate/js/et2_dataview_view_aoi.js b/etemplate/js/et2_dataview_view_aoi.js
index 2a7cc8ee6e..2edf089538 100644
--- a/etemplate/js/et2_dataview_view_aoi.js
+++ b/etemplate/js/et2_dataview_view_aoi.js
@@ -22,6 +22,9 @@
* row.
*/
+var EGW_SELECTMODE_DEFAULT = 0;
+var EGW_SELECTMODE_TOGGLE = 1;
+
/**
* An action object interface for each nextmatch widget row - "inherits" from
* egwActionObjectInterface
@@ -32,6 +35,8 @@ function et2_dataview_rowAOI(_node)
aoi.node = _node;
+ aoi.selectMode = EGW_SELECTMODE_DEFAULT;
+
aoi.checkBox = null; //($j(":checkbox", aoi.node))[0];
// Rows without a checkbox OR an id set are unselectable
@@ -45,7 +50,6 @@ function et2_dataview_rowAOI(_node)
// Now append some action code to the node
var selectHandler = function(e) {
-
// Reset the focus so that keyboard navigation will work properly
// after the element has been clicked
egwUnfocus();
@@ -57,11 +61,20 @@ function et2_dataview_rowAOI(_node)
if (e.target != aoi.checkBox)
{
var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED);
- var state = EGW_AO_SHIFT_STATE_NONE; // Multiple row selction does not work right now
+ var state = egwGetShiftState(e);
- aoi.updateState(EGW_AO_STATE_SELECTED,
- !egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
- state);
+ switch (aoi.selectMode)
+ {
+ case EGW_SELECTMODE_DEFAULT:
+ aoi.updateState(EGW_AO_STATE_SELECTED,
+ !egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
+ state);
+ break;
+ case EGW_SELECTMODE_TOGGLE:
+ aoi.updateState(EGW_AO_STATE_SELECTED, !selected,
+ egwSetBit(state, EGW_AO_SHIFT_STATE_MULTI, true));
+ break;
+ }
}
};
diff --git a/etemplate/js/et2_extension_nextmatch.js b/etemplate/js/et2_extension_nextmatch.js
index d66d1ac684..b49ac2766f 100644
--- a/etemplate/js/et2_extension_nextmatch.js
+++ b/etemplate/js/et2_extension_nextmatch.js
@@ -115,12 +115,6 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
this.dynheight = new et2_dynheight(this.egw().window,
this.innerDiv, 150);
- // Load the first data into the dataProvider
-/* if (this.options.settings.rows)
- {
- this.dataProvider.loadData({"rows": this.options.settings.rows});
- }*/
-
// Create the outer grid container
this.dataview = new et2_dataview(this.innerDiv, this.egw());
@@ -246,6 +240,9 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
// Update the filters in the grid controller
this.controller.setFilters(this.activeFilters);
+
+ // Trigger an update
+ this.controller.update();
},
/**
@@ -553,6 +550,11 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
this.options.settings.actions
);
+ // Load the initial order
+ this.controller.loadInitialOrder(this._getInitialOrder(
+ this.options.settings.rows, this.options.settings.row_id
+ ));
+
this.controller.setFilters(this.activeFilters);
},
@@ -573,6 +575,33 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
}
},
+ _getInitialOrder: function (_rows, _rowId) {
+
+ var _order = [];
+
+ // Get the length of the non-numerical rows arra
+ var len = 0;
+ for (var key in _rows) {
+ if (!isNaN(key) && parseInt(key) > len)
+ len = parseInt(key);
+ }
+
+ // Iterate over the rows
+ for (var i = 0; i < len; i++)
+ {
+ // Get the uid from the data
+ var uid = this.egw().appName + '::' + _rows[i][_rowId];
+
+ // Store the data for that uid
+ this.egw().dataStoreUID(uid, _rows[i]);
+
+ // Push the uid onto the order array
+ _order.push(uid);
+ }
+
+ return _order;
+ },
+
_selectColumnsClick: function(e) {
var self = this;
var columnMgr = this.dataview.getColumnMgr();
@@ -751,21 +780,6 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
}
},
- /**
- * Activates the actions
- */
- set_settings: function(_settings) {
-/* if (_settings.actions)
- {
- // Read the actions from the settings array
- this.actionManager.updateActions(_settings.actions);
- this.actionManager.setDefaultExecute("javaScript:nm_action");
- // this is rather hackisch, but I have no idea how to get the action_link & row_id to the actionObject of the row otherwise
- this.actionManager.action_links = _settings.action_links;
- this.actionManager.row_id = _settings.row_id;
- }*/
- },
-
getDOMNode: function(_sender) {
if (_sender == this)
{
diff --git a/etemplate/js/et2_extension_nextmatch_controller.js b/etemplate/js/et2_extension_nextmatch_controller.js
index c222efa115..e1c0c56a0c 100644
--- a/etemplate/js/et2_extension_nextmatch_controller.js
+++ b/etemplate/js/et2_extension_nextmatch_controller.js
@@ -102,9 +102,6 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
// Update the filters, reset the "lastModification"
this._filters = _filters;
this._lastModification = null;
-
- // Trigger an update
- this.update();
},
diff --git a/etemplate/js/test/test_dataview.html b/etemplate/js/test/test_dataview.html
index d26750b3a8..99122119e7 100644
--- a/etemplate/js/test/test_dataview.html
+++ b/etemplate/js/test/test_dataview.html
@@ -8,6 +8,9 @@
+
+
+
+
+
@@ -130,6 +135,10 @@
$j(_tr).append(row.children());
}
+ function linkCallback() {
+ return [];
+ }
+
// The dynheight object is responsible for automatically resizing
// the gridContainer to its maximum extends
var dynheight = new et2_dynheight(window, $j("#container"), 150);
@@ -146,9 +155,14 @@
$j("#range").text("Showing elements " + (range.top + 1) + " - " + (range.bottom + 1) + " of " + dataview.grid.getTotalCount());
});
+ // Create the action manager and the object manager (optional)
+ var actionManager = egw_getActionManager("test");
+ var objectManager = egw_getObjectManager("test");
+
// Create the gridview controller
var controller = new et2_dataview_controller(dataview.grid,
- new dataprovider(), rowCallback);
+ new dataprovider(), rowCallback, linkCallback, null,
+ objectManager);
// Trigger the initial update
controller.update();