Skip to content

Commit

Permalink
Remove legacy table from DC Views
Browse files Browse the repository at this point in the history
  • Loading branch information
iszmais committed Jul 1, 2024
1 parent 8817428 commit bc096e8
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 316 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,7 @@ public function executeCommand(): void
$this->ctrl->setParameter($this, 'tableview_id', $this->tableview_id);

if (!$this->checkAccess()) {
if ($this->table->getVisibleTableViews($this->dcl_gui_object->getRefId(), true)) {
$this->offerAlternativeViews();
} else {
$this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
}

$this->main_tpl->setOnScreenMessage('failure', $this->lng->txt('permission_denied'), true);
return;
}

Expand All @@ -141,15 +136,6 @@ public function executeCommand(): void
}
}

protected function offerAlternativeViews(): void
{
global $DIC;
$tpl = $DIC['tpl'];
$this->main_tpl->setOnScreenMessage('info', $this->lng->txt('dcl_msg_info_alternatives'));
$table_gui = new ilDclTableViewTableGUI($this, 'renderRecord', $this->table, $this->dcl_gui_object->getRefId());
$tpl->setContent($table_gui->getHTML());
}

public function jumpToRecord(): void
{
$this->ctrl->setParameterByClass(self::class, 'record_id', $this->record_id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,7 @@ public function cloneStructure(ilDclTableView $orig, array $new_fields): void
*/
public static function getAllForTableId(int $table_id): array
{
return self::where(['table_id' => $table_id])->orderBy('tableview_order')->get();
return self::where(['table_id' => $table_id])->orderBy('title')->get();
}

public static function getCountForTableId(int $table_id): int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

declare(strict_types=1);

use ILIAS\UI\Component\Button\Shy;

/**
* @ilCtrl_Calls ilDclTableViewGUI: ilDclTableViewEditGUI
*/
Expand Down Expand Up @@ -133,8 +135,57 @@ public function show(): void
'show'
);

$table_gui = new ilDclTableViewTableGUI($this, 'show', $this->table, $this->getParentObj()->getRefId());
$this->tpl->setContent($table_gui->getHTML());
$this->tpl->setContent(
$this->renderer->render(
$this->ui_factory->panel()->standard(
sprintf($this->lng->txt('dcl_tableviews_of_X'), $this->table->getTitle()),
$this->getItems()
)
)
);
}

protected function getItems(): array
{
$items = [];
foreach ($this->table->getTableViews() as $tableview) {

$this->ctrl->setParameterByClass(ilDclTableViewEditGUI::class, 'tableview_id', $tableview->getId());
$item = $this->ui_factory->item()->standard(
$this->ui_factory->link()->standard(
$tableview->getTitle(),
$this->ctrl->getLinkTargetByClass(ilDclTableViewEditGUI::class, 'show')
)
)
->withDescription($tableview->getDescription())
->withActions($this->ui_factory->dropdown()->standard($this->getActions($tableview)));

$items[] = $item;
}
return $items;
}

/**
* @return Shy[]
*/
protected function getActions(ilDclTableView $tableview): array
{
$this->ctrl->setParameterByClass(ilDclTableViewEditGUI::class, 'tableview_id', $tableview->getId());

$actions = [];
$actions[] = $this->ui_factory->button()->shy(
$this->lng->txt('edit'),
$this->ctrl->getLinkTargetByClass(ilDclTableViewEditGUI::class, 'editGeneralSettings')
);
$actions[] = $this->ui_factory->button()->shy(
$this->lng->txt('copy'),
$this->ctrl->getLinkTargetByClass(ilDclTableViewEditGUI::class, 'copy')
);
$actions[] = $this->ui_factory->button()->shy(
$this->lng->txt('delete'),
$this->ctrl->getLinkTargetByClass(ilDclTableViewEditGUI::class, 'confirmDelete')
);
return $actions;
}

/**
Expand All @@ -161,7 +212,7 @@ public function confirmDeleteTableviews(): void
$conf->setHeaderText($this->lng->txt('dcl_tableviews_confirm_delete'));

foreach ($tableviews as $tableview_id) {
$conf->addItem('dcl_tableview_ids[]', (string)$tableview_id, ilDclTableView::find($tableview_id)->getTitle());
$conf->addItem('dcl_tableview_ids[]', (string) $tableview_id, ilDclTableView::find($tableview_id)->getTitle());
}
$conf->setConfirm($this->lng->txt('delete'), 'deleteTableviews');
$conf->setCancel($this->lng->txt('cancel'), 'show');
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit bc096e8

Please sign in to comment.