mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-12-26 16:48:49 +01:00
nextmatch widget now loads the data that was passed to it in the settings array
This commit is contained in:
parent
f9e3fc5aec
commit
8dced05f23
@ -15,6 +15,7 @@
|
|||||||
et2_core_inheritance;
|
et2_core_inheritance;
|
||||||
|
|
||||||
et2_dataview_interfaces;
|
et2_dataview_interfaces;
|
||||||
|
et2_dataview_controller_selection;
|
||||||
et2_dataview_view_aoi;
|
et2_dataview_view_aoi;
|
||||||
et2_dataview_view_row;
|
et2_dataview_view_row;
|
||||||
|
|
||||||
@ -78,10 +79,17 @@ var et2_dataview_controller = Class.extend({
|
|||||||
|
|
||||||
// Register the dataFetch callback
|
// Register the dataFetch callback
|
||||||
this._grid.setDataCallback(this._gridCallback, this);
|
this._grid.setDataCallback(this._gridCallback, this);
|
||||||
|
|
||||||
|
// Create the selection manager
|
||||||
|
this._selectionMgr = new et2_dataview_selectionManager(this._indexMap);
|
||||||
},
|
},
|
||||||
|
|
||||||
destroy: function () {
|
destroy: function () {
|
||||||
|
|
||||||
|
// Destroy the selection manager
|
||||||
|
this._selectionMgr.free();
|
||||||
|
|
||||||
|
// Clear the selection timeout
|
||||||
this._clearTimer();
|
this._clearTimer();
|
||||||
|
|
||||||
this._super();
|
this._super();
|
||||||
@ -143,6 +151,16 @@ var et2_dataview_controller = Class.extend({
|
|||||||
this.update();
|
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 -- */
|
/* -- PRIVATE FUNCTIONS -- */
|
||||||
|
|
||||||
@ -446,15 +464,16 @@ var et2_dataview_controller = Class.extend({
|
|||||||
this.entry.uid
|
this.entry.uid
|
||||||
);
|
);
|
||||||
|
|
||||||
// Create the action object
|
// Create the action object interface
|
||||||
var aom = this.self._actionObjectManager;
|
var aoi = new et2_dataview_rowAOI(tr);
|
||||||
this.entry.ao = aom.addObject(
|
|
||||||
this.entry.uid,
|
|
||||||
new et2_dataview_rowAOI(tr)
|
|
||||||
);
|
|
||||||
|
|
||||||
// Update the action links
|
// Create the action object
|
||||||
this.entry.ao.updateActionLinks(links);
|
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
|
// Invalidate the current row entry
|
||||||
|
@ -22,6 +22,9 @@
|
|||||||
* row.
|
* row.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var EGW_SELECTMODE_DEFAULT = 0;
|
||||||
|
var EGW_SELECTMODE_TOGGLE = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An action object interface for each nextmatch widget row - "inherits" from
|
* An action object interface for each nextmatch widget row - "inherits" from
|
||||||
* egwActionObjectInterface
|
* egwActionObjectInterface
|
||||||
@ -32,6 +35,8 @@ function et2_dataview_rowAOI(_node)
|
|||||||
|
|
||||||
aoi.node = _node;
|
aoi.node = _node;
|
||||||
|
|
||||||
|
aoi.selectMode = EGW_SELECTMODE_DEFAULT;
|
||||||
|
|
||||||
aoi.checkBox = null; //($j(":checkbox", aoi.node))[0];
|
aoi.checkBox = null; //($j(":checkbox", aoi.node))[0];
|
||||||
|
|
||||||
// Rows without a checkbox OR an id set are unselectable
|
// 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
|
// Now append some action code to the node
|
||||||
var selectHandler = function(e) {
|
var selectHandler = function(e) {
|
||||||
|
|
||||||
// Reset the focus so that keyboard navigation will work properly
|
// Reset the focus so that keyboard navigation will work properly
|
||||||
// after the element has been clicked
|
// after the element has been clicked
|
||||||
egwUnfocus();
|
egwUnfocus();
|
||||||
@ -57,11 +61,20 @@ function et2_dataview_rowAOI(_node)
|
|||||||
if (e.target != aoi.checkBox)
|
if (e.target != aoi.checkBox)
|
||||||
{
|
{
|
||||||
var selected = egwBitIsSet(aoi.getState(), EGW_AO_STATE_SELECTED);
|
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,
|
switch (aoi.selectMode)
|
||||||
!egwBitIsSet(state, EGW_AO_SHIFT_STATE_MULTI) || !selected,
|
{
|
||||||
state);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -115,12 +115,6 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
|
|||||||
this.dynheight = new et2_dynheight(this.egw().window,
|
this.dynheight = new et2_dynheight(this.egw().window,
|
||||||
this.innerDiv, 150);
|
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
|
// Create the outer grid container
|
||||||
this.dataview = new et2_dataview(this.innerDiv, this.egw());
|
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
|
// Update the filters in the grid controller
|
||||||
this.controller.setFilters(this.activeFilters);
|
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
|
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);
|
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) {
|
_selectColumnsClick: function(e) {
|
||||||
var self = this;
|
var self = this;
|
||||||
var columnMgr = this.dataview.getColumnMgr();
|
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) {
|
getDOMNode: function(_sender) {
|
||||||
if (_sender == this)
|
if (_sender == this)
|
||||||
{
|
{
|
||||||
|
@ -102,9 +102,6 @@ var et2_nextmatch_controller = et2_dataview_controller.extend(
|
|||||||
// Update the filters, reset the "lastModification"
|
// Update the filters, reset the "lastModification"
|
||||||
this._filters = _filters;
|
this._filters = _filters;
|
||||||
this._lastModification = null;
|
this._lastModification = null;
|
||||||
|
|
||||||
// Trigger an update
|
|
||||||
this.update();
|
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
@ -8,6 +8,9 @@
|
|||||||
<script src="../../../phpgwapi/js/jquery/jquery.tools.min.js"></script>
|
<script src="../../../phpgwapi/js/jquery/jquery.tools.min.js"></script>
|
||||||
<script src="../../../phpgwapi/js/jquery/jquery-ui.js"></script>
|
<script src="../../../phpgwapi/js/jquery/jquery-ui.js"></script>
|
||||||
|
|
||||||
|
<script src="../../../phpgwapi/js/egw_action/egw_action.js"></script>
|
||||||
|
<script src="../../../phpgwapi/js/egw_action/egw_action_common.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Create the egw object template
|
// Create the egw object template
|
||||||
window["egw"] = {
|
window["egw"] = {
|
||||||
@ -27,7 +30,9 @@
|
|||||||
|
|
||||||
<script src="../et2_dataview_interfaces.js"></script>
|
<script src="../et2_dataview_interfaces.js"></script>
|
||||||
<script src="../et2_dataview_controller.js"></script>
|
<script src="../et2_dataview_controller.js"></script>
|
||||||
|
<script src="../et2_dataview_controller_selection.js"></script>
|
||||||
<script src="../et2_dataview_model_columns.js"></script>
|
<script src="../et2_dataview_model_columns.js"></script>
|
||||||
|
<script src="../et2_dataview_view_aoi.js"></script>
|
||||||
<script src="../et2_dataview_view_rowProvider.js"></script>
|
<script src="../et2_dataview_view_rowProvider.js"></script>
|
||||||
<script src="../et2_dataview_view_container.js"></script>
|
<script src="../et2_dataview_view_container.js"></script>
|
||||||
<script src="../et2_dataview_view_grid.js"></script>
|
<script src="../et2_dataview_view_grid.js"></script>
|
||||||
@ -130,6 +135,10 @@
|
|||||||
$j(_tr).append(row.children());
|
$j(_tr).append(row.children());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function linkCallback() {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
// The dynheight object is responsible for automatically resizing
|
// The dynheight object is responsible for automatically resizing
|
||||||
// the gridContainer to its maximum extends
|
// the gridContainer to its maximum extends
|
||||||
var dynheight = new et2_dynheight(window, $j("#container"), 150);
|
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());
|
$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
|
// Create the gridview controller
|
||||||
var controller = new et2_dataview_controller(dataview.grid,
|
var controller = new et2_dataview_controller(dataview.grid,
|
||||||
new dataprovider(), rowCallback);
|
new dataprovider(), rowCallback, linkCallback, null,
|
||||||
|
objectManager);
|
||||||
|
|
||||||
// Trigger the initial update
|
// Trigger the initial update
|
||||||
controller.update();
|
controller.update();
|
||||||
|
Loading…
Reference in New Issue
Block a user