From 79262972aab02b5f7d9bcaf72752d56764a92a00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20B=C3=B6hmer?= Date: Sun, 8 Oct 2023 21:28:37 +0200 Subject: [PATCH] Renamed config env to TABLE_PARTS_DEFAULT_COLUMNS and updated documentation --- .docker/symfony.conf | 2 +- .env | 3 +++ config/parameters.yaml | 2 +- config/services.yaml | 2 +- docs/configuration.md | 3 ++- src/DataTables/Helpers/ColumnSortHelper.php | 7 ++++--- src/DataTables/PartsDataTable.php | 4 ++-- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.docker/symfony.conf b/.docker/symfony.conf index 589761ba..e00445c5 100644 --- a/.docker/symfony.conf +++ b/.docker/symfony.conf @@ -35,7 +35,7 @@ PassEnv DEMO_MODE NO_URL_REWRITE_AVAILABLE FIXER_API_KEY BANNER # In old version the SAML sp private key env, was wrongly named SAMLP_SP_PRIVATE_KEY, keep it for backward compatibility PassEnv SAML_ENABLED SAML_ROLE_MAPPING SAML_UPDATE_GROUP_ON_LOGIN SAML_IDP_ENTITY_ID SAML_IDP_SINGLE_SIGN_ON_SERVICE SAML_IDP_SINGLE_LOGOUT_SERVICE SAML_IDP_X509_CERT SAML_SP_ENTITY_ID SAML_SP_X509_CERT SAML_SP_PRIVATE_KEY SAMLP_SP_PRIVATE_KEY - PassEnv TABLE_DEFAULT_PAGE_SIZE TABLE_PART_DEFAULT_COLUMNS + PassEnv TABLE_DEFAULT_PAGE_SIZE TABLE_PARTS_DEFAULT_COLUMNS PassEnv PROVIDER_DIGIKEY_CLIENT_ID PROVIDER_DIGIKEY_SECRET PROVIDER_DIGIKEY_CURRENCY PROVIDER_DIGIKEY_LANGUAGE PROVIDER_DIGIKEY_COUNTRY PassEnv PROVIDER_ELEMENT14_KEY PROVIDER_ELEMENT14_STORE_ID diff --git a/.env b/.env index 5b1a73e5..b2c31a53 100644 --- a/.env +++ b/.env @@ -93,6 +93,9 @@ ERROR_PAGE_SHOW_HELP=1 # The default page size for the part table (set to -1 to show all parts on one page) TABLE_DEFAULT_PAGE_SIZE=50 +# Configure which columns will be visible by default in the parts table (and in which order). +# This is a comma separated list of column names. See documentation for available values. +TABLE_PARTS_DEFAULT_COLUMNS=name,description,category,footprint,manufacturer,storage_location,amount ################################################################################## # Info provider settings diff --git a/config/parameters.yaml b/config/parameters.yaml index b24c7f57..9839bcf5 100644 --- a/config/parameters.yaml +++ b/config/parameters.yaml @@ -54,7 +54,7 @@ parameters: # Table settings ###################################################################################################################### partdb.table.default_page_size: '%env(int:TABLE_DEFAULT_PAGE_SIZE)%' # The default number of entries shown per page in tables - partdb.table.default_part_columns: '%env(trim:string:TABLE_PART_DEFAULT_COLUMNS)%' # The default columns in part tables and their order + partdb.table.parts.default_columns: '%env(trim:string:TABLE_PARTS_DEFAULT_COLUMNS)%' # The default columns in part tables and their order ###################################################################################################################### # Sidebar diff --git a/config/services.yaml b/config/services.yaml index a327466b..b161ec35 100644 --- a/config/services.yaml +++ b/config/services.yaml @@ -216,7 +216,7 @@ services: #################################################################################################################### App\DataTables\PartsDataTable: arguments: - $visible_columns: '%partdb.table.default_part_columns%' + $visible_columns: '%partdb.table.parts.default_columns%' App\DataTables\Helpers\ColumnSortHelper: shared: false # Service has a state so not share it between different tables diff --git a/docs/configuration.md b/docs/configuration.md index b878bd49..e5c75cce 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -46,7 +46,8 @@ The following configuration options can only be changed by the server administra ### Table related settings * `TABLE_DEFAULT_PAGE_SIZE`: The default page size for tables. This is the number of rows which are shown per page. Set to `-1` to disable pagination and show all rows at once. -* `TABLE_PART_DEFAULT_COLUMNS`: The default columns in part tables loading table for first time. Also specify default order of the columns. Specify as comma separated string. Available columns are: `name`, `id`, `ipn`, `description`, `category`, `footprint`, `manufacturer`, `storelocation`, `amount`, `minamount`, `partUnit`, `addedDate`, `lastModified`, `needs_review`, `favorite`, `manufacturing_status`, `manufacturer_product_number`, `mass`, `tags`, `attachments`, `edit`. +* `TABLE_PARTS_DEFAULT_COLUMNS`: The columns in parts tables, which are visible by default (when loading table for first time). +Also specify the default order of the columns. This is a comma separated list of column names. Available columns are: `name`, `id`, `ipn`, `description`, `category`, `footprint`, `manufacturer`, `storage_location`, `amount`, `minamount`, `partUnit`, `addedDate`, `lastModified`, `needs_review`, `favorite`, `manufacturing_status`, `manufacturer_product_number`, `mass`, `tags`, `attachments`, `edit`. ### History/Eventlog related settings The following options are used to configure, which (and how much) data is written to the system log: diff --git a/src/DataTables/Helpers/ColumnSortHelper.php b/src/DataTables/Helpers/ColumnSortHelper.php index 2cb8e0da..a16a64d8 100644 --- a/src/DataTables/Helpers/ColumnSortHelper.php +++ b/src/DataTables/Helpers/ColumnSortHelper.php @@ -76,7 +76,8 @@ class ColumnSortHelper * be visible by default. If a column is not listed here, it will be hidden by default. * @return void */ - public function applyVisibilityAndConfigureColumns(DataTable $dataTable, string|array $visible_columns): void + public function applyVisibilityAndConfigureColumns(DataTable $dataTable, string|array $visible_columns, + string $config_var_name): void { //If the config is given as a string, convert it to an array first if (!is_array($visible_columns)) { @@ -96,12 +97,12 @@ class ColumnSortHelper //Afterwards the columns, which should be visible by default foreach ($visible_columns as $col_id) { if (!isset($this->columns[$col_id]) || !$this->columns[$col_id]['visibility_configurable']) { - $this->logger->warning("Configuration option TABLE_PART_DEFAULT_COLUMNS specify invalid column '$col_id'. Column is skipped."); + $this->logger->warning("Configuration option $config_var_name specify invalid column '$col_id'. Column is skipped."); continue; } if (in_array($col_id, $processed_columns, true)) { - $this->logger->warning("Configuration option TABLE_PART_DEFAULT_COLUMNS specify column '$col_id' multiple time. Only first occurrence is used."); + $this->logger->warning("Configuration option $config_var_name specify column '$col_id' multiple time. Only first occurrence is used."); continue; } $this->addColumnEntry($dataTable, $this->columns[$col_id], true); diff --git a/src/DataTables/PartsDataTable.php b/src/DataTables/PartsDataTable.php index 99956ce7..42d622eb 100644 --- a/src/DataTables/PartsDataTable.php +++ b/src/DataTables/PartsDataTable.php @@ -167,7 +167,7 @@ final class PartsDataTable implements DataTableTypeInterface return implode('
', $tmp); }, - ]); + ], alias: 'storage_location'); } $this->csh->add('amount', TextColumn::class, [ @@ -280,7 +280,7 @@ final class PartsDataTable implements DataTableTypeInterface ]); //Apply the user configured order and visibility and add the columns to the table - $this->csh->applyVisibilityAndConfigureColumns($dataTable, $this->visible_columns); + $this->csh->applyVisibilityAndConfigureColumns($dataTable, $this->visible_columns, "TABLE_PARTS_DEFAULT_COLUMNS"); $dataTable->addOrderBy('name') ->createAdapter(TwoStepORMAdapater::class, [