Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 13 additions & 2 deletions components/ILIAS/UI/UI.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,13 @@ public function init(
$internal[UI\Implementation\Component\Entity\Factory::class] = static fn() =>
new UI\Implementation\Component\Entity\Factory();

$internal[UI\Implementation\Component\Prompt\State\Factory::class] = static fn() =>
new UI\Implementation\Component\Prompt\State\Factory();
$internal[UI\Implementation\Component\Prompt\Factory::class] = static fn() =>
new UI\Implementation\Component\Prompt\Factory(
$internal[UI\Implementation\Component\SignalGeneratorInterface::class],
$internal[UI\Implementation\Component\Prompt\State\Factory::class],
);
$internal[UI\Implementation\Component\Prompt\State\Factory::class] = static fn() =>
new UI\Implementation\Component\Prompt\State\Factory();

$internal[UI\Implementation\Component\Navigation\Factory::class] = static fn() =>
new UI\Implementation\Component\Navigation\Factory(
Expand Down Expand Up @@ -551,6 +552,16 @@ public function init(
$use[UI\HelpTextRetriever::class],
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\Entity\EntityRendererFactory(
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
$use[Language\Language::class],
$internal[UI\Implementation\Render\JavaScriptBinding::class],
$use[UI\Implementation\Render\ImagePathResolver::class],
$pull[Data\Factory::class],
$use[UI\HelpTextRetriever::class],
$internal[UI\Implementation\Component\Input\UploadLimitResolver::class],
),
new UI\Implementation\Component\Listing\ListingRendererFactory(
$use[UI\Implementation\FactoryInternal::class],
$internal[UI\Implementation\Render\TemplateFactory::class],
Expand Down
5 changes: 5 additions & 0 deletions components/ILIAS/UI/src/Component/Entity/Entity.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@
*/
interface Entity extends Component
{
/**
* Returns the technical identifier of this entity.
*/
public function getId(): string|int;

//Priority Areas

/**
Expand Down
61 changes: 61 additions & 0 deletions components/ILIAS/UI/src/Component/Entity/EntityRetrieval.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

/**
* This file is part of ILIAS, a powerful learning management system
* published by ILIAS open source e-Learning e.V.
*
* ILIAS is licensed with the GPL-3.0,
* see https://www.gnu.org/licenses/gpl-3.0.en.html
* You should have received a copy of said license along with the
* source code, too.
*
* If this is not the case or you just want to try ILIAS, you'll find
* us at:
* https://www.ilias.de
* https://github.com/ILIAS-eLearning
*
*********************************************************************/

declare(strict_types=1);

namespace ILIAS\UI\Component\Entity;

use Generator;
use ILIAS\Data\Order;
use ILIAS\Data\Range;

/**
* This describes how entities should be retrieved for different purposes.
*/
interface EntityRetrieval
{
/**
* This method is used by the Entity Listing to visualise all available entities.
*
* The signature mirrors {@see \ILIAS\UI\Component\Table\DataRetrieval::getRows()},
* so the UI framework can create expectations (order/range/grouping/etc.) globally
* and it allows future extension of additional (view/filter) controls.
*
* @return Generator<Entity>
*/
public function getEntities(
\ILIAS\UI\Factory $ui_factory,
Range $range,
Order $order,
mixed $additional_viewcontrol_data,
mixed $filter_data,
mixed $additional_parameters,
): Generator;

/**
* This method is used by the Prompt State to confirm a subset of entities.
*
* @param array<int|string> $entity_ids
* @return Generator<Entity>
*/
public function getEntitiesByIds(
\ILIAS\UI\Factory $ui_factory,
Order $order,
array $entity_ids,
): Generator;
}
8 changes: 6 additions & 2 deletions components/ILIAS/UI/src/Component/Entity/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,14 @@ interface Factory
* The Standard Entity can (and should) be used to list system entities
* such as repository objects, users and similar.
* ---
* @param string|int $technical_identifier
* @param Symbol|Image|ShyButton|ShyLink|string $primary_visual_identifier
* @param Symbol|Image|ShyButton|ShyLink|string $secondary_visual_identifier
* @return \ILIAS\UI\Component\Entity\Standard
*/
public function standard(
Symbol | Image | ShyButton | ShyLink | string $primary_identifier,
Symbol | Image | ShyButton | ShyLink | string $secondary_identifier
string|int $technical_identifier,
Symbol|Image|ShyButton|ShyLink|string $primary_visual_identifier,
Symbol|Image|ShyButton|ShyLink|string $secondary_visual_identifier,
): Standard;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@

declare(strict_types=1);

namespace ILIAS\UI\Component\Listing\Entity;
namespace ILIAS\UI\Component\Input\Field;

use ILIAS\UI\Component\Entity\Entity;
use ILIAS\UI\Component\Entity\EntityRetrieval;
use ILIAS\UI\Component\Input\Container\Form\FormInput;

/**
* Hand a record over to RecordToEntity and factor an Entity
* Carries entity identifiers through a form roundtrip and visualises them.
*/
interface Mapping
interface Entity extends FormInput
{
public function map(mixed $record): Entity;
public function getEntityRetrieval(): EntityRetrieval;
}
43 changes: 43 additions & 0 deletions components/ILIAS/UI/src/Component/Input/Field/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

use ILIAS\UI\Component\Input\Container\Form\FormInput;
use ILIAS\UI\Component\Input\Field\Node\NodeRetrieval;
use ILIAS\UI\Component\Entity\EntityRetrieval;
use ILIAS\Data\ImagePurpose;

/**
Expand Down Expand Up @@ -809,6 +810,48 @@ public function link(string $label, ?string $byline = null): Link;
*/
public function hidden(): Hidden;

/**
* ---
* description:
* purpose: >
* The Entity Input carries technical identifiers of entities through a
* form roundtrip and visualises those entities. Users must not operate
* this input. Typical context is a confirmation prompt: a Standard Form
* in a Prompt State contains this input (withValue of the affected ids)
* so the posted payload and the shown entities cannot diverge. Additional
* operable fields (e.g. type the object title) can sit in the same form.
* A confirmation Message Box as sibling Prompt content depends on
* secondary Prompt content (follow-up to GitHub issue 11105:
* show($primary, ...$secondary)).
* composition: >
* An unordered list of Entity components, each paired with a Hidden Input
* generated via withValue() (HasDynamicInputs). There is no user control.
* effect: >
* Submitting the enclosing form posts the entity ids in the request body.
* Consumers read them from the form getData() for this field.
* rivals:
* Hidden: Hidden transmits a value without visualisation. Entity Input also shows the entities.
* Entity Listing: Entity Listing is a listing, not a form field, and has its own retrieval lifecycle.
*
* context:
* - The Entity Input is used in UI-forms, especially confirmation prompts.
*
* rules:
* usage:
* 1: >
* The Entity Input MUST NOT be operated by the user.
* 2: >
* Consumers MUST set the identifiers with withValue() before rendering
* and MUST read them from the enclosing form getData() after withRequest().
* 3: >
* Entity ids MUST be posted in the request body, never attached to the
* form action URL.
*
* ---
* @return \ILIAS\UI\Component\Input\Field\Entity
*/
public function entity(EntityRetrieval $entity_retrieval): Entity;

/**
* ---
* description:
Expand Down
40 changes: 0 additions & 40 deletions components/ILIAS/UI/src/Component/Listing/Entity/DataRetrieval.php

This file was deleted.

8 changes: 1 addition & 7 deletions components/ILIAS/UI/src/Component/Listing/Entity/EntityListing.php
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,8 @@
use ILIAS\UI\Component\Component;

/**
* This is what an EntityListings looks like
* This is what an Entity Listing looks like.
*/
interface EntityListing extends Component
{
/**
* An Entity Listing is constructed with an instance of RecordToEntity,
* which is the mapping of a single record to an Entity.
* Data retrieval will accumulate/consolidate the records.
*/
public function withData(DataRetrieval $data): self;
}
10 changes: 6 additions & 4 deletions components/ILIAS/UI/src/Component/Listing/Entity/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

namespace ILIAS\UI\Component\Listing\Entity;

use ILIAS\UI\Component\Entity\EntityRetrieval;

/**
* This is what a factory for EntityListings looks like
*/
Expand All @@ -36,10 +38,10 @@ interface Factory
* the space optimally. The design of the entity is one that favors a more horizontal representation.
*
* ---
* @param \ILIAS\UI\Component\Listing\Entity\RecordToEntity $entity_mapping
* @param \ILIAS\UI\Component\Entity\EntityRetrieval $entity_retrieval
* @return \ILIAS\UI\Component\Listing\Entity\Standard
*/
public function standard(RecordToEntity $entity_mapping): Standard;
public function standard(EntityRetrieval $entity_retrieval): Standard;

/**
* ---
Expand All @@ -57,8 +59,8 @@ public function standard(RecordToEntity $entity_mapping): Standard;
* with the same height.
*
* ---
* @param \ILIAS\UI\Component\Listing\Entity\RecordToEntity $entity_mapping
* @param \ILIAS\UI\Component\Entity\EntityRetrieval $entity_retrieval
* @return \ILIAS\UI\Component\Listing\Entity\Grid
*/
public function grid(RecordToEntity $entity_mapping): Grid;
public function grid(EntityRetrieval $entity_retrieval): Grid;
}

This file was deleted.

1 change: 0 additions & 1 deletion components/ILIAS/UI/src/Component/Prompt/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

namespace ILIAS\UI\Component\Prompt;

use ILIAS\UI\Component;
use ILIAS\Data\URI;

interface Factory
Expand Down
1 change: 0 additions & 1 deletion components/ILIAS/UI/src/Component/Prompt/State/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

namespace ILIAS\UI\Component\Prompt\State;

use ILIAS\UI\Component;
use ILIAS\Data\URI;

interface Factory
Expand Down
4 changes: 4 additions & 0 deletions components/ILIAS/UI/src/Component/Prompt/State/State.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@

interface State extends Component
{
/**
* Get a Prompts State like this, but provide it with an explicit title.
*/
public function withTitle(string $title): self;
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,17 @@ abstract class Entity implements I\Entity
protected ?Workflow\Linear $workflow = null;

public function __construct(
protected string|int $id,
protected Symbol | Image | Shy | StandardLink | string $primary_identifier,
protected Symbol | Image | Shy | StandardLink | string $secondary_identifier
) {
}

public function getId(): string|int
{
return $this->id;
}

public function withPrimaryIdentifier(Symbol | Image | Shy | StandardLink | string $primary_identifier): self
{
$clone = clone $this;
Expand Down
Loading
Loading