From b5d36a04028128078e996144f2aafeffbd0675d5 Mon Sep 17 00:00:00 2001 From: Thomas Skerbis Date: Sat, 7 Sep 2024 15:16:41 +0200 Subject: [PATCH] manager: Add Custom Icon for Tables (#1518) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add customIcon * add CustomIcon * add customIcon * add customIcon * Update boot.php * add table_icon to api.php * csfix table_edit.php * csfix table.php * add class yform-table-icon so kann das Feld evtl. mit einer externen Pickerlösung ausgestattet werden. * add table_icon to table ... Mist vergessen * auf text(191) gesetzt * varchar * Nullable Type für getCustomIcon --- plugins/manager/boot.php | 3 ++- plugins/manager/install.php | 1 + plugins/manager/lang/de_de.lang | 1 + plugins/manager/lib/yform/manager/table.php | 5 +++++ plugins/manager/lib/yform/manager/table/api.php | 2 +- plugins/manager/pages/table_edit.php | 1 + 6 files changed, 11 insertions(+), 2 deletions(-) diff --git a/plugins/manager/boot.php b/plugins/manager/boot.php index 670fa77b..58f7c1ec 100644 --- a/plugins/manager/boot.php +++ b/plugins/manager/boot.php @@ -49,7 +49,8 @@ if ($table->isActive() && $table->isGranted('VIEW', rex::getUser())) { $be_page = new rex_be_page_main('yform_tables', $table->getTableName(), rex_escape($table->getNameLocalized())); $be_page->setHref('index.php?page=yform/manager/data_edit&table_name=' . $table->getTableName()); - $be_page->setIcon('rex-icon rex-icon-module'); + $icon = rex_escape($table->getCustomIcon() ?: 'rex-icon-module'); + $be_page->setIcon('rex-icon ' . $icon); $be_page->setPrio($prio); if ($table->isHidden()) { diff --git a/plugins/manager/install.php b/plugins/manager/install.php index 7709796f..7fbbe960 100644 --- a/plugins/manager/install.php +++ b/plugins/manager/install.php @@ -23,6 +23,7 @@ ->ensureColumn(new rex_sql_column('table_name', 'varchar(191)')) ->ensureColumn(new rex_sql_column('name', 'varchar(191)')) ->ensureColumn(new rex_sql_column('description', 'text')) + ->ensureColumn(new rex_sql_column('table_icon', 'varchar(191)')) ->ensureColumn(new rex_sql_column('list_amount', 'int(11)', false, '50')) ->ensureColumn(new rex_sql_column('list_sortfield', 'varchar(191)', false, 'id')) ->ensureColumn(new rex_sql_column('list_sortorder', 'enum(\'ASC\',\'DESC\')', false, 'ASC')) diff --git a/plugins/manager/lang/de_de.lang b/plugins/manager/lang/de_de.lang index 9dcc164b..f4300de7 100644 --- a/plugins/manager/lang/de_de.lang +++ b/plugins/manager/lang/de_de.lang @@ -67,6 +67,7 @@ yform_manager_table_name = Name yform_manager_table_status = Status yform_manager_name = Bezeichnung yform_manager_table_description = Beschreibung +yform_manager_custom_icon = Individuelles Icon yform_manager_entries_per_page = Datensätze pro Seite yform_manager_sortfield = Standardsortierung: Feld yform_manager_sortorder = Richtung diff --git a/plugins/manager/lib/yform/manager/table.php b/plugins/manager/lib/yform/manager/table.php index bda2e322..c5398d5d 100644 --- a/plugins/manager/lib/yform/manager/table.php +++ b/plugins/manager/lib/yform/manager/table.php @@ -241,6 +241,11 @@ public function getDescription(): string return $this->values['description']; } + public function getCustomIcon(): ?string + { + return $this->values['table_icon']; + } + /** * Fields of yform Definitions. * diff --git a/plugins/manager/lib/yform/manager/table/api.php b/plugins/manager/lib/yform/manager/table/api.php index 472c3990..44a1a1cc 100644 --- a/plugins/manager/lib/yform/manager/table/api.php +++ b/plugins/manager/lib/yform/manager/table/api.php @@ -3,7 +3,7 @@ class rex_yform_manager_table_api { /** @var array */ - public static array $table_fields = ['status', 'name', 'description', 'list_amount', 'list_sortfield', 'list_sortorder', 'prio', 'search', 'hidden', 'export', 'import', 'schema_overwrite']; + public static array $table_fields = ['status', 'name', 'description', 'table_icon', 'list_amount', 'list_sortfield', 'list_sortorder', 'prio', 'search', 'hidden', 'export', 'import', 'schema_overwrite']; public static bool $debug = false; public static array $cacheColumnsByTable = []; diff --git a/plugins/manager/pages/table_edit.php b/plugins/manager/pages/table_edit.php index ef983a83..66fb690d 100644 --- a/plugins/manager/pages/table_edit.php +++ b/plugins/manager/pages/table_edit.php @@ -121,6 +121,7 @@ $yform->setValueField('text', ['name', rex_i18n::msg('yform_manager_name')]); $yform->setValidateField('empty', ['name', rex_i18n::msg('yform_manager_table_enter_name')]); $yform->setValueField('textarea', ['description', '
' . rex_i18n::msg('yform_manager_table_description'), 'attributes' => '{"class":"form-control yform-textarea-short"}']); + $yform->setValueField('text', ['table_icon', rex_i18n::msg('yform_manager_custom_icon'), 'attributes' => '{"class":"form-control yform-table-icon"}']); $yform->setValueField('html', ['html' => '
']);