Skip to content

Commit

Permalink
review dashboard #7
Browse files Browse the repository at this point in the history
add remove to #7

add use to #7
  • Loading branch information
fhelfer committed May 24, 2023
1 parent 0e3e818 commit 2bb94ca
Show file tree
Hide file tree
Showing 13 changed files with 105 additions and 113 deletions.
6 changes: 3 additions & 3 deletions Services/Block/classes/class.ilBlockGUI.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ public function getTitle(): string

public function setOffset(int $a_offset): void
{
if ($this->correctOffset($a_offset)) {
if ($this->checkOffset($a_offset)) {
$this->offset = $a_offset;
} else {
throw new ilException("ilBlockGUI::setOffset(): Offset out of range.");
Expand All @@ -185,9 +185,9 @@ public function getOffset(): int
return $this->offset;
}

public function correctOffset(int $offset): bool
public function checkOffset(int $offset): bool
{
return $offset <= $this->max_count;
return $offset <= $this->max_count && $offset >= 0;
}

public function setLimit(int $a_limit): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,8 @@ public function editSorting(): void
{
$this->tabs_gui->activateTab("settings");
$this->setSettingsSubTabs("sorting");
$ui = $this->ui;
$form = $this->getViewForm(self::VIEW_MODE_SORTING);
$this->tpl->setContent($ui->renderer()->renderAsync($form));
$this->tpl->setContent($this->ui->renderer()->renderAsync($form));
}

public function getViewForm(string $mode): StandardForm
Expand All @@ -144,11 +143,7 @@ public function getViewForm(string $mode): StandardForm
return $this->ui_factory->input()->container()->form()->standard(
$this->ctrl->getFormAction($this, 'save' . $mode),
array_map(
fn (int $view): Section =>
$this->getViewByMode(
$mode,
$view
),
fn (int $view): Section => $this->getViewByMode($mode, $view),
$this->viewSettings->getPresentationViews()
)
);
Expand Down Expand Up @@ -204,51 +199,49 @@ static function (array $options, string $option) use ($lng): array {

public function getSettingsForm(): StandardForm
{
$ui = $this->ui;
$f = $ui->factory();
$ctrl = $this->ctrl;
$field = $this->ui->factory()->input()->field();
$lng = $this->lng;

$side_panel = $this->side_panel_settings;

$fields["enable_favourites"] = $f->input()->field()->checkbox($lng->txt("dash_enable_favourites"))
$fields["enable_favourites"] = $field->checkbox($lng->txt("dash_enable_favourites"))
->withValue($this->viewSettings->enabledSelectedItems());
$info_text = ($this->viewSettings->enabledMemberships())
? ""
: $lng->txt("dash_member_main_alt") . " " . $ui->renderer()->render(
$ui->factory()->link()->standard(
: $lng->txt("dash_member_main_alt") . " " . $this->ui->renderer()->render(
$this->ui->factory()->link()->standard(
$lng->txt("dash_click_here"),
$ctrl->getLinkTargetByClass(["ilAdministrationGUI", "ilObjMainMenuGUI", "ilmmsubitemgui"])
$this->ctrl->getLinkTargetByClass(["ilAdministrationGUI", "ilObjMainMenuGUI", "ilmmsubitemgui"])
)
);

$fields["enable_recommended_content"] = $f->input()->field()->checkbox($lng->txt("dash_enable_recommended_content"))
$fields["enable_recommended_content"] = $field->checkbox($lng->txt("dash_enable_recommended_content"))
->withValue(true)
->withDisabled(true);
$fields["enable_memberships"] = $f->input()->field()->checkbox($lng->txt("dash_enable_memberships"), $info_text)
$fields["enable_memberships"] = $field->checkbox($lng->txt("dash_enable_memberships"), $info_text)
->withValue($this->viewSettings->enabledMemberships());


$fields["enable_learning_sequences"] = $f->input()->field()->checkbox($lng->txt("dash_enable_learning_sequences"))
$fields["enable_learning_sequences"] = $field->checkbox($lng->txt("dash_enable_learning_sequences"))
->withValue($this->viewSettings->enabledLearningSequences());

$fields["enable_study_programmes"] = $f->input()->field()->checkbox($lng->txt("dash_enable_study_programmes"))
$fields["enable_study_programmes"] = $field->checkbox($lng->txt("dash_enable_study_programmes"))
->withValue($this->viewSettings->enabledStudyProgrammes());

// main panel
$section1 = $f->input()->field()->section($this->maybeDisable($fields), $lng->txt("dash_main_panel"));
$section1 = $field->section($this->maybeDisable($fields), $lng->txt("dash_main_panel"));

$sp_fields = [];
foreach ($side_panel->getValidModules() as $mod) {
$sp_fields["enable_" . $mod] = $f->input()->field()->checkbox($lng->txt("dash_enable_" . $mod))
$sp_fields["enable_" . $mod] = $field->checkbox($lng->txt("dash_enable_" . $mod))
->withValue($side_panel->isEnabled($mod));
}

// side panel
$section2 = $f->input()->field()->section($this->maybeDisable($sp_fields), $lng->txt("dash_side_panel"));
$section2 = $field->section($this->maybeDisable($sp_fields), $lng->txt("dash_side_panel"));

$form_action = $ctrl->getLinkTarget($this, "saveSettings");
return $f->input()->container()->form()->standard(
$form_action = $this->ctrl->getLinkTarget($this, "saveSettings");
return $this->ui->factory()->input()->container()->form()->standard(
$form_action,
["main_panel" => $section1, "side_panel" => $section2]
);
Expand Down Expand Up @@ -387,7 +380,7 @@ protected function savePresentation(): void
$this->viewSettings->storeViewPresentation(
$view,
$view_data['default_pres'],
$view_data['avail_pres'] ?: []
$view_data['avail_pres'] ?? []
);
}
$this->tpl->setOnScreenMessage('success', $lng->txt("msg_obj_modified"), true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @param {int} view
* @type {(view: int) => void}
*/
const handleUserInputForSortationsByView = (function() {
/**
Expand Down Expand Up @@ -28,7 +28,7 @@ const handleUserInputForSortationsByView = (function() {
function switchBackToDefaultIfEnabled(selectionInput, checkboxInput) {
selectionInput.querySelectorAll('option').forEach(function (element) {
const checkboxOption = checkboxInput.querySelector('input[value="' + element.value + '"]');
if (element.hasAttribute('default') && checkboxOption && checkboxOption.checked === true) {
if (element.hasAttribute('default') && checkboxOption && checkboxOption.checked) {
selectionInput.querySelectorAll('option').forEach(function (option) {
option.removeAttribute('selected');
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,21 @@

declare(strict_types=1);

class ilBlockDTO
{
private string $type;
private int $ref_id;
private int $obj_id;
private string $title;
private string $description;
private ?ilDateTime $startDate;
private ?ilDateTime $endDate;
private array $additional_data;
namespace ILIAS\Services\Dashboard\Block;

use ilDateTime;

class BlockDTO
{
public function __construct(
string $type,
int $ref_id,
int $obj_id,
string $title,
string $description,
?ilDateTime $startDate = null,
?ilDateTime $endDate = null,
array $additional_data = []
private string $type,
private int $ref_id,
private int $obj_id,
private string $title,
private string $description,
private ?ilDateTime $startDate = null,
private ?ilDateTime $endDate = null,
private array $additional_data = []
) {
$this->type = $type;
$this->ref_id = $ref_id;
Expand Down
Loading

0 comments on commit 2bb94ca

Please sign in to comment.