mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-18 11:21:23 +01:00
Add the ability to specify the client-side data cache prefix, to avoid collisions in applications where there can be more than one type of data
This commit is contained in:
parent
de2c9756f1
commit
616e94a7b4
@ -55,6 +55,7 @@
|
|||||||
* array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
|
* array with name=>label or name=>array('label'=>label,'type'=>type) pairs (type is a eT widget-type)
|
||||||
* or name of import/export definition
|
* or name of import/export definition
|
||||||
* 'row_id' => // I key into row content to set it's value as tr id, eg. 'id'
|
* 'row_id' => // I key into row content to set it's value as tr id, eg. 'id'
|
||||||
|
* 'dataStorePrefix' => // I Optional prefix for client side cache to prevent collisions in applications that have more than one data set, such as ProjectManager / Project elements. Defaults to appname if not set.
|
||||||
* 'actions' => // I array with actions, see nextmatch_widget::egw_actions
|
* 'actions' => // I array with actions, see nextmatch_widget::egw_actions
|
||||||
* 'action_links' => // I array with enabled actions or ones which should be checked if they are enabled
|
* 'action_links' => // I array with enabled actions or ones which should be checked if they are enabled
|
||||||
* optional, default id of all first level actions plus the ones with enabled='javaScript:...'
|
* optional, default id of all first level actions plus the ones with enabled='javaScript:...'
|
||||||
@ -224,7 +225,7 @@ class etemplate_widget_nextmatch extends etemplate_widget
|
|||||||
|
|
||||||
foreach($rows as $n => $row)
|
foreach($rows as $n => $row)
|
||||||
{
|
{
|
||||||
if (is_int($n))
|
if (is_int($n) && $row)
|
||||||
{
|
{
|
||||||
if (!isset($row[$row_id])) unset($row_id); // unset default row_id of 'id', if not used
|
if (!isset($row[$row_id])) unset($row_id); // unset default row_id of 'id', if not used
|
||||||
if (!isset($row[$row_modified])) unset($row_modified);
|
if (!isset($row[$row_modified])) unset($row_modified);
|
||||||
|
@ -179,6 +179,16 @@ var et2_dataview_controller = Class.extend({
|
|||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the data cache prefix
|
||||||
|
* The default is to use appname, but if you need to set it explicitly to
|
||||||
|
* something else to avoid conflicts. Use the same prefix everywhere for
|
||||||
|
* each type of data. eg. infolog for infolog entries, even if accessed via addressbook
|
||||||
|
*/
|
||||||
|
setPrefix: function(prefix) {
|
||||||
|
this.dataStorePrefix = prefix;
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
/* -- PRIVATE FUNCTIONS -- */
|
/* -- PRIVATE FUNCTIONS -- */
|
||||||
|
|
||||||
@ -427,6 +437,10 @@ var et2_dataview_controller = Class.extend({
|
|||||||
"start": query.start,
|
"start": query.start,
|
||||||
"count": query.num_rows,
|
"count": query.num_rows,
|
||||||
};
|
};
|
||||||
|
if(this.dataStorePrefix)
|
||||||
|
{
|
||||||
|
ctx.prefix = this.dataStorePrefix;
|
||||||
|
}
|
||||||
|
|
||||||
// Call the callback
|
// Call the callback
|
||||||
this._dataProvider.dataFetch(query, this._fetchCallback, ctx);
|
this._dataProvider.dataFetch(query, this._fetchCallback, ctx);
|
||||||
|
@ -591,6 +591,12 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
|
|||||||
this.options.settings.actions
|
this.options.settings.actions
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Set custom data cache prefix
|
||||||
|
if(this.options.settings.dataStorePrefix)
|
||||||
|
{
|
||||||
|
this.controller.setPrefix(this.options.settings.dataStorePrefix);
|
||||||
|
}
|
||||||
|
|
||||||
// Load the initial order
|
// Load the initial order
|
||||||
/*this.controller.loadInitialOrder(this._getInitialOrder(
|
/*this.controller.loadInitialOrder(this._getInitialOrder(
|
||||||
this.options.settings.rows, this.options.settings.row_id
|
this.options.settings.rows, this.options.settings.row_id
|
||||||
|
@ -25,9 +25,10 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd) {
|
|||||||
* The uid function generates a session-unique id for the current
|
* The uid function generates a session-unique id for the current
|
||||||
* application by appending the application name to the given uid.
|
* application by appending the application name to the given uid.
|
||||||
*/
|
*/
|
||||||
function UID(_uid)
|
function UID(_uid, prefix)
|
||||||
{
|
{
|
||||||
return _app + "::" + _uid;
|
prefix = prefix ? prefix : _app;
|
||||||
|
return prefix + "::" + _uid;
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseServerResponse(_result, _callback, _context)
|
function parseServerResponse(_result, _callback, _context)
|
||||||
@ -53,13 +54,13 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd) {
|
|||||||
// Assemble the correct order uids
|
// Assemble the correct order uids
|
||||||
for (var i = 0; i < _result.order.length; i++)
|
for (var i = 0; i < _result.order.length; i++)
|
||||||
{
|
{
|
||||||
_result.order[i] = UID(_result.order[i]);
|
_result.order[i] = UID(_result.order[i], _context.prefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load all data entries that have been sent or delete them
|
// Load all data entries that have been sent or delete them
|
||||||
for (var key in _result.data)
|
for (var key in _result.data)
|
||||||
{
|
{
|
||||||
var uid = UID(key);
|
var uid = UID(key, _context.prefix);
|
||||||
if (_result.data[key] === null)
|
if (_result.data[key] === null)
|
||||||
{
|
{
|
||||||
egw.dataDeleteUID(uid);
|
egw.dataDeleteUID(uid);
|
||||||
@ -162,7 +163,7 @@ egw.extend("data", egw.MODULE_APP_LOCAL, function (_app, _wnd) {
|
|||||||
_queriedRange,
|
_queriedRange,
|
||||||
_filters,
|
_filters,
|
||||||
_widgetId,
|
_widgetId,
|
||||||
_knownUids ? _knownUids : egw.dataKnownUIDs(_app),
|
_knownUids ? _knownUids : egw.dataKnownUIDs(_context.prefix ? _context.prefix : _app),
|
||||||
lm
|
lm
|
||||||
],
|
],
|
||||||
function(result) {
|
function(result) {
|
||||||
@ -433,6 +434,20 @@ egw.extend("data_storage", egw.MODULE_GLOBAL, function (_app, _wnd) {
|
|||||||
// Unregister all callbacks for that uid
|
// Unregister all callbacks for that uid
|
||||||
this.dataUnregisterUID(_uid);
|
this.dataUnregisterUID(_uid);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Force a refreash of the given uid from the server, and
|
||||||
|
* calls all associated callbacks
|
||||||
|
*
|
||||||
|
* @param uid is the uid which should be refreshed.
|
||||||
|
*/
|
||||||
|
dataRefreshUID: function (_uid) {
|
||||||
|
if (typeof localStorage[_uid] === "undefined") return;
|
||||||
|
|
||||||
|
this.dataFetch(_execId, {'refresh':_uid}, _filters, _widgetId,
|
||||||
|
_callback, _context, _knownUids);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user