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 @@ -21,7 +21,6 @@
namespace ILIAS\MetaData\OERHarvester\ControlCenter\Content;

use ILIAS\MetaData\OERHarvester\ControlCenter\State\Status;
use ILIAS\UI\Component\Modal\RoundTrip as RoundTripModal;
use ILIAS\UI\Factory as UIFactory;
use ILIAS\MetaData\OERHarvester\ControlCenter\State\StateInfoInterface;
use ILIAS\MetaData\Presentation\UtilitiesInterface as PresentationUtilities;
Expand All @@ -31,6 +30,7 @@
use ILIAS\MetaData\OERHarvester\ControlCenter\Http\LinkFactoryInterface;
use ILIAS\MetaData\OERHarvester\ControlCenter\State\Action;
use ILIAS\MetaData\Copyright\RepositoryInterface;
use ILIAS\UI\Component\Prompt\State\State as PromptState;

class ContentFactory implements ContentFactoryInterface
{
Expand All @@ -42,20 +42,20 @@ public function __construct(
) {
}

public function getInfoContent(
public function getInfoShowState(
int $ref_id,
int $obj_id,
string $type,
StateInfoInterface $state_info
): RoundTripModal {
): PromptState {
$message = $this->getStatusMessage($state_info);
$scale = $this->getStatusOverview($state_info);
$actions = $this->getActions($ref_id, $obj_id, $type, $state_info);

return $this->ui_factory->modal()->roundtrip(
$this->presentation_utilities->txt('md_publishing_center_title'),
[$message, $scale]
)->withActionButtons($actions);
return $this->ui_factory->prompt()->state()->show(
$message->withButtons($actions),
$scale
)->withTitle($this->presentation_utilities->txt('md_publishing_center_title'));
}

protected function getStatusOverview(StateInfoInterface $state_info): ScaleBar
Expand Down Expand Up @@ -136,33 +136,33 @@ protected function getActions(
return $buttons;
}

public function getConfirmationContent(
public function getConfirmationShowState(
int $ref_id,
int $obj_id,
string $type,
Action $action,
bool $is_last_reference
): RoundTripModal {
$modal_content = [];
): PromptState {
$message = match ($action) {
Action::WITHDRAW => $this->presentation_utilities->txt('md_publishing_confirmation_info_withdraw'),
Action::ACCEPT => $this->presentation_utilities->txt('md_publishing_confirmation_info_accept'),
Action::REJECT => $this->presentation_utilities->txt('md_publishing_confirmation_info_reject'),
default => ''
};
$modal_content[] = $this->ui_factory->messageBox()->confirmation($message);
$primary_message_box = $this->ui_factory->messageBox()->confirmation($message);
$title = match ($action) {
Action::WITHDRAW => $this->presentation_utilities->txt('md_publishing_confirmation_withdraw'),
Action::ACCEPT => $this->presentation_utilities->txt('md_publishing_confirmation_accept'),
Action::REJECT => $this->presentation_utilities->txt('md_publishing_confirmation_reject'),
default => ''
};

$secondary_message_boxes = [];
if (
($action === Action::REJECT || $action === Action::WITHDRAW) &&
$is_last_reference
) {
$modal_content[] = $this->ui_factory->messageBox()->info(
$secondary_message_boxes[] = $this->ui_factory->messageBox()->info(
$this->presentation_utilities->txt('md_publishing_last_reference_info')
);
}
Expand All @@ -180,7 +180,10 @@ public function getConfirmationContent(
il.UI.prompt.get(promptId).show('$action');
});"
);
return $this->ui_factory->modal()->roundtrip($title, $modal_content)->withActionButtons([$button]);
return $this->ui_factory->prompt()->state()->show(
$primary_message_box->withButtons([$button]),
...$secondary_message_boxes
)->withTitle($title);
}

public function getSuccessMessage(Action $action): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,27 @@

namespace ILIAS\MetaData\OERHarvester\ControlCenter\Content;

use ILIAS\UI\Component\Modal\RoundTrip as RoundTripModal;
use ILIAS\MetaData\OERHarvester\ControlCenter\State\StateInfoInterface;
use ILIAS\MetaData\OERHarvester\ControlCenter\State\Action;
use ILIAS\UI\Component\Prompt\State\State as PromptState;
use ILIAS\UI\Implementation\Component\Chart\ScaleBar;

interface ContentFactoryInterface
{
public function getInfoContent(
public function getInfoShowState(
int $ref_id,
int $obj_id,
string $type,
StateInfoInterface $state_info
): RoundTripModal;
): PromptState;

public function getConfirmationContent(
public function getConfirmationShowState(
int $ref_id,
int $obj_id,
string $type,
Action $action,
bool $is_last_reference
): RoundTripModal;
): PromptState;

public function getSuccessMessage(Action $action): string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,8 @@ protected function isCommandAvailable(Command $cmd): bool

protected function view(): void
{
$content = $this->content_factory->getInfoContent($this->ref_id, $this->obj_id, $this->type, $this->state_info);
echo $this->ui_renderer->renderAsync($this->ui_factory->prompt()->state()->show($content));
$show_state = $this->content_factory->getInfoShowState($this->ref_id, $this->obj_id, $this->type, $this->state_info);
echo $this->ui_renderer->renderAsync($show_state);
exit;
}

Expand Down Expand Up @@ -144,14 +144,14 @@ protected function publish(): void

protected function withdraw(): void
{
$content = $this->content_factory->getConfirmationContent(
$show_state = $this->content_factory->getConfirmationShowState(
$this->ref_id,
$this->obj_id,
$this->type,
Action::WITHDRAW,
$this->object_handler->isOnlyReference($this->ref_id)
);
echo $this->ui_renderer->renderAsync($this->ui_factory->prompt()->state()->show($content));
echo $this->ui_renderer->renderAsync($show_state);
exit;
}

Expand All @@ -175,14 +175,14 @@ protected function submit(): void

protected function accept(): void
{
$content = $this->content_factory->getConfirmationContent(
$show_state = $this->content_factory->getConfirmationShowState(
$this->ref_id,
$this->obj_id,
$this->type,
Action::ACCEPT,
$this->object_handler->isOnlyReference($this->ref_id)
);
echo $this->ui_renderer->renderAsync($this->ui_factory->prompt()->state()->show($content));
echo $this->ui_renderer->renderAsync($show_state);
exit;
}

Expand All @@ -198,14 +198,14 @@ protected function confirmAccept(): void

protected function reject(): void
{
$content = $this->content_factory->getConfirmationContent(
$show_state = $this->content_factory->getConfirmationShowState(
$this->ref_id,
$this->obj_id,
$this->type,
Action::REJECT,
$this->object_handler->isOnlyReference($this->ref_id)
);
echo $this->ui_renderer->renderAsync($this->ui_factory->prompt()->state()->show($content));
echo $this->ui_renderer->renderAsync($show_state);
exit;
}

Expand Down
2 changes: 1 addition & 1 deletion components/ILIAS/UI/resources/js/Prompt/dist/prompt.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions components/ILIAS/UI/resources/js/Prompt/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
******************************************************************** */

import terser from '@rollup/plugin-terser';
import copyright from '../../../../../../scripts/Copyright-Checker/copyright';
import preserveCopyright from '../../../../../../scripts/Copyright-Checker/preserveCopyright';
import copyright from '../../../../../../scripts/Copyright-Checker/copyright.js';
import preserveCopyright from '../../../../../../scripts/Copyright-Checker/preserveCopyright.js';

export default {
input: './src/prompt.js',
Expand Down
4 changes: 2 additions & 2 deletions components/ILIAS/UI/resources/js/Prompt/src/prompt.class.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export default class Prompt {
* @return {void}
*/
#captureForms(doc) {
const forms = doc.getElementsByTagName('form');
const forms = doc.querySelectorAll('form');
forms.forEach(
(form) => {
form.addEventListener('submit', (e) => {
Expand All @@ -146,7 +146,7 @@ export default class Prompt {
* @return {void}
*/
#captureLinks(doc) {
const links = doc.getElementsByTagName('a');
const links = doc.querySelectorAll('a');
links.forEach(
(lnk) => {
const { target } = lnk;
Expand Down
3 changes: 2 additions & 1 deletion components/ILIAS/UI/src/Component/Chart/ScaleBar.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
namespace ILIAS\UI\Component\Chart;

use ILIAS\UI\Component\Component;
use ILIAS\UI\Component\Prompt\IsPromptContent;

/**
* Interface Scale Bars
*/
interface ScaleBar extends Component
interface ScaleBar extends Component, IsPromptContent
{
/**
* Sets a key value pair as items for the list. Key is used as title and value is a boolean marking highlighted values.
Expand Down
3 changes: 2 additions & 1 deletion components/ILIAS/UI/src/Component/Prompt/State/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ interface Factory
* @return \ILIAS\UI\Component\Prompt\State\State
*/
public function show(
\ILIAS\UI\Component\Prompt\IsPromptContent $content
\ILIAS\UI\Component\Prompt\IsPromptContent $primary_content,
\ILIAS\UI\Component\Prompt\IsPromptContent ...$secondary_content
): State;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@

use ILIAS\UI\Component as C;
use ILIAS\UI\Implementation\Component\ComponentHelper;
use ILIAS\UI\Implementation\Component\Prompt\IsPromptContentInternal;

/**
* Class ScaleBar
* @package ILIAS\UI\Implementation\Component\Listing\Descriptive
*/
class ScaleBar implements C\Chart\ScaleBar
class ScaleBar implements C\Chart\ScaleBar, IsPromptContentInternal
{
use ComponentHelper;

Expand Down Expand Up @@ -55,4 +56,14 @@ public function getItems(): array
{
return $this->items;
}

public function getPromptTitle(): string
{
return '';
}

public function getPromptButtons(): array
{
return [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@

class Factory implements I\State\Factory
{
public function show(I\IsPromptContent $content): State
{
return new State($content);
public function show(
I\IsPromptContent $primary_content,
I\IsPromptContent ...$secondary_content
): State {
return new State($primary_content)->withSecondaryContent(...$secondary_content);
}

public function close(): State
{
return (new State(null))
->withCloseModal(true);
return new State(null)->withCloseModal(true);
}

public function redirect(URI $redirect): State
{
return (new State(null))
->withRedirect($redirect);
return new State(null)->withRedirect($redirect);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,26 @@ protected function renderState(State $component, RendererInterface $default_rend
$tpl->parseCurrentBlock();
}

$content_component = $component->getContent();
if ($content_component === null) {
$secondary_content_components = $component->getSecondaryContent();
foreach ($secondary_content_components as $secondary_content_component) {
$tpl->setCurrentBlock('secondary');
$tpl->setVariable('SECONDARY_CONTENT', $default_renderer->render($secondary_content_component));
$tpl->parseCurrentBlock();
}

$primary_content_component = $component->getPrimaryContent();
if ($primary_content_component === null) {
return $tpl->get();
}

$tpl->setVariable('CONTENT', $default_renderer->render($content_component));
$tpl->setVariable('PRIMARY_CONTENT', $default_renderer->render($primary_content_component));
$tpl->setVariable('TITLE', $component->getTitle());

$buttons = $component->getButtons();
if ($content_component instanceof \ILIAS\UI\Component\Input\Container\Form\Form) {
if ($primary_content_component instanceof \ILIAS\UI\Component\Input\Container\Form\Form) {
$submit_button = $this->getUIFactory()->button()->standard(
$content_component->getSubmitLabel() ?? $this->txt("save"),
$content_component->getSubmitSignal()
$primary_content_component->getSubmitLabel() ?? $this->txt("save"),
$primary_content_component->getSubmitSignal()
);
$buttons[] = $submit_button;
}
Expand Down
Loading
Loading