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 @@ -347,7 +347,7 @@ protected function showPossibleSubObjects(): void
$gui = new ILIAS\ILIASObject\Creation\AddNewItemGUI(
$this->buildAddNewItemElements($this->getCreatableObjectTypes())
);
$gui->render();
$gui->renderToolbarAction();
}

public function getContentGUI(): ilContainerContentGUI
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Course/classes/class.ilObjCourseGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ public function renderAddNewItem(string ...$disabled_object_types): void
$gui = new ILIAS\ILIASObject\Creation\AddNewItemGUI(
$this->buildAddNewItemElements($createble_object_types)
);
$gui->render();
$gui->renderToolbarAction();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ protected function showPossibleSubObjects(): void
$subtypes
)]
);
$gui->render();
$gui->renderToolbarAction();
}

protected function getCreatableObjectTypes(): array
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Folder/classes/class.ilObjFolderGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ protected function showPossibleSubObjects(): void
$this->getCreatableObjectTypes()
)
);
$gui->render();
$gui->renderToolbarAction();
}


Expand Down
37 changes: 24 additions & 13 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,18 +35,14 @@
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(
Expand All @@ -58,21 +58,31 @@ public function __construct(
$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 renderToolbarAction(): void
{
$modal = $this->createModal();

if ($modal === null) {
return;
}

$this->toolbar->addComponent(
$this->ui_factory->button()->primary(
Expand All @@ -87,7 +97,8 @@ public function render(): void
}

/**
* @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 +110,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
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public static function _getCommands(): array
global $DIC;

$DIC->language()->loadLanguageModule("itgr");
$commands = array(
array("permission" => "read", "cmd" => "gotoParent", "lang_var" => "", "default" => true),
array("permission" => "write", "cmd" => "listMaterials", "lang_var" => "itgr_assign_materials", "default" => false),
array("permission" => "write", "cmd" => "edit", "lang_var" => "settings", "default" => false)
);

return $commands;
return [
["permission" => "read", "cmd" => "gotoParent", "lang_var" => "", "default" => true],
["permission" => "write", "cmd" => "addOrAssignObject", "lang_var" => "itgr_create_and_assign_object", "default" => false],
["permission" => "write", "cmd" => "listMaterials", "lang_var" => "itgr_assign_materials", "default" => false],
["permission" => "write", "cmd" => "edit", "lang_var" => "settings", "default" => false]
];
}

public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
Expand Down
32 changes: 19 additions & 13 deletions components/ILIAS/ItemGroup/classes/class.ilObjItemGroupGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
*
*********************************************************************/

use ILIAS\ILIASObject\Creation\AddNewItemGUI;
use ILIAS\ItemGroup\StandardGUIRequest;
use ILIAS\ILIASObject\Properties\Translations\TranslationGUI;

Expand Down Expand Up @@ -225,30 +226,35 @@ protected function afterUpdate(): void

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

$this->checkPermission("write");

$ilTabs->activateTab("materials");
$this->tabs->activateTab("materials");

$parent_ref_id = $tree->getParentId($this->object->getRefId());
$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(
$add_new_item_gui = $this->resolveAddNewItemGUI();
$add_new_item_gui->renderToolbarAction();
$this->ctrl->clearParameterByClass($parent_gui_class, 'ref_id');

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

public function resolveAddNewItemGUI(): AddNewItemGUI
{
$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";

return new AddNewItemGUI(
$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());
}

public function getCreatableObjectTypes(): array
Expand Down
49 changes: 44 additions & 5 deletions components/ILIAS/ItemGroup/classes/class.ilObjItemGroupListGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
*
*********************************************************************/

use ILIAS\ILIASObject\Creation\AddNewItemGUI;
use ILIAS\UI\Component\Modal\RoundTrip;

/**
* Item group list gui class
* @author Alexander Killing <killing@leifos.de>
Expand All @@ -24,6 +27,8 @@ class ilObjItemGroupListGUI extends ilObjectListGUI
{
protected bool $subitems_enabled;

private ?RoundTrip $add_new_object_modal;

public function __construct()
{
global $DIC;
Expand Down Expand Up @@ -52,6 +57,13 @@ public function init(): void
$this->commands = ilObjItemGroupAccess::_getCommands();
}

public function initItem(int $ref_id, int $obj_id, string $type, string $title = '', string $description = ''): void
{
parent::initItem($ref_id, $obj_id, $type, $title, $description); // TODO: Change the autogenerated stub

$this->add_new_object_modal = new ilObjItemGroupGUI($ref_id)->resolveAddNewItemGUI()->createModal();
}

public function enableSubscribe(bool $status): void
{
$this->subscribe_enabled = false;
Expand All @@ -66,14 +78,41 @@ public function enableInfoScreen(bool $info_screen): void
$this->info_screen_enabled = false;
}

public function getCommandsHTML(string $title = ''): string
{
if ($this->add_new_object_modal === null) {
return parent::getCommandsHTML($title);
}

return parent::getCommandsHTML($title) . $this->ui->renderer()->render($this->add_new_object_modal);
}

public function insertCommand(
string $href,
string $text,
string $frame = '',
string $img = '',
string $cmd = '',
string $onclick = ''
): void {
if ($cmd === 'addOrAssignObject') {
$this->current_actions[] = $this->ui->factory()->button()->shy(
$this->lng->txt('itgr_create_and_assign_object'),
'#'
)->withOnClick($this->add_new_object_modal->getShowSignal());

return;
}

parent::insertCommand($href, $text, $frame, $img, $cmd, $onclick);
}

public function getCommandLink(string $cmd): string
{
$ilCtrl = $this->ctrl;
$this->ctrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $this->ref_id);
$cmd_link = $this->ctrl->getLinkTargetByClass(ilRepositoryGUI::class, $cmd);
$this->ctrl->setParameterByClass(ilRepositoryGUI::class, "ref_id", $this->requested_ref_id);

// separate method for this line
$ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->ref_id);
$cmd_link = $ilCtrl->getLinkTargetByClass("ilrepositorygui", $cmd);
$ilCtrl->setParameterByClass("ilrepositorygui", "ref_id", $this->requested_ref_id);
return $cmd_link;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,7 @@ public function showPossibleSubObjects(): void
$this->ref_id
)
);
$gui->render();
$gui->renderToolbarAction();
$this->ctrl->clearParametersByClass(ilRepositoryGUI::class);
}

Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/OrgUnit/classes/class.ilObjOrgUnitGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ protected function showPossibleSubObjects(): void
$subtypes
)]
);
$gui->render();
$gui->renderToolbarAction();
}

public function getCreatableObjectTypes(): array
Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/Session/classes/class.ilObjSessionGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ public function materialsObject(): void
$this->object->getRefId()
)
);
$gui->render();
$gui->renderToolbarAction();
$this->ctrl->clearParameterByClass($parent_gui_class, 'ref_id');

$this->event_items = new ilEventItems($this->object->getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public function render(): void
$gui = new ILIAS\ILIASObject\Creation\AddNewItemGUI(
$this->buildAvailableObjectTypes()
);
$gui->render();
$gui->renderToolbarAction();

ilObjectListGUI::prepareJsLinks(
"",
Expand Down
2 changes: 2 additions & 0 deletions lang/ilias_de.lang
Original file line number Diff line number Diff line change
Expand Up @@ -10770,6 +10770,7 @@ itgr#:#itgr_assigned_materials#:#Objekte im Objekteblock
itgr#:#itgr_assignment#:#Eingebunden
itgr#:#itgr_behaviour#:#Verhalten
itgr#:#itgr_behaviour_info#:#Das System merkt sich den Zustand (geöffnet/geschlossen) je Benutzer bis zur Abmeldung (Logout).
itgr#:#itgr_create_and_assign_object#:#Objekt erstellen und zuweisen
itgr#:#itgr_desc_info#:#Die Beschreibung wird bei der Anzeige des Objekteblocks nicht mit ausgegeben.
itgr#:#itgr_edit#:#Einstellungen des Objekteblocks
itgr#:#itgr_expandable_closed#:#Ausklappbar (zunächst geschlossen)
Expand All @@ -10780,6 +10781,7 @@ itgr#:#itgr_list_default#:#Standard
itgr#:#itgr_list_default_info#:#Übernimmt die Einstellung des übergeordneten Containers.
itgr#:#itgr_list_presentation#:#Präsentationsansicht für Inhalte
itgr#:#itgr_materials#:#Objekte
itgr#:#itgr_organise_objects#:#Objekte verwalten
itgr#:#itgr_show_title#:#Titel anzeigen
itgr#:#itgr_show_title_info#:#Der Titel des Objekteblocks wird angezeigt.
itgr#:#itgr_tile#:#Kacheln
Expand Down
4 changes: 3 additions & 1 deletion lang/ilias_en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -10739,11 +10739,12 @@ irss#:#type#:#File Type
irss#:#upload_field_title#:#Selected Files
irss#:#upload_modal_title#:#Add Files
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
itgr#:#itgr_behaviour_info#:#The system will store the opened/closed state for the current user until logout.
itgr#:#itgr_create_and_assign_object#:#Create and Assign Object
itgr#:#itgr_desc_info#:#The description will not be a part of the item group's presentation in its container.
itgr#:#itgr_edit#:#Edit Item Groups
itgr#:#itgr_expandable_closed#:#Expandable (initially closed)
Expand All @@ -10754,6 +10755,7 @@ itgr#:#itgr_list_default#:#Default
itgr#:#itgr_list_default_info#:#Inherits value from upper container.
itgr#:#itgr_list_presentation#:#Item Presentation
itgr#:#itgr_materials#:#Materials
itgr#:#itgr_organise_objects#:#Manage Objects
itgr#:#itgr_show_title#:#Show Title
itgr#:#itgr_show_title_info#:#Shows title of item group in presentation for learner.
itgr#:#itgr_tile#:#Tiles
Expand Down
Loading