mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-22 10:08:45 +02:00
WIP
This commit is contained in:
@@ -12,6 +12,7 @@ use Exception;
|
||||
use ReflectionClass;
|
||||
use ReflectionException;
|
||||
use ReflectionMethod;
|
||||
use Twig\Attribute\YieldReady;
|
||||
use Twig\Compiler;
|
||||
use Twig\Error\SyntaxError;
|
||||
use Twig\Node\Node;
|
||||
@@ -24,6 +25,7 @@ use utils;
|
||||
* @author Eric Espie <eric.espie@combodo.com>
|
||||
* @since 3.0.0
|
||||
*/
|
||||
#[YieldReady]
|
||||
class UIBlockNode extends Node
|
||||
{
|
||||
/** @var string */
|
||||
@@ -34,10 +36,10 @@ class UIBlockNode extends Node
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
public function __construct(string $sFactoryClass, string $sBlockClass, string $sType, $oParams, $oBody, int $iLineNo = 0, ?string $sTag = null)
|
||||
public function __construct(string $sFactoryClass, string $sBlockClass, string $sType, $oParams, $oBody, int $iLineNo = 0)
|
||||
{
|
||||
$aNodes = is_null($oBody) ? [] : ['body' => $oBody];
|
||||
parent::__construct($aNodes, ['type' => $sType, 'params' => $oParams], $iLineNo, $sTag);
|
||||
parent::__construct($aNodes, ['type' => $sType, 'params' => $oParams], $iLineNo);
|
||||
$this->sFactoryClass = $sFactoryClass;
|
||||
$this->sBlockClass = $sBlockClass;
|
||||
}
|
||||
|
||||
@@ -109,6 +109,11 @@ abstract class AbstractFormBlock implements IFormBlock
|
||||
return $this->oParent;
|
||||
}
|
||||
|
||||
public function HasParent(): bool
|
||||
{
|
||||
return $this->oParent !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the form block name.
|
||||
*
|
||||
@@ -128,6 +133,19 @@ abstract class AbstractFormBlock implements IFormBlock
|
||||
return $sParentName.'_'.$this->sName;
|
||||
}
|
||||
|
||||
public function GetPath(): array
|
||||
{
|
||||
$aPath = [];
|
||||
$oCurrent = $this;
|
||||
|
||||
do {
|
||||
$aPath[] = $oCurrent->GetName();
|
||||
$oCurrent = $oCurrent->getParent();
|
||||
} while ($oCurrent->HasParent());
|
||||
|
||||
return array_reverse($aPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the form block options.
|
||||
* Options will be passed to FormType for building.
|
||||
|
||||
@@ -48,11 +48,12 @@
|
||||
{%- block form_rows -%}
|
||||
|
||||
{% for block in blocks %}
|
||||
<div id="block_{{ block.identifier }}" class="ibo-field ibo-content-block ibo-block ibo-field-small">
|
||||
{{ block.name }} {{ block.added }}
|
||||
{% if block.added == 1 %}
|
||||
{{ form_row(form[block.name]) }}
|
||||
{% endif %}
|
||||
<div id="block_{{ block.id }}" class="ibo-field ibo-content-block ibo-block ibo-field-small">
|
||||
{% if block.added == 1 %}
|
||||
{{ form_row(form[block.name]) }}
|
||||
{% else %}
|
||||
<div style="background-color: #ecd9eb;border-radius: 6px;padding: 2px 5px;">Reserved place for <b>{{ block.name }}</b></div>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
@@ -65,7 +66,7 @@
|
||||
{{- block('form_widget') -}}
|
||||
{% if allow_add %}
|
||||
<div style="margin-top: 20px;">
|
||||
<button type="button" class="add_item_link ibo-button ibo-button ibo-is-regular " data-collection-holder-class="{{ name }}">{{ button_label|dict_s }}</button>
|
||||
<button type="button" class="add_item_link ibo-button ibo-button ibo-is-regular " data-collection-holder-class="{{ name }}">{{ button_label|dict_s }}</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
{%- endblock collection_widget -%}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
{# @copyright Copyright (C) 2010-2025 Combodo SARL #}
|
||||
{# @license http://opensource.org/licenses/AGPL-3.0 #}
|
||||
|
||||
{% for sId in form_diff %}
|
||||
{% if form.(sId) %}
|
||||
{% UITurboUpdate Standard { sTarget: "block_" ~ sId} %}
|
||||
{{ form_row(form.(sId)) }}
|
||||
{% EndUITurboUpdate %}
|
||||
{% for sBlockIdentifier, oBlockToRedraw in blocks_to_redraw %}
|
||||
{% UITurboUpdate Standard { sTarget: "block_" ~ sBlockIdentifier} %}
|
||||
{% if oBlockToRedraw is not null %}
|
||||
{{ form_row(oBlockToRedraw) }}
|
||||
{% endif %}
|
||||
{% EndUITurboUpdate %}
|
||||
{% endfor %}
|
||||
Reference in New Issue
Block a user