Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,7 @@ protected function addItemGroupBlock(string $block_id, int $block_pos = 0): void
$item_data["description"]
);
$commands_html = $item_list_gui->getCommandsHTML();
$commands_html .= $item_list_gui->getCustomModalsHTML();

// determine behaviour
$item_group = new ilObjItemGroup($item_data["ref_id"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2887,6 +2887,11 @@ public function getCommandsHTML(string $title = ''): string
return $this->ui->renderer()->render($this->getCommandsDropdown($title, false));
}

public function getCustomModalsHTML(): string
{
return $this->ui->renderer()->render($this->cust_modals);
}

private function getCommandsDropdown(string $title, bool $for_header = false): StandardDropdown
{
$this->populateCommands($for_header);
Expand Down
46 changes: 22 additions & 24 deletions components/ILIAS/ILIASObject/src/Creation/AddNewItemGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@

namespace ILIAS\ILIASObject\Creation;

use ILIAS\UI\Component\Clickable;
use ILIAS\UI\Component\Divider\Horizontal;
use ILIAS\UI\Component\Menu\Sub;
use ILIAS\UI\Component\Modal\RoundTrip;
use ILIAS\UI\Factory as UIFactory;
use ILIAS\UI\Renderer as UIRenderer;

Expand All @@ -31,63 +35,57 @@
class AddNewItemGUI
{
private \ilLanguage $lng;
private \ilObjectDefinition $obj_definition;
private \ilSetting $settings;
private \ilAccessHandler $access;
private \ilCtrl $ctrl;
private \ilToolbarGUI $toolbar;
private \ilGlobalTemplateInterface $tpl;

private UIFactory $ui_factory;
private UIRenderer $ui_renderer;

/**
* @param array<ILIAS\ILIASObject\Creation\AddNewItemElement> $elements
* @param array<AddNewItemElement> $elements
* The Key MUST contain the object type or the
*/
public function __construct(
private array $elements = []
) {
global $DIC;

$this->lng = $DIC['lng'];
$this->toolbar = $DIC['ilToolbar'];
$this->tpl = $DIC['tpl'];

$this->ui_factory = $DIC['ui.factory'];
$this->ui_renderer = $DIC['ui.renderer'];
}

/**
* Add new item selection to current page incl. toolbar (trigger) and overlay
*/
public function render(): void
public function createModal(): ?RoundTrip
{
if ($this->elements === []) {
return;
return null;
}
$modal = $this->ui_factory->modal()->roundtrip(

return $this->ui_factory->modal()->roundtrip(
$this->lng->txt('cntr_add_new_item'),
$this->ui_factory->menu()->drilldown(
$this->lng->txt('object_list'),
$this->buildAddNewItemsMenu($this->elements)
)
);
}

/**
* Add new item selection to current page incl. toolbar (trigger) and overlay
*/
public function render(): void
{
$modal = $this->createModal();

$this->toolbar->addComponent(
$this->ui_factory->button()->primary(
$this->lng->txt('cntr_add_new_item'),
$modal->getShowSignal()
)
);
$this->tpl->setVariable(
'IL_OBJECT_ADD_NEW_ITEM_MODAL',
$this->ui_renderer->render($modal)
$this->ui_factory->button()->primary($this->lng->txt('cntr_add_new_item'), $modal->getShowSignal())
);
$this->tpl->setVariable('IL_OBJECT_ADD_NEW_ITEM_MODAL', $this->ui_renderer->render($modal));
}

/**
* @return array<Component\Menu\Sub|Component\Clickable|Divider\Horizontal>
* @param array<AddNewItemElement> $elements
* @return ?array<Sub|Clickable|Horizontal>
*/
private function buildAddNewItemsMenu(array $elements): ?array
{
Expand All @@ -99,14 +97,14 @@ private function buildAddNewItemsMenu(array $elements): ?array
$element->getLabel(),
$this->buildAddNewItemsMenu($element->getSubElements())
);
continue;
}
if ($element->getType() === AddNewItemElementTypes::Object) {
$sub_menu[] = $this->ui_factory->link()->bulky(
$element->getIcon(),
$element->getLabel(),
$element->getCreationUri()
);
continue;
}
}

Expand Down
52 changes: 36 additions & 16 deletions components/ILIAS/ItemGroup/classes/class.ilObjItemGroupGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
*
*********************************************************************/

use ILIAS\ILIASObject\Creation\AddNewItemGUI;
use ILIAS\ItemGroup\StandardGUIRequest;
use ILIAS\ILIASObject\Properties\Translations\TranslationGUI;
use ILIAS\UI\Component\Modal\RoundTrip;

/**
* User Interface class for item groups
Expand Down Expand Up @@ -225,30 +227,48 @@ protected function afterUpdate(): void

public function listMaterials(): void
{
$tree = $this->tree;
$ilTabs = $this->tabs;
$tpl = $this->tpl;
$this->checkPermission('write');

$this->checkPermission("write");
$this->tabs->activateTab('materials');

$parent_ref_id = $this->tree->getParentId($this->object->getRefId());
$parent_type = ilObject::_lookupType($parent_ref_id, true);
$parent_gui_class = "ilObj{$this->obj_definition->getClassName($parent_type)}GUI";
$this->ctrl->setParameterByClass($parent_gui_class, 'ref_id', $parent_ref_id);

$ilTabs->activateTab("materials");
$elements = $this->buildAddNewItemElements(
$this->getCreatableObjectTypes(),
$parent_gui_class,
$this->object->getRefId()
);
$add_new_item_gui = new AddNewItemGUI($elements);
$add_new_item_gui->render();

$parent_ref_id = $tree->getParentId($this->object->getRefId());
$this->ctrl->clearParameterByClass($parent_gui_class, 'ref_id');

$tab = new ilItemGroupItemsTableGUI(
$this->gui,
$this,
'listMaterials'
);
$this->tpl->setContent($tab->getHTML());
}

public function buildAddNewObjectModal(): ?RoundTrip
{
$parent_ref_id = $this->tree->getParentId($this->object->getRefId());
$parent_type = ilObject::_lookupType($parent_ref_id, true);
$parent_gui_class = 'ilObj' . $this->obj_definition->getClassName($parent_type) . 'GUI';
$parent_gui_class = "ilObj{$this->obj_definition->getClassName($parent_type)}GUI";
$this->ctrl->setParameterByClass($parent_gui_class, 'ref_id', $parent_ref_id);
$gui = new ILIAS\ILIASObject\Creation\AddNewItemGUI(
$this->buildAddNewItemElements(
$this->getCreatableObjectTypes(),
$parent_gui_class,
$this->object->getRefId()
)

$elements = $this->buildAddNewItemElements(
$this->getCreatableObjectTypes(),
$parent_gui_class,
$this->object->getRefId()
);
$gui->render();
$this->ctrl->clearParameterByClass($parent_gui_class, 'ref_id');

$tab = new ilItemGroupItemsTableGUI($this->gui, $this, "listMaterials");
$tpl->setContent($tab->getHTML());
return (new AddNewItemGUI($elements))->createModal();
}

public function getCreatableObjectTypes(): array
Expand Down
21 changes: 21 additions & 0 deletions components/ILIAS/ItemGroup/classes/class.ilObjItemGroupListGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,27 @@ public function init(): void
$this->commands = ilObjItemGroupAccess::_getCommands();
}

public function initItem(int $ref_id, int $obj_id, string $type, string $title = '', string $description = ''): void
{
if (!$this->checkCommandAccess('write', '', $ref_id, $type)) {
return;
}

$itgr_gui = new ilObjItemGroupGUI($ref_id);
$modal = $itgr_gui->buildAddNewObjectModal();
if ($modal === null) {
return;
}

$button = $this->ui->factory()->button()->shy(
$this->lng->txt('create_and_assign_objects'),
'#'
)->withOnClick($modal->getShowSignal());
$this->addCustomCommandButton($button, $modal);

parent::initItem($ref_id, $obj_id, $type, $title, $description);
}

public function enableSubscribe(bool $status): void
{
$this->subscribe_enabled = false;
Expand Down
1 change: 1 addition & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -10760,6 +10760,7 @@ irss#:#title_manage_container#:#Dateien und Ordner verwalten
irss#:#type#:#Dateityp
irss#:#upload_field_title#:#Ausgewählte Dateien
irss#:#upload_modal_title#:#Dateien hinzufügen
itgr#:#create_and_assign_objects#:#Objekt erstellen und zuweisen
itgr#:#itgr_always_open#:#Immer offen
itgr#:#itgr_assign_materials#:#Objekte auswählen
itgr#:#itgr_assigned_materials#:#Objekte im Objekteblock
Expand Down
3 changes: 2 additions & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -10734,8 +10734,9 @@ irss#:#title_manage_container#:#Manage files and folders
irss#:#type#:#File Type
irss#:#upload_field_title#:#Selected Files
irss#:#upload_modal_title#:#Add Files
itgr#:#create_and_assign_objects#:#Create and Assign Object
itgr#:#itgr_always_open#:#Always Open
itgr#:#itgr_assign_materials#:#Assign Materials
itgr#:#itgr_assign_materials#:#Organize Objects
itgr#:#itgr_assigned_materials#:#Assigned Materials
itgr#:#itgr_assignment#:#Assigned
itgr#:#itgr_behaviour#:#Block Behaviour
Expand Down
Loading