mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-23 00:13:35 +01:00
Get nextmatch_customfilter working
This commit is contained in:
parent
8b28ba7ab6
commit
e094b35394
@ -0,0 +1,37 @@
|
||||
<?php
|
||||
/**
|
||||
* EGroupware - eTemplate custom filter widget
|
||||
*
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package etemplate
|
||||
* @subpackage api
|
||||
* @link http://www.egroupware.org
|
||||
* @author Nathan Gray
|
||||
* @copyright 2011 Nathan Gray
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
/**
|
||||
* A filter widget that fakes another widget and turns it into a nextmatch filter widget.
|
||||
* It's best to not use this, but instead make the appropriate filter widget
|
||||
*
|
||||
*/
|
||||
class etemplate_widget_nextmatch_customfilter extends etemplate_widget_transformer
|
||||
{
|
||||
|
||||
protected $legacy_options = 'type,options';
|
||||
|
||||
/**
|
||||
* Fill type options in self::$request->sel_options to be used on the client
|
||||
*
|
||||
* @param string $cname
|
||||
*/
|
||||
public function beforeSendToClient($cname)
|
||||
{
|
||||
self::$transformation['type'] = $this->attrs['type'];
|
||||
$form_name = self::form_name($cname, $this->id, $expand);
|
||||
$this->setElementAttribute($form_name, 'options', $this->attrs['options']);
|
||||
|
||||
return parent::beforeSendToClient($cname);
|
||||
}
|
||||
}
|
@ -57,7 +57,7 @@ function et2_register_widget(_constructor, _types)
|
||||
* @param _name is the name of the widget with which it is registered. If the
|
||||
* widget is not found, an et2_placeholder will be created.
|
||||
* @param _attrs is an associative array with attributes. If not passed, it will
|
||||
* default to true.
|
||||
* default to an empty object.
|
||||
* @param _parent is the parent to which the element will be attached. If _parent
|
||||
* is not passed, it will default to null. Then you have to attach the element
|
||||
* to a parent using the addChild or insertChild method.
|
||||
@ -183,10 +183,9 @@ var et2_widget = Class.extend({
|
||||
this.id = _attrs["id"];
|
||||
|
||||
// Add this widget to the given parent widget
|
||||
this._parent = _parent;
|
||||
if (_parent != null)
|
||||
{
|
||||
this._parent.addChild(this);
|
||||
_parent.addChild(this);
|
||||
}
|
||||
|
||||
// The supported widget classes array defines a whitelist for all widget
|
||||
@ -477,6 +476,13 @@ var et2_widget = Class.extend({
|
||||
// Special handling for the legacy options
|
||||
if (attrName == "options" && _proto.legacyOptions.length > 0)
|
||||
{
|
||||
// Check for modifications on legacy options here. Normal modifications
|
||||
// are handled in widget constructor, but it's too late for legacy options then
|
||||
if(_target.id && this.getArrayMgr("modifications").getEntry(_target.id))
|
||||
{
|
||||
var mod = this.getArrayMgr("modifications").getEntry(_target.id);
|
||||
if(mod.options) attrValue = _attrsObj[i].value = mod.options;
|
||||
}
|
||||
// Check for entire legacy options passed in content
|
||||
if(attrValue.charAt(0) == '@' && attrValue.indexOf(',') == -1)
|
||||
{
|
||||
|
@ -1702,8 +1702,13 @@ var et2_nextmatch_customfilter = et2_nextmatch_filterheader.extend({
|
||||
"type": "string",
|
||||
"description": "The actual type of widget you should use"
|
||||
},
|
||||
"widget_options": {
|
||||
"name": "Actual options",
|
||||
"type": "any",
|
||||
"description": "The options for the actual widget"
|
||||
},
|
||||
},
|
||||
legacyOptions: ["widget_type"],
|
||||
legacyOptions: ["widget_type","widget_options"],
|
||||
|
||||
real_node: null,
|
||||
|
||||
@ -1720,7 +1725,7 @@ var et2_nextmatch_customfilter = et2_nextmatch_filterheader.extend({
|
||||
}
|
||||
// Avoid warning about non-existant attribute
|
||||
delete(_attrs.widget_type);
|
||||
this.real_node = et2_createWidget(_attrs.type, _attrs, this._parent);
|
||||
this.real_node = et2_createWidget(_attrs.type, _attrs.widget_options, this._parent);
|
||||
},
|
||||
|
||||
// Just pass the real DOM node through, in case anybody asks
|
||||
|
@ -416,7 +416,7 @@ var et2_date_duration = et2_date.extend({
|
||||
var value = this.duration.val();
|
||||
if(value === '')
|
||||
{
|
||||
return this.options.empty_not_0 ? null : '';
|
||||
return this.options.empty_not_0 ? null : 0;
|
||||
}
|
||||
// Put value into minutes for further processing
|
||||
switch(this.format ? this.format.val() : this.options.display_format)
|
||||
|
@ -55,10 +55,15 @@ var et2_selectbox = et2_inputWidget.extend({
|
||||
},
|
||||
"value": {
|
||||
"type": "any" // Can be string or integer
|
||||
},
|
||||
// Type specific legacy options. Avoid using.
|
||||
"other": {
|
||||
"ignore": true,
|
||||
"type": "any"
|
||||
}
|
||||
},
|
||||
|
||||
legacyOptions: ["rows"],
|
||||
legacyOptions: ["rows","other"], // Other is sub-type specific
|
||||
|
||||
init: function() {
|
||||
this._super.apply(this, arguments);
|
||||
@ -159,6 +164,10 @@ var et2_selectbox = et2_inputWidget.extend({
|
||||
{
|
||||
var row_id = this.id.replace(/[0-9]+/,row_stuck[i]);
|
||||
content_options = this.getArrayMgr("sel_options").getEntry(row_id);
|
||||
if(!content_options || content_options.length == 0)
|
||||
{
|
||||
content_options = this.getArrayMgr("sel_options").getEntry(row_stuck[i] + '[' + this.id + ']');
|
||||
}
|
||||
}
|
||||
}
|
||||
if(_attrs["select_options"] && content_options)
|
||||
|
@ -171,6 +171,7 @@ var et2_tree = et2_inputWidget.extend({
|
||||
}
|
||||
|
||||
var parent_id = parseInt(options[key]['parent']);
|
||||
if(isNaN(parent_id)) parent_id = 0;
|
||||
if(!stack[parent_id]) stack[parent_id] = [];
|
||||
stack[parent_id].push(options[key]);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user