Implemented server-side callback function

This commit is contained in:
Andreas Stöckel 2011-09-09 11:29:07 +00:00
parent 2e2600fcc2
commit 58bc3367df
4 changed files with 77 additions and 28 deletions

View File

@ -0,0 +1,45 @@
<?php
/**
* EGroupware - eTemplate serverside implementation of the nextmatch widget
*
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package etemplate
* @subpackage api
* @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker@outdoor-training.de>
* @copyright 2002-11 by RalfBecker@outdoor-training.de
* @version $Id: class.etemplate_widget_button.inc.php 36221 2011-08-20 10:27:38Z ralfbecker $
*/
/**
* eTemplate image widget
* Displays image from URL, vfs, or finds by name
*/
class etemplate_widget_nextmatch extends etemplate_widget
{
public function __construct($xml='') {
if($xml) parent::__construct($xml);
}
static public function ajax_get_rows($fetchList)
{
error_log(__METHOD__."(".array2string($fetchList).")");
// Force the array to be associative
$result = array("null" => null);
foreach ($fetchList as $entry)
{
for ($i = 0; $i < $entry["count"]; $i++)
{
$result[$entry["startIdx"] + $i] = json_decode('{"info_id":"5","info_type":"email","info_from":"tracker","info_addr":"tracker","info_subject":"InfoLog grid view: problem with Opera; \'permission denied\' while saving","info_des":"<snip>","info_owner":"5","info_responsible":[],"info_access":"public","info_cat":"0","info_datemodified":1307112528,"info_startdate":1306503000,"info_enddate":"0", "info_id_parent":"0","info_planned_time":"0","info_replanned_time":"0","info_used_time":"0","info_status":"done", "info_confirm":"not","info_modifier":"5","info_link_id":0,"info_priority":"1","pl_id":"0","info_price":null, "info_percent":"100%","info_datecompleted":1307112528,"info_location":"","info_custom_from":1, "info_uid":"infolog-5-18d12c7bf195f6b9d602e1fa5cde28f1","info_cc":"","caldav_name":"5.ics","info_etag":"0", "info_created":1307112528,"info_creator":"5","links":[],"info_anz_subs":0,"sub_class":"normal_done","info_link":{"title":"tracker"},"class":"rowNoClose rowNoCloseAll ","info_type_label":"E-Mail","info_status_label":"done","info_number":"5"}');
}
}
$response = egw_json_response::get();
$response->data($result);
}
}

View File

@ -93,14 +93,14 @@ var et2_ISubmitListener = new Interface({
var et2_IDetachedDOM = new Interface({
/**
* Returns a list of attributes which can be set when working in the
* Creates a list of attributes which can be set when working in the
* "detached" mode. The result is stored in the _attrs array which is provided
* by the calling code.
*/
getDetachedAttributes: function(_attrs) {},
/**
* Returns an array of DOM nodes. The (relativly) same DOM-Nodes have to be
* Returns an array of DOM nodes. The (relatively) same DOM-Nodes have to be
* passed to the "setDetachedAttributes" function in the same order.
*/
getDetachedNodes: function() {},
@ -109,7 +109,7 @@ var et2_IDetachedDOM = new Interface({
* Sets the given associative attribute->value array and applies the
* attributes to the given DOM-Node.
*
* @param _nodes is an array of nodes which has to be in the same order as
* @param _nodes is an array of nodes which have to be in the same order as
* the nodes returned by "getDetachedNodes"
* @param _values is an associative array which contains a subset of attributes
* returned by the "getDetachedAttributes" function and sets them to the

View File

@ -131,10 +131,15 @@ var et2_dataview_dataProvider = Class.extend(et2_IDataProvider, {
key = parseInt(key);
var b = Math.max(0, key - r);
var t = Math.min(key + r, this._total - 1);
for (var i = b; i <= t; i ++)
var t = Math.min(key + this._stepSize, this._total - 1);
var c = 0;
for (var i = b; i <= t && c < this._stepSize; i ++)
{
marked[i] = true;
if (typeof this._data[i] == "undefined")
{
marked[i] = true;
c++;
}
}
}
@ -185,17 +190,20 @@ var et2_dataview_dataProvider = Class.extend(et2_IDataProvider, {
for (var key in _data)
{
// Make sure the key is a int
key = parseInt(key);
if (!isNaN(key))
{
// Make sure the key is a int
key = parseInt(key);
// Copy the data for the given index
this._data[key] = {
"data": _data[key],
"timestamp": time
};
// Copy the data for the given index
this._data[key] = {
"data": _data[key],
"timestamp": time
};
// Update the row associated to the index
this._callUpdateData(key);
// Update the row associated to the index
this._callUpdateData(key);
}
}
},

View File

@ -14,6 +14,7 @@
/*egw:uses
jquery.jquery;
/phpgwapi/egw_json.js;
et2_widget;
et2_core_interfaces;
et2_core_DOMWidget;
@ -106,20 +107,15 @@ var et2_nextmatch = et2_DOMWidget.extend(et2_IResizeable, {
* Get Rows callback
*/
getRows: function(_fetchList, _callback, _context) {
console.log("Nextmatch will fetch ", _fetchList);
// Create the entries:
var entries = {};
for (var i = 0; i < _fetchList.length; i++)
{
var start = _fetchList[i].startIdx;
for (var j = 0; j < _fetchList[i].count; j++)
{
entries[start + j] =
{"info_id":"5","info_type":"email","info_from":"tracker","info_addr":"tracker","info_subject":"InfoLog grid view: problem with Opera; 'permission denied' while saving","info_des":"<snip>","info_owner":"5","info_responsible":[],"info_access":"public","info_cat":"0","info_datemodified":1307112528,"info_startdate":1306503000,"info_enddate":"0", "info_id_parent":"0","info_planned_time":"0","info_replanned_time":"0","info_used_time":"0","info_status":"done", "info_confirm":"not","info_modifier":"5","info_link_id":0,"info_priority":"1","pl_id":"0","info_price":null, "info_percent":"100%","info_datecompleted":1307112528,"info_location":"","info_custom_from":1, "info_uid":"infolog-5-18d12c7bf195f6b9d602e1fa5cde28f1","info_cc":"","caldav_name":"5.ics","info_etag":"0", "info_created":1307112528,"info_creator":"5","links":[],"info_anz_subs":0,"sub_class":"normal_done","info_link":{"title":"tracker"},"class":"rowNoClose rowNoCloseAll ","info_type_label":"E-Mail","info_status_label":"done","info_number":"5"}
}
}
// Create an ajax-request
var request = new egw_json_request(
"etemplate_widget_nextmatch::ajax_get_rows::etemplate", [_fetchList],
this);
_callback.call(_context, entries);
// Send the request
request.sendRequest(true, function(_data) {
_callback.call(_context, _data);
}, null);
},
/**