Skip to content

Commit

Permalink
MDL-82024 format_topics: toggle un/highlight section icon correctly.
Browse files Browse the repository at this point in the history
  • Loading branch information
paulholden committed Jun 24, 2024
1 parent cd781ab commit 160617d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
2 changes: 1 addition & 1 deletion course/format/topics/amd/build/section.min.js

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

2 changes: 1 addition & 1 deletion course/format/topics/amd/build/section.min.js.map

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

2 changes: 2 additions & 0 deletions course/format/topics/amd/src/section.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class HighlightSection extends BaseComponent {
if (newIcon) {
const pixHtml = await Templates.renderPix(newIcon, 'core');
Templates.replaceNode(icon, pixHtml, '');
affectedAction.dataset.swapicon = affectedAction.dataset.icon;
affectedAction.dataset.icon = newIcon;
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,38 +117,43 @@ protected function get_highlight_control(): array {
}

$highlightoff = get_string('highlightoff');
$highlightofficon = 'i/marked';

$highlighton = get_string('highlight');
$highlightonicon = 'i/marker';

if ($course->marker == $section->section) { // Show the "light globe" on/off.
$url->param('marker', 0);
$result = [
'url' => $url,
'icon' => 'i/marked',
'icon' => $highlightofficon,
'name' => $highlightoff,
'pixattr' => ['class' => ''],
'attr' => [
'class' => 'editing_highlight',
'data-action' => 'sectionUnhighlight',
'data-sectionreturn' => $sectionreturn,
'data-id' => $section->id,
'data-icon' => $highlightofficon,
'data-swapname' => $highlighton,
'data-swapicon' => 'i/marker',
'data-swapicon' => $highlightonicon,
],
];
} else {
$url->param('marker', $section->section);
$result = [
'url' => $url,
'icon' => 'i/marker',
'icon' => $highlightonicon,
'name' => $highlighton,
'pixattr' => ['class' => ''],
'attr' => [
'class' => 'editing_highlight',
'data-action' => 'sectionHighlight',
'data-sectionreturn' => $sectionreturn,
'data-id' => $section->id,
'data-icon' => $highlightonicon,
'data-swapname' => $highlightoff,
'data-swapicon' => 'i/marked',
'data-swapicon' => $highlightofficon,
],
];
}
Expand Down

0 comments on commit 160617d

Please sign in to comment.