Skip to content

Commit

Permalink
UI/Viewcontrols: 43190, JS using factory (ILIAS-eLearning#8782)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaagen authored Jan 3, 2025
1 parent 1198a2f commit 7e8aa2c
Showing 1 changed file with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,16 @@ protected function renderSortation(
if ($triggeredSignals) {
$internal_signal = $component->getSelectSignal();
$signal = $triggeredSignals[0]->getSignal();

$component = $component->withAdditionalOnLoadCode(fn($id) => "$(document).on('$internal_signal', function(event, signalData) {
il.UI.viewcontrol.sortation.onInternalSelect(event, signalData, '$signal', '$id');
return false;
})");
$component = $component
->withAdditionalOnLoadCode(
fn($id) => "il.UI.viewcontrol.sortation.init('$id');"
)
->withAdditionalOnLoadCode(
fn($id) => "$(document).on('$internal_signal', function(event, signalData) {
il.UI.viewcontrol.sortation.get('$id').onInternalSelect(event, signalData, '$signal');
return false;
})"
);
}

$this->renderId($component, $tpl, "id", "ID");
Expand Down Expand Up @@ -177,7 +182,7 @@ protected function renderPagination(
): string {
$range = $this->getPaginationRange($component);

if($component->getNumberOfPages() < 2) {
if ($component->getNumberOfPages() < 2) {
return '';
}

Expand All @@ -187,12 +192,16 @@ protected function renderPagination(
if ($triggeredSignals) {
$internal_signal = $component->getInternalSignal();
$signal = $triggeredSignals[0]->getSignal();
$component = $component->withOnLoadCode(
fn($id) => "$(document).on('$internal_signal', function(event, signalData) {
il.UI.viewcontrol.pagination.onInternalSelect(event, signalData, '$signal', '$id');
return false;
})"
);
$component = $component
->withAdditionalOnLoadCode(
fn($id) => "il.UI.viewcontrol.pagination.init('$id');"
)
->withAdditionalOnLoadCode(
fn($id) => "$(document).on('$internal_signal', function(event, signalData) {
il.UI.viewcontrol.pagination.get('$id').onInternalSelect(event, signalData, '$signal');
return false;
})"
);
$id = $this->bindJavaScript($component);
$tpl->setVariable('ID', $id);
}
Expand Down

0 comments on commit 7e8aa2c

Please sign in to comment.