From bc096e894ecb4e5e58482593c3801aed998d2c2b Mon Sep 17 00:00:00 2001 From: iszmais Date: Mon, 1 Jul 2024 14:28:52 +0200 Subject: [PATCH] Remove legacy table from DC Views --- .../class.ilDclDetailedViewGUI.php | 16 +- .../TableView/class.ilDclTableView.php | 2 +- .../TableView/class.ilDclTableViewGUI.php | 57 +++- .../class.ilDclTableViewTableGUI.php | 266 ------------------ .../default/tpl.detailview_list_row.html | 10 - .../default/tpl.tableview_list_row.html | 21 -- lang/ilias_de.lang | 1 + lang/ilias_en.lang | 1 + 8 files changed, 58 insertions(+), 316 deletions(-) delete mode 100755 components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewTableGUI.php delete mode 100755 components/ILIAS/DataCollection/templates/default/tpl.detailview_list_row.html delete mode 100755 components/ILIAS/DataCollection/templates/default/tpl.tableview_list_row.html diff --git a/components/ILIAS/DataCollection/classes/DetailedView/class.ilDclDetailedViewGUI.php b/components/ILIAS/DataCollection/classes/DetailedView/class.ilDclDetailedViewGUI.php index f0ce00f98e99..8f2739104bdd 100755 --- a/components/ILIAS/DataCollection/classes/DetailedView/class.ilDclDetailedViewGUI.php +++ b/components/ILIAS/DataCollection/classes/DetailedView/class.ilDclDetailedViewGUI.php @@ -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; } @@ -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); diff --git a/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableView.php b/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableView.php index d9033b3adbec..96c6dbfbba9f 100755 --- a/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableView.php +++ b/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableView.php @@ -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 diff --git a/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewGUI.php b/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewGUI.php index 4b1c8c299bc9..17d27a8aa0c6 100755 --- a/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewGUI.php +++ b/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewGUI.php @@ -18,6 +18,8 @@ declare(strict_types=1); +use ILIAS\UI\Component\Button\Shy; + /** * @ilCtrl_Calls ilDclTableViewGUI: ilDclTableViewEditGUI */ @@ -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; } /** @@ -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'); diff --git a/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewTableGUI.php b/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewTableGUI.php deleted file mode 100755 index 7cfc1be3526d..000000000000 --- a/components/ILIAS/DataCollection/classes/TableView/class.ilDclTableViewTableGUI.php +++ /dev/null @@ -1,266 +0,0 @@ -ui_factory = $DIC->ui()->factory(); - $this->renderer = $DIC->ui()->renderer(); - - parent::__construct($a_parent_obj, $a_parent_cmd); - - $this->parent_obj = $a_parent_obj; - $this->table = $table; - $this->ctrl = $DIC->ctrl(); - $this->lng = $DIC->language(); - - $this->setExternalSegmentation(true); - $this->setExternalSorting(true); - - if ($this->parent_obj instanceof ilDclTableViewGUI) { - $this->ctrl->setParameterByClass(ilDclTableViewGUI::class, 'table_id', $table->getId()); - $this->setFormAction($this->ctrl->getFormActionByClass(ilDclTableViewGUI::class)); - $this->addMultiCommand('confirmDeleteTableviews', $this->lng->txt('dcl_delete_views')); - $this->addCommandButton('saveTableViewOrder', $this->lng->txt('dcl_save_order')); - - $this->setFormAction($this->ctrl->getFormAction($a_parent_obj)); - $this->setFormName('tableview_list'); - - $this->addColumn('', '', '1', true); - $this->addColumn($this->lng->txt('dcl_order'), '', '30px'); - - $this->setRowTemplate('tpl.tableview_list_row.html', 'components/ILIAS/DataCollection'); - $this->setData($this->table->getTableViews()); - } elseif ($this->parent_obj instanceof ilDclDetailedViewGUI) { - $this->setRowTemplate('tpl.detailview_list_row.html', 'components/ILIAS/DataCollection'); - $this->setData($this->table->getVisibleTableViews($ref_id, true)); - } - - $this->addColumn($this->lng->txt('title'), '', 'auto'); - $this->addColumn($this->lng->txt('description'), '', 'auto'); - $this->addColumn($this->lng->txt('dcl_configuration_complete'), '', 'auto'); - $this->addColumn($this->lng->txt('actions'), '', '30px'); - - $this->setTopCommands(true); - $this->setEnableHeader(true); - $this->setShowRowsSelector(false); - $this->setShowTemplates(false); - $this->setEnableHeader(true); - $this->setEnableTitle(true); - $this->setDefaultOrderDirection('asc'); - $this->setLimit(); - - $this->setId('dcl_tableviews'); - $this->setTitle($this->table->getTitle()); - $this->setStyle('table', $this->getStyle('table') . ' ' . 'dcl_record_list'); - } - - /** - * Get HTML - */ - public function getHTML(): string - { - if ($this->getExportMode()) { - $this->exportData($this->getExportMode(), true); - } - - $this->prepareOutput(); - - if (is_object($this->getParentObject()) && $this->getId() == "") { - $this->ctrl->saveParameter($this->getParentObject(), $this->getNavParameter()); - } - - if (!$this->getPrintMode()) { - // set form action - if ($this->form_action != "" && $this->getOpenFormTag()) { - $hash = ""; - - if ($this->form_multipart) { - $this->tpl->touchBlock("form_multipart_bl"); - } - - if ($this->getPreventDoubleSubmission()) { - $this->tpl->touchBlock("pdfs"); - } - - $this->tpl->setCurrentBlock("tbl_form_header"); - $this->tpl->setVariable("FORMACTION", $this->getFormAction() . $hash); - $this->tpl->setVariable("FORMNAME", $this->getFormName()); - $this->tpl->parseCurrentBlock(); - } - - if ($this->form_action != "" && $this->getCloseFormTag()) { - $this->tpl->touchBlock("tbl_form_footer"); - } - } - - if (!$this->enabled['content']) { - return $this->render(); - } - - if (!$this->getExternalSegmentation()) { - $this->setMaxCount(count($this->row_data)); - } - - $this->determineOffsetAndOrder(); - - $this->setFooter("tblfooter", $this->lng->txt("previous"), $this->lng->txt("next")); - - $data = $this->getData(); - if ($this->dataExists()) { - // sort - if (!$this->getExternalSorting() && $this->enabled["sort"]) { - $data = ilArrayUtil::sortArray( - $data, - $this->getOrderField(), - $this->getOrderDirection(), - $this->numericOrdering($this->getOrderField()) - ); - } - - // slice - if (!$this->getExternalSegmentation()) { - $data = array_slice($data, $this->getOffset(), $this->getLimit()); - } - } - - // fill rows - if ($this->dataExists()) { - if ($this->getPrintMode()) { - ilDatePresentation::setUseRelativeDates(false); - } - - $this->tpl->addBlockFile( - "TBL_CONTENT", - "tbl_content", - $this->row_template, - $this->row_template_dir - ); - - foreach ($data as $set) { - $this->tpl->setCurrentBlock("tbl_content"); - $this->css_row = ($this->css_row !== "tblrow1") - ? "tblrow1" - : "tblrow2"; - $this->tpl->setVariable("CSS_ROW", $this->css_row); - - $this->fillRowFromObject($set); - $this->tpl->setCurrentBlock("tbl_content"); - $this->tpl->parseCurrentBlock(); - } - } else { - // add standard no items text (please tell me, if it messes something up, alex, 29.8.2008) - $no_items_text = (trim($this->getNoEntriesText()) != '') - ? $this->getNoEntriesText() - : $this->lng->txt("no_items"); - - $this->css_row = ($this->css_row !== "tblrow1") - ? "tblrow1" - : "tblrow2"; - - $this->tpl->setCurrentBlock("tbl_no_entries"); - $this->tpl->setVariable('TBL_NO_ENTRY_CSS_ROW', $this->css_row); - $this->tpl->setVariable('TBL_NO_ENTRY_COLUMN_COUNT', $this->column_count); - $this->tpl->setVariable('TBL_NO_ENTRY_TEXT', trim($no_items_text)); - $this->tpl->parseCurrentBlock(); - } - - if (!$this->getPrintMode()) { - $this->fillFooter(); - - $this->fillHiddenRow(); - - $this->fillActionRow(); - - $this->storeNavParameter(); - } - - return $this->render(); - } - - /** - * @param ilDclTableView $a_set - */ - public function fillRowFromObject(ilDclTableView $a_set): void - { - if ($this->parent_obj instanceof ilDclTableViewGUI) { - $this->tpl->setVariable("ID", $a_set->getId()); - $this->tpl->setVariable("ORDER_NAME", "order[{$a_set->getId()}]"); - $this->tpl->setVariable("ORDER_VALUE", $a_set->getOrder()); - } - $this->tpl->setVariable("TITLE", $a_set->getTitle()); - $this->ctrl->setParameterByClass(ilDclTableViewEditGUI::class, 'tableview_id', $a_set->getId()); - $this->tpl->setVariable("TITLE_LINK", $this->ctrl->getLinkTargetByClass('ildcltablevieweditgui')); - $this->tpl->setVariable("DESCRIPTION", $a_set->getDescription()); - - $icon = $this->ui_factory->symbol()->icon()->custom(ilUtil::getImagePath('standard/icon_not_ok_monochrome.svg'), $this->lng->txt("yes")); - if ($a_set->validateConfigCompletion()) { - $icon = $this->ui_factory->symbol()->icon()->custom(ilUtil::getImagePath('standard/icon_ok_monochrome.svg'), $this->lng->txt("no")); - } - $this->tpl->setVariable("ICON_CONFIG", $this->renderer->render($icon)); - $this->tpl->setVariable('ACTIONS', $this->buildAction($a_set->getId())); - } - - /** - * build either actions menu or view button - */ - protected function buildAction(int $id): string - { - if ($this->parent_obj instanceof ilDclTableViewGUI) { - $dropdown_items = []; - - $this->ctrl->setParameterByClass(ilDclTableViewGUI::class, 'tableview_id', $id); - $this->ctrl->setParameterByClass(ilDclDetailedViewDefinitionGUI::class, 'tableview_id', $id); - - $dropdown_items[] = $this->ui_factory->link()->standard( - $this->lng->txt('edit'), - $this->ctrl->getLinkTargetByClass(ilDclTableViewEditGUI::class, 'editGeneralSettings') - ); - $dropdown_items[] = $this->ui_factory->link()->standard( - $this->lng->txt('copy'), - $this->ctrl->getLinkTargetByClass(ilDclTableViewEditGUI::class, 'copy') - ); - $dropdown_items[] = $this->ui_factory->link()->standard( - $this->lng->txt('delete'), - $this->ctrl->getLinkTargetByClass(ilDclTableViewEditGUI::class, 'confirmDelete') - ); - $dropdown = $this->ui_factory->dropdown()->standard($dropdown_items)->withLabel($this->lng->txt('actions')); - - return $this->renderer->render($dropdown); - } elseif ($this->parent_obj instanceof ilDclDetailedViewGUI) { - $this->ctrl->setParameterByClass(ilDclDetailedViewGUI::class, 'tableview_id', $id); - $this->ctrl->saveParameterByClass(ilDclDetailedViewGUI::class, 'record_id'); - $link = $this->ui_factory->link()->standard( - $this->lng->txt('view'), - $this->ctrl->getLinkTargetByClass(ilDclDetailedViewGUI::class, 'renderRecord') - ); - return $this->renderer->render($link); - } - return ""; - } -} diff --git a/components/ILIAS/DataCollection/templates/default/tpl.detailview_list_row.html b/components/ILIAS/DataCollection/templates/default/tpl.detailview_list_row.html deleted file mode 100755 index 9af7aa112ed4..000000000000 --- a/components/ILIAS/DataCollection/templates/default/tpl.detailview_list_row.html +++ /dev/null @@ -1,10 +0,0 @@ - - {TITLE} - {DESCRIPTION} - - - - - {ACTIONS} - - \ No newline at end of file diff --git a/components/ILIAS/DataCollection/templates/default/tpl.tableview_list_row.html b/components/ILIAS/DataCollection/templates/default/tpl.tableview_list_row.html deleted file mode 100755 index de31a92d4b79..000000000000 --- a/components/ILIAS/DataCollection/templates/default/tpl.tableview_list_row.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - {TITLE} - {DESCRIPTION} - - {ICON_CONFIG} - - - {ACTIONS} - - \ No newline at end of file diff --git a/lang/ilias_de.lang b/lang/ilias_de.lang index 42cd6793d40c..3056e2ba4e5f 100755 --- a/lang/ilias_de.lang +++ b/lang/ilias_de.lang @@ -8797,6 +8797,7 @@ dcl#:#dcl_tableview_required_visible#:#Verpflichtend & Sichtbar dcl#:#dcl_tableview_visible#:#Sichtbar dcl#:#dcl_tableviews#:#Ansichten dcl#:#dcl_tableviews_confirm_delete#:#Sind Sie sicher, dass die folgenden Ansichten gelöscht werden sollen? +dcl#:#dcl_tableviews_of_X#:#Ansichten der Tabelle %s dcl#:#dcl_tableviews_table#:#Ansichten der ausgewählten Tabelle dcl#:#dcl_text#:#Texteingabe dcl#:#dcl_text_area#:#Mehrzeiliges Texteingabefeld diff --git a/lang/ilias_en.lang b/lang/ilias_en.lang index 6cf3edc608c8..ea8e0e988422 100755 --- a/lang/ilias_en.lang +++ b/lang/ilias_en.lang @@ -8791,6 +8791,7 @@ dcl#:#dcl_tableview_required_visible#:#Required & Visible dcl#:#dcl_tableview_visible#:#Visible dcl#:#dcl_tableviews#:#Views dcl#:#dcl_tableviews_confirm_delete#:#Do you really want to delete the following Views? +dcl#:#dcl_tableviews_of_X#:#Views of table %s dcl#:#dcl_tableviews_table#:#Views of Selected Table dcl#:#dcl_text#:#Text Entry dcl#:#dcl_text_area#:#Textarea