19declare(strict_types=1);
37 $registry->
register(
'./assets/js/progress.min.js');
38 parent::registerResources($registry);
41 public function render(
Component $component, RendererInterface $default_renderer): string
46 if ($component instanceof
Bar) {
55 $template = $this->
getTemplate(
'tpl.progress_bar.html',
true,
true);
57 $template->setVariable(
'LABEL', $component->getLabel());
59 $template->setVariable(
'SUCCESS_GLYPH', $default_renderer->render(
60 $this->getUIFactory()->symbol()->glyph()->apply(),
63 $template->setVariable(
'FAILURE_GLYPH', $default_renderer->render(
64 $this->getUIFactory()->symbol()->glyph()->close(),
67 $async_url = $component->getAsyncUrl();
68 if (
null !== $async_url) {
69 $template->setVariable(
'ASYNC_URL', (
string) $async_url);
72 if (
null !== $component->getAsyncUrl()) {
74 static fn(
string $id):
string =>
"
75 const progressbar = il.UI.Progress.Bar.createAsync(
76 document.getElementById('$id'),
77 '{$component->getUpdateSignal()->getId()}',
78 {$component->getAsyncRefreshInterval()->getRefreshIntervalInMs()},
81 $(document).on('{$component->getResetSignal()}', () => progressBar.reset());
86 static fn(
string $id):
string =>
"
87 const progressBar = il.UI.Progress.Bar.create(
88 document.getElementById('$id'),
89 '{$component->getUpdateSignal()->getId()}',
92 $(document).on('{$component->getResetSignal()}', () => progressBar.reset());
101 $template->setVariable(
'ID',
$id);
103 return $template->get();
108 $template->
setVariable(
'MAX_VALUE', (
string) $max);
113 if (
null !== $value) {
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
renderProgressBar(Bar $component, RendererInterface $default_renderer)
maybeApplyProgressBarValue(Template $template, ?int $value=null)
applyProgressBarMaxValue(Template $template, int $max=Bar::MAX_VALUE)
render(Component $component, RendererInterface $default_renderer)
registerResources(ResourceRegistry $registry)
Announce resources this renderer requires.
Base class for all component renderers.
cannotHandleComponent(Component $component)
This method MUST be called by derived component renderers, if.
createId()
Get a fresh unique id.
bindJavaScript(JavaScriptBindable $component)
Bind the component to JavaScript.
addTriggererOnLoadCode(Triggerer $triggerer)
Add onload-code for triggerer.
getTemplate(string $name, bool $purge_unfilled_vars, bool $purge_unused_blocks)
Get template of component this renderer is made for.
A component is the most general form of an entity in the UI.
withAdditionalOnLoadCode(Closure $binder)
Add some onload-code to the component instead of replacing the existing one.
Registry for resources required by rendered output like Javascript or CSS.
register(string $name)
Add a dependency.
Interface to templating as it is used in the UI framework.
setVariable(string $name, $value)
Set a variable in the current block.
An entity that renders components to a string output.
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.