Skip to content
Merged
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/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
1 change: 1 addition & 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,5 @@

interface State extends Component
{
public function withTitle(string $title): self;
}
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\Component\Prompt\IsPromptContent;

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -281,20 +281,4 @@ public function withDedicatedName(string $dedicated_name): self
{
return $this;
}

/**
* @inheritdoc
*/
public function getPromptButtons(): array
{
return $this->buttons;
}

/**
* @inheritdoc
*/
public function getPromptTitle(): string
{
return $this->type;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
/**
* This implements a standard form.
*/
class Standard extends Form implements C\Input\Container\Form\Standard, IsPromptContentInternal, JavaScriptBindable
class Standard extends Form implements C\Input\Container\Form\Standard, JavaScriptBindable
{
use HasPostURL;
use JavaScriptBindableTrait;
Expand Down Expand Up @@ -71,16 +71,6 @@ public function getSubmitLabel(): ?string
return $this->submit_caption;
}

public function getPromptButtons(): array
{
return [];
}

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

public function getSubmitSignal(): Signal
{
return $this->submit_signal;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
use ILIAS\UI\Implementation\Component\ComponentHelper;
use ILIAS\UI\Implementation\Component\Prompt\IsPromptContentInternal;

class MessageBox implements C\MessageBox\MessageBox, IsPromptContentInternal
class MessageBox implements C\MessageBox\MessageBox
{
use ComponentHelper;

Expand Down Expand Up @@ -107,22 +107,4 @@ public function withLinks(array $links): C\MessageBox\MessageBox
$clone->links = $links;
return $clone;
}

/**
* @inheritdoc
*/
public function getPromptButtons(): array
{
return $this->buttons;
}

/**
* @inheritdoc
*/
public function getPromptTitle(): string
{
return $this->type;
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -261,20 +261,4 @@ public function withDedicatedName(string $dedicated_name): self
{
return $this;
}

/**
* @inheritdoc
*/
public function getPromptButtons(): array
{
return $this->buttons;
}

/**
* @inheritdoc
*/
public function getPromptTitle(): string
{
return $this->type;
}
}

This file was deleted.

Loading
Loading