Fix CustomFilterHeader did not work properly

Some transformations were not correctly handled, and events were therefor not bound
This commit is contained in:
nathan 2022-08-16 09:29:08 -06:00
parent 8c7cfc3e69
commit 0ae69429b5
2 changed files with 24 additions and 9 deletions

View File

@ -43,13 +43,15 @@ export class Et2CustomFilterHeader extends FilterMixin(Et2InputWidget(LitElement
{
super.transformAttributes(attrs);
switch(attrs.widgetType)
let widgetType = this.getArrayMgr("modifications").getEntry(this.id)?.widgetType || attrs.widgetType || "";
switch(widgetType)
{
case "link-entry":
this.widgetType = 'et2-nextmatch-header-entry';
break;
default:
this.widgetType = attrs.widgetType;
this.widgetType = widgetType;
// Prefer webcomponent, if legacy type was sent
if(window.customElements.get("et2-" + this.widgetType))
{
@ -89,9 +91,12 @@ export class Et2CustomFilterHeader extends FilterMixin(Et2InputWidget(LitElement
}
set value(new_value)
{
if(this.filter_node)
{
this.filter_node.value = new_value;
}
}
}
customElements.define("et2-nextmatch-header-custom", Et2CustomFilterHeader);

View File

@ -31,6 +31,7 @@ class Customfilter extends Widget\Transformer
*/
public function beforeSendToClient($cname, array $expand=null)
{
parent::beforeSendToClient($cname, $expand);
switch($this->attrs['type'])
{
case "link-entry":
@ -44,9 +45,17 @@ class Customfilter extends Widget\Transformer
{
$widget_type = $this->attrs['type'];
}
$this->attrs['type'] = 'et2-nextmatch-header-custom';
}
self::$transformation['type'] = $this->attrs['type'];
else
{
// Run the new widget type's beforeSendToClient
$expanded_child = self::factory($this->attrs['type'], false, $this->id);
$expanded_child->id = $this->id;
$expanded_child->type = $this->attrs['type'];
$expanded_child->run('beforeSendToClient', array($cname, $expand));
$widget_type = $expanded_child->attrs['type'];
}
$this->attrs['type'] = 'et2-nextmatch-header-custom';
}
$form_name = self::form_name($cname, $this->id, $expand);
@ -55,9 +64,8 @@ class Customfilter extends Widget\Transformer
self::setElementAttribute($form_name, 'type', $this->attrs['type']);
if($widget_type)
{
self::setElementAttribute($form_name, 'widget_type', $widget_type);
self::setElementAttribute($form_name, 'widgetType', $widget_type);
}
parent::beforeSendToClient($cname, $expand);
}
@ -80,4 +88,6 @@ class Customfilter extends Widget\Transformer
$valid = $value ? $value : null;
}
}
Widget::registerWidget(__NAMESPACE__.'\\Customfilter', array('nextmatch-customfilter'));
Widget::registerWidget(__NAMESPACE__ . '\\Customfilter', array('nextmatch-customfilter',
'et2-nextmatch-header-custom'));